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 {
295295 }) catch {};
296296 return;
297297 };
298 const ally = debug_info.allocator;
299298 if (step.getStackTrace()) |stack_trace| {
300299 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| {
302301 w.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch {};
303302 return;
304303 };
lib/std/builtin.zig+1-1
......@@ -55,7 +55,7 @@ pub const StackTrace = struct {
5555 };
5656 const tty_config = std.io.tty.detectConfig(std.io.getStdErr());
5757 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| {
5959 try writer.print("Unable to print stack trace: {s}\n", .{@errorName(err)});
6060 };
6161 }
lib/std/debug.zig+2-4
......@@ -377,7 +377,7 @@ pub fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void {
377377 stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return;
378378 return;
379379 };
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| {
381381 stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return;
382382 return;
383383 };
......@@ -520,11 +520,9 @@ fn waitForOtherThreadToFinishPanicking() void {
520520pub fn writeStackTrace(
521521 stack_trace: std.builtin.StackTrace,
522522 out_stream: anytype,
523 allocator: mem.Allocator,
524523 debug_info: *SelfInfo,
525524 tty_config: io.tty.Config,
526525) !void {
527 _ = allocator;
528526 if (builtin.strip_debug_info) return error.MissingDebugInfo;
529527 var frame_index: usize = 0;
530528 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
14521450 .index = frames.len,
14531451 .instruction_addresses = frames,
14541452 };
1455 writeStackTrace(stack_trace, stderr, getDebugInfoAllocator(), debug_info, tty_config) catch continue;
1453 writeStackTrace(stack_trace, stderr, debug_info, tty_config) catch continue;
14561454 }
14571455 if (t.index > end) {
14581456 stderr.print("{d} more traces not shown; consider increasing trace size\n", .{