authorgravatar for mason@gamesbymason.comMason Remaley <mason@gamesbymason.com> 2026-04-09 17:27:12-07:00
committergravatar for mason@gamesbymason.comMason Remaley <mason@gamesbymason.com> 2026-04-12 04:01:30-07:00
logdcdb562c154c950ed06a23a3a267fa8cdc172dda
tree68f7a6751e80a152ade5c054ec5b018333666178
parent492efd4c06541ca8add4147dfc2d766c1ba54693

Adds support for running the trace tests through darling, fixes compilation errors in MachO due to interface change


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

lib/std/debug/SelfInfo/MachO.zig+27-12
...@@ -22,12 +22,26 @@ pub fn deinit(si: *SelfInfo, io: Io) void {...@@ -22,12 +22,26 @@ pub fn deinit(si: *SelfInfo, io: Io) void {
22 si.modules.deinit(gpa);22 si.modules.deinit(gpa);
23}23}
2424
25pub fn getSymbol(si: *SelfInfo, io: Io, address: usize) Error!std.debug.Symbol {25pub const SymbolIterator = struct {
26 curr: ?Error!std.debug.Symbol,
27
28 pub fn deinit(self: *SymbolIterator, _: Io) void {
29 self.* = undefined;
30 }
31
32 pub fn next(self: *SymbolIterator) ?Error!std.debug.Symbol {
33 const result = self.curr;
34 self.curr = null;
35 return result;
36 }
37};
38
39pub fn getSymbols(si: *SelfInfo, io: Io, address: usize) SymbolIterator {
26 const gpa = std.debug.getDebugInfoAllocator();40 const gpa = std.debug.getDebugInfoAllocator();
27 const module = try si.findModule(gpa, io, address);41 const module = si.findModule(gpa, io, address) catch |err| return .{ .curr = err };
28 defer si.mutex.unlock(io);42 defer si.mutex.unlock(io);
2943
30 const file = try module.getFile(gpa, io);44 const file = module.getFile(gpa, io) catch |err| return .{ .curr = err };
3145
32 // This is not necessarily the same as the vmaddr_slide that dyld would report. This is46 // This is not necessarily the same as the vmaddr_slide that dyld would report. This is
33 // because the segments in the file on disk might differ from the ones in memory. Normally47 // because the segments in the file on disk might differ from the ones in memory. Normally
...@@ -43,25 +57,26 @@ pub fn getSymbol(si: *SelfInfo, io: Io, address: usize) Error!std.debug.Symbol {...@@ -43,25 +57,26 @@ pub fn getSymbol(si: *SelfInfo, io: Io, address: usize) Error!std.debug.Symbol {
4357
44 const ofile_dwarf, const ofile_vaddr = file.getDwarfForAddress(gpa, io, vaddr) catch {58 const ofile_dwarf, const ofile_vaddr = file.getDwarfForAddress(gpa, io, vaddr) catch {
45 // Return at least the symbol name if available.59 // Return at least the symbol name if available.
46 return .{60 return .{ .curr = .{
47 .name = try file.lookupSymbolName(vaddr),61 .name = file.lookupSymbolName(vaddr) catch |err| return .{ .curr = err },
48 .compile_unit_name = null,62 .compile_unit_name = null,
49 .source_location = null,63 .source_location = null,
50 };64 } };
51 };65 };
5266
53 const compile_unit = ofile_dwarf.findCompileUnit(native_endian, ofile_vaddr) catch {67 const compile_unit = ofile_dwarf.findCompileUnit(native_endian, ofile_vaddr) catch {
54 // Return at least the symbol name if available.68 // Return at least the symbol name if available.
55 return .{69 return .{ .curr = .{
56 .name = try file.lookupSymbolName(vaddr),70 .name = file.lookupSymbolName(vaddr) catch |err| return .{ .curr = err },
57 .compile_unit_name = null,71 .compile_unit_name = null,
58 .source_location = null,72 .source_location = null,
59 };73 } };
60 };74 };
6175
62 return .{76 return .{ .curr = .{
63 .name = ofile_dwarf.getSymbolName(ofile_vaddr) orelse77 .name = ofile_dwarf.getSymbolName(ofile_vaddr) orelse
64 try file.lookupSymbolName(vaddr),78 file.lookupSymbolName(vaddr) catch |err|
79 return .{ .curr = err },
65 .compile_unit_name = compile_unit.die.getAttrString(80 .compile_unit_name = compile_unit.die.getAttrString(
66 ofile_dwarf,81 ofile_dwarf,
67 native_endian,82 native_endian,
...@@ -77,7 +92,7 @@ pub fn getSymbol(si: *SelfInfo, io: Io, address: usize) Error!std.debug.Symbol {...@@ -77,7 +92,7 @@ pub fn getSymbol(si: *SelfInfo, io: Io, address: usize) Error!std.debug.Symbol {
77 compile_unit,92 compile_unit,
78 ofile_vaddr,93 ofile_vaddr,
79 ) catch null,94 ) catch null,
80 };95 } };
81}96}
82pub fn getModuleName(si: *SelfInfo, io: Io, address: usize) Error![]const u8 {97pub fn getModuleName(si: *SelfInfo, io: Io, address: usize) Error![]const u8 {
83 _ = si;98 _ = si;
test/tests.zig+6
...@@ -2033,6 +2033,12 @@ fn nativeAndCompatible32bit(b: *std.Build, skip_non_native: bool) []const std.Bu...@@ -2033,6 +2033,12 @@ fn nativeAndCompatible32bit(b: *std.Build, skip_non_native: bool) []const std.Bu
2033 .os_tag = .windows,2033 .os_tag = .windows,
2034 })) catch @panic("OOM");2034 })) catch @panic("OOM");
2035 }2035 }
2036 if (b.enable_darling and b.graph.host.result.os.tag != .macos) {
2037 targets.append(b.graph.arena, b.resolveTargetQuery(.{
2038 .cpu_arch = host.cpu.arch,
2039 .os_tag = .macos,
2040 })) catch @panic("OOM");
2041 }
2036 return targets.toOwnedSlice(b.graph.arena) catch @panic("OOM");2042 return targets.toOwnedSlice(b.graph.arena) catch @panic("OOM");
2037}2043}
20382044