diff options
author | Mitch Phillips <31459023+hctim@users.noreply.github.com> | 2022-05-23 13:11:01 -0700 |
---|---|---|
committer | Mitch Phillips <31459023+hctim@users.noreply.github.com> | 2022-05-23 13:30:22 -0700 |
commit | cead4eceb01b935fae07bf4a7e91911b344d2fec (patch) | |
tree | 1d5185aed170c75c8811d33f99fbdc2616fc258c /llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp | |
parent | 97c3ef5c8a289ca54ca0c61c75fd00adab92b7c0 (diff) | |
download | llvm-cead4eceb01b935fae07bf4a7e91911b344d2fec.zip llvm-cead4eceb01b935fae07bf4a7e91911b344d2fec.tar.gz llvm-cead4eceb01b935fae07bf4a7e91911b344d2fec.tar.bz2 |
[symbolizer] Parse DW_TAG_variable DIs to show line info for globals
Currently, llvm-symbolizer doesn't like to parse .debug_info in order to
show the line info for global variables. addr2line does this. In the
future, I'm looking to migrate AddressSanitizer off of internal metadata
over to using debuginfo, and this is predicated on being able to get the
line info for global variables.
This patch adds the requisite support for getting the line info from the
.debug_info section for symbolizing global variables. This only happens
when you ask for a global variable to be symbolized as data.
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D123538
Diffstat (limited to 'llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp index fcff531..d8ee926 100644 --- a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp +++ b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp @@ -327,6 +327,14 @@ DIGlobal SymbolizableObjectFile::symbolizeData( std::string FileName; getNameFromSymbolTable(ModuleOffset.Address, Res.Name, Res.Start, Res.Size, FileName); + Res.DeclFile = FileName; + + // Try and get a better filename:lineno pair from the debuginfo, if present. + DILineInfo DL = DebugInfoContext->getLineInfoForDataAddress(ModuleOffset); + if (DL.Line != 0) { + Res.DeclFile = DL.FileName; + Res.DeclLine = DL.Line; + } return Res; } |