[PATCH] D156446: [BPF] Emit better error on missing line info
Tamir Duberstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 27 18:02:01 PDT 2023
tamird updated this revision to Diff 544991.
tamird added a comment.
Avoid the crash
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156446/new/
https://reviews.llvm.org/D156446
Files:
llvm/lib/Target/BPF/BTFDebug.cpp
Index: llvm/lib/Target/BPF/BTFDebug.cpp
===================================================================
--- llvm/lib/Target/BPF/BTFDebug.cpp
+++ llvm/lib/Target/BPF/BTFDebug.cpp
@@ -1006,16 +1006,18 @@
void BTFDebug::constructLineInfo(const DIFile *File, MCSymbol *Label,
uint32_t Line, uint32_t Column) {
- std::string FileName = populateFileContent(File);
BTFLineInfo LineInfo;
LineInfo.Label = Label;
- LineInfo.FileNameOff = addString(FileName);
- // If file content is not available, let LineOff = 0.
- if (Line < FileContent[FileName].size())
- LineInfo.LineOff = addString(FileContent[FileName][Line]);
- else
- LineInfo.LineOff = 0;
+ LineInfo.FileNameOff = 0;
+ LineInfo.LineOff = 0;
+ if (File) {
+ std::string FileName = populateFileContent(File);
+ LineInfo.FileNameOff = addString(FileName);
+ // If file content is not available, let LineOff = 0.
+ if (Line < FileContent[FileName].size())
+ LineInfo.LineOff = addString(FileContent[FileName][Line]);
+ }
LineInfo.LineNum = Line;
LineInfo.ColumnNum = Column;
LineInfoTable[SecNameOff].push_back(LineInfo);
@@ -1372,9 +1374,15 @@
// This instruction will be skipped, no LineInfo has
// been generated, construct one based on function signature.
if (LineInfoGenerated == false) {
- auto *S = MI->getMF()->getFunction().getSubprogram();
+ const Function &F = MI->getMF()->getFunction();
+ auto *S = F.getSubprogram();
MCSymbol *FuncLabel = Asm->getFunctionBegin();
- constructLineInfo(S->getFile(), FuncLabel, S->getLine(), 0);
+ // The callee may not have been compiled with debug info.
+ if (S) {
+ constructLineInfo(S->getFile(), FuncLabel, S->getLine(), 0);
+ } else {
+ constructLineInfo(nullptr, FuncLabel, 0, 0);
+ }
LineInfoGenerated = true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156446.544991.patch
Type: text/x-patch
Size: 1893 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230728/408d74ff/attachment.bin>
More information about the llvm-commits
mailing list