mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
std.debug: don't include dumpCurrentStackTrace frame
If it's not given, we should set `first_address` to the return address of `dumpCurrentStackTrace` to avoid the call to `writeCurrentStackTrace` appearing in the trace. However, we must only do that if no `context` is given; if there's a context then we're starting the stack unwind elsewhere.
This commit is contained in:
parent
e6adddf80c
commit
f798048739
1 changed files with 9 additions and 1 deletions
|
|
@ -732,7 +732,15 @@ pub fn dumpCurrentStackTrace(options: StackUnwindOptions) void {
|
|||
const tty_config = tty.detectConfig(.stderr());
|
||||
const stderr = lockStderrWriter(&.{});
|
||||
defer unlockStderrWriter();
|
||||
writeCurrentStackTrace(options, stderr, tty_config) catch |err| switch (err) {
|
||||
writeCurrentStackTrace(.{
|
||||
.first_address = a: {
|
||||
if (options.first_address) |a| break :a a;
|
||||
if (options.context != null) break :a null;
|
||||
break :a @returnAddress(); // don't include this frame in the trace
|
||||
},
|
||||
.context = options.context,
|
||||
.allow_unsafe_unwind = options.allow_unsafe_unwind,
|
||||
}, stderr, tty_config) catch |err| switch (err) {
|
||||
error.WriteFailed => {},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue