[llvm-symbolizer] Support debug file lookup using build ID
authorPetr Hosek <phosek@google.com>
Wed, 27 Nov 2019 01:18:42 +0000 (17:18 -0800)
committerPetr Hosek <phosek@google.com>
Wed, 4 Dec 2019 23:07:56 +0000 (15:07 -0800)
commit00e436f1307f506681782d26f4d3b9e98feada5a
tree31a7e1e467fef1f7eb2366ad59956d65ceafe181
parente420c0c78eb0700989c8ba80e845b6306d66bb5f
[llvm-symbolizer] Support debug file lookup using build ID

Build ID is a protocol for looking up debug files that's already
supported by various tools including debuggers. For example, when
locating debug files, gdb would check the following directories:

- /usr/lib/debug/.build-id/ab/cdef1234.debug
- /usr/bin/ls.debug
- /usr/bin/.debug/ls.debug
- /usr/lib/debug/usr/bin/ls.debug

llvm-symbolizer currently consults all of these except for build ID
based one. This patch implements support for build ID lookup. The
set of debug directories to search is specified by the new option:
--debug-file-directory, whose name matches the debug-file-directory
variable used by gdb for the same purpose.

Differential Revision: https://reviews.llvm.org/D70759
llvm/include/llvm/DebugInfo/Symbolize/Symbolize.h
llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
llvm/test/DebugInfo/Inputs/.build-id/ab/b50d82b6bdc861.debug [new file with mode: 0755]
llvm/test/DebugInfo/symbolize-build-id.test [new file with mode: 0644]
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp