authorgravatar for mrjbq7@gmail.comJohn Benediktsson <mrjbq7@gmail.com> 2024-08-22 17:10:32-07:00
committergravatar for mrjbq7@gmail.comJohn Benediktsson <mrjbq7@gmail.com> 2024-08-22 21:23:53-07:00
logc6905371543066b9e0cc2f71e613123294e26b9f
tree635847fe5994f875b18aecf958212b9f85f4a4d2
parentc6286eee4ba8065b4a3f37fe3668041871e1b42e

std.debug: remove allocator from std.debug.writeStackTrace()


3 files changed, 4 insertions(+), 7 deletions(-)

lib/std/Build/Step.zig+1-2
...@@ -295,10 +295,9 @@ pub fn dump(step: *Step, file: std.fs.File) void {...@@ -295,10 +295,9 @@ pub fn dump(step: *Step, file: std.fs.File) void {
295 }) catch {};295 }) catch {};
296 return;296 return;
297 };297 };
298 const ally = debug_info.allocator;
299 if (step.getStackTrace()) |stack_trace| {298 if (step.getStackTrace()) |stack_trace| {
300 w.print("name: '{s}'. creation stack trace:\n", .{step.name}) catch {};299 w.print("name: '{s}'. creation stack trace:\n", .{step.name}) catch {};
301 std.debug.writeStackTrace(stack_trace, w, ally, debug_info, tty_config) catch |err| {300 std.debug.writeStackTrace(stack_trace, w, debug_info, tty_config) catch |err| {
302 w.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch {};301 w.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch {};
303 return;302 return;
304 };303 };
lib/std/builtin.zig+1-1
...@@ -55,7 +55,7 @@ pub const StackTrace = struct {...@@ -55,7 +55,7 @@ pub const StackTrace = struct {
55 };55 };
56 const tty_config = std.io.tty.detectConfig(std.io.getStdErr());56 const tty_config = std.io.tty.detectConfig(std.io.getStdErr());
57 try writer.writeAll("\n");57 try writer.writeAll("\n");
58 std.debug.writeStackTrace(self, writer, arena.allocator(), debug_info, tty_config) catch |err| {58 std.debug.writeStackTrace(self, writer, debug_info, tty_config) catch |err| {
59 try writer.print("Unable to print stack trace: {s}\n", .{@errorName(err)});59 try writer.print("Unable to print stack trace: {s}\n", .{@errorName(err)});
60 };60 };
61 }61 }
lib/std/debug.zig+2-4
...@@ -377,7 +377,7 @@ pub fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void {...@@ -377,7 +377,7 @@ pub fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void {
377 stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return;377 stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return;
378 return;378 return;
379 };379 };
380 writeStackTrace(stack_trace, stderr, getDebugInfoAllocator(), debug_info, io.tty.detectConfig(io.getStdErr())) catch |err| {380 writeStackTrace(stack_trace, stderr, debug_info, io.tty.detectConfig(io.getStdErr())) catch |err| {
381 stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return;381 stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return;
382 return;382 return;
383 };383 };
...@@ -520,11 +520,9 @@ fn waitForOtherThreadToFinishPanicking() void {...@@ -520,11 +520,9 @@ fn waitForOtherThreadToFinishPanicking() void {
520pub fn writeStackTrace(520pub fn writeStackTrace(
521 stack_trace: std.builtin.StackTrace,521 stack_trace: std.builtin.StackTrace,
522 out_stream: anytype,522 out_stream: anytype,
523 allocator: mem.Allocator,
524 debug_info: *SelfInfo,523 debug_info: *SelfInfo,
525 tty_config: io.tty.Config,524 tty_config: io.tty.Config,
526) !void {525) !void {
527 _ = allocator;
528 if (builtin.strip_debug_info) return error.MissingDebugInfo;526 if (builtin.strip_debug_info) return error.MissingDebugInfo;
529 var frame_index: usize = 0;527 var frame_index: usize = 0;
530 var frames_left: usize = @min(stack_trace.index, stack_trace.instruction_addresses.len);528 var frames_left: usize = @min(stack_trace.index, stack_trace.instruction_addresses.len);
...@@ -1452,7 +1450,7 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize...@@ -1452,7 +1450,7 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize
1452 .index = frames.len,1450 .index = frames.len,
1453 .instruction_addresses = frames,1451 .instruction_addresses = frames,
1454 };1452 };
1455 writeStackTrace(stack_trace, stderr, getDebugInfoAllocator(), debug_info, tty_config) catch continue;1453 writeStackTrace(stack_trace, stderr, debug_info, tty_config) catch continue;
1456 }1454 }
1457 if (t.index > end) {1455 if (t.index > end) {
1458 stderr.print("{d} more traces not shown; consider increasing trace size\n", .{1456 stderr.print("{d} more traces not shown; consider increasing trace size\n", .{