diff --git a/llvm/docs/CommandGuide/llvm-symbolizer.rst b/llvm/docs/CommandGuide/llvm-symbolizer.rst --- a/llvm/docs/CommandGuide/llvm-symbolizer.rst +++ b/llvm/docs/CommandGuide/llvm-symbolizer.rst @@ -188,6 +188,13 @@ Look up the object using the given build ID, specified as a hexadecimal string. Mutually exclusive with :option:`--obj`. +.. option:: --debuginfod, --no-debuginfod + + Whether or not to try debuginfod lookups for debug binaries. Unless specified, + debuginfod is only enabled if libcurl was compiled in (``LLVM_ENABLE_CURL``) + and at least one server URL was provided by the environment variable + ``DEBUGINFOD_URLS``. + .. _llvm-symbolizer-opt-C: .. option:: --demangle, -C diff --git a/llvm/test/tools/llvm-symbolizer/debuginfod.test b/llvm/test/tools/llvm-symbolizer/debuginfod.test --- a/llvm/test/tools/llvm-symbolizer/debuginfod.test +++ b/llvm/test/tools/llvm-symbolizer/debuginfod.test @@ -23,10 +23,15 @@ # The symbolizer should call the debuginfod client library, which finds the # debuginfo placed in the cache, enabling symbolization of the address. RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \ -RUN: --obj=%t/addr.exe 0x40054d | FileCheck %s --check-prefix=FOUND +RUN: --obj=%t/addr.exe 0x40054d --debuginfod | \ +RUN: FileCheck %s --check-prefix=FOUND FOUND: {{[/\]+}}tmp{{[/\]+}}x.c:14:0 # This should also work if the build ID is provided. RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \ RUN: --build-id=127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d | \ RUN: FileCheck %s --check-prefix=FOUND + +# The symbolizer shouldn't call the debuginfod library by default with no URLs. +RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer --print-address \ +RUN: --obj=%t/addr.exe 0x40054d | FileCheck %s --check-prefix=NOTFOUND diff --git a/llvm/tools/llvm-symbolizer/Opts.td b/llvm/tools/llvm-symbolizer/Opts.td --- a/llvm/tools/llvm-symbolizer/Opts.td +++ b/llvm/tools/llvm-symbolizer/Opts.td @@ -23,6 +23,7 @@ def basenames : Flag<["--"], "basenames">, HelpText<"Strip directory names from paths">; defm build_id : Eq<"build-id", "Build ID used to look up the object file">; defm debug_file_directory : Eq<"debug-file-directory", "Path to directory where to look for debug files">, MetaVarName<"