authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-28 13:59:17+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-29 07:26:59+01:00
log5dbac19d8c99478443885fab978d1d6558422ba4
tree63182470e24a12d35f2210d0226cb84c1c283d9c
parentf2214e43715d1094a2d933c3fe1b6f461391915b

macho: re-instate writing DWARF into dSYM


2 files changed, 27 insertions(+), 25 deletions(-)

src/link/MachO.zig+1-1
......@@ -3181,7 +3181,7 @@ pub fn updateDecl(self: *MachO, mod: *Module, decl_index: InternPool.DeclIndex)
31813181
31823182pub fn updateDeclLineNumber(self: *MachO, module: *Module, decl_index: InternPool.DeclIndex) !void {
31833183 if (self.llvm_object) |_| return;
3184 return self.getZigObject().?.updateDeclLineNumber(module, decl_index);
3184 return self.getZigObject().?.updateDeclLineNumber(self, module, decl_index);
31853185}
31863186
31873187pub fn updateExports(
src/link/MachO/ZigObject.zig+26-24
......@@ -531,7 +531,7 @@ pub fn updateFunc(
531531 var code_buffer = std.ArrayList(u8).init(gpa);
532532 defer code_buffer.deinit();
533533
534 var decl_state: ?Dwarf.DeclState = null; // TODO: Dwarf
534 var decl_state: ?Dwarf.DeclState = if (macho_file.getDebugSymbols()) |d_sym| try d_sym.dwarf.initDeclState(mod, decl_index) else null;
535535 defer if (decl_state) |*ds| ds.deinit();
536536
537537 const dio: codegen.DebugInfoOutput = if (decl_state) |*ds| .{ .dwarf = ds } else .none;
......@@ -557,16 +557,16 @@ pub fn updateFunc(
557557 const sect_index = try self.getDeclOutputSection(macho_file, decl, code);
558558 try self.updateDeclCode(macho_file, decl_index, sym_index, sect_index, code);
559559
560 // if (decl_state) |*ds| {
561 // const sym = elf_file.symbol(sym_index);
562 // try self.dwarf.?.commitDeclState(
563 // mod,
564 // decl_index,
565 // sym.value,
566 // sym.atom(elf_file).?.size,
567 // ds,
568 // );
569 // }
560 if (decl_state) |*ds| {
561 const sym = macho_file.getSymbol(sym_index);
562 try macho_file.getDebugSymbols().?.dwarf.commitDeclState(
563 mod,
564 decl_index,
565 sym.getAddress(.{}, macho_file),
566 sym.getAtom(macho_file).?.size,
567 ds,
568 );
569 }
570570
571571 // Since we updated the vaddr and the size, each corresponding export
572572 // symbol also needs to be updated.
......@@ -606,7 +606,7 @@ pub fn updateDecl(
606606 var code_buffer = std.ArrayList(u8).init(gpa);
607607 defer code_buffer.deinit();
608608
609 var decl_state: ?Dwarf.DeclState = null; // TODO: Dwarf
609 var decl_state: ?Dwarf.DeclState = if (macho_file.getDebugSymbols()) |d_sym| try d_sym.dwarf.initDeclState(mod, decl_index) else null;
610610 defer if (decl_state) |*ds| ds.deinit();
611611
612612 const decl_val = if (decl.val.getVariable(mod)) |variable| Value.fromInterned(variable.init) else decl.val;
......@@ -638,15 +638,16 @@ pub fn updateDecl(
638638 try self.updateDeclCode(macho_file, decl_index, sym_index, sect_index, code);
639639 }
640640
641 // if (decl_state) |*ds| {
642 // try self.d_sym.?.dwarf.commitDeclState(
643 // mod,
644 // decl_index,
645 // addr,
646 // self.getAtom(atom_index).size,
647 // ds,
648 // );
649 // }
641 if (decl_state) |*ds| {
642 const sym = macho_file.getSymbol(sym_index);
643 try macho_file.getDebugSymbols().?.dwarf.commitDeclState(
644 mod,
645 decl_index,
646 sym.getAddress(.{}, macho_file),
647 sym.getAtom(macho_file).?.size,
648 ds,
649 );
650 }
650651
651652 // Since we updated the vaddr and the size, each corresponding export symbol also
652653 // needs to be updated.
......@@ -1220,13 +1221,14 @@ fn updateLazySymbol(
12201221/// Must be called only after a successful call to `updateDecl`.
12211222pub fn updateDeclLineNumber(
12221223 self: *ZigObject,
1224 macho_file: *MachO,
12231225 mod: *Module,
12241226 decl_index: InternPool.DeclIndex,
12251227) !void {
12261228 _ = self;
1227 _ = mod;
1228 _ = decl_index;
1229 // TODO: Dwarf
1229 if (macho_file.getDebugSymbols()) |d_sym| {
1230 try d_sym.dwarf.updateDeclLineNumber(mod, decl_index);
1231 }
12301232}
12311233
12321234pub fn deleteDeclExport(