Skip to content

Commit

Permalink
[llvm-symbolizer][test] Simplify test input reading
Browse files Browse the repository at this point in the history
This change migrates most llvm-symbolizer tests away from reading input
via stdin and instead using --obj + positional arguments for the file
and addresses respectively, which makes the tests easier to read.

One exception is the test test/tools/llvm-symbolizer/pdb/pdb.test, which
was doing some manipulation on the input addresses. This patch
simplifies this somewhat, but it still reads from stdin.

More changes to follow to simplify/break-up other tests.

Reviewed by: dblaikie

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

llvm-svn: 352752
  • Loading branch information
jh7370 committed Jan 31, 2019
1 parent 63f3383 commit ca8f3cb
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
RUN: rm -rf %t && mkdir -p %t
RUN: cd %t
RUN: cp %p/Inputs/split-dwarf-no-skel-address.dwo %t
RUN: echo "%p/Inputs/split-dwarf-no-skel-address.o 0x4" > %t.input

RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \
RUN: --default-arch=i386 < %t.input | FileCheck %s
RUN: --default-arch=i386 --obj=%p/Inputs/split-dwarf-no-skel-address.o 0x4 | FileCheck %s

Built from the following source:
void f1();
Expand Down
3 changes: 1 addition & 2 deletions llvm/test/DebugInfo/llvm-symbolizer-tu.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
RUN: echo "%p/Inputs/llvm-symbolizer-tu.elf-x86-64 0x0" \
RUN: | llvm-symbolizer | FileCheck %s
RUN: llvm-symbolizer --obj=%p/Inputs/llvm-symbolizer-tu.elf-x86-64 0x0 | FileCheck %s

Built from the following source:

Expand Down
7 changes: 2 additions & 5 deletions llvm/test/DebugInfo/llvm-symbolizer-zlib.test
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
REQUIRES: zlib

RUN: echo "%p/Inputs/dwarfdump-test-zlib.elf-x86-64 0x4005e9" > %t1.input
RUN: llvm-symbolizer < %t1.input | FileCheck %s

RUN: echo "%p/Inputs/dwarfdump-test-zlibgnu.elf-x86-64 0x4005e9" > %t2.input
RUN: llvm-symbolizer < %t2.input | FileCheck %s
RUN: llvm-symbolizer --obj=%p/Inputs/dwarfdump-test-zlib.elf-x86-64 0x4005e9 | FileCheck %s
RUN: llvm-symbolizer --obj=%p/Inputs/dwarfdump-test-zlibgnu.elf-x86-64 0x4005e9 | FileCheck %s

CHECK: main
CHECK-NEXT: /tmp/dbginfo{{[/\\]}}dwarfdump-test-zlib.cc:16
12 changes: 3 additions & 9 deletions llvm/test/tools/llvm-symbolizer/coff-dwarf.test
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \
RUN: | llvm-symbolizer --inlining --relative-address -obj="%p/Inputs/coff-dwarf.exe" \
RUN: llvm-symbolizer 0x5009 0x5038 --inlining --relative-address -obj="%p/Inputs/coff-dwarf.exe" \
RUN: | FileCheck %s
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \
RUN: | llvm-symbolizer --inlines --relative-address -obj="%p/Inputs/coff-dwarf.exe" \
RUN: llvm-symbolizer 0x5009 0x5038 --inlines --relative-address -obj="%p/Inputs/coff-dwarf.exe" \
RUN: | FileCheck %s
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \
RUN: | llvm-symbolizer -i --relative-address -obj="%p/Inputs/coff-dwarf.exe" \
RUN: llvm-symbolizer 0x5009 0x5038 -i --relative-address -obj="%p/Inputs/coff-dwarf.exe" \
RUN: | FileCheck %s

This test relies on UnDecorateSymbolName, which is Windows-only.
REQUIRES: target-windows, system-windows

ADDR: 0x5009
ADDR: 0x5038

