@@ -1888,6 +1888,9 @@ void BinaryContext::preprocessDebugInfo() {
18881888
18891889 preprocessDWODebugInfo ();
18901890
1891+ // Check if required DWO files are missing.
1892+ uint64_t NumMissingDWOs = 0 ;
1893+
18911894 // Populate MCContext with DWARF files from all units.
18921895 StringRef GlobalPrefix = AsmInfo->getPrivateGlobalPrefix ();
18931896 for (const std::unique_ptr<DWARFUnit> &CU : DwCtx->compile_units ()) {
@@ -1909,19 +1912,23 @@ void BinaryContext::preprocessDebugInfo() {
19091912 std::optional<MD5::MD5Result> Checksum;
19101913 if (LineTable->Prologue .ContentTypes .HasMD5 )
19111914 Checksum = LineTable->Prologue .FileNames [0 ].Checksum ;
1912- std::optional< const char *> Name =
1915+ const char *Name =
19131916 dwarf::toString (CU->getUnitDIE ().find (dwarf::DW_AT_name), nullptr );
19141917 if (std::optional<uint64_t > DWOID = CU->getDWOId ()) {
19151918 auto Iter = DWOCUs.find (*DWOID);
19161919 if (Iter == DWOCUs.end ()) {
1917- this ->errs () << " BOLT-ERROR: DWO CU was not found for " << Name
1918- << ' \n ' ;
1919- exit (1 );
1920+ const char *DWOName =
1921+ dwarf::toString (CU->getUnitDIE ().find (dwarf::DW_AT_dwo_name),
1922+ " <missing DW_AT_dwo_name>" );
1923+ this ->errs () << " BOLT-ERROR: unable to load " << DWOName
1924+ << " for DWO_id 0x" << Twine::utohexstr (*DWOID) << ' \n ' ;
1925+ NumMissingDWOs++;
1926+ continue ;
19201927 }
19211928 Name = dwarf::toString (
19221929 Iter->second ->getUnitDIE ().find (dwarf::DW_AT_name), nullptr );
19231930 }
1924- BinaryLineTable.setRootFile (CU->getCompilationDir (), * Name, Checksum,
1931+ BinaryLineTable.setRootFile (CU->getCompilationDir (), Name, Checksum,
19251932 std::nullopt );
19261933 }
19271934
@@ -1956,6 +1963,14 @@ void BinaryContext::preprocessDebugInfo() {
19561963 DwarfVersion));
19571964 }
19581965 }
1966+
1967+ if (NumMissingDWOs) {
1968+ this ->errs () << " BOLT-ERROR: " << NumMissingDWOs
1969+ << " required DWO file(s) not found. Unable to update debug"
1970+ " info. Use --comp-dir-override to locate the file(s) or"
1971+ " --update-debug-sections=0 to remove debug info\n " ;
1972+ exit (1 );
1973+ }
19591974}
19601975
19611976bool BinaryContext::shouldEmit (const BinaryFunction &Function) const {
0 commit comments