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)...@@ -976,11 +976,7 @@ pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index)
976 // Once we support more than one source file, this will have the ability to be more976 // Once we support more than one source file, this will have the ability to be more
977 // than one possible value.977 // than one possible value.
978 const file_index = try self.addDIFile(mod, decl_index);978 const file_index = try self.addDIFile(mod, decl_index);
979 leb128.writeUnsignedFixed(979 leb128.writeUnsignedFixed(4, dbg_line_buffer.addManyAsArrayAssumeCapacity(4), file_index);
980 4,
981 dbg_line_buffer.addManyAsArrayAssumeCapacity(4),
982 file_index + 1,
983 );
984980
985 // Emit a line for the begin curly with prologue_end=false. The codegen will981 // Emit a line for the begin curly with prologue_end=false. The codegen will
986 // do the work of setting prologue_end=true and epilogue_begin=true.982 // do the work of setting prologue_end=true and epilogue_begin=true.
...@@ -2370,7 +2366,7 @@ pub fn writeDbgLineHeader(self: *Dwarf, module: *Module) !void {...@@ -2370,7 +2366,7 @@ pub fn writeDbgLineHeader(self: *Dwarf, module: *Module) !void {
2370 di_buf.appendSliceAssumeCapacity(file);2366 di_buf.appendSliceAssumeCapacity(file);
2371 di_buf.appendSliceAssumeCapacity(&[_]u8{2367 di_buf.appendSliceAssumeCapacity(&[_]u8{
2372 0, // null byte for the relative path name2368 0, // null byte for the relative path name
2373 @intCast(u8, dir_index + 1), // directory_index2369 @intCast(u8, dir_index), // directory_index
2374 0, // mtime (TODO supply this)2370 0, // mtime (TODO supply this)
2375 0, // file size bytes (TODO supply this)2371 0, // file size bytes (TODO supply this)
2376 });2372 });
...@@ -2596,7 +2592,7 @@ fn addDIFile(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index) !u28 {...@@ -2596,7 +2592,7 @@ fn addDIFile(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index) !u28 {
2596 else => unreachable,2592 else => unreachable,
2597 }2593 }
2598 }2594 }
2599 return @intCast(u28, gop.index);2595 return @intCast(u28, gop.index + 1);
2600}2596}
26012597
2602fn genIncludeDirsAndFileNames(self: *Dwarf, arena: Allocator, module: *Module) !struct {2598fn genIncludeDirsAndFileNames(self: *Dwarf, arena: Allocator, module: *Module) !struct {
...@@ -2626,7 +2622,7 @@ fn genIncludeDirsAndFileNames(self: *Dwarf, arena: Allocator, module: *Module) !...@@ -2626,7 +2622,7 @@ fn genIncludeDirsAndFileNames(self: *Dwarf, arena: Allocator, module: *Module) !
2626 break :inner dir_path[comp_dir.len + 1 ..];2622 break :inner dir_path[comp_dir.len + 1 ..];
2627 } else dir_path;2623 } else dir_path;
2628 const dirs_gop = dirs.getOrPutAssumeCapacity(actual_dir_path);2624 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);
2630 };2626 };
26312627
2632 files_dir_indexes.appendAssumeCapacity(dir_index);2628 files_dir_indexes.appendAssumeCapacity(dir_index);