authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-28 11:31:23+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-29 07:26:59+01:00
logd53cb284de0486fbb31f6377d3b86d8de5f93cd0
treee6f3e5828a06f4283ee4a84387b8fa02d5320afd
parent3ae4c3cc3643995783c996f7950e54c95126b4d0

macho: re-enable emitting empty dSYM bundle


2 files changed, 35 insertions(+), 34 deletions(-)

src/link/MachO.zig+32-29
...@@ -256,32 +256,36 @@ pub fn createEmpty(...@@ -256,32 +256,36 @@ pub fn createEmpty(
256 .program_code_size_hint = options.program_code_size_hint,256 .program_code_size_hint = options.program_code_size_hint,
257 });257 });
258258
259 // TODO init dwarf259 switch (comp.config.debug_format) {
260260 .strip => {},
261 // if (comp.config.debug_format != .strip) {261 .dwarf => {
262 // // Create dSYM bundle.262 // Create dSYM bundle.
263 // log.debug("creating {s}.dSYM bundle", .{emit.sub_path});263 log.debug("creating {s}.dSYM bundle", .{emit.sub_path});
264264
265 // const d_sym_path = try std.fmt.allocPrint(265 const sep = fs.path.sep_str;
266 // arena,266 const d_sym_path = try std.fmt.allocPrint(
267 // "{s}.dSYM" ++ fs.path.sep_str ++ "Contents" ++ fs.path.sep_str ++ "Resources" ++ fs.path.sep_str ++ "DWARF",267 arena,
268 // .{emit.sub_path},268 "{s}.dSYM" ++ sep ++ "Contents" ++ sep ++ "Resources" ++ sep ++ "DWARF",
269 // );269 .{emit.sub_path},
270270 );
271 // var d_sym_bundle = try emit.directory.handle.makeOpenPath(d_sym_path, .{});271
272 // defer d_sym_bundle.close();272 var d_sym_bundle = try emit.directory.handle.makeOpenPath(d_sym_path, .{});
273273 defer d_sym_bundle.close();
274 // const d_sym_file = try d_sym_bundle.createFile(emit.sub_path, .{274
275 // .truncate = false,275 const d_sym_file = try d_sym_bundle.createFile(emit.sub_path, .{
276 // .read = true,276 .truncate = false,
277 // });277 .read = true,
278278 });
279 // self.d_sym = .{279
280 // .allocator = gpa,280 self.d_sym = .{
281 // .dwarf = link.File.Dwarf.init(&self.base, .dwarf32),281 .allocator = gpa,
282 // .file = d_sym_file,282 .dwarf = link.File.Dwarf.init(&self.base, .dwarf32),
283 // };283 .file = d_sym_file,
284 // }284 };
285 try self.d_sym.?.initMetadata(self);
286 },
287 .code_view => unreachable,
288 }
285 }289 }
286 }290 }
287291
...@@ -3906,9 +3910,8 @@ fn reportDuplicates(self: *MachO, dupes: anytype) error{ HasDuplicates, OutOfMem...@@ -3906,9 +3910,8 @@ fn reportDuplicates(self: *MachO, dupes: anytype) error{ HasDuplicates, OutOfMem
3906}3910}
39073911
3908pub fn getDebugSymbols(self: *MachO) ?*DebugSymbols {3912pub fn getDebugSymbols(self: *MachO) ?*DebugSymbols {
3909 if (self.d_sym) |*ds| {3913 if (self.d_sym) |*ds| return ds;
3910 return ds;3914 return null;
3911 } else return null;
3912}3915}
39133916
3914pub fn ptraceAttach(self: *MachO, pid: std.os.pid_t) !void {3917pub fn ptraceAttach(self: *MachO, pid: std.os.pid_t) !void {
src/link/MachO/DebugSymbols.zig+3-5
...@@ -36,15 +36,13 @@ pub const Reloc = struct {...@@ -36,15 +36,13 @@ pub const Reloc = struct {
36 prev_vaddr: u64,36 prev_vaddr: u64,
37};37};
3838
39/// You must call this function *after* `MachO.populateMissingMetadata()`39/// You must call this function *after* `ZigObject.initMetadata()`
40/// has been called to get a viable debug symbols output.40/// has been called to get a viable debug symbols output.
41pub fn populateMissingMetadata(self: *DebugSymbols, macho_file: *MachO) !void {41pub fn initMetadata(self: *DebugSymbols, macho_file: *MachO) !void {
42 const target = macho_file.base.comp.root_mod.resolved_target.result;
43
44 if (self.dwarf_segment_cmd_index == null) {42 if (self.dwarf_segment_cmd_index == null) {
45 self.dwarf_segment_cmd_index = @as(u8, @intCast(self.segments.items.len));43 self.dwarf_segment_cmd_index = @as(u8, @intCast(self.segments.items.len));
4644
47 const page_size = MachO.getPageSize(target.cpu.arch);45 const page_size = macho_file.getPageSize();
48 const off = @as(u64, @intCast(page_size));46 const off = @as(u64, @intCast(page_size));
49 const ideal_size: u16 = 200 + 128 + 160 + 250;47 const ideal_size: u16 = 200 + 128 + 160 + 250;
50 const needed_size = mem.alignForward(u64, padToIdeal(ideal_size), page_size);48 const needed_size = mem.alignForward(u64, padToIdeal(ideal_size), page_size);