Index: test/DebugInfo/Inputs/llvm-symbolizer-test.c =================================================================== --- /dev/null +++ test/DebugInfo/Inputs/llvm-symbolizer-test.c @@ -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 dwarfdump-test.cc -o Index: test/DebugInfo/llvm-symbolizer.test =================================================================== --- test/DebugInfo/llvm-symbolizer.test +++ test/DebugInfo/llvm-symbolizer.test @@ -66,3 +66,14 @@ 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$}} Index: tools/llvm-symbolizer/LLVMSymbolize.h =================================================================== --- tools/llvm-symbolizer/LLVMSymbolize.h +++ tools/llvm-symbolizer/LLVMSymbolize.h @@ -71,7 +71,6 @@ 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 ParsedBinariesAndObjects; Index: tools/llvm-symbolizer/LLVMSymbolize.cpp =================================================================== --- tools/llvm-symbolizer/LLVMSymbolize.cpp +++ tools/llvm-symbolizer/LLVMSymbolize.cpp @@ -195,7 +195,7 @@ 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; @@ -423,6 +423,10 @@ 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) @@ -435,11 +439,5 @@ #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