Skip to content

Commit

Permalink
Cocoa: Improve backtrace logging for <redacted> symbols
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=258821
rdar://111700962

Reviewed by Wenson Hsieh.

* Source/WTF/wtf/PlatformHave.h:
* Source/WTF/wtf/StackTrace.h:
(WTF::StackTraceSymbolResolver::forEach const):
Enable backtrace_symbols on Cocoa, since we have it.
If a symbol comes back from dladdr as <redacted>, fall back to the
backtrace_symbols string, which includes:

- the symbol's image's name
- the image's DWARF UUID
- the symbol's address

...the combination of which can be used to make either better guesses about
the stack, or to actually symbolicate offline.

The strcmp check matches what `backtrace_symbols` itself does.

Canonical link: https://commits.webkit.org/266662@main
  • Loading branch information
hortont424 authored and rr-codes committed Aug 7, 2023
1 parent 52ced8d commit c120af9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
3 changes: 0 additions & 3 deletions Source/WTF/wtf/PlatformHave.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@

#if OS(DARWIN) || (OS(LINUX) && defined(__GLIBC__) && !defined(__UCLIBC__) && !CPU(MIPS))
#define HAVE_BACKTRACE 1
#endif

#if (OS(DARWIN) || OS(LINUX)) && (PLATFORM(GTK) || PLATFORM(WPE)) && defined(__GLIBC__) && !defined(__UCLIBC__) && !CPU(MIPS)
#define HAVE_BACKTRACE_SYMBOLS 1
#endif

Expand Down
2 changes: 1 addition & 1 deletion Source/WTF/wtf/StackTrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class StackTraceSymbolResolver {
if (demangled)
name = demangled->demangledName() ? demangled->demangledName() : demangled->mangledName();
#if HAVE(BACKTRACE_SYMBOLS)
if (!name)
if (!name || !strcmp(name, "<redacted>"))
name = symbols[i];
#elif OS(WINDOWS)
if (!name && DbgHelper::SymFromAddress(hProc, reinterpret_cast<DWORD64>(m_stack[i]), nullptr, symbolInfo))
Expand Down

0 comments on commit c120af9

Please sign in to comment.