mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-14 17:34:41 +00:00
llvm-symbolizer: make mangled name heuristic apply to all symbols
PR: http://llvm.org/pr18431 Review: http://llvm-reviews.chandlerc.com/D2552 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199404 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fbe67dabad
commit
22939fa0a4
18
test/DebugInfo/Inputs/llvm-symbolizer-test.c
Normal file
18
test/DebugInfo/Inputs/llvm-symbolizer-test.c
Normal 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>
|
BIN
test/DebugInfo/Inputs/llvm-symbolizer-test.elf-x86-64
Executable file
BIN
test/DebugInfo/Inputs/llvm-symbolizer-test.elf-x86-64
Executable file
Binary file not shown.
@ -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$}}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user