aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
diff options
context:
space:
mode:
authorMitch Phillips <31459023+hctim@users.noreply.github.com>2022-05-23 13:11:01 -0700
committerMitch Phillips <31459023+hctim@users.noreply.github.com>2022-05-23 13:30:22 -0700
commitcead4eceb01b935fae07bf4a7e91911b344d2fec (patch)
tree1d5185aed170c75c8811d33f99fbdc2616fc258c /llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
parent97c3ef5c8a289ca54ca0c61c75fd00adab92b7c0 (diff)
downloadllvm-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.cpp8
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;
}