mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-03-03 03:36:30 +00:00
Don't demangle Rust symbols by default, but allow linking to rust-demangle.
The Rust compiler uses GCC C++ name mangling, but it has another layer of encoding so abi::cxa_demangle doesn't produce great results. This patch changes dump_syms to dump unmangled names by default so that consumers can demangle them after-the-fact. It also adds a tiny bit of support for linking against a Rust library I wrote that can demangle Rust symbols nicely: https://github.com/luser/rust-demangle-capi BUG= Change-Id: I63a425035ebb7ac516f067fed2aa782849ea9604 Reviewed-on: https://chromium-review.googlesource.com/402308 Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
@@ -40,6 +40,10 @@
|
||||
#include <cxxabi.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_RUST_DEMANGLE)
|
||||
#include <rust_demangle.h>
|
||||
#endif
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace {
|
||||
@@ -136,6 +140,40 @@ class SwiftLanguage: public Language {
|
||||
|
||||
SwiftLanguage SwiftLanguageSingleton;
|
||||
|
||||
// Rust language-specific operations.
|
||||
class RustLanguage: public Language {
|
||||
public:
|
||||
RustLanguage() {}
|
||||
|
||||
string MakeQualifiedName(const string &parent_name,
|
||||
const string &name) const {
|
||||
return MakeQualifiedNameWithSeparator(parent_name, ".", name);
|
||||
}
|
||||
|
||||
virtual DemangleResult DemangleName(const string& mangled,
|
||||
std::string* demangled) const {
|
||||
// Rust names use GCC C++ name mangling, but demangling them with
|
||||
// abi_demangle doesn't produce stellar results due to them having
|
||||
// another layer of encoding.
|
||||
// If callers provide rustc-demangle, use that.
|
||||
#if defined(HAVE_RUST_DEMANGLE)
|
||||
char* rust_demangled = rust_demangle(mangled.c_str());
|
||||
if (rust_demangled == nullptr) {
|
||||
return kDemangleFailure;
|
||||
}
|
||||
demangled->assign(rust_demangled);
|
||||
free_rust_demangled_name(rust_demangled);
|
||||
#else
|
||||
// Otherwise, pass through the mangled name so callers can demangle
|
||||
// after the fact.
|
||||
demangled->assign(mangled);
|
||||
#endif
|
||||
return kDemangleSuccess;
|
||||
}
|
||||
};
|
||||
|
||||
RustLanguage RustLanguageSingleton;
|
||||
|
||||
// Assembler language-specific operations.
|
||||
class AssemblerLanguage: public Language {
|
||||
public:
|
||||
@@ -153,6 +191,7 @@ AssemblerLanguage AssemblerLanguageSingleton;
|
||||
const Language * const Language::CPlusPlus = &CPPLanguageSingleton;
|
||||
const Language * const Language::Java = &JavaLanguageSingleton;
|
||||
const Language * const Language::Swift = &SwiftLanguageSingleton;
|
||||
const Language * const Language::Rust = &RustLanguageSingleton;
|
||||
const Language * const Language::Assembler = &AssemblerLanguageSingleton;
|
||||
|
||||
} // namespace google_breakpad
|
||||
|
||||
Reference in New Issue
Block a user