diff options
author | Mikhail Borisov <borisov.mikhail@gmail.com> | 2020-05-26 21:44:01 +0300 |
---|---|---|
committer | Mark Mentovai <mark@chromium.org> | 2020-05-26 18:57:18 +0000 |
commit | f2679262acfb576f72d464e999cdac0950f92afc (patch) | |
tree | 6c537c634447b9d19cdd70d9dbccb1891c2f2c1f /src/common | |
parent | mac: Don’t try to demangle non-C++ symbols with the C++ demangler (diff) | |
download | breakpad-f2679262acfb576f72d464e999cdac0950f92afc.tar.xz |
Avoid calling demangler for non-C++ symbols on Linux
Bogus demangler warnings should be suppressed on both Mac and Linux
platforms, so there is no reason to keep this filter behind __APPLE__ gate.
Bug: chromium:1062556
Change-Id: Idf28db0b527c3cd6dd91510fcf7d9040aaa64694
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2210684
Reviewed-by: Mark Mentovai <mark@chromium.org>
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/language.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/common/language.cc b/src/common/language.cc index d26e5638..440d4de1 100644 --- a/src/common/language.cc +++ b/src/common/language.cc @@ -79,17 +79,12 @@ 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') { + if (!IsMangledName(mangled)) { demangled->clear(); return kDontDemangle; } -#endif int status; char* demangled_c = @@ -111,6 +106,21 @@ class CPPLanguage: public Language { return result; #endif } + + private: + static bool IsMangledName(const string &name) { + // NOTE: For proper cross-compilation support, this should depend on target + // binary's platform, not current build platform. +#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. + size_t i = name.find_first_not_of('_'); + return i > 0 && i != string::npos && i <= 4 && name[i] == 'Z'; +#else + // Linux C++ symbols always start with "_Z". + return name.size() > 2 && name[0] == '_' && name[1] == 'Z'; +#endif + } }; CPPLanguage CPPLanguageSingleton; |