diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-09-05 19:43:08 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-09-30 13:44:51 +0100 |
| commit | 5709369d059ba107accaadb4b977281e2ba843ed (patch) | |
| tree | 0141fb2b3085b6ec8366544a7b6781b39e50ec2a /lib/std/debug/SelfInfo.zig | |
| parent | d4f710791f88c29e08659241e7976c08fe05ba49 (diff) | |
| download | zig-5709369d059ba107accaadb4b977281e2ba843ed.tar.gz zig-5709369d059ba107accaadb4b977281e2ba843ed.zip | |
std.debug: improve the APIs and stuff
Diffstat (limited to 'lib/std/debug/SelfInfo.zig')
| -rw-r--r-- | lib/std/debug/SelfInfo.zig | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/std/debug/SelfInfo.zig b/lib/std/debug/SelfInfo.zig index c5e163eef2..a7dea036c4 100644 --- a/lib/std/debug/SelfInfo.zig +++ b/lib/std/debug/SelfInfo.zig @@ -158,7 +158,7 @@ test { } pub const UnwindContext = struct { - gpa: Allocator, + gpa: Allocator, // MLUGG TODO: make unmanaged (also maybe rename this type, DwarfUnwindContext or smth idk) cfa: ?usize, pc: usize, thread_context: *std.debug.ThreadContext, @@ -166,22 +166,20 @@ pub const UnwindContext = struct { vm: Dwarf.Unwind.VirtualMachine, stack_machine: Dwarf.expression.StackMachine(.{ .call_frame_context = true }), - pub fn init(gpa: Allocator, thread_context: *std.debug.ThreadContext) !UnwindContext { + pub fn init(gpa: Allocator, thread_context: *std.debug.ThreadContext) UnwindContext { comptime assert(supports_unwinding); const ip_reg_num = Dwarf.abi.ipRegNum(native_arch).?; - const pc = stripInstructionPtrAuthCode( - (try regValueNative(thread_context, ip_reg_num, null)).*, - ); - - const context_copy = try gpa.create(std.debug.ThreadContext); - std.debug.copyContext(thread_context, context_copy); + const raw_pc_ptr = regValueNative(thread_context, ip_reg_num, null) catch { + unreachable; // error means unsupported, in which case `supports_unwinding` should have been `false` + }; + const pc = stripInstructionPtrAuthCode(raw_pc_ptr.*); return .{ .gpa = gpa, .cfa = null, .pc = pc, - .thread_context = context_copy, + .thread_context = thread_context, .reg_context = undefined, .vm = .{}, .stack_machine = .{}, @@ -191,7 +189,6 @@ pub const UnwindContext = struct { pub fn deinit(self: *UnwindContext) void { self.vm.deinit(self.gpa); self.stack_machine.deinit(self.gpa); - self.gpa.destroy(self.thread_context); self.* = undefined; } |
