@@ -29,6 +29,80 @@ static const char *StripFunctionName(const char *function, const char *prefix) {
29
29
return function;
30
30
}
31
31
32
+ static const char *DemangleFunctionName (const char *function) {
33
+ if (!function) return nullptr ;
34
+
35
+ // NetBSD uses indirection for old threading functions for historical reasons
36
+ // The mangled names are internal implementation detail and should not be
37
+ // exposed even in backtraces.
38
+ #if SANITIZER_NETBSD
39
+ if (!internal_strcmp (function, " __libc_mutex_init" ))
40
+ return " pthread_mutex_init" ;
41
+ if (!internal_strcmp (function, " __libc_mutex_lock" ))
42
+ return " pthread_mutex_lock" ;
43
+ if (!internal_strcmp (function, " __libc_mutex_trylock" ))
44
+ return " pthread_mutex_trylock" ;
45
+ if (!internal_strcmp (function, " __libc_mutex_unlock" ))
46
+ return " pthread_mutex_unlock" ;
47
+ if (!internal_strcmp (function, " __libc_mutex_destroy" ))
48
+ return " pthread_mutex_destroy" ;
49
+ if (!internal_strcmp (function, " __libc_mutexattr_init" ))
50
+ return " pthread_mutexattr_init" ;
51
+ if (!internal_strcmp (function, " __libc_mutexattr_settype" ))
52
+ return " pthread_mutexattr_settype" ;
53
+ if (!internal_strcmp (function, " __libc_mutexattr_destroy" ))
54
+ return " pthread_mutexattr_destroy" ;
55
+ if (!internal_strcmp (function, " __libc_cond_init" ))
56
+ return " pthread_cond_init" ;
57
+ if (!internal_strcmp (function, " __libc_cond_signal" ))
58
+ return " pthread_cond_signal" ;
59
+ if (!internal_strcmp (function, " __libc_cond_broadcast" ))
60
+ return " pthread_cond_broadcast" ;
61
+ if (!internal_strcmp (function, " __libc_cond_wait" ))
62
+ return " pthread_cond_wait" ;
63
+ if (!internal_strcmp (function, " __libc_cond_timedwait" ))
64
+ return " pthread_cond_timedwait" ;
65
+ if (!internal_strcmp (function, " __libc_cond_destroy" ))
66
+ return " pthread_cond_destroy" ;
67
+ if (!internal_strcmp (function, " __libc_rwlock_init" ))
68
+ return " pthread_rwlock_init" ;
69
+ if (!internal_strcmp (function, " __libc_rwlock_rdlock" ))
70
+ return " pthread_rwlock_rdlock" ;
71
+ if (!internal_strcmp (function, " __libc_rwlock_wrlock" ))
72
+ return " pthread_rwlock_wrlock" ;
73
+ if (!internal_strcmp (function, " __libc_rwlock_tryrdlock" ))
74
+ return " pthread_rwlock_tryrdlock" ;
75
+ if (!internal_strcmp (function, " __libc_rwlock_trywrlock" ))
76
+ return " pthread_rwlock_trywrlock" ;
77
+ if (!internal_strcmp (function, " __libc_rwlock_unlock" ))
78
+ return " pthread_rwlock_unlock" ;
79
+ if (!internal_strcmp (function, " __libc_rwlock_destroy" ))
80
+ return " pthread_rwlock_destroy" ;
81
+ if (!internal_strcmp (function, " __libc_thr_keycreate" ))
82
+ return " pthread_key_create" ;
83
+ if (!internal_strcmp (function, " __libc_thr_setspecific" ))
84
+ return " pthread_setspecific" ;
85
+ if (!internal_strcmp (function, " __libc_thr_getspecific" ))
86
+ return " pthread_getspecific" ;
87
+ if (!internal_strcmp (function, " __libc_thr_keydelete" ))
88
+ return " pthread_key_delete" ;
89
+ if (!internal_strcmp (function, " __libc_thr_once" ))
90
+ return " pthread_once" ;
91
+ if (!internal_strcmp (function, " __libc_thr_self" ))
92
+ return " pthread_self" ;
93
+ if (!internal_strcmp (function, " __libc_thr_exit" ))
94
+ return " pthread_exit" ;
95
+ if (!internal_strcmp (function, " __libc_thr_setcancelstate" ))
96
+ return " pthread_setcancelstate" ;
97
+ if (!internal_strcmp (function, " __libc_thr_equal" ))
98
+ return " pthread_equal" ;
99
+ if (!internal_strcmp (function, " __libc_thr_curcpu" ))
100
+ return " pthread_curcpu_np" ;
101
+ #endif
102
+
103
+ return function;
104
+ }
105
+
32
106
static const char kDefaultFormat [] = " #%n %p %F %L" ;
33
107
34
108
void RenderFrame (InternalScopedString *buffer, const char *format, int frame_no,
@@ -60,7 +134,9 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
60
134
buffer->append (" 0x%zx" , info.module_offset );
61
135
break ;
62
136
case ' f' :
63
- buffer->append (" %s" , StripFunctionName (info.function , strip_func_prefix));
137
+ buffer->append (" %s" ,
138
+ DemangleFunctionName (
139
+ StripFunctionName (info.function , strip_func_prefix)));
64
140
break ;
65
141
case ' q' :
66
142
buffer->append (" 0x%zx" , info.function_offset != AddressInfo::kUnknown
@@ -81,7 +157,8 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
81
157
// Function name and offset, if file is unknown.
82
158
if (info.function ) {
83
159
buffer->append (" in %s" ,
84
- StripFunctionName (info.function , strip_func_prefix));
160
+ DemangleFunctionName (
161
+ StripFunctionName (info.function , strip_func_prefix)));
85
162
if (!info.file && info.function_offset != AddressInfo::kUnknown )
86
163
buffer->append (" +0x%zx" , info.function_offset );
87
164
}
0 commit comments