mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +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
@ -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…
x
Reference in New Issue
Block a user