Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/dwarf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,12 @@ static void ReadDWARFDebugInfo(dwarf::InfoReader& reader,

std::string dwo_path = ConstructDwoPath(dwo_info);
if (!dwo_path.empty()) {
// Check if DWO file exists before trying to open it
if (!std::filesystem::exists(dwo_path)) {
fprintf(stderr, "Warning: DWO file not found: %s\n", dwo_path.c_str());
continue;
}

auto file = MmapInputFileFactory().OpenFile(dwo_path);
dwarf::File dwo_dwarf;
cu.dwarf().open(*file, &dwo_dwarf, sink);
Expand Down
66 changes: 66 additions & 0 deletions tests/dwarf/debug_info/missing-dwo-file.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Test that missing .dwo files produce a warning but don't fail analysis.

# RUN: %yaml2obj %s -o %t.obj
# RUN: %bloaty %t.obj -d compileunits 2>&1 | %FileCheck %s

# CHECK: Warning: DWO file not found: /nonexistent/path/missing.dwo

--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_DYN
Machine: EM_X86_64
ProgramHeaders:
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .text
LastSec: .text
VAddr: 0x1000
Align: 0x1000
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x1000
AddressAlign: 0x10
Size: 0x50
- Name: .debug_addr
Type: SHT_PROGBITS
AddressAlign: 0x1
Content: '0010000000000000'
DWARF:
debug_str:
- /nonexistent/path/missing.dwo
- /some/comp/dir
debug_abbrev:
- ID: 0
Table:
- Code: 0x1
Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no
Attributes:
- Attribute: DW_AT_comp_dir
Form: DW_FORM_strp
- Attribute: DW_AT_GNU_dwo_name
Form: DW_FORM_strp
- Attribute: DW_AT_GNU_dwo_id
Form: DW_FORM_data8
- Attribute: DW_AT_GNU_addr_base
Form: DW_FORM_sec_offset
debug_info:
- Version: 4
AbbrevTableID: 0
AbbrOffset: 0x0
AddrSize: 8
Entries:
- AbbrCode: 0x1
Values:
# comp_dir offset (points to "/some/comp/dir")
- Value: 0x22
# dwo_name offset (points to "/nonexistent/path/missing.dwo")
- Value: 0x0
# dwo_id
- Value: 0x1234567890abcdef
# addr_base
- Value: 0x0