|
35 | 35 | #include <cassert>
|
36 | 36 | #include <cstring>
|
37 | 37 |
|
38 |
| -#if defined(_MSC_VER) |
39 |
| -#include <Windows.h> |
40 |
| - |
41 |
| -// This must be included after windows.h. |
42 |
| -#include <DbgHelp.h> |
43 |
| -#pragma comment(lib, "dbghelp.lib") |
44 |
| - |
45 |
| -// Windows.h conflicts with our COFF header definitions. |
46 |
| -#ifdef IMAGE_FILE_MACHINE_I386 |
47 |
| -#undef IMAGE_FILE_MACHINE_I386 |
48 |
| -#endif |
49 |
| -#endif |
50 |
| - |
51 | 38 | namespace llvm {
|
52 | 39 | namespace symbolize {
|
53 | 40 |
|
@@ -524,31 +511,11 @@ LLVMSymbolizer::DemangleName(const std::string &Name,
|
524 | 511 | const SymbolizableModule *DbiModuleDescriptor) {
|
525 | 512 | // We can spoil names of symbols with C linkage, so use an heuristic
|
526 | 513 | // approach to check if the name should be demangled.
|
527 |
| - if (Name.substr(0, 2) == "_Z") { |
528 |
| - int status = 0; |
529 |
| - char *DemangledName = itaniumDemangle(Name.c_str(), nullptr, nullptr, &status); |
530 |
| - if (status != 0) |
531 |
| - return Name; |
532 |
| - std::string Result = DemangledName; |
533 |
| - free(DemangledName); |
534 |
| - return Result; |
535 |
| - } |
| 514 | + // MSVC C++ mangled symbols start with '?', while itanium mangled ones |
| 515 | + // start with _Z. |
| 516 | + if (Name.substr(0, 2) == "_Z" || (!Name.empty() && Name.front() == '?')) |
| 517 | + return demangle(Name); |
536 | 518 |
|
537 |
| -#if defined(_MSC_VER) |
538 |
| - if (!Name.empty() && Name.front() == '?') { |
539 |
| - // Only do MSVC C++ demangling on symbols starting with '?'. |
540 |
| - char DemangledName[1024] = {0}; |
541 |
| - DWORD result = ::UnDecorateSymbolName( |
542 |
| - Name.c_str(), DemangledName, 1023, |
543 |
| - UNDNAME_NO_ACCESS_SPECIFIERS | // Strip public, private, protected |
544 |
| - UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall, etc |
545 |
| - UNDNAME_NO_THROW_SIGNATURES | // Strip throw() specifications |
546 |
| - UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc specifiers |
547 |
| - UNDNAME_NO_MS_KEYWORDS | // Strip all MS extension keywords |
548 |
| - UNDNAME_NO_FUNCTION_RETURNS); // Strip function return types |
549 |
| - return (result == 0) ? Name : std::string(DemangledName); |
550 |
| - } |
551 |
| -#endif |
552 | 519 | if (DbiModuleDescriptor && DbiModuleDescriptor->isWin32Module())
|
553 | 520 | return std::string(demanglePE32ExternCFunc(Name));
|
554 | 521 | return Name;
|
|
0 commit comments