Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/sentry/stacktraces/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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〕")
)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -223,7 +232,7 @@ def process_generics(value, start):
function = (
func_token.replace("⟨", "<")
.replace("◯", "()")
.replace("", " -> ")
.replace("", "->")
.replace("〔anonymousnamespace〕", "`anonymous namespace'")
)

Expand Down
9 changes: 9 additions & 0 deletions tests/sentry/stacktraces/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@
["main::{lambda()#42}", "main::lambda"],
["lambda_7156c3ceaa11256748687ab67e3ef4cd", "lambda"],
["<lambda_7156c3ceaa11256748687ab67e3ef4cd>::operator()", "<lambda>::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<X,std::default_delete<X> >::operator->",
"std::__1::unique_ptr<T>::operator->",
],
],
)
def test_trim_native_function_name(input, output):
Expand Down