Skip to content

Commit 6072226

Browse files
committed
std.debug: DWARFv5 fixes
handle str_offsets_base and addr_base correctly. handle data16 fix compilation on 32-bit hosts remove stray debug print statement closes #12120
1 parent 0f01e81 commit 6072226

File tree

3 files changed

+126
-120
lines changed

3 files changed

+126
-120
lines changed

lib/std/debug.zig

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -837,12 +837,12 @@ fn readCoffDebugInfo(allocator: mem.Allocator, coff_file: File) !ModuleDebugInfo
837837
// This coff file has embedded DWARF debug info
838838
_ = sec;
839839
// TODO: free the section data slices
840-
const debug_info_data = di.coff.getSectionDataAlloc(".debug_info", allocator) catch null;
841-
const debug_abbrev_data = di.coff.getSectionDataAlloc(".debug_abbrev", allocator) catch null;
842-
const debug_str_data = di.coff.getSectionDataAlloc(".debug_str", allocator) catch null;
840+
const debug_info = di.coff.getSectionDataAlloc(".debug_info", allocator) catch null;
841+
const debug_abbrev = di.coff.getSectionDataAlloc(".debug_abbrev", allocator) catch null;
842+
const debug_str = di.coff.getSectionDataAlloc(".debug_str", allocator) catch null;
843843
const debug_str_offsets = di.coff.getSectionDataAlloc(".debug_str_offsets", allocator) catch null;
844-
const debug_line_data = di.coff.getSectionDataAlloc(".debug_line", allocator) catch null;
845-
const debug_line_str_data = di.coff.getSectionDataAlloc(".debug_line_str", allocator) catch null;
844+
const debug_line = di.coff.getSectionDataAlloc(".debug_line", allocator) catch null;
845+
const debug_line_str = di.coff.getSectionDataAlloc(".debug_line_str", allocator) catch null;
846846
const debug_ranges = di.coff.getSectionDataAlloc(".debug_ranges", allocator) catch null;
847847
const debug_loclists = di.coff.getSectionDataAlloc(".debug_loclists", allocator) catch null;
848848
const debug_rnglists = di.coff.getSectionDataAlloc(".debug_rnglists", allocator) catch null;
@@ -852,12 +852,12 @@ fn readCoffDebugInfo(allocator: mem.Allocator, coff_file: File) !ModuleDebugInfo
852852

853853
var dwarf = DW.DwarfInfo{
854854
.endian = native_endian,
855-
.debug_info = debug_info_data orelse return error.MissingDebugInfo,
856-
.debug_abbrev = debug_abbrev_data orelse return error.MissingDebugInfo,
857-
.debug_str = debug_str_data orelse return error.MissingDebugInfo,
855+
.debug_info = debug_info orelse return error.MissingDebugInfo,
856+
.debug_abbrev = debug_abbrev orelse return error.MissingDebugInfo,
857+
.debug_str = debug_str orelse return error.MissingDebugInfo,
858858
.debug_str_offsets = debug_str_offsets,
859-
.debug_line = debug_line_data orelse return error.MissingDebugInfo,
860-
.debug_line_str = debug_line_str_data,
859+
.debug_line = debug_line orelse return error.MissingDebugInfo,
860+
.debug_line_str = debug_line_str,
861861
.debug_ranges = debug_ranges,
862862
.debug_loclists = debug_loclists,
863863
.debug_rnglists = debug_rnglists,
@@ -1663,6 +1663,7 @@ pub const ModuleDebugInfo = switch (native_os) {
16631663
o_file_di,
16641664
DW.AT.name,
16651665
o_file_di.debug_str,
1666+
compile_unit.*,
16661667
) catch |err| switch (err) {
16671668
error.MissingDebugInfo, error.InvalidDebugInfo => "???",
16681669
},
@@ -1784,7 +1785,7 @@ fn getSymbolFromDwarf(allocator: mem.Allocator, address: u64, di: *DW.DwarfInfo)
17841785
if (nosuspend di.findCompileUnit(address)) |compile_unit| {
17851786
return SymbolInfo{
17861787
.symbol_name = nosuspend di.getSymbolName(address) orelse "???",
1787-
.compile_unit_name = compile_unit.die.getAttrString(di, DW.AT.name, di.debug_str) catch |err| switch (err) {
1788+
.compile_unit_name = compile_unit.die.getAttrString(di, DW.AT.name, di.debug_str, compile_unit.*) catch |err| switch (err) {
17881789
error.MissingDebugInfo, error.InvalidDebugInfo => "???",
17891790
},
17901791
.line_info = nosuspend di.getLineNumberInfo(allocator, compile_unit.*, address) catch |err| switch (err) {

0 commit comments

Comments
 (0)