mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 02:38:07 +08:00
[BOLT][DWARF] Improve reporting on missing DWOs (#171506)
List all required missing DWO files and report a summary with recommendations on how to proceed.
This commit is contained in:
@@ -1888,6 +1888,9 @@ void BinaryContext::preprocessDebugInfo() {
|
||||
|
||||
preprocessDWODebugInfo();
|
||||
|
||||
// Check if required DWO files are missing.
|
||||
uint64_t NumMissingDWOs = 0;
|
||||
|
||||
// Populate MCContext with DWARF files from all units.
|
||||
StringRef GlobalPrefix = AsmInfo->getPrivateGlobalPrefix();
|
||||
for (const std::unique_ptr<DWARFUnit> &CU : DwCtx->compile_units()) {
|
||||
@@ -1909,19 +1912,23 @@ void BinaryContext::preprocessDebugInfo() {
|
||||
std::optional<MD5::MD5Result> Checksum;
|
||||
if (LineTable->Prologue.ContentTypes.HasMD5)
|
||||
Checksum = LineTable->Prologue.FileNames[0].Checksum;
|
||||
std::optional<const char *> Name =
|
||||
const char *Name =
|
||||
dwarf::toString(CU->getUnitDIE().find(dwarf::DW_AT_name), nullptr);
|
||||
if (std::optional<uint64_t> DWOID = CU->getDWOId()) {
|
||||
auto Iter = DWOCUs.find(*DWOID);
|
||||
if (Iter == DWOCUs.end()) {
|
||||
this->errs() << "BOLT-ERROR: DWO CU was not found for " << Name
|
||||
<< '\n';
|
||||
exit(1);
|
||||
const char *DWOName =
|
||||
dwarf::toString(CU->getUnitDIE().find(dwarf::DW_AT_dwo_name),
|
||||
"<missing DW_AT_dwo_name>");
|
||||
this->errs() << "BOLT-ERROR: unable to load " << DWOName
|
||||
<< " for DWO_id 0x" << Twine::utohexstr(*DWOID) << '\n';
|
||||
NumMissingDWOs++;
|
||||
continue;
|
||||
}
|
||||
Name = dwarf::toString(
|
||||
Iter->second->getUnitDIE().find(dwarf::DW_AT_name), nullptr);
|
||||
}
|
||||
BinaryLineTable.setRootFile(CU->getCompilationDir(), *Name, Checksum,
|
||||
BinaryLineTable.setRootFile(CU->getCompilationDir(), Name, Checksum,
|
||||
std::nullopt);
|
||||
}
|
||||
|
||||
@@ -1956,6 +1963,14 @@ void BinaryContext::preprocessDebugInfo() {
|
||||
DwarfVersion));
|
||||
}
|
||||
}
|
||||
|
||||
if (NumMissingDWOs) {
|
||||
this->errs() << "BOLT-ERROR: " << NumMissingDWOs
|
||||
<< " required DWO file(s) not found. Unable to update debug"
|
||||
" info. Use --comp-dir-override to locate the file(s) or"
|
||||
" --update-debug-sections=0 to remove debug info\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
bool BinaryContext::shouldEmit(const BinaryFunction &Function) const {
|
||||
|
||||
18
bolt/test/dwarf5-missing-dwo.c
Normal file
18
bolt/test/dwarf5-missing-dwo.c
Normal file
@@ -0,0 +1,18 @@
|
||||
// Check that llvm-bolt correctly reports a missing DWO file while updating
|
||||
// debug info.
|
||||
//
|
||||
// RUN: %clang %cflags -g -dwarf5 -gsplit-dwarf=single -c %s -o %t.o
|
||||
// RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
|
||||
// RUN: rm %t.o
|
||||
// RUN: not llvm-bolt %t.exe -o %t.bolt --update-debug-sections \
|
||||
// RUN: 2>&1 | FileCheck %s -DDWO=%t.o
|
||||
//
|
||||
// Check that llvm-bolt succeeds on the same binary with disabled debug info
|
||||
// update.
|
||||
//
|
||||
// RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections=0
|
||||
|
||||
// CHECK: BOLT-ERROR: unable to load [[DWO]]
|
||||
// CHECK-NEXT: BOLT-ERROR: 1 required DWO file(s) not found
|
||||
|
||||
int main() { return 0; }
|
||||
Reference in New Issue
Block a user