| ... | ... | @@ -8,6 +8,7 @@ mods: std.AutoArrayHashMapUnmanaged(*Module, ModInfo), |
| 8 | 8 | types: std.AutoArrayHashMapUnmanaged(InternPool.Index, Entry.Index), |
| 9 | 9 | values: std.AutoArrayHashMapUnmanaged(InternPool.Index, Entry.Index), |
| 10 | 10 | navs: std.AutoArrayHashMapUnmanaged(InternPool.Nav.Index, Entry.Index), |
| 11 | decls: std.AutoArrayHashMapUnmanaged(InternPool.TrackedInst.Index, Entry.Index), |
| 11 | 12 | |
| 12 | 13 | debug_abbrev: DebugAbbrev, |
| 13 | 14 | debug_aranges: DebugAranges, |
| ... | ... | @@ -51,9 +52,7 @@ pub const AddressSize = enum(u8) { |
| 51 | 52 | const ModInfo = struct { |
| 52 | 53 | root_dir_path: Entry.Index, |
| 53 | 54 | dirs: std.AutoArrayHashMapUnmanaged(Unit.Index, void), |
| 54 | | files: Files, |
| 55 | | |
| 56 | | const Files = std.AutoArrayHashMapUnmanaged(Zcu.File.Index, void); |
| 55 | files: std.AutoArrayHashMapUnmanaged(Zcu.File.Index, void), |
| 57 | 56 | |
| 58 | 57 | fn deinit(mod_info: *ModInfo, gpa: std.mem.Allocator) void { |
| 59 | 58 | mod_info.dirs.deinit(gpa); |
| ... | ... | @@ -137,6 +136,20 @@ const DebugInfo = struct { |
| 137 | 136 | return AbbrevCode.decl_bytes + dwarf.sectionOffsetBytes(); |
| 138 | 137 | } |
| 139 | 138 | |
| 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 | 153 | const trailer_bytes = 1 + 1; |
| 141 | 154 | }; |
| 142 | 155 | |
| ... | ... | @@ -206,8 +219,8 @@ const StringSection = struct { |
| 206 | 219 | const unit: Unit.Index = @enumFromInt(0); |
| 207 | 220 | |
| 208 | 221 | const init: StringSection = .{ |
| 209 | | .contents = .{}, |
| 210 | | .map = .{}, |
| 222 | .contents = .empty, |
| 223 | .map = .empty, |
| 211 | 224 | .section = Section.init, |
| 212 | 225 | }; |
| 213 | 226 | |
| ... | ... | @@ -219,9 +232,9 @@ const StringSection = struct { |
| 219 | 232 | |
| 220 | 233 | fn addString(str_sec: *StringSection, dwarf: *Dwarf, str: []const u8) UpdateError!Entry.Index { |
| 221 | 234 | const gop = try str_sec.map.getOrPutAdapted(dwarf.gpa, str, Adapter{ .str_sec = str_sec }); |
| 222 | | errdefer _ = str_sec.map.pop(); |
| 223 | 235 | const entry: Entry.Index = @enumFromInt(gop.index); |
| 224 | 236 | if (!gop.found_existing) { |
| 237 | errdefer _ = str_sec.map.pop(); |
| 225 | 238 | const unit_ptr = str_sec.section.getUnit(unit); |
| 226 | 239 | assert(try str_sec.section.getUnit(unit).addEntry(dwarf.gpa) == entry); |
| 227 | 240 | errdefer _ = unit_ptr.entries.pop(); |
| ... | ... | @@ -284,7 +297,7 @@ pub const Section = struct { |
| 284 | 297 | .index = std.math.maxInt(u32), |
| 285 | 298 | .first = .none, |
| 286 | 299 | .last = .none, |
| 287 | | .units = .{}, |
| 300 | .units = .empty, |
| 288 | 301 | .len = 0, |
| 289 | 302 | }; |
| 290 | 303 | |
| ... | ... | @@ -319,13 +332,14 @@ pub const Section = struct { |
| 319 | 332 | .next = .none, |
| 320 | 333 | .first = .none, |
| 321 | 334 | .last = .none, |
| 335 | .free = .none, |
| 322 | 336 | .header_len = aligned_header_len, |
| 323 | 337 | .trailer_len = aligned_trailer_len, |
| 324 | 338 | .off = 0, |
| 325 | 339 | .len = aligned_header_len + aligned_trailer_len, |
| 326 | | .entries = .{}, |
| 327 | | .cross_unit_relocs = .{}, |
| 328 | | .cross_section_relocs = .{}, |
| 340 | .entries = .empty, |
| 341 | .cross_unit_relocs = .empty, |
| 342 | .cross_section_relocs = .empty, |
| 329 | 343 | }; |
| 330 | 344 | if (sec.last.unwrap()) |last_unit| { |
| 331 | 345 | const last_unit_ptr = sec.getUnit(last_unit); |
| ... | ... | @@ -385,6 +399,28 @@ pub const Section = struct { |
| 385 | 399 | try unit_ptr.getEntry(entry).replace(unit_ptr, sec, dwarf, contents); |
| 386 | 400 | } |
| 387 | 401 | |
| 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 | 424 | fn resize(sec: *Section, dwarf: *Dwarf, len: u64) UpdateError!void { |
| 389 | 425 | if (len <= sec.len) return; |
| 390 | 426 | if (dwarf.bin_file.cast(.elf)) |elf_file| { |
| ... | ... | @@ -449,6 +485,7 @@ const Unit = struct { |
| 449 | 485 | next: Index.Optional, |
| 450 | 486 | first: Entry.Index.Optional, |
| 451 | 487 | last: Entry.Index.Optional, |
| 488 | free: Entry.Index.Optional, |
| 452 | 489 | /// offset within containing section |
| 453 | 490 | off: u32, |
| 454 | 491 | header_len: u32, |
| ... | ... | @@ -491,6 +528,12 @@ const Unit = struct { |
| 491 | 528 | } |
| 492 | 529 | |
| 493 | 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 | 537 | const entry: Entry.Index = @enumFromInt(unit.entries.items.len); |
| 495 | 538 | const entry_ptr = try unit.entries.addOne(gpa); |
| 496 | 539 | entry_ptr.* = .{ |
| ... | ... | @@ -498,10 +541,10 @@ const Unit = struct { |
| 498 | 541 | .next = .none, |
| 499 | 542 | .off = 0, |
| 500 | 543 | .len = 0, |
| 501 | | .cross_entry_relocs = .{}, |
| 502 | | .cross_unit_relocs = .{}, |
| 503 | | .cross_section_relocs = .{}, |
| 504 | | .external_relocs = .{}, |
| 544 | .cross_entry_relocs = .empty, |
| 545 | .cross_unit_relocs = .empty, |
| 546 | .cross_section_relocs = .empty, |
| 547 | .external_relocs = .empty, |
| 505 | 548 | }; |
| 506 | 549 | return entry; |
| 507 | 550 | } |
| ... | ... | @@ -1583,7 +1626,7 @@ pub const WipNav = struct { |
| 1583 | 1626 | const dlw = wip_nav.debug_line.writer(dwarf.gpa); |
| 1584 | 1627 | if (dwarf.incremental()) { |
| 1585 | 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 | 1630 | if (!new_nav_gop.found_existing) new_nav_gop.value_ptr.* = try dwarf.addCommonEntry(new_unit); |
| 1588 | 1631 | |
| 1589 | 1632 | try dlw.writeByte(DW.LNS.extended_op); |
| ... | ... | @@ -1603,10 +1646,8 @@ pub const WipNav = struct { |
| 1603 | 1646 | const old_file = zcu.navFileScopeIndex(old_func_info.owner_nav); |
| 1604 | 1647 | if (old_file != new_file) { |
| 1605 | 1648 | const mod_info = dwarf.getModInfo(wip_nav.unit); |
| 1606 | | const mod_gop = try mod_info.dirs.getOrPut(dwarf.gpa, new_unit); |
| 1607 | | errdefer _ = if (!mod_gop.found_existing) mod_info.dirs.pop(); |
| 1649 | try mod_info.dirs.put(dwarf.gpa, new_unit, {}); |
| 1608 | 1650 | const file_gop = try mod_info.files.getOrPut(dwarf.gpa, new_file); |
| 1609 | | errdefer _ = if (!file_gop.found_existing) mod_info.files.pop(); |
| 1610 | 1651 | |
| 1611 | 1652 | try dlw.writeByte(DW.LNS.set_file); |
| 1612 | 1653 | try uleb128(dlw, file_gop.index); |
| ... | ... | @@ -1934,6 +1975,90 @@ pub const WipNav = struct { |
| 1934 | 1975 | std.math.big.int.Mutable.init(&big_int_space.limbs, field_index).toConst()); |
| 1935 | 1976 | } |
| 1936 | 1977 | |
| 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 | 2062 | fn updateLazy(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc) UpdateError!void { |
| 1938 | 2063 | const ip = &wip_nav.pt.zcu.intern_pool; |
| 1939 | 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 | 2091 | }, |
| 1967 | 2092 | .endian = target.cpu.arch.endian(), |
| 1968 | 2093 | |
| 1969 | | .mods = .{}, |
| 1970 | | .types = .{}, |
| 1971 | | .values = .{}, |
| 1972 | | .navs = .{}, |
| 2094 | .mods = .empty, |
| 2095 | .types = .empty, |
| 2096 | .values = .empty, |
| 2097 | .navs = .empty, |
| 2098 | .decls = .empty, |
| 1973 | 2099 | |
| 1974 | 2100 | .debug_abbrev = .{ .section = Section.init }, |
| 1975 | 2101 | .debug_aranges = .{ .section = Section.init }, |
| ... | ... | @@ -2142,6 +2268,7 @@ pub fn deinit(dwarf: *Dwarf) void { |
| 2142 | 2268 | dwarf.types.deinit(gpa); |
| 2143 | 2269 | dwarf.values.deinit(gpa); |
| 2144 | 2270 | dwarf.navs.deinit(gpa); |
| 2271 | dwarf.decls.deinit(gpa); |
| 2145 | 2272 | dwarf.debug_abbrev.section.deinit(gpa); |
| 2146 | 2273 | dwarf.debug_aranges.section.deinit(gpa); |
| 2147 | 2274 | dwarf.debug_frame.section.deinit(gpa); |
| ... | ... | @@ -2161,8 +2288,8 @@ fn getUnit(dwarf: *Dwarf, mod: *Module) UpdateError!Unit.Index { |
| 2161 | 2288 | errdefer _ = dwarf.mods.pop(); |
| 2162 | 2289 | mod_gop.value_ptr.* = .{ |
| 2163 | 2290 | .root_dir_path = undefined, |
| 2164 | | .dirs = .{}, |
| 2165 | | .files = .{}, |
| 2291 | .dirs = .empty, |
| 2292 | .files = .empty, |
| 2166 | 2293 | }; |
| 2167 | 2294 | errdefer mod_gop.value_ptr.dirs.deinit(dwarf.gpa); |
| 2168 | 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 | 2346 | const ip = &zcu.intern_pool; |
| 2220 | 2347 | |
| 2221 | 2348 | const nav = ip.getNav(nav_index); |
| 2222 | | log.debug("initWipNav({})", .{nav.fqn.fmt(ip)}); |
| 2223 | | |
| 2224 | 2349 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; |
| 2225 | 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 | } |
| 2226 | 2367 | |
| 2227 | 2368 | const unit = try dwarf.getUnit(file.mod); |
| 2228 | 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 | 2371 | if (nav_gop.found_existing) { |
| 2231 | 2372 | for ([_]*Section{ |
| 2232 | 2373 | &dwarf.debug_aranges.section, |
| ... | ... | @@ -2236,7 +2377,6 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In |
| 2236 | 2377 | &dwarf.debug_rnglists.section, |
| 2237 | 2378 | }) |sec| sec.getUnit(unit).getEntry(nav_gop.value_ptr.*).clear(); |
| 2238 | 2379 | } else nav_gop.value_ptr.* = try dwarf.addCommonEntry(unit); |
| 2239 | | const nav_val = zcu.navValue(nav_index); |
| 2240 | 2380 | var wip_nav: WipNav = .{ |
| 2241 | 2381 | .dwarf = dwarf, |
| 2242 | 2382 | .pt = pt, |
| ... | ... | @@ -2248,91 +2388,52 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In |
| 2248 | 2388 | .func_high_pc = undefined, |
| 2249 | 2389 | .blocks = undefined, |
| 2250 | 2390 | .cfi = undefined, |
| 2251 | | .debug_frame = .{}, |
| 2252 | | .debug_info = .{}, |
| 2253 | | .debug_line = .{}, |
| 2254 | | .debug_loclists = .{}, |
| 2255 | | .pending_lazy = .{}, |
| 2391 | .debug_frame = .empty, |
| 2392 | .debug_info = .empty, |
| 2393 | .debug_line = .empty, |
| 2394 | .debug_loclists = .empty, |
| 2395 | .pending_lazy = .empty, |
| 2256 | 2396 | }; |
| 2257 | 2397 | errdefer wip_nav.deinit(); |
| 2258 | 2398 | |
| 2259 | | switch (ip.indexToKey(nav_val.toIntern())) { |
| 2399 | switch (nav_key) { |
| 2260 | 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 | 2401 | const diw = wip_nav.debug_info.writer(dwarf.gpa); |
| 2273 | | try wip_nav.abbrevCode(.decl_var); |
| 2274 | | try wip_nav.refType(.fromInterned(parent_type)); |
| 2275 | | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2276 | | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2277 | | try uleb128(diw, decl.src_column + 1); |
| 2278 | | try diw.writeByte(accessibility); |
| 2279 | | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2402 | try wip_nav.declCommon(.{ |
| 2403 | .decl = .decl_var, |
| 2404 | .generic_decl = .generic_decl_var, |
| 2405 | .instance = .instance_var, |
| 2406 | }, &nav, inst_info.file, &decl); |
| 2280 | 2407 | try wip_nav.strp(nav.fqn.toSlice(ip)); |
| 2281 | | const nav_ty = 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); |
| 2408 | const ty: Type = nav_val.typeOf(zcu); |
| 2314 | 2409 | const addr: Loc = .{ .addr = .{ .sym = sym_index } }; |
| 2315 | | try wip_nav.infoExprloc(if (variable.is_threadlocal) .{ .form_tls_address = &addr } else addr); |
| 2316 | | try uleb128(diw, nav.status.fully_resolved.alignment.toByteUnits() orelse |
| 2317 | | ty.abiAlignment(zcu).toByteUnits().?); |
| 2318 | | try diw.writeByte(@intFromBool(false)); |
| 2410 | const loc: Loc = if (decl.is_threadlocal) .{ .form_tls_address = &addr } else addr; |
| 2411 | switch (decl.kind) { |
| 2412 | .unnamed_test, .@"test", .decltest, .@"comptime", .@"usingnamespace" => unreachable, |
| 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 | 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 | 2433 | const func_type = ip.indexToKey(func.ty).func_type; |
| 2333 | 2434 | wip_nav.func = nav_val.toIntern(); |
| 2334 | 2435 | wip_nav.func_sym_index = sym_index; |
| 2335 | | wip_nav.blocks = .{}; |
| 2436 | wip_nav.blocks = .empty; |
| 2336 | 2437 | if (dwarf.debug_frame.header.format != .none) wip_nav.cfi = .{ |
| 2337 | 2438 | .loc = 0, |
| 2338 | 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 | 2476 | } |
| 2376 | 2477 | |
| 2377 | 2478 | const diw = wip_nav.debug_info.writer(dwarf.gpa); |
| 2378 | | try wip_nav.abbrevCode(.decl_func); |
| 2379 | | try wip_nav.refType(.fromInterned(parent_type)); |
| 2380 | | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2381 | | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2382 | | try uleb128(diw, decl.src_column + 1); |
| 2383 | | try diw.writeByte(accessibility); |
| 2384 | | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2479 | try wip_nav.declCommon(.{ |
| 2480 | .decl = .decl_func, |
| 2481 | .generic_decl = .generic_decl_func, |
| 2482 | .instance = .instance_func, |
| 2483 | }, &nav, inst_info.file, &decl); |
| 2385 | 2484 | try wip_nav.strp(nav.fqn.toSlice(ip)); |
| 2386 | 2485 | try wip_nav.refType(.fromInterned(func_type.return_type)); |
| 2387 | 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 | 2491 | .none => target_info.defaultFunctionAlignment(target), |
| 2393 | 2492 | else => |a| a.maxStrict(target_info.minFunctionAlignment(target)), |
| 2394 | 2493 | }.toByteUnits().?); |
| 2395 | | try diw.writeByte(@intFromBool(false)); |
| 2494 | try diw.writeByte(@intFromBool(decl.linkage != .normal)); |
| 2396 | 2495 | try diw.writeByte(@intFromBool(func_type.return_type == .noreturn_type)); |
| 2397 | 2496 | |
| 2398 | 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 | 2534 | return wip_nav; |
| 2436 | 2535 | } |
| 2437 | 2536 | |
| 2438 | | pub fn finishWipNav( |
| 2537 | pub fn finishWipNavFunc( |
| 2439 | 2538 | dwarf: *Dwarf, |
| 2440 | 2539 | pt: Zcu.PerThread, |
| 2441 | 2540 | nav_index: InternPool.Nav.Index, |
| 2442 | | sym: struct { index: u32, addr: u64, size: u64 }, |
| 2541 | code_size: u64, |
| 2443 | 2542 | wip_nav: *WipNav, |
| 2444 | 2543 | ) UpdateError!void { |
| 2445 | 2544 | const zcu = pt.zcu; |
| 2446 | 2545 | const ip = &zcu.intern_pool; |
| 2447 | 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)}); |
| 2449 | 2549 | |
| 2450 | | if (wip_nav.func != .none) { |
| 2451 | | { |
| 2452 | | const external_relocs = &dwarf.debug_aranges.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs; |
| 2453 | | try external_relocs.append(dwarf.gpa, .{ .target_sym = sym.index }); |
| 2454 | | var entry: [8 + 8]u8 = undefined; |
| 2455 | | @memset(entry[0..@intFromEnum(dwarf.address_size)], 0); |
| 2456 | | dwarf.writeInt(entry[@intFromEnum(dwarf.address_size)..][0..@intFromEnum(dwarf.address_size)], sym.size); |
| 2457 | | try dwarf.debug_aranges.section.replaceEntry( |
| 2458 | | wip_nav.unit, |
| 2459 | | wip_nav.entry, |
| 2460 | | dwarf, |
| 2461 | | entry[0 .. @intFromEnum(dwarf.address_size) * 2], |
| 2462 | | ); |
| 2463 | | } |
| 2464 | | switch (dwarf.debug_frame.header.format) { |
| 2465 | | .none => {}, |
| 2466 | | .debug_frame, .eh_frame => |format| { |
| 2467 | | try wip_nav.debug_frame.appendNTimes( |
| 2468 | | dwarf.gpa, |
| 2469 | | DW.CFA.nop, |
| 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), |
| 2550 | { |
| 2551 | 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 }); |
| 2553 | var entry: [8 + 8]u8 = undefined; |
| 2554 | @memset(entry[0..@intFromEnum(dwarf.address_size)], 0); |
| 2555 | dwarf.writeInt(entry[@intFromEnum(dwarf.address_size)..][0..@intFromEnum(dwarf.address_size)], code_size); |
| 2556 | try dwarf.debug_aranges.section.replaceEntry( |
| 2557 | wip_nav.unit, |
| 2558 | wip_nav.entry, |
| 2559 | dwarf, |
| 2560 | entry[0 .. @intFromEnum(dwarf.address_size) * 2], |
| 2561 | ); |
| 2562 | } |
| 2563 | switch (dwarf.debug_frame.header.format) { |
| 2564 | .none => {}, |
| 2565 | .debug_frame, .eh_frame => |format| { |
| 2566 | try wip_nav.debug_frame.appendNTimes( |
| 2567 | dwarf.gpa, |
| 2568 | DW.CFA.nop, |
| 2569 | @intCast(dwarf.debug_frame.section.alignment.forward(wip_nav.debug_frame.items.len) - wip_nav.debug_frame.items.len), |
| 2507 | 2570 | ); |
| 2508 | | } |
| 2509 | | { |
| 2510 | | try dwarf.debug_rnglists.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs.appendSlice(dwarf.gpa, &.{ |
| 2511 | | .{ |
| 2512 | | .source_off = 1, |
| 2513 | | .target_sym = sym.index, |
| 2514 | | }, |
| 2515 | | .{ |
| 2516 | | .source_off = 1 + @intFromEnum(dwarf.address_size), |
| 2517 | | .target_sym = sym.index, |
| 2518 | | .target_off = sym.size, |
| 2571 | const contents = wip_nav.debug_frame.items; |
| 2572 | try dwarf.debug_frame.section.resizeEntry(wip_nav.unit, wip_nav.entry, dwarf, @intCast(contents.len)); |
| 2573 | const unit = dwarf.debug_frame.section.getUnit(wip_nav.unit); |
| 2574 | const entry = unit.getEntry(wip_nav.entry); |
| 2575 | const unit_len = (if (entry.next.unwrap()) |next_entry| |
| 2576 | unit.getEntry(next_entry).off - entry.off |
| 2577 | else |
| 2578 | entry.len) - dwarf.unitLengthBytes(); |
| 2579 | dwarf.writeInt(contents[dwarf.unitLengthBytes() - dwarf.sectionOffsetBytes() ..][0..dwarf.sectionOffsetBytes()], unit_len); |
| 2580 | switch (format) { |
| 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 | | }); |
| 2521 | | try dwarf.debug_rnglists.section.replaceEntry( |
| 2522 | | wip_nav.unit, |
| 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 | | } |
| 2593 | } |
| 2594 | try entry.replace(unit, &dwarf.debug_frame.section, dwarf, contents); |
| 2595 | }, |
| 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 | |
| 2631 | pub 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)}); |
| 2529 | 2641 | |
| 2530 | 2642 | try dwarf.debug_info.section.replaceEntry(wip_nav.unit, wip_nav.entry, dwarf, wip_nav.debug_info.items); |
| 2531 | 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 | 2659 | const nav_val = zcu.navValue(nav_index); |
| 2548 | 2660 | |
| 2549 | 2661 | const nav = ip.getNav(nav_index); |
| 2550 | | log.debug("updateComptimeNav({})", .{nav.fqn.fmt(ip)}); |
| 2551 | | |
| 2552 | 2662 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; |
| 2553 | 2663 | const file = zcu.fileByIndex(inst_info.file); |
| 2554 | 2664 | assert(file.zir_loaded); |
| 2555 | 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 | }); |
| 2556 | 2673 | |
| 2557 | 2674 | const is_test = switch (decl.kind) { |
| 2558 | 2675 | .unnamed_test, .@"test", .decltest => true, |
| ... | ... | @@ -2563,14 +2680,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2563 | 2680 | return; |
| 2564 | 2681 | } |
| 2565 | 2682 | |
| 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 | 2683 | var wip_nav: WipNav = .{ |
| 2575 | 2684 | .dwarf = dwarf, |
| 2576 | 2685 | .pt = pt, |
| ... | ... | @@ -2582,16 +2691,16 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2582 | 2691 | .func_high_pc = undefined, |
| 2583 | 2692 | .blocks = undefined, |
| 2584 | 2693 | .cfi = undefined, |
| 2585 | | .debug_frame = .{}, |
| 2586 | | .debug_info = .{}, |
| 2587 | | .debug_line = .{}, |
| 2588 | | .debug_loclists = .{}, |
| 2589 | | .pending_lazy = .{}, |
| 2694 | .debug_frame = .empty, |
| 2695 | .debug_info = .empty, |
| 2696 | .debug_line = .empty, |
| 2697 | .debug_loclists = .empty, |
| 2698 | .pending_lazy = .empty, |
| 2590 | 2699 | }; |
| 2591 | 2700 | defer wip_nav.deinit(); |
| 2592 | 2701 | |
| 2593 | 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(); |
| 2595 | 2704 | |
| 2596 | 2705 | const tag: enum { done, decl_alias, decl_var, decl_const } = switch (ip.indexToKey(nav_val.toIntern())) { |
| 2597 | 2706 | .int_type, |
| ... | ... | @@ -2609,9 +2718,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2609 | 2718 | => .decl_alias, |
| 2610 | 2719 | .struct_type => tag: { |
| 2611 | 2720 | const loaded_struct = ip.loadStructType(nav_val.toIntern()); |
| 2612 | | |
| 2613 | | const type_inst_info = loaded_struct.zir_index.resolveFull(ip).?; |
| 2614 | | if (type_inst_info.file != inst_info.file) break :tag .decl_alias; |
| 2721 | if (loaded_struct.zir_index.resolveFile(ip) != inst_info.file) break :tag .decl_alias; |
| 2615 | 2722 | |
| 2616 | 2723 | const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern()); |
| 2617 | 2724 | if (type_gop.found_existing) { |
| ... | ... | @@ -2630,13 +2737,15 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2630 | 2737 | |
| 2631 | 2738 | switch (loaded_struct.layout) { |
| 2632 | 2739 | .auto, .@"extern" => { |
| 2633 | | try wip_nav.abbrevCode(if (loaded_struct.field_types.len == 0) .decl_namespace_struct else .decl_struct); |
| 2634 | | try wip_nav.refType(.fromInterned(parent_type)); |
| 2635 | | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2636 | | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2637 | | try uleb128(diw, decl.src_column + 1); |
| 2638 | | try diw.writeByte(accessibility); |
| 2639 | | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2740 | try wip_nav.declCommon(if (loaded_struct.field_types.len == 0) .{ |
| 2741 | .decl = .decl_namespace_struct, |
| 2742 | .generic_decl = .generic_decl_struct, |
| 2743 | .instance = .instance_namespace_struct, |
| 2744 | } else .{ |
| 2745 | .decl = .decl_struct, |
| 2746 | .generic_decl = .generic_decl_struct, |
| 2747 | .instance = .instance_struct, |
| 2748 | }, &nav, inst_info.file, &decl); |
| 2640 | 2749 | if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else { |
| 2641 | 2750 | try uleb128(diw, nav_val.toType().abiSize(zcu)); |
| 2642 | 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 | 2797 | } |
| 2689 | 2798 | }, |
| 2690 | 2799 | .@"packed" => { |
| 2691 | | try wip_nav.abbrevCode(.decl_packed_struct); |
| 2692 | | try wip_nav.refType(.fromInterned(parent_type)); |
| 2693 | | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2694 | | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2695 | | try uleb128(diw, decl.src_column + 1); |
| 2696 | | try diw.writeByte(accessibility); |
| 2697 | | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2800 | try wip_nav.declCommon(.{ |
| 2801 | .decl = .decl_packed_struct, |
| 2802 | .generic_decl = .generic_decl_struct, |
| 2803 | .instance = .instance_packed_struct, |
| 2804 | }, &nav, inst_info.file, &decl); |
| 2698 | 2805 | try wip_nav.refType(.fromInterned(loaded_struct.backingIntTypeUnordered(ip))); |
| 2699 | 2806 | var field_bit_offset: u16 = 0; |
| 2700 | 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 | 2819 | }, |
| 2713 | 2820 | .enum_type => tag: { |
| 2714 | 2821 | const loaded_enum = ip.loadEnumType(nav_val.toIntern()); |
| 2715 | | if (loaded_enum.zir_index == .none) break :tag .decl_alias; |
| 2716 | | |
| 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; |
| 2822 | const type_zir_index = loaded_enum.zir_index.unwrap() orelse break :tag .decl_alias; |
| 2823 | if (type_zir_index.resolveFile(ip) != inst_info.file) break :tag .decl_alias; |
| 2719 | 2824 | |
| 2720 | 2825 | const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern()); |
| 2721 | 2826 | if (type_gop.found_existing) { |
| ... | ... | @@ -2730,13 +2835,15 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2730 | 2835 | } |
| 2731 | 2836 | wip_nav.entry = nav_gop.value_ptr.*; |
| 2732 | 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); |
| 2734 | | try wip_nav.refType(.fromInterned(parent_type)); |
| 2735 | | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2736 | | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2737 | | try uleb128(diw, decl.src_column + 1); |
| 2738 | | try diw.writeByte(accessibility); |
| 2739 | | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2838 | try wip_nav.declCommon(if (loaded_enum.names.len > 0) .{ |
| 2839 | .decl = .decl_enum, |
| 2840 | .generic_decl = .generic_decl_enum, |
| 2841 | .instance = .instance_enum, |
| 2842 | } else .{ |
| 2843 | .decl = .decl_empty_enum, |
| 2844 | .generic_decl = .generic_decl_enum, |
| 2845 | .instance = .instance_empty_enum, |
| 2846 | }, &nav, inst_info.file, &decl); |
| 2740 | 2847 | try wip_nav.refType(.fromInterned(loaded_enum.tag_ty)); |
| 2741 | 2848 | for (0..loaded_enum.names.len) |field_index| { |
| 2742 | 2849 | try wip_nav.enumConstValue(loaded_enum, .{ |
| ... | ... | @@ -2751,9 +2858,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2751 | 2858 | }, |
| 2752 | 2859 | .union_type => tag: { |
| 2753 | 2860 | const loaded_union = ip.loadUnionType(nav_val.toIntern()); |
| 2754 | | |
| 2755 | | const type_inst_info = loaded_union.zir_index.resolveFull(ip).?; |
| 2756 | | if (type_inst_info.file != inst_info.file) break :tag .decl_alias; |
| 2861 | if (loaded_union.zir_index.resolveFile(ip) != inst_info.file) break :tag .decl_alias; |
| 2757 | 2862 | |
| 2758 | 2863 | const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern()); |
| 2759 | 2864 | if (type_gop.found_existing) { |
| ... | ... | @@ -2768,13 +2873,11 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2768 | 2873 | } |
| 2769 | 2874 | wip_nav.entry = nav_gop.value_ptr.*; |
| 2770 | 2875 | const diw = wip_nav.debug_info.writer(dwarf.gpa); |
| 2771 | | try wip_nav.abbrevCode(.decl_union); |
| 2772 | | try wip_nav.refType(.fromInterned(parent_type)); |
| 2773 | | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2774 | | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2775 | | try uleb128(diw, decl.src_column + 1); |
| 2776 | | try diw.writeByte(accessibility); |
| 2777 | | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2876 | try wip_nav.declCommon(.{ |
| 2877 | .decl = .decl_union, |
| 2878 | .generic_decl = .generic_decl_union, |
| 2879 | .instance = .instance_union, |
| 2880 | }, &nav, inst_info.file, &decl); |
| 2778 | 2881 | const union_layout = Type.getUnionLayout(loaded_union, zcu); |
| 2779 | 2882 | try uleb128(diw, union_layout.abi_size); |
| 2780 | 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 | 2928 | }, |
| 2826 | 2929 | .opaque_type => tag: { |
| 2827 | 2930 | const loaded_opaque = ip.loadOpaqueType(nav_val.toIntern()); |
| 2828 | | |
| 2829 | | const type_inst_info = loaded_opaque.zir_index.resolveFull(ip).?; |
| 2830 | | if (type_inst_info.file != inst_info.file) break :tag .decl_alias; |
| 2931 | if (loaded_opaque.zir_index.resolveFile(ip) != inst_info.file) break :tag .decl_alias; |
| 2831 | 2932 | |
| 2832 | 2933 | const type_gop = try dwarf.types.getOrPut(dwarf.gpa, nav_val.toIntern()); |
| 2833 | 2934 | if (type_gop.found_existing) { |
| ... | ... | @@ -2842,19 +2943,16 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2842 | 2943 | } |
| 2843 | 2944 | wip_nav.entry = nav_gop.value_ptr.*; |
| 2844 | 2945 | const diw = wip_nav.debug_info.writer(dwarf.gpa); |
| 2845 | | try wip_nav.abbrevCode(.decl_namespace_struct); |
| 2846 | | try wip_nav.refType(.fromInterned(parent_type)); |
| 2847 | | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2848 | | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2849 | | try uleb128(diw, decl.src_column + 1); |
| 2850 | | try diw.writeByte(accessibility); |
| 2851 | | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2852 | | try diw.writeByte(@intFromBool(false)); |
| 2946 | try wip_nav.declCommon(.{ |
| 2947 | .decl = .decl_namespace_struct, |
| 2948 | .generic_decl = .generic_decl_struct, |
| 2949 | .instance = .instance_namespace_struct, |
| 2950 | }, &nav, inst_info.file, &decl); |
| 2951 | try diw.writeByte(@intFromBool(true)); |
| 2853 | 2952 | break :tag .done; |
| 2854 | 2953 | }, |
| 2855 | 2954 | .undef, |
| 2856 | 2955 | .simple_value, |
| 2857 | | .@"extern", |
| 2858 | 2956 | .int, |
| 2859 | 2957 | .err, |
| 2860 | 2958 | .error_union, |
| ... | ... | @@ -2869,42 +2967,31 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2869 | 2967 | .un, |
| 2870 | 2968 | => .decl_const, |
| 2871 | 2969 | .variable => .decl_var, |
| 2970 | .@"extern" => unreachable, |
| 2872 | 2971 | .func => |func| tag: { |
| 2873 | | if (nav_gop.found_existing) { |
| 2874 | | const unit_ptr = dwarf.debug_info.section.getUnit(wip_nav.unit); |
| 2875 | | const entry_ptr = unit_ptr.getEntry(nav_gop.value_ptr.*); |
| 2876 | | if (entry_ptr.len >= AbbrevCode.decl_bytes) { |
| 2877 | | var abbrev_code_buf: [AbbrevCode.decl_bytes]u8 = undefined; |
| 2878 | | if (try dwarf.getFile().?.preadAll( |
| 2879 | | &abbrev_code_buf, |
| 2880 | | dwarf.debug_info.section.off(dwarf) + unit_ptr.off + unit_ptr.header_len + entry_ptr.off, |
| 2881 | | ) != abbrev_code_buf.len) return error.InputOutput; |
| 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(); |
| 2972 | if (nav_gop.found_existing) switch (try dwarf.debug_info.declAbbrevCode(wip_nav.unit, nav_gop.value_ptr.*)) { |
| 2973 | .null => {}, |
| 2974 | else => unreachable, |
| 2975 | .decl_func, .decl_empty_func, .instance_func, .instance_empty_func => return, |
| 2976 | .decl_func_generic, |
| 2977 | .decl_empty_func_generic, |
| 2978 | .instance_func_generic, |
| 2979 | .instance_empty_func_generic, |
| 2980 | => dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(nav_gop.value_ptr.*).clear(), |
| 2893 | 2981 | } else nav_gop.value_ptr.* = try dwarf.addCommonEntry(wip_nav.unit); |
| 2894 | 2982 | wip_nav.entry = nav_gop.value_ptr.*; |
| 2895 | 2983 | |
| 2896 | 2984 | const func_type = ip.indexToKey(func.ty).func_type; |
| 2897 | 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) |
| 2899 | | .decl_func_generic |
| 2900 | | else |
| 2901 | | .decl_empty_func_generic); |
| 2902 | | try wip_nav.refType(.fromInterned(parent_type)); |
| 2903 | | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2904 | | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2905 | | try uleb128(diw, decl.src_column + 1); |
| 2906 | | try diw.writeByte(accessibility); |
| 2907 | | try wip_nav.strp(nav.name.toSlice(ip)); |
| 2986 | try wip_nav.declCommon(if (func_type.param_types.len > 0 or func_type.is_var_args) .{ |
| 2987 | .decl = .decl_func_generic, |
| 2988 | .generic_decl = .generic_decl_func, |
| 2989 | .instance = .instance_func_generic, |
| 2990 | } else .{ |
| 2991 | .decl = .decl_empty_func_generic, |
| 2992 | .generic_decl = .generic_decl_func, |
| 2993 | .instance = .instance_empty_func_generic, |
| 2994 | }, &nav, inst_info.file, &decl); |
| 2908 | 2995 | try wip_nav.refType(.fromInterned(func_type.return_type)); |
| 2909 | 2996 | if (func_type.param_types.len > 0 or func_type.is_var_args) { |
| 2910 | 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 | 3016 | switch (tag) { |
| 2930 | 3017 | .done => {}, |
| 2931 | 3018 | .decl_alias => { |
| 2932 | | const diw = wip_nav.debug_info.writer(dwarf.gpa); |
| 2933 | | try wip_nav.abbrevCode(.decl_alias); |
| 2934 | | try wip_nav.refType(.fromInterned(parent_type)); |
| 2935 | | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2936 | | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2937 | | try uleb128(diw, decl.src_column + 1); |
| 2938 | | try diw.writeByte(accessibility); |
| 2939 | | try wip_nav.strp(nav.name.toSlice(ip)); |
| 3019 | try wip_nav.declCommon(.{ |
| 3020 | .decl = .decl_alias, |
| 3021 | .generic_decl = .generic_decl_alias, |
| 3022 | .instance = .instance_alias, |
| 3023 | }, &nav, inst_info.file, &decl); |
| 2940 | 3024 | try wip_nav.refType(nav_val.toType()); |
| 2941 | 3025 | }, |
| 2942 | 3026 | .decl_var => { |
| 2943 | 3027 | const diw = wip_nav.debug_info.writer(dwarf.gpa); |
| 2944 | | try wip_nav.abbrevCode(.decl_var); |
| 2945 | | try wip_nav.refType(.fromInterned(parent_type)); |
| 2946 | | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2947 | | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2948 | | try uleb128(diw, decl.src_column + 1); |
| 2949 | | try diw.writeByte(accessibility); |
| 2950 | | try wip_nav.strp(nav.name.toSlice(ip)); |
| 3028 | try wip_nav.declCommon(.{ |
| 3029 | .decl = .decl_var, |
| 3030 | .generic_decl = .generic_decl_var, |
| 3031 | .instance = .instance_var, |
| 3032 | }, &nav, inst_info.file, &decl); |
| 2951 | 3033 | try wip_nav.strp(nav.fqn.toSlice(ip)); |
| 2952 | 3034 | const nav_ty = nav_val.typeOf(zcu); |
| 2953 | 3035 | try wip_nav.refType(nav_ty); |
| 2954 | 3036 | try wip_nav.blockValue(nav_src_loc, nav_val); |
| 2955 | 3037 | try uleb128(diw, nav.status.fully_resolved.alignment.toByteUnits() orelse |
| 2956 | 3038 | nav_ty.abiAlignment(zcu).toByteUnits().?); |
| 2957 | | try diw.writeByte(@intFromBool(false)); |
| 3039 | try diw.writeByte(@intFromBool(decl.linkage != .normal)); |
| 2958 | 3040 | }, |
| 2959 | 3041 | .decl_const => { |
| 2960 | 3042 | const diw = wip_nav.debug_info.writer(dwarf.gpa); |
| 2961 | 3043 | const nav_ty = nav_val.typeOf(zcu); |
| 2962 | 3044 | const has_runtime_bits = nav_ty.hasRuntimeBits(zcu); |
| 2963 | 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) |
| 2965 | | .decl_const_runtime_bits_comptime_state |
| 2966 | | else if (has_comptime_state) |
| 2967 | | .decl_const_comptime_state |
| 2968 | | else if (has_runtime_bits) |
| 2969 | | .decl_const_runtime_bits |
| 2970 | | else |
| 2971 | | .decl_const); |
| 2972 | | try wip_nav.refType(.fromInterned(parent_type)); |
| 2973 | | assert(wip_nav.debug_info.items.len == DebugInfo.declEntryLineOff(dwarf)); |
| 2974 | | try diw.writeInt(u32, @intCast(decl.src_line + 1), dwarf.endian); |
| 2975 | | try uleb128(diw, decl.src_column + 1); |
| 2976 | | try diw.writeByte(accessibility); |
| 2977 | | try wip_nav.strp(nav.name.toSlice(ip)); |
| 3046 | try wip_nav.declCommon(if (has_runtime_bits and has_comptime_state) .{ |
| 3047 | .decl = .decl_const_runtime_bits_comptime_state, |
| 3048 | .generic_decl = .generic_decl_const, |
| 3049 | .instance = .instance_const_runtime_bits_comptime_state, |
| 3050 | } else if (has_comptime_state) .{ |
| 3051 | .decl = .decl_const_comptime_state, |
| 3052 | .generic_decl = .generic_decl_const, |
| 3053 | .instance = .instance_const_comptime_state, |
| 3054 | } else if (has_runtime_bits) .{ |
| 3055 | .decl = .decl_const_runtime_bits, |
| 3056 | .generic_decl = .generic_decl_const, |
| 3057 | .instance = .instance_const_runtime_bits, |
| 3058 | } else .{ |
| 3059 | .decl = .decl_const, |
| 3060 | .generic_decl = .generic_decl_const, |
| 3061 | .instance = .instance_const, |
| 3062 | }, &nav, inst_info.file, &decl); |
| 2978 | 3063 | try wip_nav.strp(nav.fqn.toSlice(ip)); |
| 2979 | 3064 | const nav_ty_reloc_index = try wip_nav.refForward(); |
| 2980 | 3065 | try uleb128(diw, nav.status.fully_resolved.alignment.toByteUnits() orelse |
| 2981 | 3066 | nav_ty.abiAlignment(zcu).toByteUnits().?); |
| 2982 | | try diw.writeByte(@intFromBool(false)); |
| 3067 | try diw.writeByte(@intFromBool(decl.linkage != .normal)); |
| 2983 | 3068 | if (has_runtime_bits) try wip_nav.blockValue(nav_src_loc, nav_val); |
| 2984 | 3069 | if (has_comptime_state) try wip_nav.refValue(nav_val); |
| 2985 | 3070 | wip_nav.finishForward(nav_ty_reloc_index); |
| ... | ... | @@ -3017,15 +3102,15 @@ fn updateLazyType( |
| 3017 | 3102 | .func_high_pc = undefined, |
| 3018 | 3103 | .blocks = undefined, |
| 3019 | 3104 | .cfi = undefined, |
| 3020 | | .debug_frame = .{}, |
| 3021 | | .debug_info = .{}, |
| 3022 | | .debug_line = .{}, |
| 3023 | | .debug_loclists = .{}, |
| 3105 | .debug_frame = .empty, |
| 3106 | .debug_info = .empty, |
| 3107 | .debug_line = .empty, |
| 3108 | .debug_loclists = .empty, |
| 3024 | 3109 | .pending_lazy = pending_lazy.*, |
| 3025 | 3110 | }; |
| 3026 | 3111 | defer { |
| 3027 | 3112 | pending_lazy.* = wip_nav.pending_lazy; |
| 3028 | | wip_nav.pending_lazy = .{}; |
| 3113 | wip_nav.pending_lazy = .empty; |
| 3029 | 3114 | wip_nav.deinit(); |
| 3030 | 3115 | } |
| 3031 | 3116 | const diw = wip_nav.debug_info.writer(dwarf.gpa); |
| ... | ... | @@ -3076,7 +3161,7 @@ fn updateLazyType( |
| 3076 | 3161 | } |
| 3077 | 3162 | }, |
| 3078 | 3163 | .Slice => { |
| 3079 | | try wip_nav.abbrevCode(.struct_type); |
| 3164 | try wip_nav.abbrevCode(.generated_struct_type); |
| 3080 | 3165 | try wip_nav.strp(name); |
| 3081 | 3166 | try uleb128(diw, ty.abiSize(zcu)); |
| 3082 | 3167 | try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?); |
| ... | ... | @@ -3115,7 +3200,7 @@ fn updateLazyType( |
| 3115 | 3200 | }, |
| 3116 | 3201 | .opt_type => |opt_child_type_index| { |
| 3117 | 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 | 3204 | try wip_nav.strp(name); |
| 3120 | 3205 | try uleb128(diw, ty.abiSize(zcu)); |
| 3121 | 3206 | try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?); |
| ... | ... | @@ -3199,7 +3284,7 @@ fn updateLazyType( |
| 3199 | 3284 | }, |
| 3200 | 3285 | }; |
| 3201 | 3286 | |
| 3202 | | try wip_nav.abbrevCode(.union_type); |
| 3287 | try wip_nav.abbrevCode(.generated_union_type); |
| 3203 | 3288 | try wip_nav.strp(name); |
| 3204 | 3289 | if (error_union_type.error_set_type != .generic_poison_type and |
| 3205 | 3290 | error_union_type.payload_type != .generic_poison_type) |
| ... | ... | @@ -3308,11 +3393,11 @@ fn updateLazyType( |
| 3308 | 3393 | .opaque_type, |
| 3309 | 3394 | => unreachable, |
| 3310 | 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 | 3397 | try wip_nav.strp(name); |
| 3313 | 3398 | try diw.writeByte(@intFromBool(false)); |
| 3314 | 3399 | } else { |
| 3315 | | try wip_nav.abbrevCode(.struct_type); |
| 3400 | try wip_nav.abbrevCode(.generated_struct_type); |
| 3316 | 3401 | try wip_nav.strp(name); |
| 3317 | 3402 | try uleb128(diw, ty.abiSize(zcu)); |
| 3318 | 3403 | try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?); |
| ... | ... | @@ -3357,7 +3442,7 @@ fn updateLazyType( |
| 3357 | 3442 | }, |
| 3358 | 3443 | .enum_type => { |
| 3359 | 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 | 3446 | try wip_nav.strp(name); |
| 3362 | 3447 | try wip_nav.refType(.fromInterned(loaded_enum.tag_ty)); |
| 3363 | 3448 | for (0..loaded_enum.names.len) |field_index| { |
| ... | ... | @@ -3449,7 +3534,7 @@ fn updateLazyType( |
| 3449 | 3534 | if (!is_nullary) try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 3450 | 3535 | }, |
| 3451 | 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 | 3538 | try wip_nav.strp(name); |
| 3454 | 3539 | try wip_nav.refType(.fromInterned(try pt.intern(.{ .int_type = .{ |
| 3455 | 3540 | .signedness = .unsigned, |
| ... | ... | @@ -3518,15 +3603,15 @@ fn updateLazyValue( |
| 3518 | 3603 | .func_high_pc = undefined, |
| 3519 | 3604 | .blocks = undefined, |
| 3520 | 3605 | .cfi = undefined, |
| 3521 | | .debug_frame = .{}, |
| 3522 | | .debug_info = .{}, |
| 3523 | | .debug_line = .{}, |
| 3524 | | .debug_loclists = .{}, |
| 3606 | .debug_frame = .empty, |
| 3607 | .debug_info = .empty, |
| 3608 | .debug_line = .empty, |
| 3609 | .debug_loclists = .empty, |
| 3525 | 3610 | .pending_lazy = pending_lazy.*, |
| 3526 | 3611 | }; |
| 3527 | 3612 | defer { |
| 3528 | 3613 | pending_lazy.* = wip_nav.pending_lazy; |
| 3529 | | wip_nav.pending_lazy = .{}; |
| 3614 | wip_nav.pending_lazy = .empty; |
| 3530 | 3615 | wip_nav.deinit(); |
| 3531 | 3616 | } |
| 3532 | 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 | 3955 | const ip = &zcu.intern_pool; |
| 3871 | 3956 | const ty: Type = .fromInterned(type_index); |
| 3872 | 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)}); |
| 3874 | 3959 | |
| 3875 | 3960 | const inst_info = ty.typeDeclInst(zcu).?.resolveFull(ip).?; |
| 3876 | 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 | 3964 | if (inst_info.inst == .main_struct_inst) { |
| 3878 | | const unit = try dwarf.getUnit(file.mod); |
| 3879 | 3965 | const type_gop = try dwarf.types.getOrPut(dwarf.gpa, type_index); |
| 3880 | 3966 | if (!type_gop.found_existing) type_gop.value_ptr.* = try dwarf.addCommonEntry(unit); |
| 3881 | 3967 | var wip_nav: WipNav = .{ |
| ... | ... | @@ -3889,19 +3975,18 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3889 | 3975 | .func_high_pc = undefined, |
| 3890 | 3976 | .blocks = undefined, |
| 3891 | 3977 | .cfi = undefined, |
| 3892 | | .debug_frame = .{}, |
| 3893 | | .debug_info = .{}, |
| 3894 | | .debug_line = .{}, |
| 3895 | | .debug_loclists = .{}, |
| 3896 | | .pending_lazy = .{}, |
| 3978 | .debug_frame = .empty, |
| 3979 | .debug_info = .empty, |
| 3980 | .debug_line = .empty, |
| 3981 | .debug_loclists = .empty, |
| 3982 | .pending_lazy = .empty, |
| 3897 | 3983 | }; |
| 3898 | 3984 | defer wip_nav.deinit(); |
| 3899 | 3985 | |
| 3900 | 3986 | const loaded_struct = ip.loadStructType(type_index); |
| 3901 | 3987 | |
| 3902 | 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); |
| 3904 | | const file_gop = try dwarf.getModInfo(unit).files.getOrPut(dwarf.gpa, inst_info.file); |
| 3989 | try wip_nav.abbrevCode(if (loaded_struct.field_types.len == 0) .empty_file else .file); |
| 3905 | 3990 | try uleb128(diw, file_gop.index); |
| 3906 | 3991 | try wip_nav.strp(loaded_struct.name.toSlice(ip)); |
| 3907 | 3992 | if (loaded_struct.field_types.len > 0) { |
| ... | ... | @@ -3978,7 +4063,6 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3978 | 4063 | if (name_strat == .parent) return; |
| 3979 | 4064 | } |
| 3980 | 4065 | |
| 3981 | | const unit = try dwarf.getUnit(file.mod); |
| 3982 | 4066 | const type_gop = try dwarf.types.getOrPut(dwarf.gpa, type_index); |
| 3983 | 4067 | if (!type_gop.found_existing) type_gop.value_ptr.* = try dwarf.addCommonEntry(unit); |
| 3984 | 4068 | var wip_nav: WipNav = .{ |
| ... | ... | @@ -3992,11 +4076,11 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3992 | 4076 | .func_high_pc = undefined, |
| 3993 | 4077 | .blocks = undefined, |
| 3994 | 4078 | .cfi = undefined, |
| 3995 | | .debug_frame = .{}, |
| 3996 | | .debug_info = .{}, |
| 3997 | | .debug_line = .{}, |
| 3998 | | .debug_loclists = .{}, |
| 3999 | | .pending_lazy = .{}, |
| 4079 | .debug_frame = .empty, |
| 4080 | .debug_info = .empty, |
| 4081 | .debug_line = .empty, |
| 4082 | .debug_loclists = .empty, |
| 4083 | .pending_lazy = .empty, |
| 4000 | 4084 | }; |
| 4001 | 4085 | defer wip_nav.deinit(); |
| 4002 | 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 | 4092 | const loaded_struct = ip.loadStructType(type_index); |
| 4009 | 4093 | switch (loaded_struct.layout) { |
| 4010 | 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 | 4097 | try wip_nav.strp(name); |
| 4013 | 4098 | if (loaded_struct.field_types.len == 0) try diw.writeByte(@intFromBool(false)) else { |
| 4014 | 4099 | try uleb128(diw, ty.abiSize(zcu)); |
| ... | ... | @@ -4062,6 +4147,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 4062 | 4147 | }, |
| 4063 | 4148 | .@"packed" => { |
| 4064 | 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 | 4151 | try wip_nav.strp(name); |
| 4066 | 4152 | try wip_nav.refType(.fromInterned(loaded_struct.backingIntTypeUnordered(ip))); |
| 4067 | 4153 | var field_bit_offset: u16 = 0; |
| ... | ... | @@ -4080,6 +4166,7 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 4080 | 4166 | .enum_type => { |
| 4081 | 4167 | const loaded_enum = ip.loadEnumType(type_index); |
| 4082 | 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 | 4170 | try wip_nav.strp(name); |
| 4084 | 4171 | try wip_nav.refType(.fromInterned(loaded_enum.tag_ty)); |
| 4085 | 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 | 4182 | .union_type => { |
| 4096 | 4183 | const loaded_union = ip.loadUnionType(type_index); |
| 4097 | 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 | 4186 | try wip_nav.strp(name); |
| 4099 | 4187 | const union_layout = Type.getUnionLayout(loaded_union, zcu); |
| 4100 | 4188 | try uleb128(diw, union_layout.abi_size); |
| ... | ... | @@ -4144,7 +4232,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 4144 | 4232 | if (loaded_union.field_types.len > 0) try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 4145 | 4233 | }, |
| 4146 | 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 | 4237 | try wip_nav.strp(name); |
| 4149 | 4238 | try diw.writeByte(@intFromBool(true)); |
| 4150 | 4239 | }, |
| ... | ... | @@ -4156,11 +4245,28 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 4156 | 4245 | } |
| 4157 | 4246 | } |
| 4158 | 4247 | |
| 4159 | | pub fn updateLineNumber(dwarf: *Dwarf, zcu: *Zcu, ti_id: InternPool.TrackedInst.Index) UpdateError!void { |
| 4160 | | _ = dwarf; |
| 4161 | | _ = zcu; |
| 4162 | | _ = ti_id; |
| 4163 | | @panic("TODO: Dwarf.updateLineNumber"); |
| 4248 | pub fn updateLineNumber(dwarf: *Dwarf, zcu: *Zcu, zir_index: InternPool.TrackedInst.Index) UpdateError!void { |
| 4249 | const ip = &zcu.intern_pool; |
| 4250 | |
| 4251 | const inst_info = zir_index.resolveFull(ip).?; |
| 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 | } |
| 4165 | 4271 | |
| 4166 | 4272 | pub 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 | 4309 | .func_high_pc = undefined, |
| 4204 | 4310 | .blocks = undefined, |
| 4205 | 4311 | .cfi = undefined, |
| 4206 | | .debug_frame = .{}, |
| 4207 | | .debug_info = .{}, |
| 4208 | | .debug_line = .{}, |
| 4209 | | .debug_loclists = .{}, |
| 4210 | | .pending_lazy = .{}, |
| 4312 | .debug_frame = .empty, |
| 4313 | .debug_info = .empty, |
| 4314 | .debug_line = .empty, |
| 4315 | .debug_loclists = .empty, |
| 4316 | .pending_lazy = .empty, |
| 4211 | 4317 | }; |
| 4212 | 4318 | defer wip_nav.deinit(); |
| 4213 | 4319 | const diw = wip_nav.debug_info.writer(dwarf.gpa); |
| 4214 | 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 | 4322 | try wip_nav.strp("anyerror"); |
| 4217 | 4323 | try wip_nav.refType(.fromInterned(try pt.intern(.{ .int_type = .{ |
| 4218 | 4324 | .signedness = .unsigned, |
| ... | ... | @@ -4601,7 +4707,7 @@ const AbbrevCode = enum { |
| 4601 | 4707 | // padding codes must be one byte uleb128 values to function |
| 4602 | 4708 | pad_1, |
| 4603 | 4709 | pad_n, |
| 4604 | | // decl codes are assumed to all have the same uleb128 length |
| 4710 | // (generic) decl codes are assumed to all have the same uleb128 length |
| 4605 | 4711 | decl_alias, |
| 4606 | 4712 | decl_enum, |
| 4607 | 4713 | decl_empty_enum, |
| ... | ... | @@ -4618,11 +4724,34 @@ const AbbrevCode = enum { |
| 4618 | 4724 | decl_empty_func, |
| 4619 | 4725 | decl_func_generic, |
| 4620 | 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 | 4734 | // 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 | 4751 | compile_unit, |
| 4623 | 4752 | module, |
| 4624 | | namespace_file, |
| 4625 | 4753 | file, |
| 4754 | empty_file, |
| 4626 | 4755 | signed_enum_field, |
| 4627 | 4756 | unsigned_enum_field, |
| 4628 | 4757 | big_enum_field, |
| ... | ... | @@ -4655,10 +4784,15 @@ const AbbrevCode = enum { |
| 4655 | 4784 | func_type, |
| 4656 | 4785 | func_type_param, |
| 4657 | 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 | 4792 | enum_type, |
| 4659 | 4793 | empty_enum_type, |
| 4660 | | namespace_struct_type, |
| 4661 | 4794 | struct_type, |
| 4795 | empty_struct_type, |
| 4662 | 4796 | packed_struct_type, |
| 4663 | 4797 | empty_packed_struct_type, |
| 4664 | 4798 | union_type, |
| ... | ... | @@ -4684,7 +4818,7 @@ const AbbrevCode = enum { |
| 4684 | 4818 | comptime_value_elem_runtime_bits, |
| 4685 | 4819 | comptime_value_elem_comptime_state, |
| 4686 | 4820 | |
| 4687 | | const decl_bytes = uleb128Bytes(@intFromEnum(AbbrevCode.decl_empty_func_generic)); |
| 4821 | const decl_bytes = uleb128Bytes(@intFromEnum(AbbrevCode.generic_decl_func)); |
| 4688 | 4822 | |
| 4689 | 4823 | const Attr = struct { |
| 4690 | 4824 | DeclValEnum(DW.AT), |
| ... | ... | @@ -4697,6 +4831,10 @@ const AbbrevCode = enum { |
| 4697 | 4831 | .{ .accessibility, .data1 }, |
| 4698 | 4832 | .{ .name, .strp }, |
| 4699 | 4833 | }; |
| 4834 | const instance_abbrev_common_attrs = &[_]Attr{ |
| 4835 | .{ .ZIG_parent, .ref_addr }, |
| 4836 | .{ .abstract_origin, .ref_addr }, |
| 4837 | }; |
| 4700 | 4838 | const abbrevs = std.EnumArray(AbbrevCode, struct { |
| 4701 | 4839 | tag: DeclValEnum(DW.TAG), |
| 4702 | 4840 | children: bool = false, |
| ... | ... | @@ -4847,6 +4985,184 @@ const AbbrevCode = enum { |
| 4847 | 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 | 5166 | .compile_unit = .{ |
| 4851 | 5167 | .tag = .compile_unit, |
| 4852 | 5168 | .children = true, |
| ... | ... | @@ -4869,21 +5185,21 @@ const AbbrevCode = enum { |
| 4869 | 5185 | .{ .ranges, .rnglistx }, |
| 4870 | 5186 | }, |
| 4871 | 5187 | }, |
| 4872 | | .namespace_file = .{ |
| 5188 | .file = .{ |
| 4873 | 5189 | .tag = .structure_type, |
| 5190 | .children = true, |
| 4874 | 5191 | .attrs = &.{ |
| 4875 | 5192 | .{ .decl_file, .udata }, |
| 4876 | 5193 | .{ .name, .strp }, |
| 5194 | .{ .byte_size, .udata }, |
| 5195 | .{ .alignment, .udata }, |
| 4877 | 5196 | }, |
| 4878 | 5197 | }, |
| 4879 | | .file = .{ |
| 5198 | .empty_file = .{ |
| 4880 | 5199 | .tag = .structure_type, |
| 4881 | | .children = true, |
| 4882 | 5200 | .attrs = &.{ |
| 4883 | 5201 | .{ .decl_file, .udata }, |
| 4884 | 5202 | .{ .name, .strp }, |
| 4885 | | .{ .byte_size, .udata }, |
| 4886 | | .{ .alignment, .udata }, |
| 4887 | 5203 | }, |
| 4888 | 5204 | }, |
| 4889 | 5205 | .signed_enum_field = .{ |
| ... | ... | @@ -5133,7 +5449,7 @@ const AbbrevCode = enum { |
| 5133 | 5449 | .is_var_args = .{ |
| 5134 | 5450 | .tag = .unspecified_parameters, |
| 5135 | 5451 | }, |
| 5136 | | .enum_type = .{ |
| 5452 | .generated_enum_type = .{ |
| 5137 | 5453 | .tag = .enumeration_type, |
| 5138 | 5454 | .children = true, |
| 5139 | 5455 | .attrs = &.{ |
| ... | ... | @@ -5141,33 +5457,78 @@ const AbbrevCode = enum { |
| 5141 | 5457 | .{ .type, .ref_addr }, |
| 5142 | 5458 | }, |
| 5143 | 5459 | }, |
| 5144 | | .empty_enum_type = .{ |
| 5460 | .generated_empty_enum_type = .{ |
| 5145 | 5461 | .tag = .enumeration_type, |
| 5146 | 5462 | .attrs = &.{ |
| 5147 | 5463 | .{ .name, .strp }, |
| 5148 | 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 | 5477 | .tag = .structure_type, |
| 5153 | 5478 | .attrs = &.{ |
| 5154 | 5479 | .{ .name, .strp }, |
| 5155 | 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 | 5509 | .struct_type = .{ |
| 5159 | 5510 | .tag = .structure_type, |
| 5160 | 5511 | .children = true, |
| 5161 | 5512 | .attrs = &.{ |
| 5513 | .{ .decl_file, .udata }, |
| 5162 | 5514 | .{ .name, .strp }, |
| 5163 | 5515 | .{ .byte_size, .udata }, |
| 5164 | 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 | 5527 | .packed_struct_type = .{ |
| 5168 | 5528 | .tag = .structure_type, |
| 5169 | 5529 | .children = true, |
| 5170 | 5530 | .attrs = &.{ |
| 5531 | .{ .decl_file, .udata }, |
| 5171 | 5532 | .{ .name, .strp }, |
| 5172 | 5533 | .{ .type, .ref_addr }, |
| 5173 | 5534 | }, |
| ... | ... | @@ -5175,6 +5536,7 @@ const AbbrevCode = enum { |
| 5175 | 5536 | .empty_packed_struct_type = .{ |
| 5176 | 5537 | .tag = .structure_type, |
| 5177 | 5538 | .attrs = &.{ |
| 5539 | .{ .decl_file, .udata }, |
| 5178 | 5540 | .{ .name, .strp }, |
| 5179 | 5541 | .{ .type, .ref_addr }, |
| 5180 | 5542 | }, |
| ... | ... | @@ -5183,6 +5545,7 @@ const AbbrevCode = enum { |
| 5183 | 5545 | .tag = .union_type, |
| 5184 | 5546 | .children = true, |
| 5185 | 5547 | .attrs = &.{ |
| 5548 | .{ .decl_file, .udata }, |
| 5186 | 5549 | .{ .name, .strp }, |
| 5187 | 5550 | .{ .byte_size, .udata }, |
| 5188 | 5551 | .{ .alignment, .udata }, |
| ... | ... | @@ -5191,6 +5554,7 @@ const AbbrevCode = enum { |
| 5191 | 5554 | .empty_union_type = .{ |
| 5192 | 5555 | .tag = .union_type, |
| 5193 | 5556 | .attrs = &.{ |
| 5557 | .{ .decl_file, .udata }, |
| 5194 | 5558 | .{ .name, .strp }, |
| 5195 | 5559 | .{ .byte_size, .udata }, |
| 5196 | 5560 | .{ .alignment, .udata }, |
| ... | ... | @@ -5363,6 +5727,15 @@ fn addCommonEntry(dwarf: *Dwarf, unit: Unit.Index) UpdateError!Entry.Index { |
| 5363 | 5727 | return entry; |
| 5364 | 5728 | } |
| 5365 | 5729 | |
| 5730 | fn 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 | |
| 5366 | 5739 | fn writeInt(dwarf: *Dwarf, buf: []u8, int: u64) void { |
| 5367 | 5740 | switch (buf.len) { |
| 5368 | 5741 | inline 0...8 => |len| std.mem.writeInt(@Type(.{ .int = .{ |