Skip to content

Commit 82bc183

Browse files
committed
[BPF] Narrow some interfaces
When compiling Rust code we sometimes see incomplete debug info leading to crashes. Narrow the interfaces so we can see where it happens. Reviewed By: ajwerner Differential Revision: https://reviews.llvm.org/D156443
1 parent 7f0d54b commit 82bc183

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

llvm/lib/Target/BPF/BTFDebug.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -973,8 +973,7 @@ void BTFDebug::visitMapDefType(const DIType *Ty, uint32_t &TypeId) {
973973
}
974974

975975
/// Read file contents from the actual file or from the source
976-
std::string BTFDebug::populateFileContent(const DISubprogram *SP) {
977-
auto File = SP->getFile();
976+
std::string BTFDebug::populateFileContent(const DIFile *File) {
978977
std::string FileName;
979978

980979
if (!File->getFilename().startswith("/") && File->getDirectory().size())
@@ -1005,9 +1004,9 @@ std::string BTFDebug::populateFileContent(const DISubprogram *SP) {
10051004
return FileName;
10061005
}
10071006

1008-
void BTFDebug::constructLineInfo(const DISubprogram *SP, MCSymbol *Label,
1007+
void BTFDebug::constructLineInfo(const DIFile *File, MCSymbol *Label,
10091008
uint32_t Line, uint32_t Column) {
1010-
std::string FileName = populateFileContent(SP);
1009+
std::string FileName = populateFileContent(File);
10111010
BTFLineInfo LineInfo;
10121011

10131012
LineInfo.Label = Label;
@@ -1374,7 +1373,7 @@ void BTFDebug::beginInstruction(const MachineInstr *MI) {
13741373
if (LineInfoGenerated == false) {
13751374
auto *S = MI->getMF()->getFunction().getSubprogram();
13761375
MCSymbol *FuncLabel = Asm->getFunctionBegin();
1377-
constructLineInfo(S, FuncLabel, S->getLine(), 0);
1376+
constructLineInfo(S->getFile(), FuncLabel, S->getLine(), 0);
13781377
LineInfoGenerated = true;
13791378
}
13801379

@@ -1386,8 +1385,7 @@ void BTFDebug::beginInstruction(const MachineInstr *MI) {
13861385
OS.emitLabel(LineSym);
13871386

13881387
// Construct the lineinfo.
1389-
auto SP = DL->getScope()->getSubprogram();
1390-
constructLineInfo(SP, LineSym, DL.getLine(), DL.getCol());
1388+
constructLineInfo(DL->getFile(), LineSym, DL.getLine(), DL.getCol());
13911389

13921390
LineInfoGenerated = true;
13931391
PrevInstLoc = DL;

llvm/lib/Target/BPF/BTFDebug.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,12 @@ class BTFDebug : public DebugHandlerBase {
341341
/// Check whether the type is a forward declaration candidate or not.
342342
bool IsForwardDeclCandidate(const DIType *Base);
343343

344-
/// Get the file content for the subprogram. Certain lines of the file
344+
/// Get the file content. Certain lines of the file
345345
/// later may be put into string table and referenced by line info.
346-
std::string populateFileContent(const DISubprogram *SP);
346+
std::string populateFileContent(const DIFile *File);
347347

348348
/// Construct a line info.
349-
void constructLineInfo(const DISubprogram *SP, MCSymbol *Label, uint32_t Line,
349+
void constructLineInfo(const DIFile *File, MCSymbol *Label, uint32_t Line,
350350
uint32_t Column);
351351

352352
/// Generate types and variables for globals.

0 commit comments

Comments
 (0)