diff options
author | Yngve N. Pettersen <yngve@vivaldi.com> | 2020-05-05 02:06:14 +0200 |
---|---|---|
committer | Mark Mentovai <mark@chromium.org> | 2020-05-05 12:18:53 +0000 |
commit | 2ffe116322aa4373d408a72b665fa7fe7a504d4a (patch) | |
tree | ccfb4a1ccb8352dd9e6a3ad0a22cc7e888e3a4fe /src/common | |
parent | processor: Bound number of exception parameters read (diff) | |
download | breakpad-2ffe116322aa4373d408a72b665fa7fe7a504d4a.tar.xz |
mac: Don’t try to demangle non-C++ symbols with the C++ demangler
On Mac a C++ symbol has 1-4 underscore characters followed by a 'Z'.
Symbols that do not have this format (such as plain C symbols)
causes a lot of warnings to be printed.
Bug: chromium:1062556
Change-Id: I55977f756c7e20cc5e7b1cb8e38316d7bf1f748c
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2179482
Reviewed-by: Mark Mentovai <mark@chromium.org>
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/language.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/common/language.cc b/src/common/language.cc index 978fb855..d26e5638 100644 --- a/src/common/language.cc +++ b/src/common/language.cc @@ -79,6 +79,18 @@ class CPPLanguage: public Language { demangled->clear(); return kDontDemangle; #else +#if defined(__APPLE__) + // Mac C++ symbols can have up to 4 underscores, followed by a "Z". + // Non-C++ symbols are not coded that way, but may have leading underscores. + // Attempting to demangle non-C++ symbols with the C++ demangler would print + // warnings and fail, so return kDontDemangle for these. + size_t i = mangled.find_first_not_of('_'); + if (i == 0 || i == string::npos || i > 4 || mangled[i] != 'Z') { + demangled->clear(); + return kDontDemangle; + } +#endif + int status; char* demangled_c = abi::__cxa_demangle(mangled.c_str(), NULL, NULL, &status); |