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)...@@ -3181,7 +3181,7 @@ pub fn updateDecl(self: *MachO, mod: *Module, decl_index: InternPool.DeclIndex)
31813181
3182pub fn updateDeclLineNumber(self: *MachO, module: *Module, decl_index: InternPool.DeclIndex) !void {3182pub fn updateDeclLineNumber(self: *MachO, module: *Module, decl_index: InternPool.DeclIndex) !void {
3183 if (self.llvm_object) |_| return;3183 if (self.llvm_object) |_| return;
3184 return self.getZigObject().?.updateDeclLineNumber(module, decl_index);3184 return self.getZigObject().?.updateDeclLineNumber(self, module, decl_index);
3185}3185}
31863186
3187pub fn updateExports(3187pub fn updateExports(
src/link/MachO/ZigObject.zig+26-24
...@@ -531,7 +531,7 @@ pub fn updateFunc(...@@ -531,7 +531,7 @@ pub fn updateFunc(
531 var code_buffer = std.ArrayList(u8).init(gpa);531 var code_buffer = std.ArrayList(u8).init(gpa);
532 defer code_buffer.deinit();532 defer code_buffer.deinit();
533533
534 var decl_state: ?Dwarf.DeclState = null; // TODO: Dwarf534 var decl_state: ?Dwarf.DeclState = if (macho_file.getDebugSymbols()) |d_sym| try d_sym.dwarf.initDeclState(mod, decl_index) else null;
535 defer if (decl_state) |*ds| ds.deinit();535 defer if (decl_state) |*ds| ds.deinit();
536536
537 const dio: codegen.DebugInfoOutput = if (decl_state) |*ds| .{ .dwarf = ds } else .none;537 const dio: codegen.DebugInfoOutput = if (decl_state) |*ds| .{ .dwarf = ds } else .none;
...@@ -557,16 +557,16 @@ pub fn updateFunc(...@@ -557,16 +557,16 @@ pub fn updateFunc(
557 const sect_index = try self.getDeclOutputSection(macho_file, decl, code);557 const sect_index = try self.getDeclOutputSection(macho_file, decl, code);
558 try self.updateDeclCode(macho_file, decl_index, sym_index, sect_index, code);558 try self.updateDeclCode(macho_file, decl_index, sym_index, sect_index, code);
559559
560 // if (decl_state) |*ds| {560 if (decl_state) |*ds| {
561 // const sym = elf_file.symbol(sym_index);561 const sym = macho_file.getSymbol(sym_index);
562 // try self.dwarf.?.commitDeclState(562 try macho_file.getDebugSymbols().?.dwarf.commitDeclState(
563 // mod,563 mod,
564 // decl_index,564 decl_index,
565 // sym.value,565 sym.getAddress(.{}, macho_file),
566 // sym.atom(elf_file).?.size,566 sym.getAtom(macho_file).?.size,
567 // ds,567 ds,
568 // );568 );
569 // }569 }
570570
571 // Since we updated the vaddr and the size, each corresponding export571 // Since we updated the vaddr and the size, each corresponding export
572 // symbol also needs to be updated.572 // symbol also needs to be updated.
...@@ -606,7 +606,7 @@ pub fn updateDecl(...@@ -606,7 +606,7 @@ pub fn updateDecl(
606 var code_buffer = std.ArrayList(u8).init(gpa);606 var code_buffer = std.ArrayList(u8).init(gpa);
607 defer code_buffer.deinit();607 defer code_buffer.deinit();
608608
609 var decl_state: ?Dwarf.DeclState = null; // TODO: Dwarf609 var decl_state: ?Dwarf.DeclState = if (macho_file.getDebugSymbols()) |d_sym| try d_sym.dwarf.initDeclState(mod, decl_index) else null;
610 defer if (decl_state) |*ds| ds.deinit();610 defer if (decl_state) |*ds| ds.deinit();
611611
612 const decl_val = if (decl.val.getVariable(mod)) |variable| Value.fromInterned(variable.init) else decl.val;612 const decl_val = if (decl.val.getVariable(mod)) |variable| Value.fromInterned(variable.init) else decl.val;
...@@ -638,15 +638,16 @@ pub fn updateDecl(...@@ -638,15 +638,16 @@ pub fn updateDecl(
638 try self.updateDeclCode(macho_file, decl_index, sym_index, sect_index, code);638 try self.updateDeclCode(macho_file, decl_index, sym_index, sect_index, code);
639 }639 }
640640
641 // if (decl_state) |*ds| {641 if (decl_state) |*ds| {
642 // try self.d_sym.?.dwarf.commitDeclState(642 const sym = macho_file.getSymbol(sym_index);
643 // mod,643 try macho_file.getDebugSymbols().?.dwarf.commitDeclState(
644 // decl_index,644 mod,
645 // addr,645 decl_index,
646 // self.getAtom(atom_index).size,646 sym.getAddress(.{}, macho_file),
647 // ds,647 sym.getAtom(macho_file).?.size,
648 // );648 ds,
649 // }649 );
650 }
650651
651 // Since we updated the vaddr and the size, each corresponding export symbol also652 // Since we updated the vaddr and the size, each corresponding export symbol also
652 // needs to be updated.653 // needs to be updated.
...@@ -1220,13 +1221,14 @@ fn updateLazySymbol(...@@ -1220,13 +1221,14 @@ fn updateLazySymbol(
1220/// Must be called only after a successful call to `updateDecl`.1221/// Must be called only after a successful call to `updateDecl`.
1221pub fn updateDeclLineNumber(1222pub fn updateDeclLineNumber(
1222 self: *ZigObject,1223 self: *ZigObject,
1224 macho_file: *MachO,
1223 mod: *Module,1225 mod: *Module,
1224 decl_index: InternPool.DeclIndex,1226 decl_index: InternPool.DeclIndex,
1225) !void {1227) !void {
1226 _ = self;1228 _ = self;
1227 _ = mod;1229 if (macho_file.getDebugSymbols()) |d_sym| {
1228 _ = decl_index;1230 try d_sym.dwarf.updateDeclLineNumber(mod, decl_index);
1229 // TODO: Dwarf1231 }
1230}1232}
12311233
1232pub fn deleteDeclExport(1234pub fn deleteDeclExport(