authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-01-04 00:32:28-05:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-01-05 02:20:56+00:00
logdde3116e50c0c5869c717f1eb480705165047be0
tree151ce66b74b958d7d5234cf6947c9589f3b5a132
parent065e10c95ccca509afecfecc849da9114e0000b2
signaturelock-open Commit is signed but in an unrecognized format.

Dwarf: implement new incremental line number update API


11 files changed, 856 insertions(+), 471 deletions(-)

change_line_number deleted-16
...@@ -1,16 +0,0 @@
1#target=x86_64-linux-selfhosted
2#update=initial version
3#file=main.zig
4const std = @import("std");
5pub fn main() !void {
6 try std.io.getStdOut().writeAll("foo\n");
7}
8#expect_stdout="foo\n"
9#update=change line number
10#file=main.zig
11const std = @import("std");
12
13pub fn main() !void {
14 try std.io.getStdOut().writeAll("foo\n");
15}
16#expect_stdout="foo\n"
ci/x86_64-linux-debug.sh+1-1
...@@ -64,7 +64,7 @@ stage3-debug/bin/zig build \...@@ -64,7 +64,7 @@ stage3-debug/bin/zig build \
6464
65stage3-debug/bin/zig build test docs \65stage3-debug/bin/zig build test docs \
66 --maxrss 21000000000 \66 --maxrss 21000000000 \
67 -Dlldb=$HOME/deps/lldb-zig/Debug-bfeada333/bin/lldb \67 -Dlldb=$HOME/deps/lldb-zig/Debug-e0a42bb34/bin/lldb \
68 -fqemu \68 -fqemu \
69 -fwasmtime \69 -fwasmtime \
70 -Dstatic-llvm \70 -Dstatic-llvm \
ci/x86_64-linux-release.sh+1-1
...@@ -64,7 +64,7 @@ stage3-release/bin/zig build \...@@ -64,7 +64,7 @@ stage3-release/bin/zig build \
6464
65stage3-release/bin/zig build test docs \65stage3-release/bin/zig build test docs \
66 --maxrss 21000000000 \66 --maxrss 21000000000 \
67 -Dlldb=$HOME/deps/lldb-zig/Release-bfeada333/bin/lldb \67 -Dlldb=$HOME/deps/lldb-zig/Release-e0a42bb34/bin/lldb \
68 -fqemu \68 -fqemu \
69 -fwasmtime \69 -fwasmtime \
70 -Dstatic-llvm \70 -Dstatic-llvm \
src/InternPool.zig+7-1
...@@ -168,6 +168,8 @@ pub const TrackedInst = extern struct {...@@ -168,6 +168,8 @@ pub const TrackedInst = extern struct {
168 _ => @enumFromInt(@intFromEnum(opt)),168 _ => @enumFromInt(@intFromEnum(opt)),
169 };169 };
170 }170 }
171
172 const debug_state = InternPool.debug_state;
171 };173 };
172174
173 pub const Unwrapped = struct {175 pub const Unwrapped = struct {
...@@ -187,6 +189,8 @@ pub const TrackedInst = extern struct {...@@ -187,6 +189,8 @@ pub const TrackedInst = extern struct {
187 .index = @intFromEnum(tracked_inst_index) & ip.getIndexMask(u32),189 .index = @intFromEnum(tracked_inst_index) & ip.getIndexMask(u32),
188 };190 };
189 }191 }
192
193 const debug_state = InternPool.debug_state;
190 };194 };
191};195};
192196
...@@ -508,7 +512,7 @@ pub const Nav = struct {...@@ -508,7 +512,7 @@ pub const Nav = struct {
508 /// The fully-qualified name of this `Nav`.512 /// The fully-qualified name of this `Nav`.
509 fqn: NullTerminatedString,513 fqn: NullTerminatedString,
510 /// This field is populated iff this `Nav` is resolved by semantic analysis.514 /// This field is populated iff this `Nav` is resolved by semantic analysis.
511 /// If this is `null`, then `status == .resolved` always.515 /// If this is `null`, then `status == .fully_resolved` always.
512 analysis: ?struct {516 analysis: ?struct {
513 namespace: NamespaceIndex,517 namespace: NamespaceIndex,
514 zir_index: TrackedInst.Index,518 zir_index: TrackedInst.Index,
...@@ -6631,6 +6635,8 @@ pub fn activate(ip: *const InternPool) void {...@@ -6631,6 +6635,8 @@ pub fn activate(ip: *const InternPool) void {
6631 _ = OptionalString.debug_state;6635 _ = OptionalString.debug_state;
6632 _ = NullTerminatedString.debug_state;6636 _ = NullTerminatedString.debug_state;
6633 _ = OptionalNullTerminatedString.debug_state;6637 _ = OptionalNullTerminatedString.debug_state;
6638 _ = TrackedInst.Index.debug_state;
6639 _ = TrackedInst.Index.Optional.debug_state;
6634 _ = Nav.Index.debug_state;6640 _ = Nav.Index.debug_state;
6635 _ = Nav.Index.Optional.debug_state;6641 _ = Nav.Index.Optional.debug_state;
6636 std.debug.assert(debug_state.intern_pool == null);6642 std.debug.assert(debug_state.intern_pool == null);
src/link/Dwarf.zig+745-372
...@@ -8,6 +8,7 @@ mods: std.AutoArrayHashMapUnmanaged(*Module, ModInfo),...@@ -8,6 +8,7 @@ mods: std.AutoArrayHashMapUnmanaged(*Module, ModInfo),
8types: std.AutoArrayHashMapUnmanaged(InternPool.Index, Entry.Index),8types: std.AutoArrayHashMapUnmanaged(InternPool.Index, Entry.Index),
9values: std.AutoArrayHashMapUnmanaged(InternPool.Index, Entry.Index),9values: std.AutoArrayHashMapUnmanaged(InternPool.Index, Entry.Index),
10navs: std.AutoArrayHashMapUnmanaged(InternPool.Nav.Index, Entry.Index),10navs: std.AutoArrayHashMapUnmanaged(InternPool.Nav.Index, Entry.Index),
11decls: std.AutoArrayHashMapUnmanaged(InternPool.TrackedInst.Index, Entry.Index),
1112
12debug_abbrev: DebugAbbrev,13debug_abbrev: DebugAbbrev,
13debug_aranges: DebugAranges,14debug_aranges: DebugAranges,
...@@ -51,9 +52,7 @@ pub const AddressSize = enum(u8) {...@@ -51,9 +52,7 @@ pub const AddressSize = enum(u8) {
51const ModInfo = struct {52const ModInfo = struct {
52 root_dir_path: Entry.Index,53 root_dir_path: Entry.Index,
53 dirs: std.AutoArrayHashMapUnmanaged(Unit.Index, void),54 dirs: std.AutoArrayHashMapUnmanaged(Unit.Index, void),
54 files: Files,55 files: std.AutoArrayHashMapUnmanaged(Zcu.File.Index, void),
55
56 const Files = std.AutoArrayHashMapUnmanaged(Zcu.File.Index, void);
5756
58 fn deinit(mod_info: *ModInfo, gpa: std.mem.Allocator) void {57 fn deinit(mod_info: *ModInfo, gpa: std.mem.Allocator) void {
59 mod_info.dirs.deinit(gpa);58 mod_info.dirs.deinit(gpa);
...@@ -137,6 +136,20 @@ const DebugInfo = struct {...@@ -137,6 +136,20 @@ const DebugInfo = struct {
137 return AbbrevCode.decl_bytes + dwarf.sectionOffsetBytes();136 return AbbrevCode.decl_bytes + dwarf.sectionOffsetBytes();
138 }137 }
139138
139 fn declAbbrevCode(debug_info: *DebugInfo, unit: Unit.Index, entry: Entry.Index) !AbbrevCode {
140 const dwarf: *Dwarf = @fieldParentPtr("debug_info", debug_info);
141 const unit_ptr = debug_info.section.getUnit(unit);
142 const entry_ptr = unit_ptr.getEntry(entry);
143 if (entry_ptr.len < AbbrevCode.decl_bytes) return .null;
144 var abbrev_code_buf: [AbbrevCode.decl_bytes]u8 = undefined;
145 if (try dwarf.getFile().?.preadAll(
146 &abbrev_code_buf,
147 debug_info.section.off(dwarf) + unit_ptr.off + unit_ptr.header_len + entry_ptr.off,
148 ) != abbrev_code_buf.len) return error.InputOutput;
149 var abbrev_code_fbs = std.io.fixedBufferStream(&abbrev_code_buf);
150 return @enumFromInt(std.leb.readUleb128(@typeInfo(AbbrevCode).@"enum".tag_type, abbrev_code_fbs.reader()) catch unreachable);
151 }
152
140 const trailer_bytes = 1 + 1;153 const trailer_bytes = 1 + 1;
141};154};
142155
...@@ -206,8 +219,8 @@ const StringSection = struct {...@@ -206,8 +219,8 @@ const StringSection = struct {
206 const unit: Unit.Index = @enumFromInt(0);219 const unit: Unit.Index = @enumFromInt(0);
207220
208 const init: StringSection = .{221 const init: StringSection = .{
209 .contents = .{},222 .contents = .empty,
210 .map = .{},223 .map = .empty,
211 .section = Section.init,224 .section = Section.init,
212 };225 };
213226
...@@ -219,9 +232,9 @@ const StringSection = struct {...@@ -219,9 +232,9 @@ const StringSection = struct {
219232
220 fn addString(str_sec: *StringSection, dwarf: *Dwarf, str: []const u8) UpdateError!Entry.Index {233 fn addString(str_sec: *StringSection, dwarf: *Dwarf, str: []const u8) UpdateError!Entry.Index {
221 const gop = try str_sec.map.getOrPutAdapted(dwarf.gpa, str, Adapter{ .str_sec = str_sec });234 const gop = try str_sec.map.getOrPutAdapted(dwarf.gpa, str, Adapter{ .str_sec = str_sec });
222 errdefer _ = str_sec.map.pop();
223 const entry: Entry.Index = @enumFromInt(gop.index);235 const entry: Entry.Index = @enumFromInt(gop.index);
224 if (!gop.found_existing) {236 if (!gop.found_existing) {
237 errdefer _ = str_sec.map.pop();
225 const unit_ptr = str_sec.section.getUnit(unit);238 const unit_ptr = str_sec.section.getUnit(unit);
226 assert(try str_sec.section.getUnit(unit).addEntry(dwarf.gpa) == entry);239 assert(try str_sec.section.getUnit(unit).addEntry(dwarf.gpa) == entry);
227 errdefer _ = unit_ptr.entries.pop();240 errdefer _ = unit_ptr.entries.pop();
...@@ -284,7 +297,7 @@ pub const Section = struct {...@@ -284,7 +297,7 @@ pub const Section = struct {
284 .index = std.math.maxInt(u32),297 .index = std.math.maxInt(u32),
285 .first = .none,298 .first = .none,
286 .last = .none,299 .last = .none,
287 .units = .{},300 .units = .empty,
288 .len = 0,301 .len = 0,
289 };302 };
290303
...@@ -319,13 +332,14 @@ pub const Section = struct {...@@ -319,13 +332,14 @@ pub const Section = struct {
319 .next = .none,332 .next = .none,
320 .first = .none,333 .first = .none,
321 .last = .none,334 .last = .none,
335 .free = .none,
322 .header_len = aligned_header_len,336 .header_len = aligned_header_len,
323 .trailer_len = aligned_trailer_len,337 .trailer_len = aligned_trailer_len,
324 .off = 0,338 .off = 0,
325 .len = aligned_header_len + aligned_trailer_len,339 .len = aligned_header_len + aligned_trailer_len,
326 .entries = .{},340 .entries = .empty,
327 .cross_unit_relocs = .{},341 .cross_unit_relocs = .empty,
328 .cross_section_relocs = .{},342 .cross_section_relocs = .empty,
329 };343 };
330 if (sec.last.unwrap()) |last_unit| {344 if (sec.last.unwrap()) |last_unit| {
331 const last_unit_ptr = sec.getUnit(last_unit);345 const last_unit_ptr = sec.getUnit(last_unit);
...@@ -385,6 +399,28 @@ pub const Section = struct {...@@ -385,6 +399,28 @@ pub const Section = struct {
385 try unit_ptr.getEntry(entry).replace(unit_ptr, sec, dwarf, contents);399 try unit_ptr.getEntry(entry).replace(unit_ptr, sec, dwarf, contents);
386 }400 }
387401
402 fn freeEntry(sec: *Section, unit: Unit.Index, entry: Entry.Index, dwarf: *Dwarf) UpdateError!void {
403 const unit_ptr = sec.getUnit(unit);
404 const entry_ptr = unit_ptr.getEntry(entry);
405 if (entry_ptr.len > 0) {
406 if (entry_ptr.next.unwrap()) |next_entry| unit_ptr.getEntry(next_entry).prev = entry_ptr.prev;
407 if (entry_ptr.prev.unwrap()) |prev_entry| {
408 const prev_entry_ptr = unit_ptr.getEntry(prev_entry);
409 prev_entry_ptr.next = entry_ptr.next;
410 try prev_entry_ptr.pad(unit_ptr, sec, dwarf);
411 } else {
412 unit_ptr.trim();
413 sec.trim(dwarf);
414 }
415 } else assert(entry_ptr.prev == .none and entry_ptr.next == .none);
416 entry_ptr.prev = .none;
417 entry_ptr.next = unit_ptr.free;
418 entry_ptr.off = 0;
419 entry_ptr.len = 0;
420 entry_ptr.clear();
421 unit_ptr.free = entry.toOptional();
422 }
423
388 fn resize(sec: *Section, dwarf: *Dwarf, len: u64) UpdateError!void {424 fn resize(sec: *Section, dwarf: *Dwarf, len: u64) UpdateError!void {
389 if (len <= sec.len) return;425 if (len <= sec.len) return;
390 if (dwarf.bin_file.cast(.elf)) |elf_file| {426 if (dwarf.bin_file.cast(.elf)) |elf_file| {
...@@ -449,6 +485,7 @@ const Unit = struct {...@@ -449,6 +485,7 @@ const Unit = struct {
449 next: Index.Optional,485 next: Index.Optional,
450 first: Entry.Index.Optional,486 first: Entry.Index.Optional,
451 last: Entry.Index.Optional,487 last: Entry.Index.Optional,
488 free: Entry.Index.Optional,
452 /// offset within containing section489 /// offset within containing section
453 off: u32,490 off: u32,
454 header_len: u32,491 header_len: u32,
...@@ -491,6 +528,12 @@ const Unit = struct {...@@ -491,6 +528,12 @@ const Unit = struct {
491 }528 }
492529
493 fn addEntry(unit: *Unit, gpa: std.mem.Allocator) std.mem.Allocator.Error!Entry.Index {530 fn addEntry(unit: *Unit, gpa: std.mem.Allocator) std.mem.Allocator.Error!Entry.Index {
531 if (unit.free.unwrap()) |entry| {
532 const entry_ptr = unit.getEntry(entry);
533 unit.free = entry_ptr.next;
534 entry_ptr.next = .none;
535 return entry;
536 }
494 const entry: Entry.Index = @enumFromInt(unit.entries.items.len);537 const entry: Entry.Index = @enumFromInt(unit.entries.items.len);
495 const entry_ptr = try unit.entries.addOne(gpa);538 const entry_ptr = try unit.entries.addOne(gpa);
496 entry_ptr.* = .{539 entry_ptr.* = .{
...@@ -498,10 +541,10 @@ const Unit = struct {...@@ -498,10 +541,10 @@ const Unit = struct {
498 .next = .none,541 .next = .none,
499 .off = 0,542 .off = 0,
500 .len = 0,543 .len = 0,
501 .cross_entry_relocs = .{},544 .cross_entry_relocs = .empty,
502 .cross_unit_relocs = .{},545 .cross_unit_relocs = .empty,
503 .cross_section_relocs = .{},546 .cross_section_relocs = .empty,
504 .external_relocs = .{},547 .external_relocs = .empty,
505 };548 };
506 return entry;549 return entry;
507 }550 }
...@@ -1583,7 +1626,7 @@ pub const WipNav = struct {...@@ -1583,7 +1626,7 @@ pub const WipNav = struct {
1583 const dlw = wip_nav.debug_line.writer(dwarf.gpa);1626 const dlw = wip_nav.debug_line.writer(dwarf.gpa);
1584 if (dwarf.incremental()) {1627 if (dwarf.incremental()) {
1585 const new_nav_gop = try dwarf.navs.getOrPut(dwarf.gpa, new_func_info.owner_nav);1628 const new_nav_gop = try dwarf.navs.getOrPut(dwarf.gpa, new_func_info.owner_nav);
1586 errdefer _ = dwarf.navs.pop();1629 errdefer _ = if (!new_nav_gop.found_existing) dwarf.navs.pop();
1587 if (!new_nav_gop.found_existing) new_nav_gop.value_ptr.* = try dwarf.addCommonEntry(new_unit);1630 if (!new_nav_gop.found_existing) new_nav_gop.value_ptr.* = try dwarf.addCommonEntry(new_unit);
15881631
1589 try dlw.writeByte(DW.LNS.extended_op);1632 try dlw.writeByte(DW.LNS.extended_op);
...@@ -1603,10 +1646,8 @@ pub const WipNav = struct {...@@ -1603,10 +1646,8 @@ pub const WipNav = struct {
1603 const old_file = zcu.navFileScopeIndex(old_func_info.owner_nav);1646 const old_file = zcu.navFileScopeIndex(old_func_info.owner_nav);
1604 if (old_file != new_file) {1647 if (old_file != new_file) {
1605 const mod_info = dwarf.getModInfo(wip_nav.unit);1648 const mod_info = dwarf.getModInfo(wip_nav.unit);
1606 const mod_gop = try mod_info.dirs.getOrPut(dwarf.gpa, new_unit);1649 try mod_info.dirs.put(dwarf.gpa, new_unit, {});
1607 errdefer _ = if (!mod_gop.found_existing) mod_info.dirs.pop();
1608 const file_gop = try mod_info.files.getOrPut(dwarf.gpa, new_file);1650 const file_gop = try mod_info.files.getOrPut(dwarf.gpa, new_file);
1609 errdefer _ = if (!file_gop.found_existing) mod_info.files.pop();
16101651
1611 try dlw.writeByte(DW.LNS.set_file);1652 try dlw.writeByte(DW.LNS.set_file);
1612 try uleb128(dlw, file_gop.index);1653 try uleb128(dlw, file_gop.index);
...@@ -1934,6 +1975,90 @@ pub const WipNav = struct {...@@ -1934,6 +1975,90 @@ pub const WipNav = struct {
1934 std.math.big.int.Mutable.init(&big_int_space.limbs, field_index).toConst());1975 std.math.big.int.Mutable.init(&big_int_space.limbs, field_index).toConst());
1935 }1976 }
19361977
1978 fn declCommon(
1979 wip_nav: *WipNav,
1980 abbrev_code: struct {
1981 decl: AbbrevCode,
1982 generic_decl: AbbrevCode,
1983 instance: AbbrevCode,
1984 },
1985 nav: *const InternPool.Nav,
1986 file: Zcu.File.Index,
1987 decl: *const std.zig.Zir.Inst.Declaration.Unwrapped,
1988 ) UpdateError!void {
1989 const zcu = wip_nav.pt.zcu;
1990 const ip = &zcu.intern_pool;
1991 const dwarf = wip_nav.dwarf;
1992 const diw = wip_nav.debug_info.writer(dwarf.gpa);
1993
1994 const orig_entry = wip_nav.entry;
1995 defer wip_nav.entry = orig_entry;
1996 const parent_type, const is_generic_decl = if (nav.analysis) |analysis| parent_info: {
1997 const parent_type: Type = .fromInterned(zcu.namespacePtr(analysis.namespace).owner_type);
1998 const decl_gop = try dwarf.decls.getOrPut(dwarf.gpa, analysis.zir_index);
1999 errdefer _ = if (!decl_gop.found_existing) dwarf.decls.pop();
2000 const was_generic_decl = decl_gop.found_existing and
2001 switch (try dwarf.debug_info.declAbbrevCode(wip_nav.unit, decl_gop.value_ptr.*)) {
2002 else => unreachable,
2003 .decl_alias,
2004 .decl_enum,
2005 .decl_empty_enum,
2006 .decl_namespace_struct,
2007 .decl_struct,
2008 .decl_packed_struct,
2009 .decl_union,
2010 .decl_var,
2011 .decl_const,
2012 .decl_const_runtime_bits,
2013 .decl_const_comptime_state,
2014 .decl_const_runtime_bits_comptime_state,
2015 .decl_func,
2016 .decl_empty_func,
2017 .decl_func_generic,
2018 .decl_empty_func_generic,
2019 => false,
2020 .generic_decl_alias,
2021 .generic_decl_enum,
2022 .generic_decl_struct,
2023 .generic_decl_union,
2024 .generic_decl_var,
2025 .generic_decl_const,
2026 .generic_decl_func,
2027 => true,
2028 };
2029 if (parent_type.getCaptures(zcu).len == 0) {
2030 if (was_generic_decl) try dwarf.freeCommonEntry(wip_nav.unit, decl_gop.value_ptr.*);
2031 decl_gop.value_ptr.* = orig_entry;
2032 break :parent_info .{ parent_type, false };
2033 } else {
2034 if (was_generic_decl)
2035 dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(decl_gop.value_ptr.*).clear()
2036 else
2037 decl_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2038 wip_nav.entry = decl_gop.value_ptr.*;
2039 break :parent_info .{ parent_type, true };
2040 }
2041 } else .{ null, false };
2042
2043 try wip_nav.abbrevCode(if (is_generic_decl) abbrev_code.generic_decl else abbrev_code.decl);
2044 try wip_nav.refType((if (is_generic_decl) null else parent_type) orelse
2045 .fromInterned(zcu.fileRootType(file)));
2046 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2047 try diw.writeInt(u32, decl.src_line + 1, dwarf.endian);
2048 try uleb128(diw, decl.src_column + 1);
2049 try diw.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private);
2050 try wip_nav.strp(nav.name.toSlice(ip));
2051
2052 if (!is_generic_decl) return;
2053 const generic_decl_entry = wip_nav.entry;
2054 try dwarf.debug_info.section.replaceEntry(wip_nav.unit, generic_decl_entry, dwarf, wip_nav.debug_info.items);
2055 wip_nav.debug_info.clearRetainingCapacity();
2056 wip_nav.entry = orig_entry;
2057 try wip_nav.abbrevCode(abbrev_code.instance);
2058 try wip_nav.refType(parent_type.?);
2059 try wip_nav.infoSectionOffset(.debug_info, wip_nav.unit, generic_decl_entry, 0);
2060 }
2061
1937 fn updateLazy(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc) UpdateError!void {2062 fn updateLazy(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc) UpdateError!void {
1938 const ip = &wip_nav.pt.zcu.intern_pool;2063 const ip = &wip_nav.pt.zcu.intern_pool;
1939 while (wip_nav.pending_lazy.popOrNull()) |val| switch (ip.typeOf(val)) {2064 while (wip_nav.pending_lazy.popOrNull()) |val| switch (ip.typeOf(val)) {
...@@ -1966,10 +2091,11 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf {...@@ -1966,10 +2091,11 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf {
1966 },2091 },
1967 .endian = target.cpu.arch.endian(),2092 .endian = target.cpu.arch.endian(),
19682093
1969 .mods = .{},2094 .mods = .empty,
1970 .types = .{},2095 .types = .empty,
1971 .values = .{},2096 .values = .empty,
1972 .navs = .{},2097 .navs = .empty,
2098 .decls = .empty,
19732099
1974 .debug_abbrev = .{ .section = Section.init },2100 .debug_abbrev = .{ .section = Section.init },
1975 .debug_aranges = .{ .section = Section.init },2101 .debug_aranges = .{ .section = Section.init },
...@@ -2142,6 +2268,7 @@ pub fn deinit(dwarf: *Dwarf) void {...@@ -2142,6 +2268,7 @@ pub fn deinit(dwarf: *Dwarf) void {
2142 dwarf.types.deinit(gpa);2268 dwarf.types.deinit(gpa);
2143 dwarf.values.deinit(gpa);2269 dwarf.values.deinit(gpa);
2144 dwarf.navs.deinit(gpa);2270 dwarf.navs.deinit(gpa);
2271 dwarf.decls.deinit(gpa);
2145 dwarf.debug_abbrev.section.deinit(gpa);2272 dwarf.debug_abbrev.section.deinit(gpa);
2146 dwarf.debug_aranges.section.deinit(gpa);2273 dwarf.debug_aranges.section.deinit(gpa);
2147 dwarf.debug_frame.section.deinit(gpa);2274 dwarf.debug_frame.section.deinit(gpa);
...@@ -2161,8 +2288,8 @@ fn getUnit(dwarf: *Dwarf, mod: *Module) UpdateError!Unit.Index {...@@ -2161,8 +2288,8 @@ fn getUnit(dwarf: *Dwarf, mod: *Module) UpdateError!Unit.Index {
2161 errdefer _ = dwarf.mods.pop();2288 errdefer _ = dwarf.mods.pop();
2162 mod_gop.value_ptr.* = .{2289 mod_gop.value_ptr.* = .{
2163 .root_dir_path = undefined,2290 .root_dir_path = undefined,
2164 .dirs = .{},2291 .dirs = .empty,
2165 .files = .{},2292 .files = .empty,
2166 };2293 };
2167 errdefer mod_gop.value_ptr.dirs.deinit(dwarf.gpa);2294 errdefer mod_gop.value_ptr.dirs.deinit(dwarf.gpa);
2168 try mod_gop.value_ptr.dirs.putNoClobber(dwarf.gpa, unit, {});2295 try mod_gop.value_ptr.dirs.putNoClobber(dwarf.gpa, unit, {});
...@@ -2219,14 +2346,28 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In...@@ -2219,14 +2346,28 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
2219 const ip = &zcu.intern_pool;2346 const ip = &zcu.intern_pool;
22202347
2221 const nav = ip.getNav(nav_index);2348 const nav = ip.getNav(nav_index);
2222 log.debug("initWipNav({})", .{nav.fqn.fmt(ip)});
2223
2224 const inst_info = nav.srcInst(ip).resolveFull(ip).?;2349 const inst_info = nav.srcInst(ip).resolveFull(ip).?;
2225 const file = zcu.fileByIndex(inst_info.file);2350 const file = zcu.fileByIndex(inst_info.file);
2351 assert(file.zir_loaded);
2352 const decl = file.zir.getDeclaration(inst_info.inst);
2353 log.debug("initWipNav({s}:{d}:{d} %{d} = {})", .{
2354 file.sub_file_path,
2355 decl.src_line + 1,
2356 decl.src_column + 1,
2357 @intFromEnum(inst_info.inst),
2358 nav.fqn.fmt(ip),
2359 });
2360
2361 const nav_val = zcu.navValue(nav_index);
2362 const nav_key = ip.indexToKey(nav_val.toIntern());
2363 switch (nav_key) {
2364 .@"extern" => return null,
2365 else => {},
2366 }
22262367
2227 const unit = try dwarf.getUnit(file.mod);2368 const unit = try dwarf.getUnit(file.mod);
2228 const nav_gop = try dwarf.navs.getOrPut(dwarf.gpa, nav_index);2369 const nav_gop = try dwarf.navs.getOrPut(dwarf.gpa, nav_index);
2229 errdefer _ = dwarf.navs.pop();2370 errdefer _ = if (!nav_gop.found_existing) dwarf.navs.pop();
2230 if (nav_gop.found_existing) {2371 if (nav_gop.found_existing) {
2231 for ([_]*Section{2372 for ([_]*Section{
2232 &dwarf.debug_aranges.section,2373 &dwarf.debug_aranges.section,
...@@ -2236,7 +2377,6 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In...@@ -2236,7 +2377,6 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
2236 &dwarf.debug_rnglists.section,2377 &dwarf.debug_rnglists.section,
2237 }) |sec| sec.getUnit(unit).getEntry(nav_gop.value_ptr.*).clear();2378 }) |sec| sec.getUnit(unit).getEntry(nav_gop.value_ptr.*).clear();
2238 } else nav_gop.value_ptr.* = try dwarf.addCommonEntry(unit);2379 } else nav_gop.value_ptr.* = try dwarf.addCommonEntry(unit);
2239 const nav_val = zcu.navValue(nav_index);
2240 var wip_nav: WipNav = .{2380 var wip_nav: WipNav = .{
2241 .dwarf = dwarf,2381 .dwarf = dwarf,
2242 .pt = pt,2382 .pt = pt,
...@@ -2248,91 +2388,52 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In...@@ -2248,91 +2388,52 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
2248 .func_high_pc = undefined,2388 .func_high_pc = undefined,
2249 .blocks = undefined,2389 .blocks = undefined,
2250 .cfi = undefined,2390 .cfi = undefined,
2251 .debug_frame = .{},2391 .debug_frame = .empty,
2252 .debug_info = .{},2392 .debug_info = .empty,
2253 .debug_line = .{},2393 .debug_line = .empty,
2254 .debug_loclists = .{},2394 .debug_loclists = .empty,
2255 .pending_lazy = .{},2395 .pending_lazy = .empty,
2256 };2396 };
2257 errdefer wip_nav.deinit();2397 errdefer wip_nav.deinit();
22582398
2259 switch (ip.indexToKey(nav_val.toIntern())) {2399 switch (nav_key) {
2260 else => {2400 else => {
2261 assert(file.zir_loaded);
2262 const decl = file.zir.getDeclaration(inst_info.inst);
2263
2264 const parent_type, const accessibility: u8 = if (nav.analysis) |a| parent: {
2265 const parent_namespace_ptr = ip.namespacePtr(a.namespace);
2266 break :parent .{
2267 parent_namespace_ptr.owner_type,
2268 if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private,
2269 };
2270 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
2271
2272 const diw = wip_nav.debug_info.writer(dwarf.gpa);2401 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2273 try wip_nav.abbrevCode(.decl_var);2402 try wip_nav.declCommon(.{
2274 try wip_nav.refType(.fromInterned(parent_type));2403 .decl = .decl_var,
2275 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));2404 .generic_decl = .generic_decl_var,
2276 try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian);2405 .instance = .instance_var,
2277 try uleb128(diw, decl.src_column + 1);2406 }, &nav, inst_info.file, &decl);
2278 try diw.writeByte(accessibility);
2279 try wip_nav.strp(nav.name.toSlice(ip));
2280 try wip_nav.strp(nav.fqn.toSlice(ip));2407 try wip_nav.strp(nav.fqn.toSlice(ip));
2281 const nav_ty = nav_val.typeOf(zcu);2408 const ty: Type = nav_val.typeOf(zcu);
2282 const nav_ty_reloc_index = try wip_nav.refForward();
2283 try wip_nav.infoExprloc(.{ .addr = .{ .sym = sym_index } });
2284 try uleb128(diw, nav.status.fully_resolved.alignment.toByteUnits() orelse
2285 nav_ty.abiAlignment(zcu).toByteUnits().?);
2286 try diw.writeByte(@intFromBool(false));
2287 wip_nav.finishForward(nav_ty_reloc_index);
2288 try wip_nav.abbrevCode(.is_const);
2289 try wip_nav.refType(nav_ty);
2290 },
2291 .variable => |variable| {
2292 assert(file.zir_loaded);
2293 const decl = file.zir.getDeclaration(inst_info.inst);
2294
2295 const parent_type, const accessibility: u8 = if (nav.analysis) |a| parent: {
2296 const parent_namespace_ptr = ip.namespacePtr(a.namespace);
2297 break :parent .{
2298 parent_namespace_ptr.owner_type,
2299 if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private,
2300 };
2301 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
2302
2303 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2304 try wip_nav.abbrevCode(.decl_var);
2305 try wip_nav.refType(.fromInterned(parent_type));
2306 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));
2307 try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian);
2308 try uleb128(diw, decl.src_column + 1);
2309 try diw.writeByte(accessibility);
2310 try wip_nav.strp(nav.name.toSlice(ip));
2311 try wip_nav.strp(nav.fqn.toSlice(ip));
2312 const ty: Type = .fromInterned(variable.ty);
2313 try wip_nav.refType(ty);
2314 const addr: Loc = .{ .addr = .{ .sym = sym_index } };2409 const addr: Loc = .{ .addr = .{ .sym = sym_index } };
2315 try wip_nav.infoExprloc(if (variable.is_threadlocal) .{ .form_tls_address = &addr } else addr);2410 const loc: Loc = if (decl.is_threadlocal) .{ .form_tls_address = &addr } else addr;
2316 try uleb128(diw, nav.status.fully_resolved.alignment.toByteUnits() orelse2411 switch (decl.kind) {
2317 ty.abiAlignment(zcu).toByteUnits().?);2412 .unnamed_test, .@"test", .decltest, .@"comptime", .@"usingnamespace" => unreachable,
2318 try diw.writeByte(@intFromBool(false));2413 .@"const" => {
2414 const const_ty_reloc_index = try wip_nav.refForward();
2415 try wip_nav.infoExprloc(loc);
2416 try uleb128(diw, nav.status.fully_resolved.alignment.toByteUnits() orelse
2417 ty.abiAlignment(zcu).toByteUnits().?);
2418 try diw.writeByte(@intFromBool(decl.linkage != .normal));
2419 wip_nav.finishForward(const_ty_reloc_index);
2420 try wip_nav.abbrevCode(.is_const);
2421 try wip_nav.refType(ty);
2422 },
2423 .@"var" => {
2424 try wip_nav.refType(ty);
2425 try wip_nav.infoExprloc(loc);
2426 try uleb128(diw, nav.status.fully_resolved.alignment.toByteUnits() orelse
2427 ty.abiAlignment(zcu).toByteUnits().?);
2428 try diw.writeByte(@intFromBool(decl.linkage != .normal));
2429 },
2430 }
2319 },2431 },
2320 .func => |func| {2432 .func => |func| {
2321 assert(file.zir_loaded);
2322 const decl = file.zir.getDeclaration(inst_info.inst);
2323
2324 const parent_type, const accessibility: u8 = if (nav.analysis) |a| parent: {
2325 const parent_namespace_ptr = ip.namespacePtr(a.namespace);
2326 break :parent .{
2327 parent_namespace_ptr.owner_type,
2328 if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private,
2329 };
2330 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
2331
2332 const func_type = ip.indexToKey(func.ty).func_type;2433 const func_type = ip.indexToKey(func.ty).func_type;
2333 wip_nav.func = nav_val.toIntern();2434 wip_nav.func = nav_val.toIntern();
2334 wip_nav.func_sym_index = sym_index;2435 wip_nav.func_sym_index = sym_index;
2335 wip_nav.blocks = .{};2436 wip_nav.blocks = .empty;
2336 if (dwarf.debug_frame.header.format != .none) wip_nav.cfi = .{2437 if (dwarf.debug_frame.header.format != .none) wip_nav.cfi = .{
2337 .loc = 0,2438 .loc = 0,
2338 .cfa = dwarf.debug_frame.header.initial_instructions[0].def_cfa,2439 .cfa = dwarf.debug_frame.header.initial_instructions[0].def_cfa,
...@@ -2375,13 +2476,11 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In...@@ -2375,13 +2476,11 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
2375 }2476 }
23762477
2377 const diw = wip_nav.debug_info.writer(dwarf.gpa);2478 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2378 try wip_nav.abbrevCode(.decl_func);2479 try wip_nav.declCommon(.{
2379 try wip_nav.refType(.fromInterned(parent_type));2480 .decl = .decl_func,
2380 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));2481 .generic_decl = .generic_decl_func,
2381 try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian);2482 .instance = .instance_func,
2382 try uleb128(diw, decl.src_column + 1);2483 }, &nav, inst_info.file, &decl);
2383 try diw.writeByte(accessibility);
2384 try wip_nav.strp(nav.name.toSlice(ip));
2385 try wip_nav.strp(nav.fqn.toSlice(ip));2484 try wip_nav.strp(nav.fqn.toSlice(ip));
2386 try wip_nav.refType(.fromInterned(func_type.return_type));2485 try wip_nav.refType(.fromInterned(func_type.return_type));
2387 try wip_nav.infoAddrSym(sym_index, 0);2486 try wip_nav.infoAddrSym(sym_index, 0);
...@@ -2392,7 +2491,7 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In...@@ -2392,7 +2491,7 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
2392 .none => target_info.defaultFunctionAlignment(target),2491 .none => target_info.defaultFunctionAlignment(target),
2393 else => |a| a.maxStrict(target_info.minFunctionAlignment(target)),2492 else => |a| a.maxStrict(target_info.minFunctionAlignment(target)),
2394 }.toByteUnits().?);2493 }.toByteUnits().?);
2395 try diw.writeByte(@intFromBool(false));2494 try diw.writeByte(@intFromBool(decl.linkage != .normal));
2396 try diw.writeByte(@intFromBool(func_type.return_type == .noreturn_type));2495 try diw.writeByte(@intFromBool(func_type.return_type == .noreturn_type));
23972496
2398 const dlw = wip_nav.debug_line.writer(dwarf.gpa);2497 const dlw = wip_nav.debug_line.writer(dwarf.gpa);
...@@ -2435,97 +2534,110 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In...@@ -2435,97 +2534,110 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
2435 return wip_nav;2534 return wip_nav;
2436}2535}
24372536
2438pub fn finishWipNav(2537pub fn finishWipNavFunc(
2439 dwarf: *Dwarf,2538 dwarf: *Dwarf,
2440 pt: Zcu.PerThread,2539 pt: Zcu.PerThread,
2441 nav_index: InternPool.Nav.Index,2540 nav_index: InternPool.Nav.Index,
2442 sym: struct { index: u32, addr: u64, size: u64 },2541 code_size: u64,
2443 wip_nav: *WipNav,2542 wip_nav: *WipNav,
2444) UpdateError!void {2543) UpdateError!void {
2445 const zcu = pt.zcu;2544 const zcu = pt.zcu;
2446 const ip = &zcu.intern_pool;2545 const ip = &zcu.intern_pool;
2447 const nav = ip.getNav(nav_index);2546 const nav = ip.getNav(nav_index);
2448 log.debug("finishWipNav({})", .{nav.fqn.fmt(ip)});2547 assert(wip_nav.func != .none);
2548 log.debug("finishWipNavFunc({})", .{nav.fqn.fmt(ip)});
24492549
2450 if (wip_nav.func != .none) {2550 {
2451 {2551 const external_relocs = &dwarf.debug_aranges.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs;
2452 const external_relocs = &dwarf.debug_aranges.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs;2552 try external_relocs.append(dwarf.gpa, .{ .target_sym = wip_nav.func_sym_index });
2453 try external_relocs.append(dwarf.gpa, .{ .target_sym = sym.index });2553 var entry: [8 + 8]u8 = undefined;
2454 var entry: [8 + 8]u8 = undefined;2554 @memset(entry[0..@intFromEnum(dwarf.address_size)], 0);
2455 @memset(entry[0..@intFromEnum(dwarf.address_size)], 0);2555 dwarf.writeInt(entry[@intFromEnum(dwarf.address_size)..][0..@intFromEnum(dwarf.address_size)], code_size);
2456 dwarf.writeInt(entry[@intFromEnum(dwarf.address_size)..][0..@intFromEnum(dwarf.address_size)], sym.size);2556 try dwarf.debug_aranges.section.replaceEntry(
2457 try dwarf.debug_aranges.section.replaceEntry(2557 wip_nav.unit,
2458 wip_nav.unit,2558 wip_nav.entry,
2459 wip_nav.entry,2559 dwarf,
2460 dwarf,2560 entry[0 .. @intFromEnum(dwarf.address_size) * 2],
2461 entry[0 .. @intFromEnum(dwarf.address_size) * 2],2561 );
2462 );2562 }
2463 }2563 switch (dwarf.debug_frame.header.format) {
2464 switch (dwarf.debug_frame.header.format) {2564 .none => {},
2465 .none => {},2565 .debug_frame, .eh_frame => |format| {
2466 .debug_frame, .eh_frame => |format| {2566 try wip_nav.debug_frame.appendNTimes(
2467 try wip_nav.debug_frame.appendNTimes(2567 dwarf.gpa,
2468 dwarf.gpa,2568 DW.CFA.nop,
2469 DW.CFA.nop,2569 @intCast(dwarf.debug_frame.section.alignment.forward(wip_nav.debug_frame.items.len) - wip_nav.debug_frame.items.len),
2470 @intCast(dwarf.debug_frame.section.alignment.forward(wip_nav.debug_frame.items.len) - wip_nav.debug_frame.items.len),
2471 );
2472 const contents = wip_nav.debug_frame.items;
2473 try dwarf.debug_frame.section.resizeEntry(wip_nav.unit, wip_nav.entry, dwarf, @intCast(contents.len));
2474 const unit = dwarf.debug_frame.section.getUnit(wip_nav.unit);
2475 const entry = unit.getEntry(wip_nav.entry);
2476 const unit_len = (if (entry.next.unwrap()) |next_entry|
2477 unit.getEntry(next_entry).off - entry.off
2478 else
2479 entry.len) - dwarf.unitLengthBytes();
2480 dwarf.writeInt(contents[dwarf.unitLengthBytes() - dwarf.sectionOffsetBytes() ..][0..dwarf.sectionOffsetBytes()], unit_len);
2481 switch (format) {
2482 .none => unreachable,
2483 .debug_frame => dwarf.writeInt(contents[dwarf.unitLengthBytes() + dwarf.sectionOffsetBytes() +
2484 @intFromEnum(dwarf.address_size) ..][0..@intFromEnum(dwarf.address_size)], sym.size),
2485 .eh_frame => {
2486 std.mem.writeInt(
2487 u32,
2488 contents[dwarf.unitLengthBytes()..][0..4],
2489 unit.header_len + entry.off + dwarf.unitLengthBytes(),
2490 dwarf.endian,
2491 );
2492 std.mem.writeInt(u32, contents[dwarf.unitLengthBytes() + 4 + 4 ..][0..4], @intCast(sym.size), dwarf.endian);
2493 },
2494 }
2495 try entry.replace(unit, &dwarf.debug_frame.section, dwarf, contents);
2496 },
2497 }
2498 {
2499 std.mem.writeInt(u32, wip_nav.debug_info.items[wip_nav.func_high_pc..][0..4], @intCast(sym.size), dwarf.endian);
2500 if (wip_nav.any_children) {
2501 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2502 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2503 } else std.leb.writeUnsignedFixed(
2504 AbbrevCode.decl_bytes,
2505 wip_nav.debug_info.items[0..AbbrevCode.decl_bytes],
2506 try dwarf.refAbbrevCode(.decl_empty_func),
2507 );2570 );
2508 }2571 const contents = wip_nav.debug_frame.items;
2509 {2572 try dwarf.debug_frame.section.resizeEntry(wip_nav.unit, wip_nav.entry, dwarf, @intCast(contents.len));
2510 try dwarf.debug_rnglists.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs.appendSlice(dwarf.gpa, &.{2573 const unit = dwarf.debug_frame.section.getUnit(wip_nav.unit);
2511 .{2574 const entry = unit.getEntry(wip_nav.entry);
2512 .source_off = 1,2575 const unit_len = (if (entry.next.unwrap()) |next_entry|
2513 .target_sym = sym.index,2576 unit.getEntry(next_entry).off - entry.off
2514 },2577 else
2515 .{2578 entry.len) - dwarf.unitLengthBytes();
2516 .source_off = 1 + @intFromEnum(dwarf.address_size),2579 dwarf.writeInt(contents[dwarf.unitLengthBytes() - dwarf.sectionOffsetBytes() ..][0..dwarf.sectionOffsetBytes()], unit_len);
2517 .target_sym = sym.index,2580 switch (format) {
2518 .target_off = sym.size,2581 .none => unreachable,
2582 .debug_frame => dwarf.writeInt(contents[dwarf.unitLengthBytes() + dwarf.sectionOffsetBytes() +
2583 @intFromEnum(dwarf.address_size) ..][0..@intFromEnum(dwarf.address_size)], code_size),
2584 .eh_frame => {
2585 std.mem.writeInt(
2586 u32,
2587 contents[dwarf.unitLengthBytes()..][0..4],
2588 unit.header_len + entry.off + dwarf.unitLengthBytes(),
2589 dwarf.endian,
2590 );
2591 std.mem.writeInt(u32, contents[dwarf.unitLengthBytes() + 4 + 4 ..][0..4], @intCast(code_size), dwarf.endian);
2519 },2592 },
2520 });2593 }
2521 try dwarf.debug_rnglists.section.replaceEntry(2594 try entry.replace(unit, &dwarf.debug_frame.section, dwarf, contents);
2522 wip_nav.unit,2595 },
2523 wip_nav.entry,
2524 dwarf,
2525 ([1]u8{DW.RLE.start_end} ++ [1]u8{0} ** (8 + 8))[0 .. 1 + @intFromEnum(dwarf.address_size) + @intFromEnum(dwarf.address_size)],
2526 );
2527 }
2528 }2596 }
2597 {
2598 std.mem.writeInt(u32, wip_nav.debug_info.items[wip_nav.func_high_pc..][0..4], @intCast(code_size), dwarf.endian);
2599 if (wip_nav.any_children) {
2600 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2601 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2602 } else std.leb.writeUnsignedFixed(
2603 AbbrevCode.decl_bytes,
2604 wip_nav.debug_info.items[0..AbbrevCode.decl_bytes],
2605 try dwarf.refAbbrevCode(.decl_empty_func),
2606 );
2607 }
2608 {
2609 try dwarf.debug_rnglists.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs.appendSlice(dwarf.gpa, &.{
2610 .{
2611 .source_off = 1,
2612 .target_sym = wip_nav.func_sym_index,
2613 },
2614 .{
2615 .source_off = 1 + @intFromEnum(dwarf.address_size),
2616 .target_sym = wip_nav.func_sym_index,
2617 .target_off = code_size,
2618 },
2619 });
2620 try dwarf.debug_rnglists.section.replaceEntry(
2621 wip_nav.unit,
2622 wip_nav.entry,
2623 dwarf,
2624 ([1]u8{DW.RLE.start_end} ++ [1]u8{0} ** (8 + 8))[0 .. 1 + @intFromEnum(dwarf.address_size) + @intFromEnum(dwarf.address_size)],
2625 );
2626 }
2627
2628 try dwarf.finishWipNav(pt, nav_index, wip_nav);
2629}
2630
2631pub fn finishWipNav(
2632 dwarf: *Dwarf,
2633 pt: Zcu.PerThread,
2634 nav_index: InternPool.Nav.Index,
2635 wip_nav: *WipNav,
2636) UpdateError!void {
2637 const zcu = pt.zcu;
2638 const ip = &zcu.intern_pool;
2639 const nav = ip.getNav(nav_index);
2640 log.debug("finishWipNav({})", .{nav.fqn.fmt(ip)});
25292641
2530 try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items);2642 try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items);
2531 if (wip_nav.debug_line.items.len > 0) {2643 if (wip_nav.debug_line.items.len > 0) {
...@@ -2547,12 +2659,17 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2547,12 +2659,17 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2547 const nav_val = zcu.navValue(nav_index);2659 const nav_val = zcu.navValue(nav_index);
25482660
2549 const nav = ip.getNav(nav_index);2661 const nav = ip.getNav(nav_index);
2550 log.debug("updateComptimeNav({})", .{nav.fqn.fmt(ip)});
2551
2552 const inst_info = nav.srcInst(ip).resolveFull(ip).?;2662 const inst_info = nav.srcInst(ip).resolveFull(ip).?;
2553 const file = zcu.fileByIndex(inst_info.file);2663 const file = zcu.fileByIndex(inst_info.file);
2554 assert(file.zir_loaded);2664 assert(file.zir_loaded);
2555 const decl = file.zir.getDeclaration(inst_info.inst);2665 const decl = file.zir.getDeclaration(inst_info.inst);
2666 log.debug("updateComptimeNav({s}:{d}:{d} %{d} = {})", .{
2667 file.sub_file_path,
2668 decl.src_line + 1,
2669 decl.src_column + 1,
2670 @intFromEnum(inst_info.inst),
2671 nav.fqn.fmt(ip),
2672 });
25562673
2557 const is_test = switch (decl.kind) {2674 const is_test = switch (decl.kind) {
2558 .unnamed_test, .@"test", .decltest => true,2675 .unnamed_test, .@"test", .decltest => true,
...@@ -2563,14 +2680,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2563,14 +2680,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2563 return;2680 return;
2564 }2681 }
25652682
2566 const parent_type, const accessibility: u8 = if (nav.analysis) |a| parent: {
2567 const parent_namespace_ptr = ip.namespacePtr(a.namespace);
2568 break :parent .{
2569 parent_namespace_ptr.owner_type,
2570 if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private,
2571 };
2572 } else .{ zcu.fileRootType(inst_info.file), DW.ACCESS.private };
2573
2574 var wip_nav: WipNav = .{2683 var wip_nav: WipNav = .{
2575 .dwarf = dwarf,2684 .dwarf = dwarf,
2576 .pt = pt,2685 .pt = pt,
...@@ -2582,16 +2691,16 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2582,16 +2691,16 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2582 .func_high_pc = undefined,2691 .func_high_pc = undefined,
2583 .blocks = undefined,2692 .blocks = undefined,
2584 .cfi = undefined,2693 .cfi = undefined,
2585 .debug_frame = .{},2694 .debug_frame = .empty,
2586 .debug_info = .{},2695 .debug_info = .empty,
2587 .debug_line = .{},2696 .debug_line = .empty,
2588 .debug_loclists = .{},2697 .debug_loclists = .empty,
2589 .pending_lazy = .{},2698 .pending_lazy = .empty,
2590 };2699 };
2591 defer wip_nav.deinit();2700 defer wip_nav.deinit();
25922701
2593 const nav_gop = try dwarf.navs.getOrPut(dwarf.gpa, nav_index);2702 const nav_gop = try dwarf.navs.getOrPut(dwarf.gpa, nav_index);
2594 errdefer _ = dwarf.navs.pop();2703 errdefer _ = if (!nav_gop.found_existing) dwarf.navs.pop();
25952704
2596 const tag: enum { done, decl_alias, decl_var, decl_const } = switch (ip.indexToKey(nav_val.toIntern())) {2705 const tag: enum { done, decl_alias, decl_var, decl_const } = switch (ip.indexToKey(nav_val.toIntern())) {
2597 .int_type,2706 .int_type,
...@@ -2609,9 +2718,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2609,9 +2718,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2609 => .decl_alias,2718 => .decl_alias,
2610 .struct_type => tag: {2719 .struct_type => tag: {
2611 const loaded_struct = ip.loadStructType(nav_val.toIntern());2720 const loaded_struct = ip.loadStructType(nav_val.toIntern());
26122721 if (loaded_struct.zir_index.resolveFile(ip) != inst_info.file) break :tag .decl_alias;
2613 const type_inst_info = loaded_struct.zir_index.resolveFull(ip).?;
2614 if (type_inst_info.file != inst_info.file) break :tag .decl_alias;
26152722
2616 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());2723 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
2617 if (type_gop.found_existing) {2724 if (type_gop.found_existing) {
...@@ -2630,13 +2737,15 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2630,13 +2737,15 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
26302737
2631 switch (loaded_struct.layout) {2738 switch (loaded_struct.layout) {
2632 .auto, .@"extern" => {2739 .auto, .@"extern" => {
2633 try wip_nav.abbrevCode(if (loaded_struct.field_types.len == 0) .decl_namespace_struct else .decl_struct);2740 try wip_nav.declCommon(if (loaded_struct.field_types.len == 0) .{
2634 try wip_nav.refType(.fromInterned(parent_type));2741 .decl = .decl_namespace_struct,
2635 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));2742 .generic_decl = .generic_decl_struct,
2636 try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian);2743 .instance = .instance_namespace_struct,
2637 try uleb128(diw, decl.src_column + 1);2744 } else .{
2638 try diw.writeByte(accessibility);2745 .decl = .decl_struct,
2639 try wip_nav.strp(nav.name.toSlice(ip));2746 .generic_decl = .generic_decl_struct,
2747 .instance = .instance_struct,
2748 }, &nav, inst_info.file, &decl);
2640 if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else {2749 if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else {
2641 try uleb128(diw, nav_val.toType().abiSize(zcu));2750 try uleb128(diw, nav_val.toType().abiSize(zcu));
2642 try uleb128(diw, nav_val.toType().abiAlignment(zcu).toByteUnits().?);2751 try uleb128(diw, nav_val.toType().abiAlignment(zcu).toByteUnits().?);
...@@ -2688,13 +2797,11 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2688,13 +2797,11 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2688 }2797 }
2689 },2798 },
2690 .@"packed" => {2799 .@"packed" => {
2691 try wip_nav.abbrevCode(.decl_packed_struct);2800 try wip_nav.declCommon(.{
2692 try wip_nav.refType(.fromInterned(parent_type));2801 .decl = .decl_packed_struct,
2693 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));2802 .generic_decl = .generic_decl_struct,
2694 try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian);2803 .instance = .instance_packed_struct,
2695 try uleb128(diw, decl.src_column + 1);2804 }, &nav, inst_info.file, &decl);
2696 try diw.writeByte(accessibility);
2697 try wip_nav.strp(nav.name.toSlice(ip));
2698 try wip_nav.refType(.fromInterned(loaded_struct.backingIntTypeUnordered(ip)));2805 try wip_nav.refType(.fromInterned(loaded_struct.backingIntTypeUnordered(ip)));
2699 var field_bit_offset: u16 = 0;2806 var field_bit_offset: u16 = 0;
2700 for (0..loaded_struct.field_types.len) |field_index| {2807 for (0..loaded_struct.field_types.len) |field_index| {
...@@ -2712,10 +2819,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2712,10 +2819,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2712 },2819 },
2713 .enum_type => tag: {2820 .enum_type => tag: {
2714 const loaded_enum = ip.loadEnumType(nav_val.toIntern());2821 const loaded_enum = ip.loadEnumType(nav_val.toIntern());
2715 if (loaded_enum.zir_index == .none) break :tag .decl_alias;2822 const type_zir_index = loaded_enum.zir_index.unwrap() orelse break :tag .decl_alias;
27162823 if (type_zir_index.resolveFile(ip) != inst_info.file) break :tag .decl_alias;
2717 const type_inst_info = loaded_enum.zir_index.unwrap().?.resolveFull(ip).?;
2718 if (type_inst_info.file != inst_info.file) break :tag .decl_alias;
27192824
2720 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());2825 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
2721 if (type_gop.found_existing) {2826 if (type_gop.found_existing) {
...@@ -2730,13 +2835,15 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2730,13 +2835,15 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2730 }2835 }
2731 wip_nav.entry = nav_gop.value_ptr.*;2836 wip_nav.entry = nav_gop.value_ptr.*;
2732 const diw = wip_nav.debug_info.writer(dwarf.gpa);2837 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2733 try wip_nav.abbrevCode(if (loaded_enum.names.len > 0) .decl_enum else .decl_empty_enum);2838 try wip_nav.declCommon(if (loaded_enum.names.len > 0) .{
2734 try wip_nav.refType(.fromInterned(parent_type));2839 .decl = .decl_enum,
2735 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));2840 .generic_decl = .generic_decl_enum,
2736 try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian);2841 .instance = .instance_enum,
2737 try uleb128(diw, decl.src_column + 1);2842 } else .{
2738 try diw.writeByte(accessibility);2843 .decl = .decl_empty_enum,
2739 try wip_nav.strp(nav.name.toSlice(ip));2844 .generic_decl = .generic_decl_enum,
2845 .instance = .instance_empty_enum,
2846 }, &nav, inst_info.file, &decl);
2740 try wip_nav.refType(.fromInterned(loaded_enum.tag_ty));2847 try wip_nav.refType(.fromInterned(loaded_enum.tag_ty));
2741 for (0..loaded_enum.names.len) |field_index| {2848 for (0..loaded_enum.names.len) |field_index| {
2742 try wip_nav.enumConstValue(loaded_enum, .{2849 try wip_nav.enumConstValue(loaded_enum, .{
...@@ -2751,9 +2858,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2751,9 +2858,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2751 },2858 },
2752 .union_type => tag: {2859 .union_type => tag: {
2753 const loaded_union = ip.loadUnionType(nav_val.toIntern());2860 const loaded_union = ip.loadUnionType(nav_val.toIntern());
27542861 if (loaded_union.zir_index.resolveFile(ip) != inst_info.file) break :tag .decl_alias;
2755 const type_inst_info = loaded_union.zir_index.resolveFull(ip).?;
2756 if (type_inst_info.file != inst_info.file) break :tag .decl_alias;
27572862
2758 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());2863 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
2759 if (type_gop.found_existing) {2864 if (type_gop.found_existing) {
...@@ -2768,13 +2873,11 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2768,13 +2873,11 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2768 }2873 }
2769 wip_nav.entry = nav_gop.value_ptr.*;2874 wip_nav.entry = nav_gop.value_ptr.*;
2770 const diw = wip_nav.debug_info.writer(dwarf.gpa);2875 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2771 try wip_nav.abbrevCode(.decl_union);2876 try wip_nav.declCommon(.{
2772 try wip_nav.refType(.fromInterned(parent_type));2877 .decl = .decl_union,
2773 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));2878 .generic_decl = .generic_decl_union,
2774 try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian);2879 .instance = .instance_union,
2775 try uleb128(diw, decl.src_column + 1);2880 }, &nav, inst_info.file, &decl);
2776 try diw.writeByte(accessibility);
2777 try wip_nav.strp(nav.name.toSlice(ip));
2778 const union_layout = Type.getUnionLayout(loaded_union, zcu);2881 const union_layout = Type.getUnionLayout(loaded_union, zcu);
2779 try uleb128(diw, union_layout.abi_size);2882 try uleb128(diw, union_layout.abi_size);
2780 try uleb128(diw, union_layout.abi_align.toByteUnits().?);2883 try uleb128(diw, union_layout.abi_align.toByteUnits().?);
...@@ -2825,9 +2928,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2825,9 +2928,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2825 },2928 },
2826 .opaque_type => tag: {2929 .opaque_type => tag: {
2827 const loaded_opaque = ip.loadOpaqueType(nav_val.toIntern());2930 const loaded_opaque = ip.loadOpaqueType(nav_val.toIntern());
28282931 if (loaded_opaque.zir_index.resolveFile(ip) != inst_info.file) break :tag .decl_alias;
2829 const type_inst_info = loaded_opaque.zir_index.resolveFull(ip).?;
2830 if (type_inst_info.file != inst_info.file) break :tag .decl_alias;
28312932
2832 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());2933 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern());
2833 if (type_gop.found_existing) {2934 if (type_gop.found_existing) {
...@@ -2842,19 +2943,16 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2842,19 +2943,16 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2842 }2943 }
2843 wip_nav.entry = nav_gop.value_ptr.*;2944 wip_nav.entry = nav_gop.value_ptr.*;
2844 const diw = wip_nav.debug_info.writer(dwarf.gpa);2945 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2845 try wip_nav.abbrevCode(.decl_namespace_struct);2946 try wip_nav.declCommon(.{
2846 try wip_nav.refType(.fromInterned(parent_type));2947 .decl = .decl_namespace_struct,
2847 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));2948 .generic_decl = .generic_decl_struct,
2848 try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian);2949 .instance = .instance_namespace_struct,
2849 try uleb128(diw, decl.src_column + 1);2950 }, &nav, inst_info.file, &decl);
2850 try diw.writeByte(accessibility);2951 try diw.writeByte(@intFromBool(true));
2851 try wip_nav.strp(nav.name.toSlice(ip));
2852 try diw.writeByte(@intFromBool(false));
2853 break :tag .done;2952 break :tag .done;
2854 },2953 },
2855 .undef,2954 .undef,
2856 .simple_value,2955 .simple_value,
2857 .@"extern",
2858 .int,2956 .int,
2859 .err,2957 .err,
2860 .error_union,2958 .error_union,
...@@ -2869,42 +2967,31 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2869,42 +2967,31 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2869 .un,2967 .un,
2870 => .decl_const,2968 => .decl_const,
2871 .variable => .decl_var,2969 .variable => .decl_var,
2970 .@"extern" => unreachable,
2872 .func => |func| tag: {2971 .func => |func| tag: {
2873 if (nav_gop.found_existing) {2972 if (nav_gop.found_existing) switch (try dwarf.debug_info.declAbbrevCode(wip_nav.unit, nav_gop.value_ptr.*)) {
2874 const unit_ptr = dwarf.debug_info.section.getUnit(wip_nav.unit);2973 .null => {},
2875 const entry_ptr = unit_ptr.getEntry(nav_gop.value_ptr.*);2974 else => unreachable,
2876 if (entry_ptr.len >= AbbrevCode.decl_bytes) {2975 .decl_func, .decl_empty_func, .instance_func, .instance_empty_func => return,
2877 var abbrev_code_buf: [AbbrevCode.decl_bytes]u8 = undefined;2976 .decl_func_generic,
2878 if (try dwarf.getFile().?.preadAll(2977 .decl_empty_func_generic,
2879 &abbrev_code_buf,2978 .instance_func_generic,
2880 dwarf.debug_info.section.off(dwarf) + unit_ptr.off + unit_ptr.header_len + entry_ptr.off,2979 .instance_empty_func_generic,
2881 ) != abbrev_code_buf.len) return error.InputOutput;2980 => dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear(),
2882 var abbrev_code_fbs = std.io.fixedBufferStream(&abbrev_code_buf);
2883 const abbrev_code: AbbrevCode = @enumFromInt(
2884 std.leb.readUleb128(@typeInfo(AbbrevCode).@"enum".tag_type, abbrev_code_fbs.reader()) catch unreachable,
2885 );
2886 switch (abbrev_code) {
2887 else => unreachable,
2888 .decl_func, .decl_empty_func => return,
2889 .decl_func_generic, .decl_empty_func_generic => {},
2890 }
2891 }
2892 entry_ptr.clear();
2893 } else nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);2981 } else nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit);
2894 wip_nav.entry = nav_gop.value_ptr.*;2982 wip_nav.entry = nav_gop.value_ptr.*;
28952983
2896 const func_type = ip.indexToKey(func.ty).func_type;2984 const func_type = ip.indexToKey(func.ty).func_type;
2897 const diw = wip_nav.debug_info.writer(dwarf.gpa);2985 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2898 try wip_nav.abbrevCode(if (func_type.param_types.len > 0 or func_type.is_var_args)2986 try wip_nav.declCommon(if (func_type.param_types.len > 0 or func_type.is_var_args) .{
2899 .decl_func_generic2987 .decl = .decl_func_generic,
2900 else2988 .generic_decl = .generic_decl_func,
2901 .decl_empty_func_generic);2989 .instance = .instance_func_generic,
2902 try wip_nav.refType(.fromInterned(parent_type));2990 } else .{
2903 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));2991 .decl = .decl_empty_func_generic,
2904 try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian);2992 .generic_decl = .generic_decl_func,
2905 try uleb128(diw, decl.src_column + 1);2993 .instance = .instance_empty_func_generic,
2906 try diw.writeByte(accessibility);2994 }, &nav, inst_info.file, &decl);
2907 try wip_nav.strp(nav.name.toSlice(ip));
2908 try wip_nav.refType(.fromInterned(func_type.return_type));2995 try wip_nav.refType(.fromInterned(func_type.return_type));
2909 if (func_type.param_types.len > 0 or func_type.is_var_args) {2996 if (func_type.param_types.len > 0 or func_type.is_var_args) {
2910 for (0..func_type.param_types.len) |param_index| {2997 for (0..func_type.param_types.len) |param_index| {
...@@ -2929,57 +3016,55 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2929,57 +3016,55 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2929 switch (tag) {3016 switch (tag) {
2930 .done => {},3017 .done => {},
2931 .decl_alias => {3018 .decl_alias => {
2932 const diw = wip_nav.debug_info.writer(dwarf.gpa);3019 try wip_nav.declCommon(.{
2933 try wip_nav.abbrevCode(.decl_alias);3020 .decl = .decl_alias,
2934 try wip_nav.refType(.fromInterned(parent_type));3021 .generic_decl = .generic_decl_alias,
2935 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));3022 .instance = .instance_alias,
2936 try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian);3023 }, &nav, inst_info.file, &decl);
2937 try uleb128(diw, decl.src_column + 1);
2938 try diw.writeByte(accessibility);
2939 try wip_nav.strp(nav.name.toSlice(ip));
2940 try wip_nav.refType(nav_val.toType());3024 try wip_nav.refType(nav_val.toType());
2941 },3025 },
2942 .decl_var => {3026 .decl_var => {
2943 const diw = wip_nav.debug_info.writer(dwarf.gpa);3027 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2944 try wip_nav.abbrevCode(.decl_var);3028 try wip_nav.declCommon(.{
2945 try wip_nav.refType(.fromInterned(parent_type));3029 .decl = .decl_var,
2946 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));3030 .generic_decl = .generic_decl_var,
2947 try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian);3031 .instance = .instance_var,
2948 try uleb128(diw, decl.src_column + 1);3032 }, &nav, inst_info.file, &decl);
2949 try diw.writeByte(accessibility);
2950 try wip_nav.strp(nav.name.toSlice(ip));
2951 try wip_nav.strp(nav.fqn.toSlice(ip));3033 try wip_nav.strp(nav.fqn.toSlice(ip));
2952 const nav_ty = nav_val.typeOf(zcu);3034 const nav_ty = nav_val.typeOf(zcu);
2953 try wip_nav.refType(nav_ty);3035 try wip_nav.refType(nav_ty);
2954 try wip_nav.blockValue(nav_src_loc, nav_val);3036 try wip_nav.blockValue(nav_src_loc, nav_val);
2955 try uleb128(diw, nav.status.fully_resolved.alignment.toByteUnits() orelse3037 try uleb128(diw, nav.status.fully_resolved.alignment.toByteUnits() orelse
2956 nav_ty.abiAlignment(zcu).toByteUnits().?);3038 nav_ty.abiAlignment(zcu).toByteUnits().?);
2957 try diw.writeByte(@intFromBool(false));3039 try diw.writeByte(@intFromBool(decl.linkage != .normal));
2958 },3040 },
2959 .decl_const => {3041 .decl_const => {
2960 const diw = wip_nav.debug_info.writer(dwarf.gpa);3042 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2961 const nav_ty = nav_val.typeOf(zcu);3043 const nav_ty = nav_val.typeOf(zcu);
2962 const has_runtime_bits = nav_ty.hasRuntimeBits(zcu);3044 const has_runtime_bits = nav_ty.hasRuntimeBits(zcu);
2963 const has_comptime_state = nav_ty.comptimeOnly(zcu) and try nav_ty.onePossibleValue(pt) == null;3045 const has_comptime_state = nav_ty.comptimeOnly(zcu) and try nav_ty.onePossibleValue(pt) == null;
2964 try wip_nav.abbrevCode(if (has_runtime_bits and has_comptime_state)3046 try wip_nav.declCommon(if (has_runtime_bits and has_comptime_state) .{
2965 .decl_const_runtime_bits_comptime_state3047 .decl = .decl_const_runtime_bits_comptime_state,
2966 else if (has_comptime_state)3048 .generic_decl = .generic_decl_const,
2967 .decl_const_comptime_state3049 .instance = .instance_const_runtime_bits_comptime_state,
2968 else if (has_runtime_bits)3050 } else if (has_comptime_state) .{
2969 .decl_const_runtime_bits3051 .decl = .decl_const_comptime_state,
2970 else3052 .generic_decl = .generic_decl_const,
2971 .decl_const);3053 .instance = .instance_const_comptime_state,
2972 try wip_nav.refType(.fromInterned(parent_type));3054 } else if (has_runtime_bits) .{
2973 assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf));3055 .decl = .decl_const_runtime_bits,
2974 try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian);3056 .generic_decl = .generic_decl_const,
2975 try uleb128(diw, decl.src_column + 1);3057 .instance = .instance_const_runtime_bits,
2976 try diw.writeByte(accessibility);3058 } else .{
2977 try wip_nav.strp(nav.name.toSlice(ip));3059 .decl = .decl_const,
3060 .generic_decl = .generic_decl_const,
3061 .instance = .instance_const,
3062 }, &nav, inst_info.file, &decl);
2978 try wip_nav.strp(nav.fqn.toSlice(ip));3063 try wip_nav.strp(nav.fqn.toSlice(ip));
2979 const nav_ty_reloc_index = try wip_nav.refForward();3064 const nav_ty_reloc_index = try wip_nav.refForward();
2980 try uleb128(diw, nav.status.fully_resolved.alignment.toByteUnits() orelse3065 try uleb128(diw, nav.status.fully_resolved.alignment.toByteUnits() orelse
2981 nav_ty.abiAlignment(zcu).toByteUnits().?);3066 nav_ty.abiAlignment(zcu).toByteUnits().?);
2982 try diw.writeByte(@intFromBool(false));3067 try diw.writeByte(@intFromBool(decl.linkage != .normal));
2983 if (has_runtime_bits) try wip_nav.blockValue(nav_src_loc, nav_val);3068 if (has_runtime_bits) try wip_nav.blockValue(nav_src_loc, nav_val);
2984 if (has_comptime_state) try wip_nav.refValue(nav_val);3069 if (has_comptime_state) try wip_nav.refValue(nav_val);
2985 wip_nav.finishForward(nav_ty_reloc_index);3070 wip_nav.finishForward(nav_ty_reloc_index);
...@@ -3017,15 +3102,15 @@ fn updateLazyType(...@@ -3017,15 +3102,15 @@ fn updateLazyType(
3017 .func_high_pc = undefined,3102 .func_high_pc = undefined,
3018 .blocks = undefined,3103 .blocks = undefined,
3019 .cfi = undefined,3104 .cfi = undefined,
3020 .debug_frame = .{},3105 .debug_frame = .empty,
3021 .debug_info = .{},3106 .debug_info = .empty,
3022 .debug_line = .{},3107 .debug_line = .empty,
3023 .debug_loclists = .{},3108 .debug_loclists = .empty,
3024 .pending_lazy = pending_lazy.*,3109 .pending_lazy = pending_lazy.*,
3025 };3110 };
3026 defer {3111 defer {
3027 pending_lazy.* = wip_nav.pending_lazy;3112 pending_lazy.* = wip_nav.pending_lazy;
3028 wip_nav.pending_lazy = .{};3113 wip_nav.pending_lazy = .empty;
3029 wip_nav.deinit();3114 wip_nav.deinit();
3030 }3115 }
3031 const diw = wip_nav.debug_info.writer(dwarf.gpa);3116 const diw = wip_nav.debug_info.writer(dwarf.gpa);
...@@ -3076,7 +3161,7 @@ fn updateLazyType(...@@ -3076,7 +3161,7 @@ fn updateLazyType(
3076 }3161 }
3077 },3162 },
3078 .Slice => {3163 .Slice => {
3079 try wip_nav.abbrevCode(.struct_type);3164 try wip_nav.abbrevCode(.generated_struct_type);
3080 try wip_nav.strp(name);3165 try wip_nav.strp(name);
3081 try uleb128(diw, ty.abiSize(zcu));3166 try uleb128(diw, ty.abiSize(zcu));
3082 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);3167 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
...@@ -3115,7 +3200,7 @@ fn updateLazyType(...@@ -3115,7 +3200,7 @@ fn updateLazyType(
3115 },3200 },
3116 .opt_type => |opt_child_type_index| {3201 .opt_type => |opt_child_type_index| {
3117 const opt_child_type: Type = .fromInterned(opt_child_type_index);3202 const opt_child_type: Type = .fromInterned(opt_child_type_index);
3118 try wip_nav.abbrevCode(.union_type);3203 try wip_nav.abbrevCode(.generated_union_type);
3119 try wip_nav.strp(name);3204 try wip_nav.strp(name);
3120 try uleb128(diw, ty.abiSize(zcu));3205 try uleb128(diw, ty.abiSize(zcu));
3121 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);3206 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
...@@ -3199,7 +3284,7 @@ fn updateLazyType(...@@ -3199,7 +3284,7 @@ fn updateLazyType(
3199 },3284 },
3200 };3285 };
32013286
3202 try wip_nav.abbrevCode(.union_type);3287 try wip_nav.abbrevCode(.generated_union_type);
3203 try wip_nav.strp(name);3288 try wip_nav.strp(name);
3204 if (error_union_type.error_set_type != .generic_poison_type and3289 if (error_union_type.error_set_type != .generic_poison_type and
3205 error_union_type.payload_type != .generic_poison_type)3290 error_union_type.payload_type != .generic_poison_type)
...@@ -3308,11 +3393,11 @@ fn updateLazyType(...@@ -3308,11 +3393,11 @@ fn updateLazyType(
3308 .opaque_type,3393 .opaque_type,
3309 => unreachable,3394 => unreachable,
3310 .tuple_type => |tuple_type| if (tuple_type.types.len == 0) {3395 .tuple_type => |tuple_type| if (tuple_type.types.len == 0) {
3311 try wip_nav.abbrevCode(.namespace_struct_type);3396 try wip_nav.abbrevCode(.generated_empty_struct_type);
3312 try wip_nav.strp(name);3397 try wip_nav.strp(name);
3313 try diw.writeByte(@intFromBool(false));3398 try diw.writeByte(@intFromBool(false));
3314 } else {3399 } else {
3315 try wip_nav.abbrevCode(.struct_type);3400 try wip_nav.abbrevCode(.generated_struct_type);
3316 try wip_nav.strp(name);3401 try wip_nav.strp(name);
3317 try uleb128(diw, ty.abiSize(zcu));3402 try uleb128(diw, ty.abiSize(zcu));
3318 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);3403 try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?);
...@@ -3357,7 +3442,7 @@ fn updateLazyType(...@@ -3357,7 +3442,7 @@ fn updateLazyType(
3357 },3442 },
3358 .enum_type => {3443 .enum_type => {
3359 const loaded_enum = ip.loadEnumType(type_index);3444 const loaded_enum = ip.loadEnumType(type_index);
3360 try wip_nav.abbrevCode(if (loaded_enum.names.len > 0) .enum_type else .empty_enum_type);3445 try wip_nav.abbrevCode(if (loaded_enum.names.len > 0) .generated_enum_type else .generated_empty_enum_type);
3361 try wip_nav.strp(name);3446 try wip_nav.strp(name);
3362 try wip_nav.refType(.fromInterned(loaded_enum.tag_ty));3447 try wip_nav.refType(.fromInterned(loaded_enum.tag_ty));
3363 for (0..loaded_enum.names.len) |field_index| {3448 for (0..loaded_enum.names.len) |field_index| {
...@@ -3449,7 +3534,7 @@ fn updateLazyType(...@@ -3449,7 +3534,7 @@ fn updateLazyType(
3449 if (!is_nullary) try uleb128(diw, @intFromEnum(AbbrevCode.null));3534 if (!is_nullary) try uleb128(diw, @intFromEnum(AbbrevCode.null));
3450 },3535 },
3451 .error_set_type => |error_set_type| {3536 .error_set_type => |error_set_type| {
3452 try wip_nav.abbrevCode(if (error_set_type.names.len > 0) .enum_type else .empty_enum_type);3537 try wip_nav.abbrevCode(if (error_set_type.names.len > 0) .generated_enum_type else .generated_empty_enum_type);
3453 try wip_nav.strp(name);3538 try wip_nav.strp(name);
3454 try wip_nav.refType(.fromInterned(try pt.intern(.{ .int_type = .{3539 try wip_nav.refType(.fromInterned(try pt.intern(.{ .int_type = .{
3455 .signedness = .unsigned,3540 .signedness = .unsigned,
...@@ -3518,15 +3603,15 @@ fn updateLazyValue(...@@ -3518,15 +3603,15 @@ fn updateLazyValue(
3518 .func_high_pc = undefined,3603 .func_high_pc = undefined,
3519 .blocks = undefined,3604 .blocks = undefined,
3520 .cfi = undefined,3605 .cfi = undefined,
3521 .debug_frame = .{},3606 .debug_frame = .empty,
3522 .debug_info = .{},3607 .debug_info = .empty,
3523 .debug_line = .{},3608 .debug_line = .empty,
3524 .debug_loclists = .{},3609 .debug_loclists = .empty,
3525 .pending_lazy = pending_lazy.*,3610 .pending_lazy = pending_lazy.*,
3526 };3611 };
3527 defer {3612 defer {
3528 pending_lazy.* = wip_nav.pending_lazy;3613 pending_lazy.* = wip_nav.pending_lazy;
3529 wip_nav.pending_lazy = .{};3614 wip_nav.pending_lazy = .empty;
3530 wip_nav.deinit();3615 wip_nav.deinit();
3531 }3616 }
3532 const diw = wip_nav.debug_info.writer(dwarf.gpa);3617 const diw = wip_nav.debug_info.writer(dwarf.gpa);
...@@ -3870,12 +3955,13 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3870,12 +3955,13 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3870 const ip = &zcu.intern_pool;3955 const ip = &zcu.intern_pool;
3871 const ty: Type = .fromInterned(type_index);3956 const ty: Type = .fromInterned(type_index);
3872 const ty_src_loc = ty.srcLoc(zcu);3957 const ty_src_loc = ty.srcLoc(zcu);
3873 log.debug("updateContainerType({}({d}))", .{ ty.fmt(pt), @intFromEnum(type_index) });3958 log.debug("updateContainerType({})", .{ty.fmt(pt)});
38743959
3875 const inst_info = ty.typeDeclInst(zcu).?.resolveFull(ip).?;3960 const inst_info = ty.typeDeclInst(zcu).?.resolveFull(ip).?;
3876 const file = zcu.fileByIndex(inst_info.file);3961 const file = zcu.fileByIndex(inst_info.file);
3962 const unit = try dwarf.getUnit(file.mod);
3963 const file_gop = try dwarf.getModInfo(unit).files.getOrPut(dwarf.gpa, inst_info.file);
3877 if (inst_info.inst == .main_struct_inst) {3964 if (inst_info.inst == .main_struct_inst) {
3878 const unit = try dwarf.getUnit(file.mod);
3879 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, type_index);3965 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, type_index);
3880 if (!type_gop.found_existing) type_gop.value_ptr.* = try dwarf.addCommonEntry(unit);3966 if (!type_gop.found_existing) type_gop.value_ptr.* = try dwarf.addCommonEntry(unit);
3881 var wip_nav: WipNav = .{3967 var wip_nav: WipNav = .{
...@@ -3889,19 +3975,18 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3889,19 +3975,18 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3889 .func_high_pc = undefined,3975 .func_high_pc = undefined,
3890 .blocks = undefined,3976 .blocks = undefined,
3891 .cfi = undefined,3977 .cfi = undefined,
3892 .debug_frame = .{},3978 .debug_frame = .empty,
3893 .debug_info = .{},3979 .debug_info = .empty,
3894 .debug_line = .{},3980 .debug_line = .empty,
3895 .debug_loclists = .{},3981 .debug_loclists = .empty,
3896 .pending_lazy = .{},3982 .pending_lazy = .empty,
3897 };3983 };
3898 defer wip_nav.deinit();3984 defer wip_nav.deinit();
38993985
3900 const loaded_struct = ip.loadStructType(type_index);3986 const loaded_struct = ip.loadStructType(type_index);
39013987
3902 const diw = wip_nav.debug_info.writer(dwarf.gpa);3988 const diw = wip_nav.debug_info.writer(dwarf.gpa);
3903 try wip_nav.abbrevCode(if (loaded_struct.field_types.len == 0) .namespace_file else .file);3989 try wip_nav.abbrevCode(if (loaded_struct.field_types.len == 0) .empty_file else .file);
3904 const file_gop = try dwarf.getModInfo(unit).files.getOrPut(dwarf.gpa, inst_info.file);
3905 try uleb128(diw, file_gop.index);3990 try uleb128(diw, file_gop.index);
3906 try wip_nav.strp(loaded_struct.name.toSlice(ip));3991 try wip_nav.strp(loaded_struct.name.toSlice(ip));
3907 if (loaded_struct.field_types.len > 0) {3992 if (loaded_struct.field_types.len > 0) {
...@@ -3978,7 +4063,6 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3978,7 +4063,6 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3978 if (name_strat == .parent) return;4063 if (name_strat == .parent) return;
3979 }4064 }
39804065
3981 const unit = try dwarf.getUnit(file.mod);
3982 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, type_index);4066 const type_gop = try dwarf.types.getOrPut(dwarf.gpa, type_index);
3983 if (!type_gop.found_existing) type_gop.value_ptr.* = try dwarf.addCommonEntry(unit);4067 if (!type_gop.found_existing) type_gop.value_ptr.* = try dwarf.addCommonEntry(unit);
3984 var wip_nav: WipNav = .{4068 var wip_nav: WipNav = .{
...@@ -3992,11 +4076,11 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3992,11 +4076,11 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3992 .func_high_pc = undefined,4076 .func_high_pc = undefined,
3993 .blocks = undefined,4077 .blocks = undefined,
3994 .cfi = undefined,4078 .cfi = undefined,
3995 .debug_frame = .{},4079 .debug_frame = .empty,
3996 .debug_info = .{},4080 .debug_info = .empty,
3997 .debug_line = .{},4081 .debug_line = .empty,
3998 .debug_loclists = .{},4082 .debug_loclists = .empty,
3999 .pending_lazy = .{},4083 .pending_lazy = .empty,
4000 };4084 };
4001 defer wip_nav.deinit();4085 defer wip_nav.deinit();
4002 const diw = wip_nav.debug_info.writer(dwarf.gpa);4086 const diw = wip_nav.debug_info.writer(dwarf.gpa);
...@@ -4008,7 +4092,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -4008,7 +4092,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
4008 const loaded_struct = ip.loadStructType(type_index);4092 const loaded_struct = ip.loadStructType(type_index);
4009 switch (loaded_struct.layout) {4093 switch (loaded_struct.layout) {
4010 .auto, .@"extern" => {4094 .auto, .@"extern" => {
4011 try wip_nav.abbrevCode(if (loaded_struct.field_types.len == 0) .namespace_struct_type else .struct_type);4095 try wip_nav.abbrevCode(if (loaded_struct.field_types.len == 0) .empty_struct_type else .struct_type);
4096 try uleb128(diw, file_gop.index);
4012 try wip_nav.strp(name);4097 try wip_nav.strp(name);
4013 if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else {4098 if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else {
4014 try uleb128(diw, ty.abiSize(zcu));4099 try uleb128(diw, ty.abiSize(zcu));
...@@ -4062,6 +4147,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -4062,6 +4147,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
4062 },4147 },
4063 .@"packed" => {4148 .@"packed" => {
4064 try wip_nav.abbrevCode(if (loaded_struct.field_types.len > 0) .packed_struct_type else .empty_packed_struct_type);4149 try wip_nav.abbrevCode(if (loaded_struct.field_types.len > 0) .packed_struct_type else .empty_packed_struct_type);
4150 try uleb128(diw, file_gop.index);
4065 try wip_nav.strp(name);4151 try wip_nav.strp(name);
4066 try wip_nav.refType(.fromInterned(loaded_struct.backingIntTypeUnordered(ip)));4152 try wip_nav.refType(.fromInterned(loaded_struct.backingIntTypeUnordered(ip)));
4067 var field_bit_offset: u16 = 0;4153 var field_bit_offset: u16 = 0;
...@@ -4080,6 +4166,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -4080,6 +4166,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
4080 .enum_type => {4166 .enum_type => {
4081 const loaded_enum = ip.loadEnumType(type_index);4167 const loaded_enum = ip.loadEnumType(type_index);
4082 try wip_nav.abbrevCode(if (loaded_enum.names.len > 0) .enum_type else .empty_enum_type);4168 try wip_nav.abbrevCode(if (loaded_enum.names.len > 0) .enum_type else .empty_enum_type);
4169 try uleb128(diw, file_gop.index);
4083 try wip_nav.strp(name);4170 try wip_nav.strp(name);
4084 try wip_nav.refType(.fromInterned(loaded_enum.tag_ty));4171 try wip_nav.refType(.fromInterned(loaded_enum.tag_ty));
4085 for (0..loaded_enum.names.len) |field_index| {4172 for (0..loaded_enum.names.len) |field_index| {
...@@ -4095,6 +4182,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -4095,6 +4182,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
4095 .union_type => {4182 .union_type => {
4096 const loaded_union = ip.loadUnionType(type_index);4183 const loaded_union = ip.loadUnionType(type_index);
4097 try wip_nav.abbrevCode(if (loaded_union.field_types.len > 0) .union_type else .empty_union_type);4184 try wip_nav.abbrevCode(if (loaded_union.field_types.len > 0) .union_type else .empty_union_type);
4185 try uleb128(diw, file_gop.index);
4098 try wip_nav.strp(name);4186 try wip_nav.strp(name);
4099 const union_layout = Type.getUnionLayout(loaded_union, zcu);4187 const union_layout = Type.getUnionLayout(loaded_union, zcu);
4100 try uleb128(diw, union_layout.abi_size);4188 try uleb128(diw, union_layout.abi_size);
...@@ -4144,7 +4232,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -4144,7 +4232,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
4144 if (loaded_union.field_types.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));4232 if (loaded_union.field_types.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null));
4145 },4233 },
4146 .opaque_type => {4234 .opaque_type => {
4147 try wip_nav.abbrevCode(.namespace_struct_type);4235 try wip_nav.abbrevCode(.empty_struct_type);
4236 try uleb128(diw, file_gop.index);
4148 try wip_nav.strp(name);4237 try wip_nav.strp(name);
4149 try diw.writeByte(@intFromBool(true));4238 try diw.writeByte(@intFromBool(true));
4150 },4239 },
...@@ -4156,11 +4245,28 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -4156,11 +4245,28 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
4156 }4245 }
4157}4246}
41584247
4159pub fn updateLineNumber(dwarf: *Dwarf, zcu: *Zcu, ti_id: InternPool.TrackedInst.Index) UpdateError!void {4248pub fn updateLineNumber(dwarf: *Dwarf, zcu: *Zcu, zir_index: InternPool.TrackedInst.Index) UpdateError!void {
4160 _ = dwarf;4249 const ip = &zcu.intern_pool;
4161 _ = zcu;4250
4162 _ = ti_id;4251 const inst_info = zir_index.resolveFull(ip).?;
4163 @panic("TODO: Dwarf.updateLineNumber");4252 assert(inst_info.inst != .main_struct_inst);
4253 const file = zcu.fileByIndex(inst_info.file);
4254 assert(file.zir_loaded);
4255 const decl = file.zir.getDeclaration(inst_info.inst);
4256 log.debug("updateLineNumber({s}:{d}:{d} %{d} = {s})", .{
4257 file.sub_file_path,
4258 decl.src_line + 1,
4259 decl.src_column + 1,
4260 @intFromEnum(inst_info.inst),
4261 file.zir.nullTerminatedString(decl.name),
4262 });
4263
4264 var line_buf: [4]u8 = undefined;
4265 std.mem.writeInt(u32, &line_buf, decl.src_line + 1, dwarf.endian);
4266
4267 const unit = dwarf.debug_info.section.getUnit(dwarf.getUnitIfExists(file.mod) orelse return);
4268 const entry = unit.getEntry(dwarf.decls.get(zir_index) orelse return);
4269 try dwarf.getFile().?.pwriteAll(&line_buf, dwarf.debug_info.section.off(dwarf) + unit.off + unit.header_len + entry.off + DebugInfo.declEntryLineOff(dwarf));
4164}4270}
41654271
4166pub fn freeNav(dwarf: *Dwarf, nav_index: InternPool.Nav.Index) void {4272pub fn freeNav(dwarf: *Dwarf, nav_index: InternPool.Nav.Index) void {
...@@ -4203,16 +4309,16 @@ pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void {...@@ -4203,16 +4309,16 @@ pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void {
4203 .func_high_pc = undefined,4309 .func_high_pc = undefined,
4204 .blocks = undefined,4310 .blocks = undefined,
4205 .cfi = undefined,4311 .cfi = undefined,
4206 .debug_frame = .{},4312 .debug_frame = .empty,
4207 .debug_info = .{},4313 .debug_info = .empty,
4208 .debug_line = .{},4314 .debug_line = .empty,
4209 .debug_loclists = .{},4315 .debug_loclists = .empty,
4210 .pending_lazy = .{},4316 .pending_lazy = .empty,
4211 };4317 };
4212 defer wip_nav.deinit();4318 defer wip_nav.deinit();
4213 const diw = wip_nav.debug_info.writer(dwarf.gpa);4319 const diw = wip_nav.debug_info.writer(dwarf.gpa);
4214 const global_error_set_names = ip.global_error_set.getNamesFromMainThread();4320 const global_error_set_names = ip.global_error_set.getNamesFromMainThread();
4215 try wip_nav.abbrevCode(if (global_error_set_names.len > 0) .enum_type else .empty_enum_type);4321 try wip_nav.abbrevCode(if (global_error_set_names.len > 0) .generated_enum_type else .generated_empty_enum_type);
4216 try wip_nav.strp("anyerror");4322 try wip_nav.strp("anyerror");
4217 try wip_nav.refType(.fromInterned(try pt.intern(.{ .int_type = .{4323 try wip_nav.refType(.fromInterned(try pt.intern(.{ .int_type = .{
4218 .signedness = .unsigned,4324 .signedness = .unsigned,
...@@ -4601,7 +4707,7 @@ const AbbrevCode = enum {...@@ -4601,7 +4707,7 @@ const AbbrevCode = enum {
4601 // padding codes must be one byte uleb128 values to function4707 // padding codes must be one byte uleb128 values to function
4602 pad_1,4708 pad_1,
4603 pad_n,4709 pad_n,
4604 // decl codes are assumed to all have the same uleb128 length4710 // (generic) decl codes are assumed to all have the same uleb128 length
4605 decl_alias,4711 decl_alias,
4606 decl_enum,4712 decl_enum,
4607 decl_empty_enum,4713 decl_empty_enum,
...@@ -4618,11 +4724,34 @@ const AbbrevCode = enum {...@@ -4618,11 +4724,34 @@ const AbbrevCode = enum {
4618 decl_empty_func,4724 decl_empty_func,
4619 decl_func_generic,4725 decl_func_generic,
4620 decl_empty_func_generic,4726 decl_empty_func_generic,
4727 generic_decl_alias,
4728 generic_decl_enum,
4729 generic_decl_struct,
4730 generic_decl_union,
4731 generic_decl_var,
4732 generic_decl_const,
4733 generic_decl_func,
4621 // the rest are unrestricted4734 // the rest are unrestricted
4735 instance_alias,
4736 instance_enum,
4737 instance_empty_enum,
4738 instance_namespace_struct,
4739 instance_struct,
4740 instance_packed_struct,
4741 instance_union,
4742 instance_var,
4743 instance_const,
4744 instance_const_runtime_bits,
4745 instance_const_comptime_state,
4746 instance_const_runtime_bits_comptime_state,
4747 instance_func,
4748 instance_empty_func,
4749 instance_func_generic,
4750 instance_empty_func_generic,
4622 compile_unit,4751 compile_unit,
4623 module,4752 module,
4624 namespace_file,
4625 file,4753 file,
4754 empty_file,
4626 signed_enum_field,4755 signed_enum_field,
4627 unsigned_enum_field,4756 unsigned_enum_field,
4628 big_enum_field,4757 big_enum_field,
...@@ -4655,10 +4784,15 @@ const AbbrevCode = enum {...@@ -4655,10 +4784,15 @@ const AbbrevCode = enum {
4655 func_type,4784 func_type,
4656 func_type_param,4785 func_type_param,
4657 is_var_args,4786 is_var_args,
4787 generated_enum_type,
4788 generated_empty_enum_type,
4789 generated_struct_type,
4790 generated_empty_struct_type,
4791 generated_union_type,
4658 enum_type,4792 enum_type,
4659 empty_enum_type,4793 empty_enum_type,
4660 namespace_struct_type,
4661 struct_type,4794 struct_type,
4795 empty_struct_type,
4662 packed_struct_type,4796 packed_struct_type,
4663 empty_packed_struct_type,4797 empty_packed_struct_type,
4664 union_type,4798 union_type,
...@@ -4684,7 +4818,7 @@ const AbbrevCode = enum {...@@ -4684,7 +4818,7 @@ const AbbrevCode = enum {
4684 comptime_value_elem_runtime_bits,4818 comptime_value_elem_runtime_bits,
4685 comptime_value_elem_comptime_state,4819 comptime_value_elem_comptime_state,
46864820
4687 const decl_bytes = uleb128Bytes(@intFromEnum(AbbrevCode.decl_empty_func_generic));4821 const decl_bytes = uleb128Bytes(@intFromEnum(AbbrevCode.generic_decl_func));
46884822
4689 const Attr = struct {4823 const Attr = struct {
4690 DeclValEnum(DW.AT),4824 DeclValEnum(DW.AT),
...@@ -4697,6 +4831,10 @@ const AbbrevCode = enum {...@@ -4697,6 +4831,10 @@ const AbbrevCode = enum {
4697 .{ .accessibility, .data1 },4831 .{ .accessibility, .data1 },
4698 .{ .name, .strp },4832 .{ .name, .strp },
4699 };4833 };
4834 const instance_abbrev_common_attrs = &[_]Attr{
4835 .{ .ZIG_parent, .ref_addr },
4836 .{ .abstract_origin, .ref_addr },
4837 };
4700 const abbrevs = std.EnumArray(AbbrevCode, struct {4838 const abbrevs = std.EnumArray(AbbrevCode, struct {
4701 tag: DeclValEnum(DW.TAG),4839 tag: DeclValEnum(DW.TAG),
4702 children: bool = false,4840 children: bool = false,
...@@ -4847,6 +4985,184 @@ const AbbrevCode = enum {...@@ -4847,6 +4985,184 @@ const AbbrevCode = enum {
4847 .{ .type, .ref_addr },4985 .{ .type, .ref_addr },
4848 },4986 },
4849 },4987 },
4988 .generic_decl_alias = .{
4989 .tag = .imported_declaration,
4990 .attrs = decl_abbrev_common_attrs ++ .{
4991 .{ .declaration, .flag_present },
4992 },
4993 },
4994 .generic_decl_enum = .{
4995 .tag = .enumeration_type,
4996 .attrs = decl_abbrev_common_attrs ++ .{
4997 .{ .declaration, .flag_present },
4998 },
4999 },
5000 .generic_decl_struct = .{
5001 .tag = .structure_type,
5002 .attrs = decl_abbrev_common_attrs ++ .{
5003 .{ .declaration, .flag_present },
5004 },
5005 },
5006 .generic_decl_union = .{
5007 .tag = .union_type,
5008 .attrs = decl_abbrev_common_attrs ++ .{
5009 .{ .declaration, .flag_present },
5010 },
5011 },
5012 .generic_decl_var = .{
5013 .tag = .variable,
5014 .attrs = decl_abbrev_common_attrs ++ .{
5015 .{ .declaration, .flag_present },
5016 },
5017 },
5018 .generic_decl_const = .{
5019 .tag = .constant,
5020 .attrs = decl_abbrev_common_attrs ++ .{
5021 .{ .declaration, .flag_present },
5022 },
5023 },
5024 .generic_decl_func = .{
5025 .tag = .subprogram,
5026 .attrs = decl_abbrev_common_attrs ++ .{
5027 .{ .declaration, .flag_present },
5028 },
5029 },
5030 .instance_alias = .{
5031 .tag = .imported_declaration,
5032 .attrs = instance_abbrev_common_attrs ++ .{
5033 .{ .import, .ref_addr },
5034 },
5035 },
5036 .instance_enum = .{
5037 .tag = .enumeration_type,
5038 .children = true,
5039 .attrs = instance_abbrev_common_attrs ++ .{
5040 .{ .type, .ref_addr },
5041 },
5042 },
5043 .instance_empty_enum = .{
5044 .tag = .enumeration_type,
5045 .attrs = instance_abbrev_common_attrs ++ .{
5046 .{ .type, .ref_addr },
5047 },
5048 },
5049 .instance_namespace_struct = .{
5050 .tag = .structure_type,
5051 .attrs = instance_abbrev_common_attrs ++ .{
5052 .{ .declaration, .flag },
5053 },
5054 },
5055 .instance_struct = .{
5056 .tag = .structure_type,
5057 .children = true,
5058 .attrs = instance_abbrev_common_attrs ++ .{
5059 .{ .byte_size, .udata },
5060 .{ .alignment, .udata },
5061 },
5062 },
5063 .instance_packed_struct = .{
5064 .tag = .structure_type,
5065 .children = true,
5066 .attrs = instance_abbrev_common_attrs ++ .{
5067 .{ .type, .ref_addr },
5068 },
5069 },
5070 .instance_union = .{
5071 .tag = .union_type,
5072 .children = true,
5073 .attrs = instance_abbrev_common_attrs ++ .{
5074 .{ .byte_size, .udata },
5075 .{ .alignment, .udata },
5076 },
5077 },
5078 .instance_var = .{
5079 .tag = .variable,
5080 .attrs = instance_abbrev_common_attrs ++ .{
5081 .{ .linkage_name, .strp },
5082 .{ .type, .ref_addr },
5083 .{ .location, .exprloc },
5084 .{ .alignment, .udata },
5085 .{ .external, .flag },
5086 },
5087 },
5088 .instance_const = .{
5089 .tag = .constant,
5090 .attrs = instance_abbrev_common_attrs ++ .{
5091 .{ .linkage_name, .strp },
5092 .{ .type, .ref_addr },
5093 .{ .alignment, .udata },
5094 .{ .external, .flag },
5095 },
5096 },
5097 .instance_const_runtime_bits = .{
5098 .tag = .constant,
5099 .attrs = instance_abbrev_common_attrs ++ .{
5100 .{ .linkage_name, .strp },
5101 .{ .type, .ref_addr },
5102 .{ .alignment, .udata },
5103 .{ .external, .flag },
5104 .{ .const_value, .block },
5105 },
5106 },
5107 .instance_const_comptime_state = .{
5108 .tag = .constant,
5109 .attrs = instance_abbrev_common_attrs ++ .{
5110 .{ .linkage_name, .strp },
5111 .{ .type, .ref_addr },
5112 .{ .alignment, .udata },
5113 .{ .external, .flag },
5114 .{ .ZIG_comptime_value, .ref_addr },
5115 },
5116 },
5117 .instance_const_runtime_bits_comptime_state = .{
5118 .tag = .constant,
5119 .attrs = instance_abbrev_common_attrs ++ .{
5120 .{ .linkage_name, .strp },
5121 .{ .type, .ref_addr },
5122 .{ .alignment, .udata },
5123 .{ .external, .flag },
5124 .{ .const_value, .block },
5125 .{ .ZIG_comptime_value, .ref_addr },
5126 },
5127 },
5128 .instance_func = .{
5129 .tag = .subprogram,
5130 .children = true,
5131 .attrs = instance_abbrev_common_attrs ++ .{
5132 .{ .linkage_name, .strp },
5133 .{ .type, .ref_addr },
5134 .{ .low_pc, .addr },
5135 .{ .high_pc, .data4 },
5136 .{ .alignment, .udata },
5137 .{ .external, .flag },
5138 .{ .noreturn, .flag },
5139 },
5140 },
5141 .instance_empty_func = .{
5142 .tag = .subprogram,
5143 .attrs = instance_abbrev_common_attrs ++ .{
5144 .{ .linkage_name, .strp },
5145 .{ .type, .ref_addr },
5146 .{ .low_pc, .addr },
5147 .{ .high_pc, .data4 },
5148 .{ .alignment, .udata },
5149 .{ .external, .flag },
5150 .{ .noreturn, .flag },
5151 },
5152 },
5153 .instance_func_generic = .{
5154 .tag = .subprogram,
5155 .children = true,
5156 .attrs = instance_abbrev_common_attrs ++ .{
5157 .{ .type, .ref_addr },
5158 },
5159 },
5160 .instance_empty_func_generic = .{
5161 .tag = .subprogram,
5162 .attrs = instance_abbrev_common_attrs ++ .{
5163 .{ .type, .ref_addr },
5164 },
5165 },
4850 .compile_unit = .{5166 .compile_unit = .{
4851 .tag = .compile_unit,5167 .tag = .compile_unit,
4852 .children = true,5168 .children = true,
...@@ -4869,21 +5185,21 @@ const AbbrevCode = enum {...@@ -4869,21 +5185,21 @@ const AbbrevCode = enum {
4869 .{ .ranges, .rnglistx },5185 .{ .ranges, .rnglistx },
4870 },5186 },
4871 },5187 },
4872 .namespace_file = .{5188 .file = .{
4873 .tag = .structure_type,5189 .tag = .structure_type,
5190 .children = true,
4874 .attrs = &.{5191 .attrs = &.{
4875 .{ .decl_file, .udata },5192 .{ .decl_file, .udata },
4876 .{ .name, .strp },5193 .{ .name, .strp },
5194 .{ .byte_size, .udata },
5195 .{ .alignment, .udata },
4877 },5196 },
4878 },5197 },
4879 .file = .{5198 .empty_file = .{
4880 .tag = .structure_type,5199 .tag = .structure_type,
4881 .children = true,
4882 .attrs = &.{5200 .attrs = &.{
4883 .{ .decl_file, .udata },5201 .{ .decl_file, .udata },
4884 .{ .name, .strp },5202 .{ .name, .strp },
4885 .{ .byte_size, .udata },
4886 .{ .alignment, .udata },
4887 },5203 },
4888 },5204 },
4889 .signed_enum_field = .{5205 .signed_enum_field = .{
...@@ -5133,7 +5449,7 @@ const AbbrevCode = enum {...@@ -5133,7 +5449,7 @@ const AbbrevCode = enum {
5133 .is_var_args = .{5449 .is_var_args = .{
5134 .tag = .unspecified_parameters,5450 .tag = .unspecified_parameters,
5135 },5451 },
5136 .enum_type = .{5452 .generated_enum_type = .{
5137 .tag = .enumeration_type,5453 .tag = .enumeration_type,
5138 .children = true,5454 .children = true,
5139 .attrs = &.{5455 .attrs = &.{
...@@ -5141,33 +5457,78 @@ const AbbrevCode = enum {...@@ -5141,33 +5457,78 @@ const AbbrevCode = enum {
5141 .{ .type, .ref_addr },5457 .{ .type, .ref_addr },
5142 },5458 },
5143 },5459 },
5144 .empty_enum_type = .{5460 .generated_empty_enum_type = .{
5145 .tag = .enumeration_type,5461 .tag = .enumeration_type,
5146 .attrs = &.{5462 .attrs = &.{
5147 .{ .name, .strp },5463 .{ .name, .strp },
5148 .{ .type, .ref_addr },5464 .{ .type, .ref_addr },
5149 },5465 },
5150 },5466 },
5151 .namespace_struct_type = .{5467 .generated_struct_type = .{
5468 .tag = .structure_type,
5469 .children = true,
5470 .attrs = &.{
5471 .{ .name, .strp },
5472 .{ .byte_size, .udata },
5473 .{ .alignment, .udata },
5474 },
5475 },
5476 .generated_empty_struct_type = .{
5152 .tag = .structure_type,5477 .tag = .structure_type,
5153 .attrs = &.{5478 .attrs = &.{
5154 .{ .name, .strp },5479 .{ .name, .strp },
5155 .{ .declaration, .flag },5480 .{ .declaration, .flag },
5156 },5481 },
5157 },5482 },
5483 .generated_union_type = .{
5484 .tag = .union_type,
5485 .children = true,
5486 .attrs = &.{
5487 .{ .name, .strp },
5488 .{ .byte_size, .udata },
5489 .{ .alignment, .udata },
5490 },
5491 },
5492 .enum_type = .{
5493 .tag = .enumeration_type,
5494 .children = true,
5495 .attrs = &.{
5496 .{ .decl_file, .udata },
5497 .{ .name, .strp },
5498 .{ .type, .ref_addr },
5499 },
5500 },
5501 .empty_enum_type = .{
5502 .tag = .enumeration_type,
5503 .attrs = &.{
5504 .{ .decl_file, .udata },
5505 .{ .name, .strp },
5506 .{ .type, .ref_addr },
5507 },
5508 },
5158 .struct_type = .{5509 .struct_type = .{
5159 .tag = .structure_type,5510 .tag = .structure_type,
5160 .children = true,5511 .children = true,
5161 .attrs = &.{5512 .attrs = &.{
5513 .{ .decl_file, .udata },
5162 .{ .name, .strp },5514 .{ .name, .strp },
5163 .{ .byte_size, .udata },5515 .{ .byte_size, .udata },
5164 .{ .alignment, .udata },5516 .{ .alignment, .udata },
5165 },5517 },
5166 },5518 },
5519 .empty_struct_type = .{
5520 .tag = .structure_type,
5521 .attrs = &.{
5522 .{ .decl_file, .udata },
5523 .{ .name, .strp },
5524 .{ .declaration, .flag },
5525 },
5526 },
5167 .packed_struct_type = .{5527 .packed_struct_type = .{
5168 .tag = .structure_type,5528 .tag = .structure_type,
5169 .children = true,5529 .children = true,
5170 .attrs = &.{5530 .attrs = &.{
5531 .{ .decl_file, .udata },
5171 .{ .name, .strp },5532 .{ .name, .strp },
5172 .{ .type, .ref_addr },5533 .{ .type, .ref_addr },
5173 },5534 },
...@@ -5175,6 +5536,7 @@ const AbbrevCode = enum {...@@ -5175,6 +5536,7 @@ const AbbrevCode = enum {
5175 .empty_packed_struct_type = .{5536 .empty_packed_struct_type = .{
5176 .tag = .structure_type,5537 .tag = .structure_type,
5177 .attrs = &.{5538 .attrs = &.{
5539 .{ .decl_file, .udata },
5178 .{ .name, .strp },5540 .{ .name, .strp },
5179 .{ .type, .ref_addr },5541 .{ .type, .ref_addr },
5180 },5542 },
...@@ -5183,6 +5545,7 @@ const AbbrevCode = enum {...@@ -5183,6 +5545,7 @@ const AbbrevCode = enum {
5183 .tag = .union_type,5545 .tag = .union_type,
5184 .children = true,5546 .children = true,
5185 .attrs = &.{5547 .attrs = &.{
5548 .{ .decl_file, .udata },
5186 .{ .name, .strp },5549 .{ .name, .strp },
5187 .{ .byte_size, .udata },5550 .{ .byte_size, .udata },
5188 .{ .alignment, .udata },5551 .{ .alignment, .udata },
...@@ -5191,6 +5554,7 @@ const AbbrevCode = enum {...@@ -5191,6 +5554,7 @@ const AbbrevCode = enum {
5191 .empty_union_type = .{5554 .empty_union_type = .{
5192 .tag = .union_type,5555 .tag = .union_type,
5193 .attrs = &.{5556 .attrs = &.{
5557 .{ .decl_file, .udata },
5194 .{ .name, .strp },5558 .{ .name, .strp },
5195 .{ .byte_size, .udata },5559 .{ .byte_size, .udata },
5196 .{ .alignment, .udata },5560 .{ .alignment, .udata },
...@@ -5363,6 +5727,15 @@ fn addCommonEntry(dwarf: *Dwarf, unit: Unit.Index) UpdateError!Entry.Index {...@@ -5363,6 +5727,15 @@ fn addCommonEntry(dwarf: *Dwarf, unit: Unit.Index) UpdateError!Entry.Index {
5363 return entry;5727 return entry;
5364}5728}
53655729
5730fn freeCommonEntry(dwarf: *Dwarf, unit: Unit.Index, entry: Entry.Index) UpdateError!void {
5731 try dwarf.debug_aranges.section.freeEntry(unit, entry, dwarf);
5732 try dwarf.debug_frame.section.freeEntry(unit, entry, dwarf);
5733 try dwarf.debug_info.section.freeEntry(unit, entry, dwarf);
5734 try dwarf.debug_line.section.freeEntry(unit, entry, dwarf);
5735 try dwarf.debug_loclists.section.freeEntry(unit, entry, dwarf);
5736 try dwarf.debug_rnglists.section.freeEntry(unit, entry, dwarf);
5737}
5738
5366fn writeInt(dwarf: *Dwarf, buf: []u8, int: u64) void {5739fn writeInt(dwarf: *Dwarf, buf: []u8, int: u64) void {
5367 switch (buf.len) {5740 switch (buf.len) {
5368 inline 0...8 => |len| std.mem.writeInt(@Type(.{ .int = .{5741 inline 0...8 => |len| std.mem.writeInt(@Type(.{ .int = .{
src/link/Elf/ZigObject.zig+12-28
...@@ -1463,19 +1463,7 @@ pub fn updateFunc(...@@ -1463,19 +1463,7 @@ pub fn updateFunc(
1463 break :blk .{ atom_ptr.value, atom_ptr.alignment };1463 break :blk .{ atom_ptr.value, atom_ptr.alignment };
1464 };1464 };
14651465
1466 if (debug_wip_nav) |*wip_nav| {1466 if (debug_wip_nav) |*wip_nav| try self.dwarf.?.finishWipNavFunc(pt, func.owner_nav, code.len, wip_nav);
1467 const sym = self.symbol(sym_index);
1468 try self.dwarf.?.finishWipNav(
1469 pt,
1470 func.owner_nav,
1471 .{
1472 .index = sym_index,
1473 .addr = @intCast(sym.address(.{}, elf_file)),
1474 .size = self.atom(sym.ref.index).?.size,
1475 },
1476 wip_nav,
1477 );
1478 }
14791467
1480 // Exports will be updated by `Zcu.processExports` after the update.1468 // Exports will be updated by `Zcu.processExports` after the update.
14811469
...@@ -1546,13 +1534,21 @@ pub fn updateNav(...@@ -1546,13 +1534,21 @@ pub fn updateNav(
1546 .func => .none,1534 .func => .none,
1547 .variable => |variable| variable.init,1535 .variable => |variable| variable.init,
1548 .@"extern" => |@"extern"| {1536 .@"extern" => |@"extern"| {
1549 if (ip.isFunctionType(@"extern".ty)) return;
1550 const sym_index = try self.getGlobalSymbol(1537 const sym_index = try self.getGlobalSymbol(
1551 elf_file,1538 elf_file,
1552 nav.name.toSlice(ip),1539 nav.name.toSlice(ip),
1553 @"extern".lib_name.toSlice(ip),1540 @"extern".lib_name.toSlice(ip),
1554 );1541 );
1555 self.symbol(sym_index).flags.is_extern_ptr = true;1542 if (!ip.isFunctionType(@"extern".ty)) {
1543 const sym = self.symbol(sym_index);
1544 sym.flags.is_extern_ptr = true;
1545 if (@"extern".is_threadlocal) sym.flags.is_tls = true;
1546 }
1547 if (self.dwarf) |*dwarf| dwarf: {
1548 var debug_wip_nav = try dwarf.initWipNav(pt, nav_index, sym_index) orelse break :dwarf;
1549 defer debug_wip_nav.deinit();
1550 try dwarf.finishWipNav(pt, nav_index, &debug_wip_nav);
1551 }
1556 return;1552 return;
1557 },1553 },
1558 else => nav.status.fully_resolved.val,1554 else => nav.status.fully_resolved.val,
...@@ -1596,19 +1592,7 @@ pub fn updateNav(...@@ -1596,19 +1592,7 @@ pub fn updateNav(
1596 else1592 else
1597 try self.updateNavCode(elf_file, pt, nav_index, sym_index, shndx, code, elf.STT_OBJECT);1593 try self.updateNavCode(elf_file, pt, nav_index, sym_index, shndx, code, elf.STT_OBJECT);
15981594
1599 if (debug_wip_nav) |*wip_nav| {1595 if (debug_wip_nav) |*wip_nav| try self.dwarf.?.finishWipNav(pt, nav_index, wip_nav);
1600 const sym = self.symbol(sym_index);
1601 try self.dwarf.?.finishWipNav(
1602 pt,
1603 nav_index,
1604 .{
1605 .index = sym_index,
1606 .addr = @intCast(sym.address(.{}, elf_file)),
1607 .size = sym.atom(elf_file).?.size,
1608 },
1609 wip_nav,
1610 );
1611 }
1612 } else if (self.dwarf) |*dwarf| try dwarf.updateComptimeNav(pt, nav_index);1596 } else if (self.dwarf) |*dwarf| try dwarf.updateComptimeNav(pt, nav_index);
16131597
1614 // Exports will be updated by `Zcu.processExports` after the update.1598 // Exports will be updated by `Zcu.processExports` after the update.
src/link/MachO/ZigObject.zig+16-33
...@@ -780,8 +780,8 @@ pub fn updateFunc(...@@ -780,8 +780,8 @@ pub fn updateFunc(
780 var code_buffer = std.ArrayList(u8).init(gpa);780 var code_buffer = std.ArrayList(u8).init(gpa);
781 defer code_buffer.deinit();781 defer code_buffer.deinit();
782782
783 var dwarf_wip_nav = if (self.dwarf) |*dwarf| try dwarf.initWipNav(pt, func.owner_nav, sym_index) else null;783 var debug_wip_nav = if (self.dwarf) |*dwarf| try dwarf.initWipNav(pt, func.owner_nav, sym_index) else null;
784 defer if (dwarf_wip_nav) |*wip_nav| wip_nav.deinit();784 defer if (debug_wip_nav) |*wip_nav| wip_nav.deinit();
785785
786 const res = try codegen.generateFunction(786 const res = try codegen.generateFunction(
787 &macho_file.base,787 &macho_file.base,
...@@ -791,7 +791,7 @@ pub fn updateFunc(...@@ -791,7 +791,7 @@ pub fn updateFunc(
791 air,791 air,
792 liveness,792 liveness,
793 &code_buffer,793 &code_buffer,
794 if (dwarf_wip_nav) |*wip_nav| .{ .dwarf = wip_nav } else .none,794 if (debug_wip_nav) |*wip_nav| .{ .dwarf = wip_nav } else .none,
795 );795 );
796796
797 const code = switch (res) {797 const code = switch (res) {
...@@ -813,19 +813,7 @@ pub fn updateFunc(...@@ -813,19 +813,7 @@ pub fn updateFunc(
813 break :blk .{ atom.value, atom.alignment };813 break :blk .{ atom.value, atom.alignment };
814 };814 };
815815
816 if (dwarf_wip_nav) |*wip_nav| {816 if (debug_wip_nav) |*wip_nav| try self.dwarf.?.finishWipNavFunc(pt, func.owner_nav, code.len, wip_nav);
817 const sym = self.symbols.items[sym_index];
818 try self.dwarf.?.finishWipNav(
819 pt,
820 func.owner_nav,
821 .{
822 .index = sym_index,
823 .addr = sym.getAddress(.{}, macho_file),
824 .size = sym.getAtom(macho_file).?.size,
825 },
826 wip_nav,
827 );
828 }
829817
830 // Exports will be updated by `Zcu.processExports` after the update.818 // Exports will be updated by `Zcu.processExports` after the update.
831 if (old_rva != new_rva and old_rva > 0) {819 if (old_rva != new_rva and old_rva > 0) {
...@@ -883,13 +871,20 @@ pub fn updateNav(...@@ -883,13 +871,20 @@ pub fn updateNav(
883 .func => .none,871 .func => .none,
884 .variable => |variable| variable.init,872 .variable => |variable| variable.init,
885 .@"extern" => |@"extern"| {873 .@"extern" => |@"extern"| {
886 if (ip.isFunctionType(@"extern".ty)) return;
887 // Extern variable gets a __got entry only874 // Extern variable gets a __got entry only
888 const name = @"extern".name.toSlice(ip);875 const name = @"extern".name.toSlice(ip);
889 const lib_name = @"extern".lib_name.toSlice(ip);876 const lib_name = @"extern".lib_name.toSlice(ip);
890 const index = try self.getGlobalSymbol(macho_file, name, lib_name);877 const sym_index = try self.getGlobalSymbol(macho_file, name, lib_name);
891 const sym = &self.symbols.items[index];878 if (!ip.isFunctionType(@"extern".ty)) {
892 sym.flags.is_extern_ptr = true;879 const sym = &self.symbols.items[sym_index];
880 sym.flags.is_extern_ptr = true;
881 if (@"extern".is_threadlocal) sym.flags.tlv = true;
882 }
883 if (self.dwarf) |*dwarf| dwarf: {
884 var debug_wip_nav = try dwarf.initWipNav(pt, nav_index, sym_index) orelse break :dwarf;
885 defer debug_wip_nav.deinit();
886 try dwarf.finishWipNav(pt, nav_index, &debug_wip_nav);
887 }
893 return;888 return;
894 },889 },
895 else => nav.status.fully_resolved.val,890 else => nav.status.fully_resolved.val,
...@@ -927,19 +922,7 @@ pub fn updateNav(...@@ -927,19 +922,7 @@ pub fn updateNav(
927 else922 else
928 try self.updateNavCode(macho_file, pt, nav_index, sym_index, sect_index, code);923 try self.updateNavCode(macho_file, pt, nav_index, sym_index, sect_index, code);
929924
930 if (debug_wip_nav) |*wip_nav| {925 if (debug_wip_nav) |*wip_nav| try self.dwarf.?.finishWipNav(pt, nav_index, wip_nav);
931 const sym = self.symbols.items[sym_index];
932 try self.dwarf.?.finishWipNav(
933 pt,
934 nav_index,
935 .{
936 .index = sym_index,
937 .addr = sym.getAddress(.{}, macho_file),
938 .size = sym.getAtom(macho_file).?.size,
939 },
940 wip_nav,
941 );
942 }
943 } else if (self.dwarf) |*dwarf| try dwarf.updateComptimeNav(pt, nav_index);926 } else if (self.dwarf) |*dwarf| try dwarf.updateComptimeNav(pt, nav_index);
944927
945 // Exports will be updated by `Zcu.processExports` after the update.928 // Exports will be updated by `Zcu.processExports` after the update.
test/incremental/change_generic_line_number created+32
...@@ -0,0 +1,32 @@
1#target=x86_64-linux-selfhosted
2#update=initial version
3#file=main.zig
4const std = @import("std");
5fn Printer(message: []const u8) type {
6 return struct {
7 fn print() !void {
8 try std.io.getStdOut().writeAll(message);
9 }
10 };
11}
12pub fn main() !void {
13 try Printer("foo\n").print();
14 try Printer("bar\n").print();
15}
16#expect_stdout="foo\nbar\n"
17#update=change line number
18#file=main.zig
19const std = @import("std");
20
21fn Printer(message: []const u8) type {
22 return struct {
23 fn print() !void {
24 try std.io.getStdOut().writeAll(message);
25 }
26 };
27}
28pub fn main() !void {
29 try Printer("foo\n").print();
30 try Printer("bar\n").print();
31}
32#expect_stdout="foo\nbar\n"
test/incremental/change_line_number created+16
...@@ -0,0 +1,16 @@
1#target=x86_64-linux-selfhosted
2#update=initial version
3#file=main.zig
4const std = @import("std");
5pub fn main() !void {
6 try std.io.getStdOut().writeAll("foo\n");
7}
8#expect_stdout="foo\n"
9#update=change line number
10#file=main.zig
11const std = @import("std");
12
13pub fn main() !void {
14 try std.io.getStdOut().writeAll("foo\n");
15}
16#expect_stdout="foo\n"
tools/incr-check.zig+8-2
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const Allocator = std.mem.Allocator;2const Allocator = std.mem.Allocator;
3const Cache = std.Build.Cache;3const Cache = std.Build.Cache;
44
5const usage = "usage: incr-check <zig binary path> <input file> [--zig-lib-dir lib] [--debug-zcu] [--debug-link] [--preserve-tmp] [--zig-cc-binary /path/to/zig]";5const usage = "usage: incr-check <zig binary path> <input file> [--zig-lib-dir lib] [--debug-zcu] [--debug-dwarf] [--debug-link] [--preserve-tmp] [--zig-cc-binary /path/to/zig]";
66
7pub fn main() !void {7pub fn main() !void {
8 const fatal = std.process.fatal;8 const fatal = std.process.fatal;
...@@ -16,6 +16,7 @@ pub fn main() !void {...@@ -16,6 +16,7 @@ pub fn main() !void {
16 var opt_lib_dir: ?[]const u8 = null;16 var opt_lib_dir: ?[]const u8 = null;
17 var opt_cc_zig: ?[]const u8 = null;17 var opt_cc_zig: ?[]const u8 = null;
18 var debug_zcu = false;18 var debug_zcu = false;
19 var debug_dwarf = false;
19 var debug_link = false;20 var debug_link = false;
20 var preserve_tmp = false;21 var preserve_tmp = false;
2122
...@@ -27,6 +28,8 @@ pub fn main() !void {...@@ -27,6 +28,8 @@ pub fn main() !void {
27 opt_lib_dir = arg_it.next() orelse fatal("expected arg after '--zig-lib-dir'\n{s}", .{usage});28 opt_lib_dir = arg_it.next() orelse fatal("expected arg after '--zig-lib-dir'\n{s}", .{usage});
28 } else if (std.mem.eql(u8, arg, "--debug-zcu")) {29 } else if (std.mem.eql(u8, arg, "--debug-zcu")) {
29 debug_zcu = true;30 debug_zcu = true;
31 } else if (std.mem.eql(u8, arg, "--debug-dwarf")) {
32 debug_dwarf = true;
30 } else if (std.mem.eql(u8, arg, "--debug-link")) {33 } else if (std.mem.eql(u8, arg, "--debug-link")) {
31 debug_link = true;34 debug_link = true;
32 } else if (std.mem.eql(u8, arg, "--preserve-tmp")) {35 } else if (std.mem.eql(u8, arg, "--preserve-tmp")) {
...@@ -85,7 +88,7 @@ pub fn main() !void {...@@ -85,7 +88,7 @@ pub fn main() !void {
8588
86 const host = try std.zig.system.resolveTargetQuery(.{});89 const host = try std.zig.system.resolveTargetQuery(.{});
8790
88 const debug_log_verbose = debug_zcu or debug_link;91 const debug_log_verbose = debug_zcu or debug_dwarf or debug_link;
8992
90 for (case.targets) |target| {93 for (case.targets) |target| {
91 const target_prog_node = node: {94 const target_prog_node = node: {
...@@ -125,6 +128,9 @@ pub fn main() !void {...@@ -125,6 +128,9 @@ pub fn main() !void {
125 if (debug_zcu) {128 if (debug_zcu) {
126 try child_args.appendSlice(arena, &.{ "--debug-log", "zcu" });129 try child_args.appendSlice(arena, &.{ "--debug-log", "zcu" });
127 }130 }
131 if (debug_dwarf) {
132 try child_args.appendSlice(arena, &.{ "--debug-log", "dwarf" });
133 }
128 if (debug_link) {134 if (debug_link) {
129 try child_args.appendSlice(arena, &.{ "--debug-log", "link", "--debug-log", "link_state", "--debug-log", "link_relocs" });135 try child_args.appendSlice(arena, &.{ "--debug-log", "link", "--debug-log", "link_state", "--debug-log", "link_relocs" });
130 }136 }
tools/lldb_pretty_printers.py+18-17
...@@ -25,7 +25,7 @@ def create_struct(parent, name, struct_type, inits):...@@ -25,7 +25,7 @@ def create_struct(parent, name, struct_type, inits):
25 case lldb.eByteOrderBig:25 case lldb.eByteOrderBig:
26 byte_order = 'big'26 byte_order = 'big'
27 field_bytes = field_init.to_bytes(field_size, byte_order, signed=field.type.GetTypeFlags() & lldb.eTypeIsSigned != 0)27 field_bytes = field_init.to_bytes(field_size, byte_order, signed=field.type.GetTypeFlags() & lldb.eTypeIsSigned != 0)
28 elif isinstance(field_init_type, lldb.SBValue):28 elif isinstance(field_init, lldb.SBValue):
29 field_bytes = field_init.data.uint829 field_bytes = field_init.data.uint8
30 else: return30 else: return
31 match struct_data.byte_order:31 match struct_data.byte_order:
...@@ -731,7 +731,7 @@ def root_InternPool_Index_SummaryProvider(value, _=None):...@@ -731,7 +731,7 @@ def root_InternPool_Index_SummaryProvider(value, _=None):
731 if not unwrapped: return '' # .none731 if not unwrapped: return '' # .none
732 tag = unwrapped.GetChildMemberWithName('tag')732 tag = unwrapped.GetChildMemberWithName('tag')
733 tag_value = tag.value733 tag_value = tag.value
734 summary = tag.CreateValueFromType(tag.type).GetChildMemberWithName('encodings').GetChildMemberWithName(tag_value.removeprefix('.')).GetChildMemberWithName('summary')734 summary = tag.CreateValueFromType(tag.type).GetChildMemberWithName('encodings').GetChildMemberWithName(tag_value.removeprefix('.').removeprefix('@"').removesuffix('"').replace(r'\"', '"')).GetChildMemberWithName('summary')
735 if not summary: return tag_value735 if not summary: return tag_value
736 return re.sub(736 return re.sub(
737 expr_path_re,737 expr_path_re,
...@@ -767,7 +767,7 @@ class root_InternPool_Index_Unwrapped_SynthProvider:...@@ -767,7 +767,7 @@ class root_InternPool_Index_Unwrapped_SynthProvider:
767 shared = ip.GetChildMemberWithName('locals').GetSyntheticValue().child[self.value.GetChildMemberWithName('tid').unsigned].GetChildMemberWithName('shared')767 shared = ip.GetChildMemberWithName('locals').GetSyntheticValue().child[self.value.GetChildMemberWithName('tid').unsigned].GetChildMemberWithName('shared')
768 item = shared.GetChildMemberWithName('items').GetChildMemberWithName('view').child[index.unsigned]768 item = shared.GetChildMemberWithName('items').GetChildMemberWithName('view').child[index.unsigned]
769 self.tag, item_data = item.GetChildMemberWithName('tag'), item.GetChildMemberWithName('data')769 self.tag, item_data = item.GetChildMemberWithName('tag'), item.GetChildMemberWithName('data')
770 encoding = self.tag.CreateValueFromType(self.tag.type).GetChildMemberWithName('encodings').GetChildMemberWithName(self.tag.value.removeprefix('.'))770 encoding = self.tag.CreateValueFromType(self.tag.type).GetChildMemberWithName('encodings').GetChildMemberWithName(self.tag.value.removeprefix('.').removeprefix('@"').removesuffix('"').replace(r'\"', '"'))
771 encoding_index, encoding_data, encoding_payload, encoding_trailing, encoding_config = encoding.GetChildMemberWithName('index'), encoding.GetChildMemberWithName('data'), encoding.GetChildMemberWithName('payload'), encoding.GetChildMemberWithName('trailing'), encoding.GetChildMemberWithName('config')771 encoding_index, encoding_data, encoding_payload, encoding_trailing, encoding_config = encoding.GetChildMemberWithName('index'), encoding.GetChildMemberWithName('data'), encoding.GetChildMemberWithName('payload'), encoding.GetChildMemberWithName('trailing'), encoding.GetChildMemberWithName('config')
772 if encoding_index:772 if encoding_index:
773 index_type = encoding_index.GetValueAsType()773 index_type = encoding_index.GetValueAsType()
...@@ -869,6 +869,7 @@ class root_InternPool_Index_Unwrapped_SynthProvider:...@@ -869,6 +869,7 @@ class root_InternPool_Index_Unwrapped_SynthProvider:
869869
870def root_InternPool_String_SummaryProvider(value, _=None):870def root_InternPool_String_SummaryProvider(value, _=None):
871 wrapped = value.unsigned871 wrapped = value.unsigned
872 if wrapped == (1 << 32) - 1: return ''
872 ip = value.CreateValueFromType(value.type).GetChildMemberWithName('debug_state').GetChildMemberWithName('intern_pool').GetNonSyntheticValue().GetChildMemberWithName('?')873 ip = value.CreateValueFromType(value.type).GetChildMemberWithName('debug_state').GetChildMemberWithName('intern_pool').GetNonSyntheticValue().GetChildMemberWithName('?')
873 tid_shift_32 = ip.GetChildMemberWithName('tid_shift_32').unsigned874 tid_shift_32 = ip.GetChildMemberWithName('tid_shift_32').unsigned
874 locals_value = ip.GetChildMemberWithName('locals').GetSyntheticValue()875 locals_value = ip.GetChildMemberWithName('locals').GetSyntheticValue()
...@@ -880,24 +881,24 @@ def root_InternPool_String_SummaryProvider(value, _=None):...@@ -880,24 +881,24 @@ def root_InternPool_String_SummaryProvider(value, _=None):
880 string.format = lldb.eFormatCString881 string.format = lldb.eFormatCString
881 return string.value882 return string.value
882883
883class root_InternPool_Cau_Index_SynthProvider:884class root_InternPool_TrackedInst_Index_SynthProvider:
884 def __init__(self, value, _=None): self.value = value885 def __init__(self, value, _=None): self.value = value
885 def update(self):886 def update(self):
886 self.cau = None887 self.tracked_inst = None
887 wrapped = self.value.unsigned888 wrapped = self.value.unsigned
888 if wrapped == (1 << 32) - 1: return889 if wrapped == (1 << 32) - 1: return
889 ip = self.value.CreateValueFromType(self.value.type).GetChildMemberWithName('debug_state').GetChildMemberWithName('intern_pool').GetNonSyntheticValue().GetChildMemberWithName('?')890 ip = self.value.CreateValueFromType(self.value.type).GetChildMemberWithName('debug_state').GetChildMemberWithName('intern_pool').GetNonSyntheticValue().GetChildMemberWithName('?')
890 tid_shift_31 = ip.GetChildMemberWithName('tid_shift_31').unsigned891 tid_shift_32 = ip.GetChildMemberWithName('tid_shift_32').unsigned
891 locals_value = ip.GetChildMemberWithName('locals').GetSyntheticValue()892 locals_value = ip.GetChildMemberWithName('locals').GetSyntheticValue()
892 local_value = locals_value.child[wrapped >> tid_shift_31]893 local_value = locals_value.child[wrapped >> tid_shift_32]
893 if local_value is None:894 if local_value is None:
894 wrapped = 0895 wrapped = 0
895 local_value = locals_value.child[0]896 local_value = locals_value.child[0]
896 self.cau = local_value.GetChildMemberWithName('shared').GetChildMemberWithName('caus').GetChildMemberWithName('view').GetChildMemberWithName('0').child[wrapped & (1 << tid_shift_31) - 1]897 self.tracked_inst = local_value.GetChildMemberWithName('shared').GetChildMemberWithName('tracked_insts').GetChildMemberWithName('view').GetChildMemberWithName('0').child[wrapped & (1 << tid_shift_32) - 1]
897 def has_children(self): return self.cau.GetNumChildren(1) > 0898 def has_children(self): return False if self.tracked_inst is None else self.tracked_inst.GetNumChildren(1) > 0
898 def num_children(self): return self.cau.GetNumChildren()899 def num_children(self): return 0 if self.tracked_inst is None else self.tracked_inst.GetNumChildren()
899 def get_child_index(self, name): return self.cau.GetIndexOfChildWithName(name)900 def get_child_index(self, name): return -1 if self.tracked_inst is None else self.tracked_inst.GetIndexOfChildWithName(name)
900 def get_child_at_index(self, index): return self.cau.GetChildAtIndex(index)901 def get_child_at_index(self, index): return None if self.tracked_inst is None else self.tracked_inst.GetChildAtIndex(index)
901902
902class root_InternPool_Nav_Index_SynthProvider:903class root_InternPool_Nav_Index_SynthProvider:
903 def __init__(self, value, _=None): self.value = value904 def __init__(self, value, _=None): self.value = value
...@@ -913,10 +914,10 @@ class root_InternPool_Nav_Index_SynthProvider:...@@ -913,10 +914,10 @@ class root_InternPool_Nav_Index_SynthProvider:
913 wrapped = 0914 wrapped = 0
914 local_value = locals_value.child[0]915 local_value = locals_value.child[0]
915 self.nav = local_value.GetChildMemberWithName('shared').GetChildMemberWithName('navs').GetChildMemberWithName('view').child[wrapped & (1 << tid_shift_32) - 1]916 self.nav = local_value.GetChildMemberWithName('shared').GetChildMemberWithName('navs').GetChildMemberWithName('view').child[wrapped & (1 << tid_shift_32) - 1]
916 def has_children(self): return self.nav.GetNumChildren(1) > 0917 def has_children(self): return False if self.nav is None else self.nav.GetNumChildren(1) > 0
917 def num_children(self): return self.nav.GetNumChildren()918 def num_children(self): return 0 if self.nav is None else self.nav.GetNumChildren()
918 def get_child_index(self, name): return self.nav.GetIndexOfChildWithName(name)919 def get_child_index(self, name): return -1 if self.nav is None else self.nav.GetIndexOfChildWithName(name)
919 def get_child_at_index(self, index): return self.nav.GetChildAtIndex(index)920 def get_child_at_index(self, index): return None if self.nav is None else self.nav.GetChildAtIndex(index)
920921
921# Initialize922# Initialize
922923
...@@ -973,5 +974,5 @@ def __lldb_init_module(debugger, _=None):...@@ -973,5 +974,5 @@ def __lldb_init_module(debugger, _=None):
973 add(debugger, category='zig', type='root.InternPool.Index', synth=True, summary=True)974 add(debugger, category='zig', type='root.InternPool.Index', synth=True, summary=True)
974 add(debugger, category='zig', type='root.InternPool.Index.Unwrapped', synth=True)975 add(debugger, category='zig', type='root.InternPool.Index.Unwrapped', synth=True)
975 add(debugger, category='zig', regex=True, type=r'^root\.InternPool\.(Optional)?(NullTerminated)?String$', identifier='root_InternPool_String', summary=True)976 add(debugger, category='zig', regex=True, type=r'^root\.InternPool\.(Optional)?(NullTerminated)?String$', identifier='root_InternPool_String', summary=True)
976 add(debugger, category='zig', regex=True, type=r'^root\.InternPool\.Cau\.Index(\.Optional)?$', identifier='root_InternPool_Cau_Index', synth=True)977 add(debugger, category='zig', regex=True, type=r'^root\.InternPool\.TrackedInst\.Index(\.Optional)?$', identifier='root_InternPool_TrackedInst_Index', synth=True)
977 add(debugger, category='zig', regex=True, type=r'^root\.InternPool\.Nav\.Index(\.Optional)?$', identifier='root_InternPool_Nav_Index', synth=True)978 add(debugger, category='zig', regex=True, type=r'^root\.InternPool\.Nav\.Index(\.Optional)?$', identifier='root_InternPool_Nav_Index', synth=True)