CHECK: foo(void)
CHECK: coff-dwarf.cpp:7
CHECK: bar(void)
Expand Down
19 changes: 6 additions & 13 deletions llvm/test/tools/llvm-symbolizer/coff-exports.test
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \
RUN: | llvm-symbolizer --inlining --relative-address -obj="%p/Inputs/coff-exports.exe" \
RUN: | FileCheck %s
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \
RUN: | llvm-symbolizer --inlines --relative-address -obj="%p/Inputs/coff-exports.exe" \
RUN: | FileCheck %s
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \
RUN: | llvm-symbolizer -i --relative-address -obj="%p/Inputs/coff-exports.exe" \
RUN: | FileCheck %s
RUN: llvm-symbolizer 0x500A 0x5038 0x504B --inlining --relative-address -obj="%p/Inputs/coff-exports.exe" \
RUN: | FileCheck %s
RUN: llvm-symbolizer 0x500A 0x5038 0x504B --inlines --relative-address -obj="%p/Inputs/coff-exports.exe" \
RUN: | FileCheck %s
RUN: llvm-symbolizer 0x500A 0x5038 0x504B -i --relative-address -obj="%p/Inputs/coff-exports.exe" \
RUN: | FileCheck %s

This test relies on UnDecorateSymbolName, which is Win32-only.
REQUIRES: system-windows
REQUIRES: target-windows
FIXME: This test depends on host, not target.

ADDR: 0x500A
ADDR: 0x5038
ADDR: 0x504B

We get the expected stack trace, except 'foo' appears for the 'bar' frame
because 'bar' isn't in the export table.

Expand Down
10 changes: 5 additions & 5 deletions llvm/test/tools/llvm-symbolizer/fat.test
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=x86_64 | FileCheck --check-prefix=X86_64 %s
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=x86_64h | FileCheck --check-prefix=X86_64H %s
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=armv7 | FileCheck --check-prefix=ARMV7 %s
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=armv7em | FileCheck --check-prefix=ARMV7EM %s
RUN: echo 0 | llvm-symbolizer -obj=%p/Inputs/fat.o -default-arch=armv7m | FileCheck --check-prefix=ARMV7M %s
RUN: llvm-symbolizer 0 -obj=%p/Inputs/fat.o -default-arch=x86_64 | FileCheck --check-prefix=X86_64 %s
RUN: llvm-symbolizer 0 -obj=%p/Inputs/fat.o -default-arch=x86_64h | FileCheck --check-prefix=X86_64H %s
RUN: llvm-symbolizer 0 -obj=%p/Inputs/fat.o -default-arch=armv7 | FileCheck --check-prefix=ARMV7 %s
RUN: llvm-symbolizer 0 -obj=%p/Inputs/fat.o -default-arch=armv7em | FileCheck --check-prefix=ARMV7EM %s
RUN: llvm-symbolizer 0 -obj=%p/Inputs/fat.o -default-arch=armv7m | FileCheck --check-prefix=ARMV7M %s

X86_64: x86_64_function
X86_64H: x86_64h_function
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/tools/llvm-symbolizer/padding-x86_64.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
; Checks if symbolizer can correctly symbolize address in the padding between
; functions.
; RUN: llc -o %t.o -filetype=obj -mtriple=x86_64-pc-linux %s
; RUN: echo 0x5 | llvm-symbolizer -obj=%t.o | FileCheck %s --check-prefix=FOO
; RUN: echo 0xd | llvm-symbolizer -obj=%t.o | FileCheck %s --check-prefix=PADDING
; RUN: echo 0x10 | llvm-symbolizer -obj=%t.o | FileCheck %s --check-prefix=MAIN
; RUN: llvm-symbolizer 0x5 -obj=%t.o | FileCheck %s --check-prefix=FOO
; RUN: llvm-symbolizer 0xd -obj=%t.o | FileCheck %s --check-prefix=PADDING
; RUN: llvm-symbolizer 0x10 -obj=%t.o | FileCheck %s --check-prefix=MAIN

