authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-05 19:32:06-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-15 15:11:36-08:00
log94648a0383056e99110a4a894b86f4a762e4526c
tree9ae806dc24eefd67ecc59ee480163b337eab57bc
parentb41b5fe52935ec19402704742751dc9c973518a4

fix merge conflicts with updating line numbers


6 files changed, 54 insertions(+), 24 deletions(-)

src/codegen.zig+1-1
......@@ -142,7 +142,7 @@ pub fn generateLazySymbol(
142142 var string_index: u32 = @intCast(4 * (1 + err_names.len + @intFromBool(err_names.len > 0)));
143143 try code.resize(gpa, offset_index + string_index);
144144 mem.writeInt(u32, code.items[offset_index..][0..4], @intCast(err_names.len), endian);
145 if (err_names.len == 0) return .ok;
145 if (err_names.len == 0) return;
146146 offset_index += 4;
147147 for (err_names) |err_name_nts| {
148148 const err_name = err_name_nts.toSlice(ip);
src/link.zig+7-1
......@@ -738,9 +738,15 @@ pub const File = struct {
738738 }
739739 }
740740
741 pub const UpdateLineNumberError = error{
742 OutOfMemory,
743 Overflow,
744 LinkFailure,
745 };
746
741747 /// On an incremental update, fixup the line number of all `Nav`s at the given `TrackedInst`, because
742748 /// its line number has changed. The ZIR instruction `ti_id` has tag `.declaration`.
743 pub fn updateLineNumber(base: *File, pt: Zcu.PerThread, ti_id: InternPool.TrackedInst.Index) UpdateNavError!void {
749 pub fn updateLineNumber(base: *File, pt: Zcu.PerThread, ti_id: InternPool.TrackedInst.Index) UpdateLineNumberError!void {
744750 {
745751 const ti = ti_id.resolveFull(&pt.zcu.intern_pool).?;
746752 const file = pt.zcu.fileByIndex(ti.file);
src/link/Dwarf.zig+1-13
......@@ -2661,19 +2661,7 @@ pub fn finishWipNav(
26612661 pt: Zcu.PerThread,
26622662 nav_index: InternPool.Nav.Index,
26632663 wip_nav: *WipNav,
2664) error{ OutOfMemory, CodegenFail }!void {
2665 return finishWipNavInner(dwarf, pt, nav_index, wip_nav) catch |err| switch (err) {
2666 error.OutOfMemory => return error.OutOfMemory,
2667 else => |e| return pt.zcu.codegenFail(nav_index, "failed to finish dwarf: {s}", .{@errorName(e)}),
2668 };
2669}
2670
2671fn finishWipNavInner(
2672 dwarf: *Dwarf,
2673 pt: Zcu.PerThread,
2674 nav_index: InternPool.Nav.Index,
2675 wip_nav: *WipNav,
2676) !void {
2664) UpdateError!void {
26772665 const zcu = pt.zcu;
26782666 const ip = &zcu.intern_pool;
26792667 const nav = ip.getNav(nav_index);
src/link/Elf/ZigObject.zig+19-4
......@@ -1465,7 +1465,8 @@ pub fn updateFunc(
14651465 break :blk .{ atom_ptr.value, atom_ptr.alignment };
14661466 };
14671467
1468 if (debug_wip_nav) |*wip_nav| try self.dwarf.?.finishWipNavFunc(pt, func.owner_nav, code.len, wip_nav);
1468 if (debug_wip_nav) |*wip_nav| self.dwarf.?.finishWipNavFunc(pt, func.owner_nav, code.len, wip_nav) catch |err|
1469 return elf_file.base.cgFail(func.owner_nav, "failed to finish dwarf function: {s}", .{@errorName(err)});
14691470
14701471 // Exports will be updated by `Zcu.processExports` after the update.
14711472
......@@ -1550,7 +1551,11 @@ pub fn updateNav(
15501551 if (self.dwarf) |*dwarf| dwarf: {
15511552 var debug_wip_nav = try dwarf.initWipNav(pt, nav_index, sym_index) orelse break :dwarf;
15521553 defer debug_wip_nav.deinit();
1553 try dwarf.finishWipNav(pt, nav_index, &debug_wip_nav);
1554 dwarf.finishWipNav(pt, nav_index, &debug_wip_nav) catch |err| switch (err) {
1555 error.OutOfMemory => return error.OutOfMemory,
1556 error.Overflow => return error.Overflow,
1557 else => |e| return elf_file.base.cgFail(nav_index, "failed to finish dwarf nav: {s}", .{@errorName(e)}),
1558 };
15541559 }
15551560 return;
15561561 },
......@@ -1588,7 +1593,11 @@ pub fn updateNav(
15881593 else
15891594 try self.updateNavCode(elf_file, pt, nav_index, sym_index, shndx, code, elf.STT_OBJECT);
15901595
1591 if (debug_wip_nav) |*wip_nav| try self.dwarf.?.finishWipNav(pt, nav_index, wip_nav);
1596 if (debug_wip_nav) |*wip_nav| self.dwarf.?.finishWipNav(pt, nav_index, wip_nav) catch |err| switch (err) {
1597 error.OutOfMemory => return error.OutOfMemory,
1598 error.Overflow => return error.Overflow,
1599 else => |e| return elf_file.base.cgFail(nav_index, "failed to finish dwarf nav: {s}", .{@errorName(e)}),
1600 };
15921601 } else if (self.dwarf) |*dwarf| try dwarf.updateComptimeNav(pt, nav_index);
15931602
15941603 // Exports will be updated by `Zcu.processExports` after the update.
......@@ -1836,7 +1845,13 @@ pub fn updateExports(
18361845
18371846pub fn updateLineNumber(self: *ZigObject, pt: Zcu.PerThread, ti_id: InternPool.TrackedInst.Index) !void {
18381847 if (self.dwarf) |*dwarf| {
1839 try dwarf.updateLineNumber(pt.zcu, ti_id);
1848 const comp = dwarf.bin_file.comp;
1849 const diags = &comp.link_diags;
1850 dwarf.updateLineNumber(pt.zcu, ti_id) catch |err| switch (err) {
1851 error.Overflow => return error.Overflow,
1852 error.OutOfMemory => return error.OutOfMemory,
1853 else => |e| return diags.fail("failed to update dwarf line numbers: {s}", .{@errorName(e)}),
1854 };
18401855 }
18411856}
18421857
src/link/MachO/ZigObject.zig+19-4
......@@ -818,7 +818,8 @@ pub fn updateFunc(
818818 break :blk .{ atom.value, atom.alignment };
819819 };
820820
821 if (debug_wip_nav) |*wip_nav| try self.dwarf.?.finishWipNavFunc(pt, func.owner_nav, code.len, wip_nav);
821 if (debug_wip_nav) |*wip_nav| self.dwarf.?.finishWipNavFunc(pt, func.owner_nav, code.len, wip_nav) catch |err|
822 return macho_file.base.cgFail(func.owner_nav, "falied to finish dwarf function: {s}", .{@errorName(err)});
822823
823824 // Exports will be updated by `Zcu.processExports` after the update.
824825 if (old_rva != new_rva and old_rva > 0) {
......@@ -889,7 +890,11 @@ pub fn updateNav(
889890 if (self.dwarf) |*dwarf| dwarf: {
890891 var debug_wip_nav = try dwarf.initWipNav(pt, nav_index, sym_index) orelse break :dwarf;
891892 defer debug_wip_nav.deinit();
892 try dwarf.finishWipNav(pt, nav_index, &debug_wip_nav);
893 dwarf.finishWipNav(pt, nav_index, &debug_wip_nav) catch |err| switch (err) {
894 error.OutOfMemory => return error.OutOfMemory,
895 error.Overflow => return error.Overflow,
896 else => |e| return macho_file.base.cgFail(nav_index, "failed to finish dwarf nav: {s}", .{@errorName(e)}),
897 };
893898 }
894899 return;
895900 },
......@@ -922,7 +927,11 @@ pub fn updateNav(
922927 else
923928 try self.updateNavCode(macho_file, pt, nav_index, sym_index, sect_index, code);
924929
925 if (debug_wip_nav) |*wip_nav| try self.dwarf.?.finishWipNav(pt, nav_index, wip_nav);
930 if (debug_wip_nav) |*wip_nav| self.dwarf.?.finishWipNav(pt, nav_index, wip_nav) catch |err| switch (err) {
931 error.OutOfMemory => return error.OutOfMemory,
932 error.Overflow => return error.Overflow,
933 else => |e| return macho_file.base.cgFail(nav_index, "failed to finish dwarf nav: {s}", .{@errorName(e)}),
934 };
926935 } else if (self.dwarf) |*dwarf| try dwarf.updateComptimeNav(pt, nav_index);
927936
928937 // Exports will be updated by `Zcu.processExports` after the update.
......@@ -1411,7 +1420,13 @@ fn updateLazySymbol(
14111420
14121421pub fn updateLineNumber(self: *ZigObject, pt: Zcu.PerThread, ti_id: InternPool.TrackedInst.Index) !void {
14131422 if (self.dwarf) |*dwarf| {
1414 try dwarf.updateLineNumber(pt.zcu, ti_id);
1423 const comp = dwarf.bin_file.comp;
1424 const diags = &comp.link_diags;
1425 dwarf.updateLineNumber(pt.zcu, ti_id) catch |err| switch (err) {
1426 error.Overflow => return error.Overflow,
1427 error.OutOfMemory => return error.OutOfMemory,
1428 else => |e| return diags.fail("failed to update dwarf line numbers: {s}", .{@errorName(e)}),
1429 };
14151430 }
14161431}
14171432
src/link/Wasm.zig+7-1
......@@ -3106,8 +3106,14 @@ pub fn updateNav(wasm: *Wasm, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index
31063106}
31073107
31083108pub fn updateLineNumber(wasm: *Wasm, pt: Zcu.PerThread, ti_id: InternPool.TrackedInst.Index) !void {
3109 const comp = wasm.base.comp;
3110 const diags = &comp.link_diags;
31093111 if (wasm.dwarf) |*dw| {
3110 try dw.updateLineNumber(pt.zcu, ti_id);
3112 dw.updateLineNumber(pt.zcu, ti_id) catch |err| switch (err) {
3113 error.Overflow => return error.Overflow,
3114 error.OutOfMemory => return error.OutOfMemory,
3115 else => |e| return diags.fail("failed to update dwarf line numbers: {s}", .{@errorName(e)}),
3116 };
31113117 }
31123118}
31133119