| author | |
| committer | |
| log | 94648a0383056e99110a4a894b86f4a762e4526c |
| tree | 9ae806dc24eefd67ecc59ee480163b337eab57bc |
| parent | b41b5fe52935ec19402704742751dc9c973518a4 |
6 files changed, 54 insertions(+), 24 deletions(-)
src/codegen.zig+1-1| ... | ... | @@ -142,7 +142,7 @@ pub fn generateLazySymbol( |
| 142 | 142 | var string_index: u32 = @intCast(4 * (1 + err_names.len + @intFromBool(err_names.len > 0))); |
| 143 | 143 | try code.resize(gpa, offset_index + string_index); |
| 144 | 144 | 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; | |
| 146 | 146 | offset_index += 4; |
| 147 | 147 | for (err_names) |err_name_nts| { |
| 148 | 148 | const err_name = err_name_nts.toSlice(ip); |
src/link.zig+7-1| ... | ... | @@ -738,9 +738,15 @@ pub const File = struct { |
| 738 | 738 | } |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | pub const UpdateLineNumberError = error{ | |
| 742 | OutOfMemory, | |
| 743 | Overflow, | |
| 744 | LinkFailure, | |
| 745 | }; | |
| 746 | ||
| 741 | 747 | /// On an incremental update, fixup the line number of all `Nav`s at the given `TrackedInst`, because |
| 742 | 748 | /// 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 { | |
| 744 | 750 | { |
| 745 | 751 | const ti = ti_id.resolveFull(&pt.zcu.intern_pool).?; |
| 746 | 752 | const file = pt.zcu.fileByIndex(ti.file); |
src/link/Dwarf.zig+1-13| ... | ... | @@ -2661,19 +2661,7 @@ pub fn finishWipNav( |
| 2661 | 2661 | pt: Zcu.PerThread, |
| 2662 | 2662 | nav_index: InternPool.Nav.Index, |
| 2663 | 2663 | 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 | ||
| 2671 | fn finishWipNavInner( | |
| 2672 | dwarf: *Dwarf, | |
| 2673 | pt: Zcu.PerThread, | |
| 2674 | nav_index: InternPool.Nav.Index, | |
| 2675 | wip_nav: *WipNav, | |
| 2676 | ) !void { | |
| 2664 | ) UpdateError!void { | |
| 2677 | 2665 | const zcu = pt.zcu; |
| 2678 | 2666 | const ip = &zcu.intern_pool; |
| 2679 | 2667 | const nav = ip.getNav(nav_index); |
src/link/Elf/ZigObject.zig+19-4| ... | ... | @@ -1465,7 +1465,8 @@ pub fn updateFunc( |
| 1465 | 1465 | break :blk .{ atom_ptr.value, atom_ptr.alignment }; |
| 1466 | 1466 | }; |
| 1467 | 1467 | |
| 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)}); | |
| 1469 | 1470 | |
| 1470 | 1471 | // Exports will be updated by `Zcu.processExports` after the update. |
| 1471 | 1472 | |
| ... | ... | @@ -1550,7 +1551,11 @@ pub fn updateNav( |
| 1550 | 1551 | if (self.dwarf) |*dwarf| dwarf: { |
| 1551 | 1552 | var debug_wip_nav = try dwarf.initWipNav(pt, nav_index, sym_index) orelse break :dwarf; |
| 1552 | 1553 | 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 | }; | |
| 1554 | 1559 | } |
| 1555 | 1560 | return; |
| 1556 | 1561 | }, |
| ... | ... | @@ -1588,7 +1593,11 @@ pub fn updateNav( |
| 1588 | 1593 | else |
| 1589 | 1594 | try self.updateNavCode(elf_file, pt, nav_index, sym_index, shndx, code, elf.STT_OBJECT); |
| 1590 | 1595 | |
| 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 | }; | |
| 1592 | 1601 | } else if (self.dwarf) |*dwarf| try dwarf.updateComptimeNav(pt, nav_index); |
| 1593 | 1602 | |
| 1594 | 1603 | // Exports will be updated by `Zcu.processExports` after the update. |
| ... | ... | @@ -1836,7 +1845,13 @@ pub fn updateExports( |
| 1836 | 1845 | |
| 1837 | 1846 | pub fn updateLineNumber(self: *ZigObject, pt: Zcu.PerThread, ti_id: InternPool.TrackedInst.Index) !void { |
| 1838 | 1847 | 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 | }; | |
| 1840 | 1855 | } |
| 1841 | 1856 | } |
| 1842 | 1857 |
src/link/MachO/ZigObject.zig+19-4| ... | ... | @@ -818,7 +818,8 @@ pub fn updateFunc( |
| 818 | 818 | break :blk .{ atom.value, atom.alignment }; |
| 819 | 819 | }; |
| 820 | 820 | |
| 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)}); | |
| 822 | 823 | |
| 823 | 824 | // Exports will be updated by `Zcu.processExports` after the update. |
| 824 | 825 | if (old_rva != new_rva and old_rva > 0) { |
| ... | ... | @@ -889,7 +890,11 @@ pub fn updateNav( |
| 889 | 890 | if (self.dwarf) |*dwarf| dwarf: { |
| 890 | 891 | var debug_wip_nav = try dwarf.initWipNav(pt, nav_index, sym_index) orelse break :dwarf; |
| 891 | 892 | 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 | }; | |
| 893 | 898 | } |
| 894 | 899 | return; |
| 895 | 900 | }, |
| ... | ... | @@ -922,7 +927,11 @@ pub fn updateNav( |
| 922 | 927 | else |
| 923 | 928 | try self.updateNavCode(macho_file, pt, nav_index, sym_index, sect_index, code); |
| 924 | 929 | |
| 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 | }; | |
| 926 | 935 | } else if (self.dwarf) |*dwarf| try dwarf.updateComptimeNav(pt, nav_index); |
| 927 | 936 | |
| 928 | 937 | // Exports will be updated by `Zcu.processExports` after the update. |
| ... | ... | @@ -1411,7 +1420,13 @@ fn updateLazySymbol( |
| 1411 | 1420 | |
| 1412 | 1421 | pub fn updateLineNumber(self: *ZigObject, pt: Zcu.PerThread, ti_id: InternPool.TrackedInst.Index) !void { |
| 1413 | 1422 | 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 | }; | |
| 1415 | 1430 | } |
| 1416 | 1431 | } |
| 1417 | 1432 |
src/link/Wasm.zig+7-1| ... | ... | @@ -3106,8 +3106,14 @@ pub fn updateNav(wasm: *Wasm, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index |
| 3106 | 3106 | } |
| 3107 | 3107 | |
| 3108 | 3108 | pub 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; | |
| 3109 | 3111 | 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 | }; | |
| 3111 | 3117 | } |
| 3112 | 3118 | } |
| 3113 | 3119 |