diff --git a/src/sentry/stacktraces/functions.py b/src/sentry/stacktraces/functions.py index 61067b3680472b..aa325ed57b7acc 100644 --- a/src/sentry/stacktraces/functions.py +++ b/src/sentry/stacktraces/functions.py @@ -141,6 +141,7 @@ def trim_native_function_name(function, platform, normalize_lambdas=True): function.replace("operator<<", "operator⟨⟨") .replace("operator<", "operator⟨") .replace("operator()", "operator◯") + .replace("operator->", "operator⟿") .replace(" -> ", " ⟿ ") .replace("`anonymous namespace'", "〔anonymousnamespace〕") ) @@ -189,6 +190,14 @@ def process_generics(value, start): function = replace_enclosed_string(function, "<", ">", process_generics) + # Remove special `[clone .foo]` annotations for cloned/split functions + def process_brackets(value, start): + if value.startswith("clone ."): + return "" + return "[%s]" % value + + function = replace_enclosed_string(function, "[", "]", process_brackets) + is_thunk = "thunk for " in function # swift tokens = split_func_tokens(function) @@ -203,7 +212,7 @@ def process_generics(value, start): # find the token which is the function name. Since we chopped of C++ # trailers there are only two cases we care about: the token left to # the -> return marker which is for instance used in Swift and if that - # is not found, the last token in the last. + # is not found, consider the last token to be the function. # # ["unsigned", "int", "whatever"] -> whatever # ["@objc", "whatever", "->", "int"] -> whatever @@ -223,7 +232,7 @@ def process_generics(value, start): function = ( func_token.replace("⟨", "<") .replace("◯", "()") - .replace(" ⟿ ", " -> ") + .replace("⟿", "->") .replace("〔anonymousnamespace〕", "`anonymous namespace'") ) diff --git a/tests/sentry/stacktraces/test_functions.py b/tests/sentry/stacktraces/test_functions.py index f0ab4aa076021a..81f193f84a163f 100644 --- a/tests/sentry/stacktraces/test_functions.py +++ b/tests/sentry/stacktraces/test_functions.py @@ -89,6 +89,15 @@ ["main::{lambda()#42}", "main::lambda"], ["lambda_7156c3ceaa11256748687ab67e3ef4cd", "lambda"], ["::operator()", "::operator()"], + ["trigger_crash_a(int*) [clone .constprop.0]", "trigger_crash_a"], + [ + "__gnu_cxx::__verbose_terminate_handler() [clone .cold]", + "__gnu_cxx::__verbose_terminate_handler", + ], + [ + "std::__1::unique_ptr >::operator->", + "std::__1::unique_ptr::operator->", + ], ], ) def test_trim_native_function_name(input, output):