1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00

[llvm-symbolizer] Make the output with -output-style=GNU closer to addr2line's

This patch addresses two differences in the output of llvm-symbolizer
and GNU's addr2line:

* llvm-symbolizer prints an empty line after the report for an address.

* With "-f -i=0", llvm-symbolizer replaces the name of an inlined
  function with the name from the symbol table, i. e., the top caller
  function in the inlining chain. addr2line preserves the name of the
  inlined function.

Differential Revision: https://reviews.llvm.org/D60770

llvm-svn: 358747
This commit is contained in:
Igor Kudrin 2019-04-19 10:12:56 +00:00
parent 0e90564849
commit 317006d21f
4 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,19 @@
This test checks that with --output-style=GNU the tool does not print an empty
line after the report for an address. The current behavior is preserved for
--output-style=LLVM or if the option is omitted.
RUN: llvm-symbolizer -e %p/Inputs/addr.exe < %p/Inputs/addr.inp \
RUN: | FileCheck %s --check-prefix=LLVM
RUN: llvm-symbolizer --output-style=LLVM -e %p/Inputs/addr.exe < %p/Inputs/addr.inp \
RUN: | FileCheck %s --check-prefix=LLVM
RUN: llvm-symbolizer --output-style=GNU -e %p/Inputs/addr.exe < %p/Inputs/addr.inp \
RUN: | FileCheck %s --check-prefix=GNU
LLVM: x.c:14:0
LLVM-EMPTY:
LLVM-NEXT: some text2
GNU: x.c:14
GNU-NEXT: some text2

View File

@ -0,0 +1,17 @@
This test checks that when inlined frames are not shown (-i=0) and the output
style is set to GNU (--output-style=GNU) the name of an inlined function is not
replaced with the name of the top caller function. At the same time, the current
behavior of llvm-symbolizer is preserved with --output-style=LLVM or when
the option is not specified.
RUN: llvm-symbolizer -i=0 -e %p/Inputs/addr.exe 0x40054d \
RUN: | FileCheck %s --check-prefix=LLVM --implicit-check-not=inctwo
RUN: llvm-symbolizer --output-style=LLVM -i=0 -e %p/Inputs/addr.exe 0x40054d \
RUN: | FileCheck %s --check-prefix=LLVM --implicit-check-not=inctwo
RUN: llvm-symbolizer --output-style=GNU -i=0 -e %p/Inputs/addr.exe 0x40054d \
RUN: | FileCheck %s --check-prefix=GNU --implicit-check-not=main
LLVM: main
GNU: inctwo

View File

@ -227,13 +227,25 @@ static void symbolizeInput(StringRef InputString, LLVMSymbolizer &Symbolizer,
ModuleName, {Offset, object::SectionedAddress::UndefSection},
ClDwpName);
Printer << (error(ResOrErr) ? DIInliningInfo() : ResOrErr.get());
} else if (ClOutputStyle == DIPrinter::OutputStyle::GNU) {
// With ClPrintFunctions == FunctionNameKind::LinkageName (default)
// and ClUseSymbolTable == true (also default), Symbolizer.symbolizeCode()
// may override the name of an inlined function with the name of the topmost
// caller function in the inlining chain. This contradicts the existing
// behavior of addr2line. Symbolizer.symbolizeInlinedCode() overrides only
// the topmost function, which suits our needs better.
auto ResOrErr = Symbolizer.symbolizeInlinedCode(
ModuleName, {Offset, object::SectionedAddress::UndefSection},
ClDwpName);
Printer << (error(ResOrErr) ? DILineInfo() : ResOrErr.get().getFrame(0));
} else {
auto ResOrErr = Symbolizer.symbolizeCode(
ModuleName, {Offset, object::SectionedAddress::UndefSection},
ClDwpName);
Printer << (error(ResOrErr) ? DILineInfo() : ResOrErr.get());
}
outs() << "\n";
if (ClOutputStyle == DIPrinter::OutputStyle::LLVM)
outs() << "\n";
outs().flush();
}