1 # This test uses the local debuginfod cache to test the llvm-objdump integration
2 # with the debuginfod client.
3 REQUIRES: x86-registered-target
8 # Produce a stripped copy of the input binary.
9 # Note: See embedded-source.test for details about the input file.
10 RUN: llvm-objcopy --strip-debug %p/Inputs/embedded-source %t/stripped
12 # Printing source for the stripped binary should fail.
13 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-objdump -d --source %t/stripped | \
14 RUN: FileCheck %s --check-prefix=NOTFOUND
16 # Use cp to write the debug binary to an appropriately-named file in the llvm
18 RUN: cp %p/Inputs/embedded-source %t/llvmcache-17908201640401622315
20 # Write a broken "binary" under %t/broken.
22 RUN: echo "bad" > %t/broken/llvmcache-17908201640401622315
24 # Write the stripped binary under %t/stripped-cache.
25 RUN: mkdir %t/stripped-cache
26 RUN: cp %t/stripped %t/stripped-cache/llvmcache-17908201640401622315
28 # Write to a debug info directory as well.
29 RUN: mkdir -p %t/debug/.build-id/15
30 RUN: cp %p/Inputs/embedded-source %t/debug/.build-id/15/12f769114c011387393822af15dd660c080295.debug
32 # Don't use debuginfod by default without any URLs.
33 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-objdump -d --source %t/stripped | \
34 RUN: FileCheck %s --check-prefix=NOTFOUND
36 # Don't use debuginfod if disabled.
37 RUN: env DEBUGINFOD_CACHE_PATH=%t DEBUGINFOD_URLS=http://foo \
38 RUN: llvm-objdump -d --source --no-debuginfod %t/stripped | \
39 RUN: FileCheck %s --check-prefix=NOTFOUND
41 # Look up build IDs locally without debuginfod.
42 RUN: llvm-objdump -d --source --no-debuginfod --debug-file-directory %t/debug \
44 RUN: FileCheck %s --check-prefix=FOUND
46 # Use debuginfod without URLs if requested.
47 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-objdump -d --source --debuginfod \
49 RUN: FileCheck %s --check-prefix=FOUND
51 # Produce a warning if a bad binary is fetched, but do not fail.
52 RUN: env DEBUGINFOD_CACHE_PATH=%t/broken llvm-objdump -d --source --debuginfod \
53 RUN: %t/stripped 2> %t.err | \
54 RUN: FileCheck %s --check-prefix=NOTFOUND
55 RUN: FileCheck %s --check-prefix=BADBINARYERROR -DPATH=%t --input-file %t.err
56 BADBINARYERROR: warning: '[[PATH]]/broken{{[/\\]}}llvmcache-17908201640401622315': The file was not recognized as a valid object file
58 # Use the original binary if the fetched binary has no debug info.
59 RUN: env DEBUGINFOD_CACHE_PATH=%t/stripped-cache llvm-objdump -d --source \
60 RUN: --debuginfod %t/stripped 2> %t.err | \
61 RUN: FileCheck %s --check-prefix=NOTFOUND
64 # Use debuginfod to look up build IDs.
65 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-objdump -d --source \
66 RUN: --build-id 1512f769114c011387393822af15dd660c080295 | \
67 RUN: FileCheck %s --check-prefix=FOUND
69 # Produce an error if malformed (not a hex string).
70 RUN: not env DEBUGINFOD_CACHE_PATH=%t llvm-objdump -d --source --build-id foo \
72 RUN: FileCheck %s --check-prefix=MALFORMEDERROR --input-file %t.err
73 MALFORMEDERROR: error: --build-id: expected a build ID, but got 'foo'
75 # Produce an error if not found.
76 RUN: not env DEBUGINFOD_CACHE_PATH=%t llvm-objdump -d --source --build-id abc \
78 RUN: FileCheck %s --check-prefix=NOTFOUNDERROR --input-file %t.err
79 NOTFOUNDERROR: error: --build-id: could not find build ID 'abc'
81 # Use debuginfod to recover symbols.
82 RUN: llvm-strip --strip-sections %t/stripped
83 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-objdump -d --debuginfod \
85 RUN: FileCheck %s --check-prefix=SYMBOLS
87 # Use debuginfod to recover section headers, but not symbols.
88 RUN: mkdir %t/stripped-symbols
89 RUN: cp %p/Inputs/embedded-source %t/stripped-symbols/llvmcache-17908201640401622315
90 RUN: llvm-strip %t/stripped-symbols/llvmcache-17908201640401622315
91 RUN: env DEBUGINFOD_CACHE_PATH=%t/stripped-symbols llvm-objdump -d \
92 RUN: --debuginfod %t/stripped | \
93 RUN: FileCheck %s --check-prefix=SECTIONS
95 # Don't use debuginfod if neither section headers nor symbols can be recovered.
96 RUN: mkdir %t/stripped-sections
97 RUN: echo "" | llvm-mc -filetype=obj -triple x86_64 > \
98 RUN: %t/stripped-sections/llvmcache-17908201640401622315
99 RUN: llvm-strip --strip-sections %t/stripped-sections/llvmcache-17908201640401622315
100 RUN: env DEBUGINFOD_CACHE_PATH=%t/stripped-sections llvm-objdump -d \
101 RUN: --debuginfod %t/stripped | \
102 RUN: FileCheck %s --check-prefix=NOSECTIONS
104 NOTFOUND-NOT: int main(int argc, char *argv[]) {
105 FOUND: int main(int argc, char *argv[]) {
109 NOSECTIONS: <PT_LOAD#{{[0-9]+}}>: