authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-05 22:46:30-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-07 00:48:32-07:00
log40edd11516081b455df09ce0d19b3ca686655924
treef7412e8c4da4c0cd31c065855c9db0612a958072
parent8dae629c4f89155b6945ee952ee2aeb5bfa1d271

std.debug: fix compile errors on windows and macos


2 files changed, 15 insertions(+), 12 deletions(-)

lib/std/debug/Dwarf.zig+1-1
......@@ -2352,7 +2352,7 @@ pub const ElfModule = struct {
23522352 }
23532353};
23542354
2355fn getSymbol(di: *Dwarf, allocator: Allocator, address: u64) !std.debug.Symbol {
2355pub fn getSymbol(di: *Dwarf, allocator: Allocator, address: u64) !std.debug.Symbol {
23562356 if (di.findCompileUnit(address)) |compile_unit| {
23572357 return .{
23582358 .name = di.getSymbolName(address) orelse "???",
lib/std/debug/SelfInfo.zig+14-11
......@@ -602,10 +602,11 @@ pub const Module = switch (native_os) {
602602 sections[@intFromEnum(Dwarf.Section.Id.debug_line)] == null;
603603 if (missing_debug_info) return error.MissingDebugInfo;
604604
605 var di = Dwarf{
605 var di: Dwarf = .{
606606 .endian = .little,
607607 .sections = sections,
608608 .is_macho = true,
609 .compile_units_sorted = false,
609610 };
610611
611612 try Dwarf.open(&di, allocator);
......@@ -622,7 +623,7 @@ pub const Module = switch (native_os) {
622623 return result.value_ptr;
623624 }
624625
625 pub fn getSymbolAtAddress(self: *@This(), allocator: Allocator, address: usize) !Dwarf.SymbolInfo {
626 pub fn getSymbolAtAddress(self: *@This(), allocator: Allocator, address: usize) !std.debug.Symbol {
626627 nosuspend {
627628 const result = try self.getOFileInfoForAddress(allocator, address);
628629 if (result.symbol == null) return .{};
......@@ -630,19 +631,19 @@ pub const Module = switch (native_os) {
630631 // Take the symbol name from the N_FUN STAB entry, we're going to
631632 // use it if we fail to find the DWARF infos
632633 const stab_symbol = mem.sliceTo(self.strings[result.symbol.?.strx..], 0);
633 if (result.o_file_info == null) return .{ .symbol_name = stab_symbol };
634 if (result.o_file_info == null) return .{ .name = stab_symbol };
634635
635636 // Translate again the address, this time into an address inside the
636637 // .o file
637638 const relocated_address_o = result.o_file_info.?.addr_table.get(stab_symbol) orelse return .{
638 .symbol_name = "???",
639 .name = "???",
639640 };
640641
641642 const addr_off = result.relocated_address - result.symbol.?.addr;
642643 const o_file_di = &result.o_file_info.?.di;
643644 if (o_file_di.findCompileUnit(relocated_address_o)) |compile_unit| {
644645 return .{
645 .symbol_name = o_file_di.getSymbolName(relocated_address_o) orelse "???",
646 .name = o_file_di.getSymbolName(relocated_address_o) orelse "???",
646647 .compile_unit_name = compile_unit.die.getAttrString(
647648 o_file_di,
648649 std.dwarf.AT.name,
......@@ -651,9 +652,9 @@ pub const Module = switch (native_os) {
651652 ) catch |err| switch (err) {
652653 error.MissingDebugInfo, error.InvalidDebugInfo => "???",
653654 },
654 .line_info = o_file_di.getLineNumberInfo(
655 .source_location = o_file_di.getLineNumberInfo(
655656 allocator,
656 compile_unit.*,
657 compile_unit,
657658 relocated_address_o + addr_off,
658659 ) catch |err| switch (err) {
659660 error.MissingDebugInfo, error.InvalidDebugInfo => null,
......@@ -662,7 +663,7 @@ pub const Module = switch (native_os) {
662663 };
663664 } else |err| switch (err) {
664665 error.MissingDebugInfo, error.InvalidDebugInfo => {
665 return .{ .symbol_name = stab_symbol };
666 return .{ .name = stab_symbol };
666667 },
667668 else => return err,
668669 }
......@@ -760,9 +761,9 @@ pub const Module = switch (native_os) {
760761 );
761762
762763 return .{
763 .symbol_name = symbol_name,
764 .name = symbol_name,
764765 .compile_unit_name = obj_basename,
765 .line_info = opt_line_info,
766 .source_location = opt_line_info,
766767 };
767768 }
768769
......@@ -991,10 +992,11 @@ fn readCoffDebugInfo(allocator: Allocator, coff_obj: *coff.Coff) !Module {
991992 } else null;
992993 }
993994
994 var dwarf = Dwarf{
995 var dwarf: Dwarf = .{
995996 .endian = native_endian,
996997 .sections = sections,
997998 .is_macho = false,
999 .compile_units_sorted = false,
9981000 };
9991001
10001002 try Dwarf.open(&dwarf, allocator);
......@@ -1808,6 +1810,7 @@ fn unwindFrameMachODwarf(
18081810 var di: Dwarf = .{
18091811 .endian = native_endian,
18101812 .is_macho = true,
1813 .compile_units_sorted = false,
18111814 };
18121815 defer di.deinit(context.allocator);
18131816