[PATCH] D118174: [Symbolize][DebugInfoD] Try looking up failed paths as Build IDs.
Daniel Thornburgh via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 26 12:20:51 PST 2022
mysterymath updated this revision to Diff 403372.
mysterymath marked an inline comment as done.
mysterymath added a comment.
- Bail on small hex strings, not exact size.
- Reworded comment.
- Fixed typo.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118174/new/
https://reviews.llvm.org/D118174
Files:
llvm/docs/CommandGuide/llvm-symbolizer.rst
llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
llvm/test/tools/llvm-symbolizer/debuginfod.test
Index: llvm/test/tools/llvm-symbolizer/debuginfod.test
===================================================================
--- llvm/test/tools/llvm-symbolizer/debuginfod.test
+++ llvm/test/tools/llvm-symbolizer/debuginfod.test
@@ -25,3 +25,8 @@
RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
RUN: --obj=%t/addr.exe 0x40054d | FileCheck %s --check-prefix=FOUND
FOUND: {{[/\]+}}tmp{{[/\]+}}x.c:14:0
+
+# This should also work if the Build ID is provided in lieu of a path.
+RUN: env DEBUGINFOD_CACHE_PATH=%t llvm-symbolizer \
+RUN: --obj=127da749021c1fc1a58cba734a1f542cbe2b7ce4 0x40054d | \
+RUN: FileCheck %s --check-prefix=FOUND
Index: llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
===================================================================
--- llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -508,9 +508,32 @@
Bin = Pair.first->second.getBinary();
} else {
Expected<OwningBinary<Binary>> BinOrErr = createBinary(Path);
- if (!BinOrErr)
- return BinOrErr.takeError();
- Pair.first->second = std::move(BinOrErr.get());
+ if (BinOrErr) {
+ Pair.first->second = std::move(BinOrErr.get());
+ } else {
+ ArrayRef<uint8_t> BuildID;
+
+ // Since this isn't a path to a valid binary, maybe it's a Build ID.
+ std::string Bytes;
+ if (!tryGetFromHex(Path, Bytes))
+ return BinOrErr.takeError();
+ BuildID = ArrayRef<uint8_t>(
+ reinterpret_cast<const uint8_t *>(Bytes.data()), Bytes.size());
+ // There's no fixed size for Build IDs, but if it's fewer than 128 bits,
+ // it's unlikely to be one.
+ if (BuildID.size() < 16)
+ return BinOrErr.takeError();
+
+ std::string PathFromBuildID;
+ if (!findDebugBinary(Opts.DebugFileDirectory, BuildID, PathFromBuildID))
+ return BinOrErr.takeError();
+ Expected<OwningBinary<Binary>> BuildIDBinOrErr =
+ createBinary(PathFromBuildID);
+ if (!BuildIDBinOrErr)
+ return joinErrors(BinOrErr.takeError(), BuildIDBinOrErr.takeError());
+ consumeError(BinOrErr.takeError());
+ Pair.first->second = std::move(BuildIDBinOrErr.get());
+ }
Bin = Pair.first->second.getBinary();
}
Index: llvm/docs/CommandGuide/llvm-symbolizer.rst
===================================================================
--- llvm/docs/CommandGuide/llvm-symbolizer.rst
+++ llvm/docs/CommandGuide/llvm-symbolizer.rst
@@ -28,6 +28,13 @@
input or as positional arguments on the command-line, following any "DATA" or
"CODE" prefix.
+Wherever a binary filename is accepted, a Build ID can be provided instead to
+search for the binary. Various cache directories are searched first, followed by
+any DebugInfoD servers configured via the ``DEBUGINFOD_URLS`` environment
+variable. For server lookups to work, the tool needs must have been built with
+``LLVM_ENABLE_CURL`` enabled.
+
+
:program:`llvm-symbolizer` parses options from the environment variable
``LLVM_SYMBOLIZER_OPTS`` after parsing options from the command line.
``LLVM_SYMBOLIZER_OPTS`` is primarily useful for supplementing the command-line
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118174.403372.patch
Type: text/x-patch
Size: 3138 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220126/37849cdf/attachment.bin>
More information about the llvm-commits
mailing list