From f8e015c85f2eaf4d35523d362a7be2b9614a162b Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 27 Jan 2020 13:10:35 +0100 Subject: [PATCH 1/2] Handle S_GPROC32 symbols in PDB files Fixes some incomplete stack traces on Windows. --- lib/std/debug.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 857fe9223f..442b5db210 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -412,7 +412,7 @@ fn printSourceAtAddressWindows( if (prefix.RecordLen < 2) return error.InvalidDebugInfo; switch (prefix.RecordKind) { - pdb.SymbolKind.S_LPROC32 => { + .S_LPROC32, .S_GPROC32 => { const proc_sym = @ptrCast(*pdb.ProcSym, &mod.symbols[symbol_i + @sizeOf(pdb.RecordPrefix)]); const vaddr_start = coff_section.header.virtual_address + proc_sym.CodeOffset; const vaddr_end = vaddr_start + proc_sym.CodeSize; From 7336b750bd5e3c271a654e6d44d572cf0427a0b1 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 27 Jan 2020 13:12:01 +0100 Subject: [PATCH 2/2] Fix stack-trace address calculation on Windows Let's always subtract 1 from the return address so that we're sure to be inside the callee. Fixes some edge case where the stack trace skipped the first entry. --- lib/std/debug.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 442b5db210..97c20e5104 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -360,7 +360,7 @@ pub fn writeCurrentStackTraceWindows( return; } else 0; for (addrs[start_i..]) |addr| { - try printSourceAtAddress(debug_info, out_stream, addr, tty_config); + try printSourceAtAddress(debug_info, out_stream, addr - 1, tty_config); } }