authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-12-07 22:35:04+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-12-09 09:24:25+01:00
log8e71a79e4b8252eba22465ebe7e305a2a348f438
tree30937276650925781e4e2edbe2e3f936e4a3cec9
parent62145a1b0850f4def3f2ab401da7bed47045044d

dwarf: fix incorrect calc of dir index


1 files changed, 4 insertions(+), 8 deletions(-)

src/link/Dwarf.zig+4-8
......@@ -976,11 +976,7 @@ pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index)
976976 // Once we support more than one source file, this will have the ability to be more
977977 // than one possible value.
978978 const file_index = try self.addDIFile(mod, decl_index);
979 leb128.writeUnsignedFixed(
980 4,
981 dbg_line_buffer.addManyAsArrayAssumeCapacity(4),
982 file_index + 1,
983 );
979 leb128.writeUnsignedFixed(4, dbg_line_buffer.addManyAsArrayAssumeCapacity(4), file_index);
984980
985981 // Emit a line for the begin curly with prologue_end=false. The codegen will
986982 // do the work of setting prologue_end=true and epilogue_begin=true.
......@@ -2370,7 +2366,7 @@ pub fn writeDbgLineHeader(self: *Dwarf, module: *Module) !void {
23702366 di_buf.appendSliceAssumeCapacity(file);
23712367 di_buf.appendSliceAssumeCapacity(&[_]u8{
23722368 0, // null byte for the relative path name
2373 @intCast(u8, dir_index + 1), // directory_index
2369 @intCast(u8, dir_index), // directory_index
23742370 0, // mtime (TODO supply this)
23752371 0, // file size bytes (TODO supply this)
23762372 });
......@@ -2596,7 +2592,7 @@ fn addDIFile(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index) !u28 {
25962592 else => unreachable,
25972593 }
25982594 }
2599 return @intCast(u28, gop.index);
2595 return @intCast(u28, gop.index + 1);
26002596}
26012597
26022598fn genIncludeDirsAndFileNames(self: *Dwarf, arena: Allocator, module: *Module) !struct {
......@@ -2626,7 +2622,7 @@ fn genIncludeDirsAndFileNames(self: *Dwarf, arena: Allocator, module: *Module) !
26262622 break :inner dir_path[comp_dir.len + 1 ..];
26272623 } else dir_path;
26282624 const dirs_gop = dirs.getOrPutAssumeCapacity(actual_dir_path);
2629 break :blk @intCast(u28, dirs_gop.index);
2625 break :blk @intCast(u28, dirs_gop.index + 1);
26302626 };
26312627
26322628 files_dir_indexes.appendAssumeCapacity(dir_index);