aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
diff options
context:
space:
mode:
authorZequan Wu <zequanwu@google.com>2025-03-25 13:09:23 -0700
committerGitHub <noreply@github.com>2025-03-25 16:09:23 -0400
commit535b28444f8e1284583c3771eaf64e1e27bbcb28 (patch)
tree15a3c9b48a19cf2dc97fb84cd43fbbbfb6eee29a /llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
parentaacc4e9a38ad93482e6c19a53eefec8406ee1b40 (diff)
downloadllvm-535b28444f8e1284583c3771eaf64e1e27bbcb28.zip
llvm-535b28444f8e1284583c3771eaf64e1e27bbcb28.tar.gz
llvm-535b28444f8e1284583c3771eaf64e1e27bbcb28.tar.bz2
[Symbolize] Always use filename:line from debug info when debug info for the given address is available. (#128619)
To reland https://github.com/llvm/llvm-project/pull/124846, we need to make symbolizer consistent with the case when line number is 0. Always using filename and line from debug info even if the line number is 0 sounds like the reasonable path to go.
Diffstat (limited to 'llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp')
-rw-r--r--llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
index dcd6188..29fd4d9 100644
--- a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
@@ -277,9 +277,9 @@ SymbolizableObjectFile::symbolizeCode(object::SectionedAddress ModuleOffset,
ModuleOffset.SectionIndex =
getModuleSectionIndexForAddress(ModuleOffset.Address);
DILineInfo LineInfo;
- if (std::optional<DILineInfo> DBGLineInfo =
- DebugInfoContext->getLineInfoForAddress(ModuleOffset,
- LineInfoSpecifier))
+ std::optional<DILineInfo> DBGLineInfo =
+ DebugInfoContext->getLineInfoForAddress(ModuleOffset, LineInfoSpecifier);
+ if (DBGLineInfo)
LineInfo = *DBGLineInfo;
// Override function name from symbol table if necessary.
@@ -290,7 +290,9 @@ SymbolizableObjectFile::symbolizeCode(object::SectionedAddress ModuleOffset,
FileName)) {
LineInfo.FunctionName = FunctionName;
LineInfo.StartAddress = Start;
- if (LineInfo.FileName == DILineInfo::BadString && !FileName.empty())
+ // Only use the filename from symbol table if the debug info for the
+ // address is missing.
+ if (!DBGLineInfo && !FileName.empty())
LineInfo.FileName = FileName;
}
}
@@ -307,8 +309,11 @@ DIInliningInfo SymbolizableObjectFile::symbolizeInlinedCode(
ModuleOffset, LineInfoSpecifier);
// Make sure there is at least one frame in context.
- if (InlinedContext.getNumberOfFrames() == 0)
+ bool EmptyFrameAdded = false;
+ if (InlinedContext.getNumberOfFrames() == 0) {
+ EmptyFrameAdded = true;
InlinedContext.addFrame(DILineInfo());
+ }
// Override the function name in lower frame with name from symbol table.
if (shouldOverrideWithSymbolTable(LineInfoSpecifier.FNKind, UseSymbolTable)) {
@@ -320,7 +325,9 @@ DIInliningInfo SymbolizableObjectFile::symbolizeInlinedCode(
InlinedContext.getNumberOfFrames() - 1);
LI->FunctionName = FunctionName;
LI->StartAddress = Start;
- if (LI->FileName == DILineInfo::BadString && !FileName.empty())
+ // Only use the filename from symbol table if the debug info for the
+ // address is missing.
+ if (EmptyFrameAdded && !FileName.empty())
LI->FileName = FileName;
}
}