[llvm] r199404 - llvm-symbolizer: make mangled name heuristic apply to all symbols
Ed Maste
emaste at freebsd.org
Thu Jan 16 09:25:12 PST 2014
Author: emaste
Date: Thu Jan 16 11:25:12 2014
New Revision: 199404
URL: http://llvm.org/viewvc/llvm-project?rev=199404&view=rev
Log:
llvm-symbolizer: make mangled name heuristic apply to all symbols
PR: http://llvm.org/pr18431
Review: http://llvm-reviews.chandlerc.com/D2552
Added:
llvm/trunk/test/DebugInfo/Inputs/llvm-symbolizer-test.c
llvm/trunk/test/DebugInfo/Inputs/llvm-symbolizer-test.elf-x86-64 (with props)
Modified:
llvm/trunk/test/DebugInfo/llvm-symbolizer.test
llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h
Added: llvm/trunk/test/DebugInfo/Inputs/llvm-symbolizer-test.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/llvm-symbolizer-test.c?rev=199404&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/Inputs/llvm-symbolizer-test.c (added)
+++ llvm/trunk/test/DebugInfo/Inputs/llvm-symbolizer-test.c Thu Jan 16 11:25:12 2014
@@ -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>
Added: llvm/trunk/test/DebugInfo/Inputs/llvm-symbolizer-test.elf-x86-64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/llvm-symbolizer-test.elf-x86-64?rev=199404&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/DebugInfo/Inputs/llvm-symbolizer-test.elf-x86-64
------------------------------------------------------------------------------
svn:executable = *
Propchange: llvm/trunk/test/DebugInfo/Inputs/llvm-symbolizer-test.elf-x86-64
------------------------------------------------------------------------------
svn:mime-type = application/x-executable
Modified: llvm/trunk/test/DebugInfo/llvm-symbolizer.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/llvm-symbolizer.test?rev=199404&r1=199403&r2=199404&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/llvm-symbolizer.test (original)
+++ llvm/trunk/test/DebugInfo/llvm-symbolizer.test Thu Jan 16 11:25:12 2014
@@ -66,3 +66,14 @@ RUN: | FileCheck %s --check-prefix=BIN
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$}}
Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=199404&r1=199403&r2=199404&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp (original)
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp Thu Jan 16 11:25:12 2014
@@ -195,7 +195,7 @@ std::string LLVMSymbolizer::symbolizeDat
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 ch
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
#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
Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h?rev=199404&r1=199403&r2=199404&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h (original)
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.h Thu Jan 16 11:25:12 2014
@@ -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;
More information about the llvm-commits
mailing list