1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

llvm-symbolizer: make mangled name heuristic apply to all symbols

PR: http://llvm.org/pr18431
Review: http://llvm-reviews.chandlerc.com/D2552
llvm-svn: 199404
This commit is contained in:
Ed Maste 2014-01-16 17:25:12 +00:00
parent 571d7cac93
commit 0234b50a22
5 changed files with 34 additions and 8 deletions

View File

@ -0,0 +1,18 @@
int f(int a, int b) {
return a + b;
}
int g(int a) {
return a + 1;
}
int main() {
return f(2, g(2));
}
// Built with Clang 3.3:
// $ mkdir -p /tmp/dbginfo
// $ cp llvm-symbolizer-test.c /tmp/dbginfo
// $ cd /tmp/dbginfo
// $ clang -g llvm-symbolizer-test.c -o <output>

Binary file not shown.

View File

@ -66,3 +66,14 @@ RUN: | FileCheck %s --check-prefix=BINARY
BINARY: main
BINARY-NEXT: /tmp/dbginfo{{[/\\]}}dwarfdump-test.cc:16
BINARY: _start
RUN: echo "0x400720" > %t.input5
RUN: echo "0x4004a0" >> %t.input5
RUN: echo "0x4006f0" >> %t.input5
RUN: llvm-symbolizer --obj %p/Inputs/llvm-symbolizer-test.elf-x86-64 < %t.input5 \
RUN: | FileCheck %s --check-prefix=BINARY_C
BINARY_C: main
BINARY_C-NEXT: /tmp/dbginfo{{[/\\]}}llvm-symbolizer-test.c:10
BINARY_C: _start
BINARY_C: {{g$}}

View File

@ -195,7 +195,7 @@ std::string LLVMSymbolizer::symbolizeData(const std::string &ModuleName,
if (Opts.UseSymbolTable) {
if (ModuleInfo *Info = getOrCreateModuleInfo(ModuleName)) {
if (Info->symbolizeData(ModuleOffset, Name, Start, Size) && Opts.Demangle)
Name = DemangleGlobalName(Name);
Name = DemangleName(Name);
}
}
std::stringstream ss;
@ -424,6 +424,10 @@ extern "C" char *__cxa_demangle(const char *mangled_name, char *output_buffer,
std::string LLVMSymbolizer::DemangleName(const std::string &Name) {
#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")
return Name;
int status = 0;
char *DemangledName = __cxa_demangle(Name.c_str(), 0, 0, &status);
if (status != 0)
@ -436,11 +440,5 @@ std::string LLVMSymbolizer::DemangleName(const std::string &Name) {
#endif
}
std::string LLVMSymbolizer::DemangleGlobalName(const std::string &Name) {
// We can spoil names of globals with C linkage, so use an heuristic
// approach to check if the name should be demangled.
return (Name.substr(0, 2) == "_Z") ? DemangleName(Name) : Name;
}
} // namespace symbolize
} // namespace llvm

View File

@ -71,7 +71,6 @@ private:
ObjectFile *getObjectFileFromBinary(Binary *Bin, const std::string &ArchName);
std::string printDILineInfo(DILineInfo LineInfo) const;
static std::string DemangleGlobalName(const std::string &Name);
// Owns all the parsed binaries and object files.
SmallVector<Binary*, 4> ParsedBinariesAndObjects;