1 # This test uses the local debuginfod cache to test the symbolizer integration
2 # with the debuginfod client.
6 # Produce a stripped copy of the input binary addr.exe
7 RUN: llvm-objcopy --strip-debug %p/Inputs/addr.exe %t/addr.exe
9 # Symbolizing the stripped binary should fail.
10 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer --print-address \
11 RUN: --obj=%t/addr.exe 0x40054d | FileCheck %s --check-prefix=NOTFOUND
16 # Use llvm-objcopy to write the debuginfo of the addr.exe binary to an
17 # appropriately-named file in the llvm debuginfod cache. The filename is
18 # determined by the debuginfod client's caching scheme, so it is manually
19 # specified here as llvmcache-\d+
20 RUN: llvm-objcopy --keep-section=.debug_info %p/Inputs/addr.exe \
21 RUN: %t/llvmcache-1165050469834211050
23 # The symbolizer should call the debuginfod client library, which finds the
24 # debuginfo placed in the cache, enabling symbolization of the address.
25 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
26 RUN: --obj=%t/addr.exe 0x40054d --debuginfod | \
27 RUN: FileCheck %s --check-prefix=FOUND
28 FOUND: {{[/\]+}}tmp{{[/\]+}}x.c:14:0
30 # This should also work if the build ID is provided via flag.
31 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
32 RUN: --build-id=127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d | \
33 RUN: FileCheck %s --check-prefix=FOUND
35 # This should also work if the build ID is provided via stdin.
36 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
37 RUN: "BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" | \
38 RUN: FileCheck %s --check-prefix=FOUND
40 # Passing BUILDID twice is a syntax error.
41 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
42 RUN: "BUILDID:BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" 2>&1 | \
43 RUN: FileCheck %s --check-prefix=BUILDIDBUILDID
44 BUILDIDBUILDID: error: 'BUILDID:BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d': duplicate input file specification prefix
46 # CODE should work preceding build ID.
47 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
48 RUN: "CODE BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" | \
49 RUN: FileCheck %s --check-prefix=FOUND
51 # The symbolizer shouldn't call the debuginfod library by default with no URLs.
52 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer --print-address \
53 RUN: --obj=%t/addr.exe 0x40054d | FileCheck %s --check-prefix=NOTFOUND
55 # The symbolizer shouldn't call the debuginfod library if explicitly disabled.
56 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
57 RUN: --no-debuginfod \
58 RUN: "BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" | \
59 RUN: FileCheck %s --check-prefix=NOTHINGFOUND
61 NOTHINGFOUND-NEXT: ??:0:0
63 # BUILDID shouldn't be parsed if --obj is given, just like regular filenames.
64 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
65 RUN: --obj=%t/addr.exe \
66 RUN: "BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" 2>&1 | \
67 RUN: FileCheck %s --check-prefix=BUILDIDIGNORED
68 BUILDIDIGNORED: error: 'BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d': input file has already been specified
70 # Providing both BUILDID and FILE is a syntax error.
71 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
72 RUN: "BUILDID:FILE:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" 2>&1 | \
73 RUN: FileCheck %s --check-prefix=BUILDIDFILE
74 BUILDIDFILE: error: 'BUILDID:FILE:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d': duplicate input file specification prefix
75 RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
76 RUN: "FILE:BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d" 2>&1 | \
77 RUN: FileCheck %s --check-prefix=FILEBUILDID
78 FILEBUILDID: error: 'FILE:BUILDID:127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d': duplicate input file specification prefix