From 1fb15be05f1037aad53d2db32d13123363365d10 Mon Sep 17 00:00:00 2001 From: Sahnvour Date: Wed, 28 Nov 2018 00:24:06 +0100 Subject: [PATCH] stack traces: fix for windows --- std/debug/index.zig | 5 +++-- std/pdb.zig | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/std/debug/index.zig b/std/debug/index.zig index b077bdb3b0..134f0a479f 100644 --- a/std/debug/index.zig +++ b/std/debug/index.zig @@ -282,8 +282,9 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres var coff_section: *coff.Section = undefined; const mod_index = for (di.sect_contribs) |sect_contrib| { - if (sect_contrib.Section >= di.coff.sections.len) continue; - coff_section = &di.coff.sections.toSlice()[sect_contrib.Section]; + if (sect_contrib.Section > di.coff.sections.len) continue; + // Remember that SectionContribEntry.Section is 1-based. + coff_section = &di.coff.sections.toSlice()[sect_contrib.Section-1]; const vaddr_start = coff_section.header.virtual_address + sect_contrib.Offset; const vaddr_end = vaddr_start + sect_contrib.Size; diff --git a/std/pdb.zig b/std/pdb.zig index 17275ab2a5..2c5df3e597 100644 --- a/std/pdb.zig +++ b/std/pdb.zig @@ -34,6 +34,7 @@ pub const DbiStreamHeader = packed struct { }; pub const SectionContribEntry = packed struct { + /// COFF Section index, 1-based Section: u16, Padding1: [2]u8, Offset: u32,