;FOO: foo
;PADDING: ??
Expand Down
6 changes: 1 addition & 5 deletions llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \
RUN: | llvm-symbolizer -obj="%p/Inputs/missing_pdb.exe" 2>%t.err \
RUN: llvm-symbolizer 0x401000 0x401001 -obj="%p/Inputs/missing_pdb.exe" 2>%t.err \
RUN: | FileCheck %s
RUN: FileCheck --check-prefix=ERROR %s < %t.err

ADDR: 0x401000
ADDR: 0x401001

llvm-symbolizer should print one error and two unknown line info records.

ERROR: LLVMSymbolizer: error reading file: {{.*}}: {{N|n}}o such file or directory
Expand Down
30 changes: 13 additions & 17 deletions llvm/test/tools/llvm-symbolizer/pdb/pdb.test
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \
RUN: | llvm-symbolizer -obj="%p/Inputs/test.exe" \
RUN: echo 0x401380 > %t.input
RUN: echo 0x401390 >> %t.input
RUN: echo 0x4013A0 >> %t.input
RUN: echo 0x4013C0 >> %t.input
RUN: echo 0x4013D0 >> %t.input
RUN: echo 0x4013E0 >> %t.input
RUN: echo 0x4013F0 >> %t.input
RUN: echo 0x401420 >> %t.input
RUN: llvm-symbolizer -obj="%p/Inputs/test.exe" < %t.input \
RUN: | FileCheck %s
RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \
RUN: | llvm-symbolizer -obj="%p/Inputs/test.exe" -demangle=false \
RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE
RUN: llvm-symbolizer -obj="%p/Inputs/test.exe" -demangle=false < %t.input \
RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE

Subtract ImageBase from all the offsets and run the test again with
--relative-address.

RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \
RUN: | %python -c 'import sys;print("\n".join([hex(int(x, 16) - 0x400000) for x in sys.stdin]))' \
RUN: | llvm-symbolizer -obj="%p/Inputs/test.exe" -demangle=false --relative-address \
RUN: %python -c 'import sys;print("\n".join([hex(int(x, 16) - 0x400000) for x in sys.stdin]))' < %t.input \
RUN: | llvm-symbolizer -obj="%p/Inputs/test.exe" -demangle=false --relative-address \
RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE

ADDR: 0x401380
ADDR: 0x401390
ADDR: 0x4013A0
ADDR: 0x4013C0
ADDR: 0x4013D0
ADDR: 0x4013E0
ADDR: 0x4013F0
ADDR: 0x401420

CHECK: foo(void)
CHECK-NEXT: test.cpp:10
CHECK: {{^private_symbol$}}
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-symbolizer/ppc64.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ int foo() { return 0; }
int bar() { return foo(); }
int _start() { return bar(); }

RUN: %python -c "print('0x1000014c\n0x1000018c\n0x100001cc')" | llvm-symbolizer -obj=%p/Inputs/ppc64 | FileCheck %s
RUN: llvm-symbolizer 0x1000014c 0x1000018c 0x100001cc -obj=%p/Inputs/ppc64 | FileCheck %s

CHECK: foo
CHECK: bar
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-symbolizer/print_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main() {
// RUN: cp %s %t/
// RUN: cp %p/Inputs/print_context.o %t
// RUN: cd %t
// RUN: echo "%t/print_context.o 0x0" | llvm-symbolizer -print-source-context-lines=5 | FileCheck %s
// RUN: llvm-symbolizer -obj=%t/print_context.o 0x0 -print-source-context-lines=5 | FileCheck %s

// Inputs/print_context.o built with plain -g -c from this source file
// Specifying -Xclang -fdebug-compilation-dir -Xclang . to make the debug info
Expand Down

0 comments on commit ca8f3cb

Please sign in to comment.