brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.5 KiB · 3909169 Raw
110 lines · plain
1# This test uses the local debuginfod cache to test the llvm-objdump integration2# with the debuginfod client.3REQUIRES: x86-registered-target4 5RUN: rm -rf %t6RUN: mkdir %t7 8# Produce a stripped copy of the input binary.9# Note: See embedded-source.test for details about the input file.10RUN: llvm-objcopy --strip-debug %p/Inputs/embedded-source %t/stripped11 12# Printing source for the stripped binary should fail.13RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-objdump -d --source %t/stripped | \14RUN:   FileCheck %s --check-prefix=NOTFOUND15 16# Use cp to write the debug binary to an appropriately-named file in the llvm17# debuginfod cache.18RUN: cp %p/Inputs/embedded-source %t/llvmcache-1790820164040162231519 20# Write a broken "binary" under %t/broken.21RUN: mkdir %t/broken22RUN: echo "bad" > %t/broken/llvmcache-1790820164040162231523 24# Write the stripped binary under %t/stripped-cache.25RUN: mkdir %t/stripped-cache26RUN: cp %t/stripped %t/stripped-cache/llvmcache-1790820164040162231527 28# Write to a debug info directory as well.29RUN: mkdir -p %t/debug/.build-id/1530RUN: cp %p/Inputs/embedded-source %t/debug/.build-id/15/12f769114c011387393822af15dd660c080295.debug31 32# Don't use debuginfod by default without any URLs.33RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-objdump -d --source %t/stripped | \34RUN:   FileCheck %s --check-prefix=NOTFOUND35 36# Don't use debuginfod if disabled.37RUN: env DEBUGINFOD_CACHE_PATH=%t DEBUGINFOD_URLS=http://foo \38RUN:   llvm-objdump -d --source --no-debuginfod %t/stripped | \39RUN:   FileCheck %s --check-prefix=NOTFOUND40 41# Look up build IDs locally without debuginfod.42RUN: llvm-objdump -d --source --no-debuginfod --debug-file-directory %t/debug \43RUN:      %t/stripped | \44RUN:   FileCheck %s --check-prefix=FOUND45 46# Use debuginfod without URLs if requested.47RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-objdump -d --source --debuginfod \48RUN:   %t/stripped | \49RUN:   FileCheck %s --check-prefix=FOUND50 51# Produce a warning if a bad binary is fetched, but do not fail.52RUN: env DEBUGINFOD_CACHE_PATH=%t/broken llvm-objdump -d --source --debuginfod \53RUN:   %t/stripped 2> %t.err | \54RUN:   FileCheck %s --check-prefix=NOTFOUND55RUN: FileCheck %s --check-prefix=BADBINARYERROR -DPATH=%t --input-file %t.err56BADBINARYERROR: warning: '[[PATH]]/broken{{[/\\]}}llvmcache-17908201640401622315': The file was not recognized as a valid object file57 58# Use the original binary if the fetched binary has no debug info.59RUN: env DEBUGINFOD_CACHE_PATH=%t/stripped-cache llvm-objdump -d --source \60RUN:   --debuginfod %t/stripped 2> %t.err | \61RUN:   FileCheck %s --check-prefix=NOTFOUND62RUN: count 0 < %t.err63 64# Use debuginfod to look up build IDs.65RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-objdump -d --source \66RUN:   --build-id 1512f769114c011387393822af15dd660c080295 | \67RUN:   FileCheck %s --check-prefix=FOUND68 69# Produce an error if malformed (not a hex string).70RUN: not env DEBUGINFOD_CACHE_PATH=%t llvm-objdump -d --source --build-id foo \71RUN:   2> %t.err72RUN: FileCheck %s --check-prefix=MALFORMEDERROR --input-file %t.err73MALFORMEDERROR: error: --build-id: expected a build ID, but got 'foo'74 75# Produce an error if not found.76RUN: not env DEBUGINFOD_CACHE_PATH=%t llvm-objdump -d --source --build-id abc \77RUN:   2> %t.err78RUN: FileCheck %s --check-prefix=NOTFOUNDERROR --input-file %t.err79NOTFOUNDERROR: error: --build-id: could not find build ID 'abc'80 81# Use debuginfod to recover symbols.82RUN: llvm-strip --strip-sections %t/stripped83RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-objdump -d --debuginfod \84RUN:   %t/stripped | \85RUN:   FileCheck %s --check-prefix=SYMBOLS86 87# Use debuginfod to recover section headers, but not symbols.88RUN: mkdir %t/stripped-symbols89RUN: cp %p/Inputs/embedded-source %t/stripped-symbols/llvmcache-1790820164040162231590RUN: llvm-strip %t/stripped-symbols/llvmcache-1790820164040162231591RUN: env DEBUGINFOD_CACHE_PATH=%t/stripped-symbols llvm-objdump -d \92RUN:   --debuginfod %t/stripped | \93RUN:   FileCheck %s --check-prefix=SECTIONS94 95# Don't use debuginfod if neither section headers nor symbols can be recovered.96RUN: mkdir %t/stripped-sections97RUN: echo "" | llvm-mc -filetype=obj -triple x86_64 > \98RUN:   %t/stripped-sections/llvmcache-1790820164040162231599RUN: llvm-strip --strip-sections %t/stripped-sections/llvmcache-17908201640401622315100RUN: env DEBUGINFOD_CACHE_PATH=%t/stripped-sections llvm-objdump -d \101RUN:   --debuginfod %t/stripped | \102RUN:   FileCheck %s --check-prefix=NOSECTIONS103 104NOTFOUND-NOT: int main(int argc, char *argv[]) {105FOUND: int main(int argc, char *argv[]) {106 107SYMBOLS: <main>:108SECTIONS: <.text>:109NOSECTIONS: <PT_LOAD#{{[0-9]+}}>:110