gecko-dev/toolkit/crashreporter/breakpad-patches/01-llvm-windows-symbol-fixu...

85 строки
3.4 KiB
Diff

diff --git a/src/common/windows/pdb_source_line_writer.cc b/src/common/windows/pdb_source_line_writer.cc
--- a/src/common/windows/pdb_source_line_writer.cc
+++ b/src/common/windows/pdb_source_line_writer.cc
@@ -1019,34 +1019,50 @@ bool PDBSourceLineWriter::FindPEFile() {
}
}
}
}
return false;
}
+static const DWORD kUndecorateOptions =
+ UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_FUNCTION_RETURNS |
+ UNDNAME_NO_ALLOCATION_MODEL | UNDNAME_NO_ALLOCATION_LANGUAGE |
+ UNDNAME_NO_THISTYPE | UNDNAME_NO_ACCESS_SPECIFIERS |
+ UNDNAME_NO_THROW_SIGNATURES | UNDNAME_NO_MEMBER_TYPE |
+ UNDNAME_NO_RETURN_UDT_MODEL | UNDNAME_NO_ECSU;
+
+static void FixupLlvmUniqueSymbol(BSTR *name) {
+ wchar_t *suffix = wcsstr(*name, L".llvm.");
+
+ if (suffix != nullptr) {
+ *suffix = L'\0';
+
+ const size_t undecorated_len = 1024;
+ wchar_t undecorated[undecorated_len] = {};
+ DWORD res = UnDecorateSymbolNameW(*name, undecorated, undecorated_len,
+ kUndecorateOptions);
+ if (res == 0) {
+ fprintf(stderr, "failed to undecorate symbol %S\n", *name);
+ } else {
+ SysFreeString(*name);
+ *name = SysAllocString(undecorated);
+ }
+ }
+}
+
// static
bool PDBSourceLineWriter::GetSymbolFunctionName(IDiaSymbol *function,
BSTR *name,
int *stack_param_size) {
*stack_param_size = -1;
- const DWORD undecorate_options = UNDNAME_NO_MS_KEYWORDS |
- UNDNAME_NO_FUNCTION_RETURNS |
- UNDNAME_NO_ALLOCATION_MODEL |
- UNDNAME_NO_ALLOCATION_LANGUAGE |
- UNDNAME_NO_THISTYPE |
- UNDNAME_NO_ACCESS_SPECIFIERS |
- UNDNAME_NO_THROW_SIGNATURES |
- UNDNAME_NO_MEMBER_TYPE |
- UNDNAME_NO_RETURN_UDT_MODEL |
- UNDNAME_NO_ECSU;
// Use get_undecoratedNameEx to get readable C++ names with arguments.
- if (function->get_undecoratedNameEx(undecorate_options, name) != S_OK) {
+ if (function->get_undecoratedNameEx(kUndecorateOptions, name) != S_OK) {
if (function->get_name(name) != S_OK) {
fprintf(stderr, "failed to get function name\n");
return false;
}
// It's possible for get_name to return an empty string, so
// special-case that.
if (wcscmp(*name, L"") == 0) {
@@ -1060,16 +1076,18 @@ bool PDBSourceLineWriter::GetSymbolFunct
// it's already formatted properly to be used as output. Don't do any
// additional processing.
//
// MSVC7's DIA seems to not undecorate names in as many cases as MSVC8's.
// This will result in calling get_name for some C++ symbols, so
// all of the parameter and return type information may not be included in
// the name string.
} else {
+ FixupLlvmUniqueSymbol(name);
+
// C++ uses a bogus "void" argument for functions and methods that don't
// take any parameters. Take it out of the undecorated name because it's
// ugly and unnecessary.
const wchar_t *replace_string = L"(void)";
const size_t replace_length = wcslen(replace_string);
const wchar_t *replacement_string = L"()";
size_t length = wcslen(*name);
if (length >= replace_length) {