aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/Build.zig50
-rw-r--r--lib/std/Build/Step.zig12
2 files changed, 15 insertions, 47 deletions
diff --git a/lib/std/Build.zig b/lib/std/Build.zig
index 15db8487d4..212c71576b 100644
--- a/lib/std/Build.zig
+++ b/lib/std/Build.zig
@@ -1768,49 +1768,21 @@ pub fn dumpBadGetPathHelp(
});
const tty_config = std.io.tty.detectConfig(stderr);
- if (s.getStackTrace()) |stack_trace| {
- tty_config.setColor(w, .red) catch {};
- try stderr.writeAll(" The step was created by this stack trace:\n");
- tty_config.setColor(w, .reset) catch {};
-
- const debug_info = std.debug.getSelfDebugInfo() catch |err| {
- try w.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)});
- return;
- };
- const ally = debug_info.allocator;
+ tty_config.setColor(w, .red) catch {};
+ try stderr.writeAll(" The step was created by this stack trace:\n");
+ tty_config.setColor(w, .reset) catch {};
- std.debug.writeStackTrace(stack_trace, w, ally, debug_info, tty_config) catch |err| {
- try stderr.writer().print("Unable to dump stack trace: {s}\n", .{@errorName(err)});
- return;
- };
- if (asking_step) |as| {
- tty_config.setColor(w, .red) catch {};
- try stderr.writer().print(" The step '{s}' that is missing a dependency on the above step was created by this stack trace:\n", .{as.name});
- tty_config.setColor(w, .reset) catch {};
-
- if (as.getStackTrace()) |as_stack_trace| {
- std.debug.writeStackTrace(as_stack_trace, w, ally, debug_info, tty_config) catch |err| {
- try stderr.writer().print("Unable to dump stack trace: {s}\n", .{@errorName(err)});
- return;
- };
- } else {
- const field = "debug_stack_frames_count";
- comptime assert(@hasField(Build, field));
- tty_config.setColor(w, .yellow) catch {};
- try stderr.writer().print("no stack trace collected for this step, see std.Build." ++ field ++ "\n", .{});
- tty_config.setColor(w, .reset) catch {};
- }
- }
+ s.dump(stderr);
+ if (asking_step) |as| {
tty_config.setColor(w, .red) catch {};
- try stderr.writeAll(" Hope that helps. Proceeding to panic.\n");
- tty_config.setColor(w, .reset) catch {};
- } else {
- const field = "debug_stack_frames_count";
- comptime assert(@hasField(Build, field));
- tty_config.setColor(w, .yellow) catch {};
- try stderr.writer().print("no stack trace collected for this step, see std.Build." ++ field ++ "\n", .{});
+ try stderr.writer().print(" The step '{s}' that is missing a dependency on the above step was created by this stack trace:\n", .{as.name});
tty_config.setColor(w, .reset) catch {};
+
+ as.dump(stderr);
}
+ tty_config.setColor(w, .red) catch {};
+ try stderr.writeAll(" Hope that helps. Proceeding to panic.\n");
+ tty_config.setColor(w, .reset) catch {};
}
/// Allocates a new string for assigning a value to a named macro.
diff --git a/lib/std/Build/Step.zig b/lib/std/Build/Step.zig
index b421309eac..475fc82e1a 100644
--- a/lib/std/Build/Step.zig
+++ b/lib/std/Build/Step.zig
@@ -231,13 +231,9 @@ pub fn cast(step: *Step, comptime T: type) ?*T {
}
/// For debugging purposes, prints identifying information about this Step.
-pub fn dump(step: *Step) void {
- std.debug.getStderrMutex().lock();
- defer std.debug.getStderrMutex().unlock();
-
- const stderr = std.io.getStdErr();
- const w = stderr.writer();
- const tty_config = std.io.tty.detectConfig(stderr);
+pub fn dump(step: *Step, file: std.fs.File) void {
+ const w = file.writer();
+ const tty_config = std.io.tty.detectConfig(file);
const debug_info = std.debug.getSelfDebugInfo() catch |err| {
w.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{
@errorName(err),
@@ -248,7 +244,7 @@ pub fn dump(step: *Step) void {
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| {
- stderr.writer().print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch {};
+ w.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch {};
return;
};
} else {