Skip to content

Commit

Permalink
std.debug: remove allocator from std.debug.writeStackTrace()
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 authored and richerfu committed Oct 28, 2024
1 parent d65ee0e commit b3f1374
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions lib/std/Build/Step.zig
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,9 @@ pub fn dump(step: *Step, file: std.fs.File) void {
}) catch {};
return;
};
const ally = debug_info.allocator;
if (step.getStackTrace()) |stack_trace| {
w.print("name: '{s}'. creation stack trace:\n", .{step.name}) catch {};
std.debug.writeStackTrace(stack_trace, w, ally, debug_info, tty_config) catch |err| {
std.debug.writeStackTrace(stack_trace, w, debug_info, tty_config) catch |err| {
w.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch {};
return;
};
Expand Down
2 changes: 1 addition & 1 deletion lib/std/builtin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub const StackTrace = struct {
};
const tty_config = std.io.tty.detectConfig(std.io.getStdErr());
try writer.writeAll("\n");
std.debug.writeStackTrace(self, writer, arena.allocator(), debug_info, tty_config) catch |err| {
std.debug.writeStackTrace(self, writer, debug_info, tty_config) catch |err| {
try writer.print("Unable to print stack trace: {s}\n", .{@errorName(err)});
};
}
Expand Down
6 changes: 2 additions & 4 deletions lib/std/debug.zig
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ pub fn dumpStackTrace(stack_trace: std.builtin.StackTrace) void {
stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return;
return;
};
writeStackTrace(stack_trace, stderr, getDebugInfoAllocator(), debug_info, io.tty.detectConfig(io.getStdErr())) catch |err| {
writeStackTrace(stack_trace, stderr, debug_info, io.tty.detectConfig(io.getStdErr())) catch |err| {
stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return;
return;
};
Expand Down Expand Up @@ -520,11 +520,9 @@ fn waitForOtherThreadToFinishPanicking() void {
pub fn writeStackTrace(
stack_trace: std.builtin.StackTrace,
out_stream: anytype,
allocator: mem.Allocator,
debug_info: *SelfInfo,
tty_config: io.tty.Config,
) !void {
_ = allocator;
if (builtin.strip_debug_info) return error.MissingDebugInfo;
var frame_index: usize = 0;
var frames_left: usize = @min(stack_trace.index, stack_trace.instruction_addresses.len);
Expand Down Expand Up @@ -1452,7 +1450,7 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize
.index = frames.len,
.instruction_addresses = frames,
};
writeStackTrace(stack_trace, stderr, getDebugInfoAllocator(), debug_info, tty_config) catch continue;
writeStackTrace(stack_trace, stderr, debug_info, tty_config) catch continue;
}
if (t.index > end) {
stderr.print("{d} more traces not shown; consider increasing trace size\n", .{
Expand Down

0 comments on commit b3f1374

Please sign in to comment.