[PATCH] D44192: Proper handling of Itanium mangled names in LLVMSymbolizer on Windows
Eugene Zemtsov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 7 01:32:51 PST 2018
eugene created this revision.
eugene added reviewers: zturner, rnk, labath.
Herald added a subscriber: mgorny.
Currently on Windows (_MSC_VER) LLVMSymbolizer tries only Microsoft mangling, it makes it difficult to use for crossplat tools.
This fix just explicitly uses itaniumDemangle when __cxa_demangle is not available. LLDB on Windows does the same.
Repository:
rL LLVM
https://reviews.llvm.org/D44192
Files:
lib/DebugInfo/Symbolize/Symbolize.cpp
tools/llvm-symbolizer/CMakeLists.txt
Index: tools/llvm-symbolizer/CMakeLists.txt
===================================================================
--- tools/llvm-symbolizer/CMakeLists.txt
+++ tools/llvm-symbolizer/CMakeLists.txt
@@ -6,6 +6,7 @@
set(LLVM_LINK_COMPONENTS
DebugInfoDWARF
DebugInfoPDB
+ Demangle
Object
Support
Symbolize
Index: lib/DebugInfo/Symbolize/Symbolize.cpp
===================================================================
--- lib/DebugInfo/Symbolize/Symbolize.cpp
+++ lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -21,6 +21,7 @@
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/PDB/PDB.h"
#include "llvm/DebugInfo/PDB/PDBContext.h"
+#include "llvm/Demangle/Demangle.h"
#include "llvm/Object/COFF.h"
#include "llvm/Object/MachO.h"
#include "llvm/Object/MachOUniversal.h"
@@ -468,19 +469,23 @@
std::string
LLVMSymbolizer::DemangleName(const std::string &Name,
const SymbolizableModule *DbiModuleDescriptor) {
-#if !defined(_MSC_VER)
// We can spoil names of symbols with C linkage, so use an heuristic
// approach to check if the name should be demangled.
if (Name.substr(0, 2) == "_Z") {
int status = 0;
+#if defined(_MSC_VER)
+ char *DemangledName = itaniumDemangle(Name.c_str(), nullptr, nullptr, &status);
+#else
char *DemangledName = __cxa_demangle(Name.c_str(), nullptr, nullptr, &status);
+#endif
if (status != 0)
return Name;
std::string Result = DemangledName;
free(DemangledName);
return Result;
}
-#else
+
+#if defined(_MSC_VER)
if (!Name.empty() && Name.front() == '?') {
// Only do MSVC C++ demangling on symbols starting with '?'.
char DemangledName[1024] = {0};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44192.137335.patch
Type: text/x-patch
Size: 1703 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180307/07be9f2c/attachment.bin>
More information about the llvm-commits
mailing list