| ... | @@ -10,9 +10,10 @@ consts: std.ArrayList(Const), | ... | @@ -10,9 +10,10 @@ consts: std.ArrayList(Const), |
| 10 | globals: std.array_hash_map.Auto(InternPool.Nav.Index, Global), | 10 | globals: std.array_hash_map.Auto(InternPool.Nav.Index, Global), |
| 11 | funcs: std.array_hash_map.Auto(InternPool.Nav.Index, Func), | 11 | funcs: std.array_hash_map.Auto(InternPool.Nav.Index, Func), |
| 12 | decls: std.array_hash_map.Auto(InternPool.TrackedInst.Index, Decl), | 12 | decls: std.array_hash_map.Auto(InternPool.TrackedInst.Index, Decl), |
| 13 | pending_decl: struct { di: Decl.Index, instance_val: InternPool.Index }, | 13 | pending_decl: struct { di: Decl.Index, instance: Decl.Instance }, |
| 14 | | 14 | |
| 15 | debug_abbrev: Abbrev, | 15 | debug_abbrev: Abbrev, |
| | 16 | debug_addr: Addr, |
| 16 | frame: Frame, | 17 | frame: Frame, |
| 17 | debug_info: Info, | 18 | debug_info: Info, |
| 18 | debug_line: Line, | 19 | debug_line: Line, |
| ... | @@ -81,6 +82,7 @@ pub const Unit = struct { | ... | @@ -81,6 +82,7 @@ pub const Unit = struct { |
| 81 | ui: Unit.Index, | 82 | ui: Unit.Index, |
| 82 | zfi: Zcu.File.Index, | 83 | zfi: Zcu.File.Index, |
| 83 | ) std.mem.Allocator.Error!struct { DirIndex, FileIndex } { | 84 | ) std.mem.Allocator.Error!struct { DirIndex, FileIndex } { |
| | 85 | assert(unit.alive); |
| 84 | try unit.dirs.ensureUnusedCapacity(gpa, 1); | 86 | try unit.dirs.ensureUnusedCapacity(gpa, 1); |
| 85 | try unit.files.ensureUnusedCapacity(gpa, 1); | 87 | try unit.files.ensureUnusedCapacity(gpa, 1); |
| 86 | const dir_gop = unit.dirs.getOrPutAssumeCapacity(ui); | 88 | const dir_gop = unit.dirs.getOrPutAssumeCapacity(ui); |
| ... | @@ -154,6 +156,12 @@ pub const Decl = struct { | ... | @@ -154,6 +156,12 @@ pub const Decl = struct { |
| 154 | return &dwarf.decls.values()[@backingInt(di)]; | 156 | return &dwarf.decls.values()[@backingInt(di)]; |
| 155 | } | 157 | } |
| 156 | }; | 158 | }; |
| | 159 | |
| | 160 | const Instance = union(enum) { |
| | 161 | none, |
| | 162 | @"const": InternPool.Index, |
| | 163 | global: InternPool.Nav.Index, |
| | 164 | }; |
| 157 | }; | 165 | }; |
| 158 | | 166 | |
| 159 | pub const Frame = struct { | 167 | pub const Frame = struct { |
| ... | @@ -175,6 +183,29 @@ pub const Abbrev = struct { | ... | @@ -175,6 +183,29 @@ pub const Abbrev = struct { |
| 175 | set: std.enums.EnumSet(AbbrevCode), | 183 | set: std.enums.EnumSet(AbbrevCode), |
| 176 | }; | 184 | }; |
| 177 | | 185 | |
| | 186 | pub const Addr = struct { |
| | 187 | ni: link.MappedFile.Node.Index.Optional, |
| | 188 | pending_index: usize, |
| | 189 | map: std.array_hash_map.Auto(link.File.SymbolId, void), |
| | 190 | |
| | 191 | fn get(a: *Addr, gpa: std.mem.Allocator, si: link.File.SymbolId) std.mem.Allocator.Error!usize { |
| | 192 | const gop = try a.map.getOrPut(gpa, si); |
| | 193 | return gop.index; |
| | 194 | } |
| | 195 | |
| | 196 | fn tableOffset(dwarf: *Dwarf) usize { |
| | 197 | return dwarf.unitLengthSize() + 2 + 1 + 1; |
| | 198 | } |
| | 199 | |
| | 200 | pub fn size(a: *Addr, dwarf: *Dwarf) usize { |
| | 201 | return tableOffset(dwarf) + @backingInt(dwarf.address_size) * a.pending_index; |
| | 202 | } |
| | 203 | |
| | 204 | pub fn anyPending(a: *Addr) bool { |
| | 205 | return a.map.count() - a.pending_index > 0; |
| | 206 | } |
| | 207 | }; |
| | 208 | |
| 178 | pub const Info = struct {}; | 209 | pub const Info = struct {}; |
| 179 | | 210 | |
| 180 | pub const Line = struct { | 211 | pub const Line = struct { |
| ... | @@ -192,8 +223,8 @@ pub const Line = struct { | ... | @@ -192,8 +223,8 @@ pub const Line = struct { |
| 192 | | 223 | |
| 193 | pub const Str = struct { | 224 | pub const Str = struct { |
| 194 | ni: link.MappedFile.Node.Index.Optional, | 225 | ni: link.MappedFile.Node.Index.Optional, |
| 195 | offset: usize, | 226 | end: usize, |
| 196 | map: std.HashMapUnmanaged(usize, void, Context, std.hash_map.default_max_load_percentage), | 227 | map: std.array_hash_map.Custom(usize, void, Context, true), |
| 197 | | 228 | |
| 198 | fn get( | 229 | fn get( |
| 199 | s: *Str, | 230 | s: *Str, |
| ... | @@ -210,21 +241,21 @@ pub const Str = struct { | ... | @@ -210,21 +241,21 @@ pub const Str = struct { |
| 210 | .{ .slice = slice }, | 241 | .{ .slice = slice }, |
| 211 | ); | 242 | ); |
| 212 | if (!gop.found_existing) { | 243 | if (!gop.found_existing) { |
| 213 | gop.key_ptr.* = s.offset; | 244 | gop.key_ptr.* = s.end; |
| 214 | try ni.ensureMinimumSize(gpa, mf, s.offset + str.len + 1); | 245 | try ni.ensureMinimumSize(gpa, mf, s.end + str.len + 1); |
| 215 | const slice_mut = ni.slice(mf); | 246 | const slice_mut = ni.slice(mf); |
| 216 | @memcpy(slice_mut[s.offset..][0..str.len], str); | 247 | @memcpy(slice_mut[s.end..][0..str.len], str); |
| 217 | s.offset += str.len; | 248 | s.end += str.len; |
| 218 | slice_mut[s.offset] = 0; | 249 | slice_mut[s.end] = 0; |
| 219 | s.offset += 1; | 250 | s.end += 1; |
| 220 | } | 251 | } |
| 221 | return gop.key_ptr.*; | 252 | return gop.key_ptr.*; |
| 222 | } | 253 | } |
| 223 | | 254 | |
| 224 | const Context = struct { | 255 | const Context = struct { |
| 225 | slice: []const u8, | 256 | slice: []const u8, |
| 226 | pub fn hash(context: Context, offset: usize) u64 { | 257 | pub fn hash(context: Context, offset: usize) u32 { |
| 227 | return std.hash.Wyhash.hash(0, std.mem.sliceTo(context.slice[offset..], 0)); | 258 | return @truncate(std.hash.Wyhash.hash(0, std.mem.sliceTo(context.slice[offset..], 0))); |
| 228 | } | 259 | } |
| 229 | pub fn eql(_: Context, lhs_offset: usize, rhs_offset: usize) bool { | 260 | pub fn eql(_: Context, lhs_offset: usize, rhs_offset: usize) bool { |
| 230 | return lhs_offset == rhs_offset; | 261 | return lhs_offset == rhs_offset; |
| ... | @@ -233,10 +264,10 @@ pub const Str = struct { | ... | @@ -233,10 +264,10 @@ pub const Str = struct { |
| 233 | | 264 | |
| 234 | const Adapter = struct { | 265 | const Adapter = struct { |
| 235 | slice: []const u8, | 266 | slice: []const u8, |
| 236 | pub fn hash(_: Adapter, key: []const u8) u64 { | 267 | pub fn hash(_: Adapter, key: []const u8) u32 { |
| 237 | return std.hash.Wyhash.hash(0, key); | 268 | return @truncate(std.hash.Wyhash.hash(0, key)); |
| 238 | } | 269 | } |
| 239 | pub fn eql(adapter: Adapter, key: []const u8, rhs_offset: usize) bool { | 270 | pub fn eql(adapter: Adapter, key: []const u8, rhs_offset: usize, _: usize) bool { |
| 240 | return std.mem.startsWith(u8, adapter.slice[rhs_offset..], key) and | 271 | return std.mem.startsWith(u8, adapter.slice[rhs_offset..], key) and |
| 241 | adapter.slice[rhs_offset + key.len] == 0; | 272 | adapter.slice[rhs_offset + key.len] == 0; |
| 242 | } | 273 | } |
| ... | @@ -244,21 +275,60 @@ pub const Str = struct { | ... | @@ -244,21 +275,60 @@ pub const Str = struct { |
| 244 | }; | 275 | }; |
| 245 | | 276 | |
| 246 | pub const Rnglists = struct { | 277 | pub const Rnglists = struct { |
| 247 | fn offsetsTableOffset(dwarf: *Dwarf) usize { | 278 | fn tableOffset(dwarf: *Dwarf) usize { |
| 248 | return dwarf.unitLengthSize() + 2 + 1 + 1 + 4; | 279 | return dwarf.unitLengthSize() + 2 + 1 + 1 + 4; |
| 249 | } | 280 | } |
| | 281 | |
| | 282 | pub fn size(dwarf: *Dwarf, ui: Unit.Index) usize { |
| | 283 | return ui.get(dwarf).debug_rnglists_end + 1; |
| | 284 | } |
| 250 | }; | 285 | }; |
| 251 | | 286 | |
| 252 | pub const StrOffsets = struct { | 287 | pub const StrOffsets = struct { |
| 253 | ni: link.MappedFile.Node.Index.Optional, | 288 | ni: link.MappedFile.Node.Index.Optional, |
| 254 | offset: usize, | 289 | pending_index: usize, |
| | 290 | map: std.array_hash_map.Auto(usize, void), |
| | 291 | |
| | 292 | fn get( |
| | 293 | so: *StrOffsets, |
| | 294 | dwarf: *Dwarf, |
| | 295 | s: *Str, |
| | 296 | mf: *link.MappedFile, |
| | 297 | str: []const u8, |
| | 298 | ) link.Error!usize { |
| | 299 | const comp = dwarf.lf.comp; |
| | 300 | try so.map.ensureUnusedCapacity(comp.gpa, 1); |
| | 301 | const offset = s.get(comp.gpa, mf, str) catch |err| switch (err) { |
| | 302 | else => |e| return e, |
| | 303 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| | 304 | mf.io_err.?, |
| | 305 | }), |
| | 306 | }; |
| | 307 | const gop = so.map.getOrPutAssumeCapacity(offset); |
| | 308 | return gop.index; |
| | 309 | } |
| | 310 | |
| | 311 | fn tableOffset(dwarf: *Dwarf) usize { |
| | 312 | return dwarf.unitLengthSize() + 2 + 2; |
| | 313 | } |
| | 314 | |
| | 315 | pub fn size(so: *StrOffsets, dwarf: *Dwarf) usize { |
| | 316 | return tableOffset(dwarf) + dwarf.secOffsetSize() * so.pending_index; |
| | 317 | } |
| | 318 | |
| | 319 | pub fn anyPending(so: *StrOffsets) bool { |
| | 320 | return so.map.count() - so.pending_index > 0; |
| | 321 | } |
| 255 | }; | 322 | }; |
| 256 | | 323 | |
| 257 | pub const SharedSection = enum { debug_abbrev, debug_line_str, debug_str, debug_str_offsets }; | 324 | pub const SharedSection = enum { debug_abbrev, debug_line_str, debug_str }; |
| 258 | | 325 | |
| 259 | pub const Loc = union(enum) { | 326 | pub const Loc = union(enum) { |
| 260 | empty, | 327 | empty, |
| 261 | addr_reloc: link.File.SymbolId, | 328 | addr_sym: struct { |
| | 329 | si: link.File.SymbolId, |
| | 330 | offset: usize = 0, |
| | 331 | }, |
| 262 | deref: *const Loc, | 332 | deref: *const Loc, |
| 263 | constu: u64, | 333 | constu: u64, |
| 264 | consts: i64, | 334 | consts: i64, |
| ... | @@ -277,6 +347,8 @@ pub const Loc = union(enum) { | ... | @@ -277,6 +347,8 @@ pub const Loc = union(enum) { |
| 277 | node: link.MappedFile.Node.Index, | 347 | node: link.MappedFile.Node.Index, |
| 278 | offset: i65 = 0, | 348 | offset: i65 = 0, |
| 279 | }, | 349 | }, |
| | 350 | addrx_sym: link.File.SymbolId, |
| | 351 | constx_sym: link.File.SymbolId, |
| 280 | wasm_ext: union(enum) { | 352 | wasm_ext: union(enum) { |
| 281 | local: u32, | 353 | local: u32, |
| 282 | global: u32, | 354 | global: u32, |
| ... | @@ -319,11 +391,11 @@ pub const Loc = union(enum) { | ... | @@ -319,11 +391,11 @@ pub const Loc = union(enum) { |
| 319 | }; | 391 | }; |
| 320 | switch (loc) { | 392 | switch (loc) { |
| 321 | .empty => {}, | 393 | .empty => {}, |
| 322 | .addr_reloc => |si| { | 394 | .addr_sym => |sym| { |
| 323 | try w.writeByte(DW.OP.addr); | 395 | try w.writeByte(DW.OP.addr); |
| 324 | switch (writer) { | 396 | switch (writer) { |
| 325 | .io => try dwarf.addrPlaceholder(w), | 397 | .io => try dwarf.addrPlaceholder(w), |
| 326 | .mf => |nw| try dwarf.addrSym(nw, si, 0), | 398 | .mf => |nw| try dwarf.addrSym(nw, sym.si, sym.offset), |
| 327 | } | 399 | } |
| 328 | }, | 400 | }, |
| 329 | .deref => |addr| { | 401 | .deref => |addr| { |
| ... | @@ -442,6 +514,14 @@ pub const Loc = union(enum) { | ... | @@ -442,6 +514,14 @@ pub const Loc = union(enum) { |
| 442 | } | 514 | } |
| 443 | try w.writeSleb128(implicit_pointer.offset); | 515 | try w.writeSleb128(implicit_pointer.offset); |
| 444 | }, | 516 | }, |
| | 517 | .addrx_sym => |si| { |
| | 518 | try w.writeByte(DW.OP.addrx); |
| | 519 | try dwarf.addrxSym(w, si); |
| | 520 | }, |
| | 521 | .constx_sym => |si| { |
| | 522 | try w.writeByte(DW.OP.constx); |
| | 523 | try dwarf.addrxSym(w, si); |
| | 524 | }, |
| 445 | .wasm_ext => |wasm_ext| { | 525 | .wasm_ext => |wasm_ext| { |
| 446 | try w.writeByte(DW.OP.WASM_location); | 526 | try w.writeByte(DW.OP.WASM_location); |
| 447 | switch (wasm_ext) { | 527 | switch (wasm_ext) { |
| ... | @@ -490,33 +570,33 @@ pub const Cfa = union(enum) { | ... | @@ -490,33 +570,33 @@ pub const Cfa = union(enum) { |
| 490 | const RegOff = struct { reg: u32, off: i64 }; | 570 | const RegOff = struct { reg: u32, off: i64 }; |
| 491 | const RegExpr = struct { reg: u32, expr: Loc }; | 571 | const RegExpr = struct { reg: u32, expr: Loc }; |
| 492 | | 572 | |
| 493 | fn write(cfa: Cfa, wip_nav: *WipNav) link.EmitError!void { | 573 | fn write(cfa: Cfa, wip_func: *WipFunc) link.EmitError!void { |
| 494 | const df_nw = &wip_nav.fde_writer; | 574 | const df_nw = &wip_func.fde_writer; |
| 495 | const df_w = &df_nw.interface; | 575 | const df_w = &df_nw.interface; |
| 496 | switch (cfa) { | 576 | switch (cfa) { |
| 497 | .nop => try df_w.writeByte(DW.CFA.nop), | 577 | .nop => try df_w.writeByte(DW.CFA.nop), |
| 498 | .advance_loc => |loc| { | 578 | .advance_loc => |loc| { |
| 499 | const delta = | 579 | const delta = |
| 500 | @divExact(loc - wip_nav.cfi.loc, wip_nav.dwarf.frame.header.code_alignment_factor); | 580 | @divExact(loc - wip_func.cfi.loc, wip_func.dwarf.frame.header.code_alignment_factor); |
| 501 | if (delta == 0) {} else if (std.math.cast(u6, delta)) |small_delta| | 581 | if (delta == 0) {} else if (std.math.cast(u6, delta)) |small_delta| |
| 502 | try df_w.writeByte(@as(u8, DW.CFA.advance_loc) + small_delta) | 582 | try df_w.writeByte(@as(u8, DW.CFA.advance_loc) + small_delta) |
| 503 | else if (std.math.cast(u8, delta)) |ubyte_delta| | 583 | else if (std.math.cast(u8, delta)) |ubyte_delta| |
| 504 | try df_w.writeAll(&.{ DW.CFA.advance_loc1, ubyte_delta }) | 584 | try df_w.writeAll(&.{ DW.CFA.advance_loc1, ubyte_delta }) |
| 505 | else if (std.math.cast(u16, delta)) |uhalf_delta| { | 585 | else if (std.math.cast(u16, delta)) |uhalf_delta| { |
| 506 | try df_w.writeByte(DW.CFA.advance_loc2); | 586 | try df_w.writeByte(DW.CFA.advance_loc2); |
| 507 | try df_w.writeInt(u16, uhalf_delta, wip_nav.dwarf.endian); | 587 | try df_w.writeInt(u16, uhalf_delta, wip_func.dwarf.endian); |
| 508 | } else if (std.math.cast(u32, delta)) |uword_delta| { | 588 | } else if (std.math.cast(u32, delta)) |uword_delta| { |
| 509 | try df_w.writeByte(DW.CFA.advance_loc4); | 589 | try df_w.writeByte(DW.CFA.advance_loc4); |
| 510 | try df_w.writeInt(u32, uword_delta, wip_nav.dwarf.endian); | 590 | try df_w.writeInt(u32, uword_delta, wip_func.dwarf.endian); |
| 511 | } | 591 | } |
| 512 | wip_nav.cfi.loc = loc; | 592 | wip_func.cfi.loc = loc; |
| 513 | }, | 593 | }, |
| 514 | .offset, .rel_offset => |reg_off| { | 594 | .offset, .rel_offset => |reg_off| { |
| 515 | const factored_off = @divExact(reg_off.off - switch (cfa) { | 595 | const factored_off = @divExact(reg_off.off - switch (cfa) { |
| 516 | else => unreachable, | 596 | else => unreachable, |
| 517 | .offset => 0, | 597 | .offset => 0, |
| 518 | .rel_offset => wip_nav.cfi.cfa.off, | 598 | .rel_offset => wip_func.cfi.cfa.off, |
| 519 | }, wip_nav.dwarf.frame.header.data_alignment_factor); | 599 | }, wip_func.dwarf.frame.header.data_alignment_factor); |
| 520 | if (std.math.cast(u63, factored_off)) |unsigned_off| { | 600 | if (std.math.cast(u63, factored_off)) |unsigned_off| { |
| 521 | if (std.math.cast(u6, reg_off.reg)) |small_reg| { | 601 | if (std.math.cast(u6, reg_off.reg)) |small_reg| { |
| 522 | try df_w.writeByte(@as(u8, DW.CFA.offset) + small_reg); | 602 | try df_w.writeByte(@as(u8, DW.CFA.offset) + small_reg); |
| ... | @@ -558,21 +638,21 @@ pub const Cfa = union(enum) { | ... | @@ -558,21 +638,21 @@ pub const Cfa = union(enum) { |
| 558 | const reg_off: RegOff = switch (cfa) { | 638 | const reg_off: RegOff = switch (cfa) { |
| 559 | else => unreachable, | 639 | else => unreachable, |
| 560 | .def_cfa => |reg_off| reg_off, | 640 | .def_cfa => |reg_off| reg_off, |
| 561 | .def_cfa_register => |reg| .{ .reg = reg, .off = wip_nav.cfi.cfa.off }, | 641 | .def_cfa_register => |reg| .{ .reg = reg, .off = wip_func.cfi.cfa.off }, |
| 562 | .def_cfa_offset => |off| .{ .reg = wip_nav.cfi.cfa.reg, .off = off }, | 642 | .def_cfa_offset => |off| .{ .reg = wip_func.cfi.cfa.reg, .off = off }, |
| 563 | .adjust_cfa_offset => |off| .{ | 643 | .adjust_cfa_offset => |off| .{ |
| 564 | .reg = wip_nav.cfi.cfa.reg, | 644 | .reg = wip_func.cfi.cfa.reg, |
| 565 | .off = wip_nav.cfi.cfa.off + off, | 645 | .off = wip_func.cfi.cfa.off + off, |
| 566 | }, | 646 | }, |
| 567 | }; | 647 | }; |
| 568 | const changed_reg = reg_off.reg != wip_nav.cfi.cfa.reg; | 648 | const changed_reg = reg_off.reg != wip_func.cfi.cfa.reg; |
| 569 | const unsigned_off = std.math.cast(u63, reg_off.off); | 649 | const unsigned_off = std.math.cast(u63, reg_off.off); |
| 570 | if (reg_off.off == wip_nav.cfi.cfa.off) { | 650 | if (reg_off.off == wip_func.cfi.cfa.off) { |
| 571 | if (changed_reg) { | 651 | if (changed_reg) { |
| 572 | try df_w.writeByte(DW.CFA.def_cfa_register); | 652 | try df_w.writeByte(DW.CFA.def_cfa_register); |
| 573 | try df_w.writeUleb128(reg_off.reg); | 653 | try df_w.writeUleb128(reg_off.reg); |
| 574 | } | 654 | } |
| 575 | } else if (switch (wip_nav.dwarf.frame.header.data_alignment_factor) { | 655 | } else if (switch (wip_func.dwarf.frame.header.data_alignment_factor) { |
| 576 | 0 => unreachable, | 656 | 0 => unreachable, |
| 577 | 1 => unsigned_off != null, | 657 | 1 => unsigned_off != null, |
| 578 | else => |data_alignment_factor| @rem(reg_off.off, data_alignment_factor) != 0, | 658 | else => |data_alignment_factor| @rem(reg_off.off, data_alignment_factor) != 0, |
| ... | @@ -584,23 +664,23 @@ pub const Cfa = union(enum) { | ... | @@ -584,23 +664,23 @@ pub const Cfa = union(enum) { |
| 584 | try df_w.writeByte(if (changed_reg) DW.CFA.def_cfa_sf else DW.CFA.def_cfa_offset_sf); | 664 | try df_w.writeByte(if (changed_reg) DW.CFA.def_cfa_sf else DW.CFA.def_cfa_offset_sf); |
| 585 | if (changed_reg) try df_w.writeUleb128(reg_off.reg); | 665 | if (changed_reg) try df_w.writeUleb128(reg_off.reg); |
| 586 | try df_w.writeSleb128( | 666 | try df_w.writeSleb128( |
| 587 | @divExact(reg_off.off, wip_nav.dwarf.frame.header.data_alignment_factor), | 667 | @divExact(reg_off.off, wip_func.dwarf.frame.header.data_alignment_factor), |
| 588 | ); | 668 | ); |
| 589 | } | 669 | } |
| 590 | wip_nav.cfi.cfa = reg_off; | 670 | wip_func.cfi.cfa = reg_off; |
| 591 | }, | 671 | }, |
| 592 | .def_cfa_expression => |expr| { | 672 | .def_cfa_expression => |expr| { |
| 593 | try df_w.writeByte(DW.CFA.def_cfa_expression); | 673 | try df_w.writeByte(DW.CFA.def_cfa_expression); |
| 594 | try wip_nav.dwarf.exprLoc(df_nw, expr); | 674 | try wip_func.dwarf.exprLoc(df_nw, expr); |
| 595 | }, | 675 | }, |
| 596 | .expression => |reg_expr| { | 676 | .expression => |reg_expr| { |
| 597 | try df_w.writeByte(DW.CFA.expression); | 677 | try df_w.writeByte(DW.CFA.expression); |
| 598 | try df_w.writeUleb128(reg_expr.reg); | 678 | try df_w.writeUleb128(reg_expr.reg); |
| 599 | try wip_nav.dwarf.exprLoc(df_nw, reg_expr.expr); | 679 | try wip_func.dwarf.exprLoc(df_nw, reg_expr.expr); |
| 600 | }, | 680 | }, |
| 601 | .val_offset => |reg_off| { | 681 | .val_offset => |reg_off| { |
| 602 | const factored_off = | 682 | const factored_off = |
| 603 | @divExact(reg_off.off, wip_nav.dwarf.frame.header.data_alignment_factor); | 683 | @divExact(reg_off.off, wip_func.dwarf.frame.header.data_alignment_factor); |
| 604 | if (std.math.cast(u63, factored_off)) |unsigned_off| { | 684 | if (std.math.cast(u63, factored_off)) |unsigned_off| { |
| 605 | try df_w.writeByte(DW.CFA.val_offset); | 685 | try df_w.writeByte(DW.CFA.val_offset); |
| 606 | try df_w.writeUleb128(reg_off.reg); | 686 | try df_w.writeUleb128(reg_off.reg); |
| ... | @@ -614,14 +694,14 @@ pub const Cfa = union(enum) { | ... | @@ -614,14 +694,14 @@ pub const Cfa = union(enum) { |
| 614 | .val_expression => |reg_expr| { | 694 | .val_expression => |reg_expr| { |
| 615 | try df_w.writeByte(DW.CFA.val_expression); | 695 | try df_w.writeByte(DW.CFA.val_expression); |
| 616 | try df_w.writeUleb128(reg_expr.reg); | 696 | try df_w.writeUleb128(reg_expr.reg); |
| 617 | try wip_nav.dwarf.exprLoc(df_nw, reg_expr.expr); | 697 | try wip_func.dwarf.exprLoc(df_nw, reg_expr.expr); |
| 618 | }, | 698 | }, |
| 619 | .escape => |bytes| try df_w.writeAll(bytes), | 699 | .escape => |bytes| try df_w.writeAll(bytes), |
| 620 | } | 700 | } |
| 621 | } | 701 | } |
| 622 | }; | 702 | }; |
| 623 | | 703 | |
| 624 | pub const WipNav = struct { | 704 | pub const WipFunc = struct { |
| 625 | dwarf: *Dwarf, | 705 | dwarf: *Dwarf, |
| 626 | unit: Unit.Index, | 706 | unit: Unit.Index, |
| 627 | func: InternPool.Index, | 707 | func: InternPool.Index, |
| ... | @@ -635,44 +715,50 @@ pub const WipNav = struct { | ... | @@ -635,44 +715,50 @@ pub const WipNav = struct { |
| 635 | frame_func_length: struct { offset: usize, size: AddressSize }, | 715 | frame_func_length: struct { offset: usize, size: AddressSize }, |
| 636 | | 716 | |
| 637 | pub const Debug = struct { | 717 | pub const Debug = struct { |
| 638 | wip_nav: WipNav, | 718 | wip_func: WipFunc, |
| 639 | pt: Zcu.PerThread, | 719 | pt: Zcu.PerThread, |
| 640 | any_children: bool, | 720 | is_empty: bool, |
| | 721 | empty_abbrev_code: AbbrevCode, |
| 641 | blocks: std.ArrayList(struct { | 722 | blocks: std.ArrayList(struct { |
| 642 | abbrev_code: u32, | 723 | abbrev_code_offset: usize, |
| 643 | low_pc_off: usize, | 724 | low_pc: usize, |
| 644 | high_pc: u32, | 725 | high_pc_offset: usize, |
| 645 | }), | 726 | }), |
| 646 | info_writer: link.MappedFile.Node.Writer, | 727 | info_writer: link.MappedFile.Node.Writer, |
| 647 | info_func_length_offset: usize, | 728 | info_func_length_offset: usize, |
| 648 | line_writer: link.MappedFile.Node.Writer, | 729 | line_writer: link.MappedFile.Node.Writer, |
| 649 | | 730 | |
| | 731 | pub fn init(debug: *Debug, pt: Zcu.PerThread) void { |
| | 732 | debug.pt = pt; |
| | 733 | debug.is_empty = true; |
| | 734 | debug.blocks = .empty; |
| | 735 | } |
| | 736 | |
| 650 | pub fn deinit(debug: *Debug) void { | 737 | pub fn deinit(debug: *Debug) void { |
| 651 | const gpa = debug.pt.zcu.gpa; | 738 | const gpa = debug.pt.zcu.gpa; |
| 652 | debug.line_writer.deinit(); | 739 | debug.line_writer.deinit(); |
| 653 | debug.info_writer.deinit(); | 740 | debug.info_writer.deinit(); |
| 654 | debug.blocks.deinit(gpa); | 741 | debug.blocks.deinit(gpa); |
| 655 | debug.wip_nav.deinit(); | 742 | debug.wip_func.deinit(); |
| 656 | debug.* = undefined; | 743 | debug.* = undefined; |
| 657 | } | 744 | } |
| 658 | | 745 | |
| 659 | pub fn genDebugFrame(debug: *Debug, loc: u32, cfa: Cfa) link.Error!void { | 746 | pub fn genDebugFrame(debug: *Debug, loc: u32, cfa: Cfa) link.Error!void { |
| 660 | return debug.wip_nav.genDebugFrame(loc, cfa); | 747 | return debug.wip_func.genDebugFrame(loc, cfa); |
| 661 | } | 748 | } |
| 662 | | 749 | |
| 663 | pub fn startFuncDebugInfo(debug: *Debug) link.Error!void { | 750 | pub fn startDebugInfo(debug: *Debug) link.Error!void { |
| 664 | assert(debug.wip_nav.func != .none); | 751 | debug.startDebugInfoInner() catch |err| switch (err) { |
| 665 | debug.startFuncDebugInfoInner() catch |err| switch (err) { | | |
| 666 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.info_writer), | | |
| 667 | else => |e| return e, | 752 | else => |e| return e, |
| | 753 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.info_writer), |
| 668 | }; | 754 | }; |
| 669 | } | 755 | } |
| 670 | fn startFuncDebugInfoInner(debug: *Debug) link.EmitError!void { | 756 | fn startDebugInfoInner(debug: *Debug) link.EmitError!void { |
| 671 | const dwarf = debug.wip_nav.dwarf; | 757 | const dwarf = debug.wip_func.dwarf; |
| 672 | const pt = debug.pt; | 758 | const pt = debug.pt; |
| 673 | const zcu = pt.zcu; | 759 | const zcu = pt.zcu; |
| 674 | const ip = &zcu.intern_pool; | 760 | const ip = &zcu.intern_pool; |
| 675 | const func = zcu.funcInfo(debug.wip_nav.func); | 761 | const func = zcu.funcInfo(debug.wip_func.func); |
| 676 | const nav = ip.getNav(func.owner_nav); | 762 | const nav = ip.getNav(func.owner_nav); |
| 677 | const func_type = ip.indexToKey(func.ty).func_type; | 763 | const func_type = ip.indexToKey(func.ty).func_type; |
| 678 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; | 764 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; |
| ... | @@ -681,42 +767,52 @@ pub const WipNav = struct { | ... | @@ -681,42 +767,52 @@ pub const WipNav = struct { |
| 681 | const decl = zf.zir.?.getDeclaration(inst_info.inst); | 767 | const decl = zf.zir.?.getDeclaration(inst_info.inst); |
| 682 | const di_nw = &debug.info_writer; | 768 | const di_nw = &debug.info_writer; |
| 683 | const di_w = &di_nw.interface; | 769 | const di_w = &di_nw.interface; |
| 684 | try dwarf.abbrevCode(di_nw, .decl_func); | 770 | const parent_ty: Type = .fromInterned(ip.namespacePtr(switch (func.generic_owner) { |
| 685 | try dwarf.refType(pt, di_nw, .fromInterned(ip.namespacePtr(switch (func.generic_owner) { | | |
| 686 | .none => nav, | | |
| 687 | else => |generic_owner| ip.getNav(zcu.funcInfo(generic_owner).owner_nav), | 771 | else => |generic_owner| ip.getNav(zcu.funcInfo(generic_owner).owner_nav), |
| 688 | }.analysis.?.namespace).owner_type)); | 772 | .none => nav, |
| 689 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 773 | }.analysis.?.namespace).owner_type); |
| 690 | try di_w.writeUleb128(decl.src_column + 1); | 774 | if (func.generic_owner != .none or parent_ty.getCaptures(zcu).len > 0) { |
| 691 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 775 | debug.empty_abbrev_code = .decl_instance_empty_func; |
| 692 | try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip)); | 776 | try dwarf.abbrevCode(di_nw, .decl_instance_func); |
| 693 | try dwarf.strp(&dwarf.debug_str, di_nw, switch (decl.linkage) { | 777 | try dwarf.refType(pt, di_nw, parent_ty); |
| | 778 | try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, debug.wip_func.func), 0); |
| | 779 | } else { |
| | 780 | debug.empty_abbrev_code = .decl_empty_func; |
| | 781 | try dwarf.abbrevCode(di_nw, .decl_func); |
| | 782 | try dwarf.refType(pt, di_nw, parent_ty); |
| | 783 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 784 | try di_w.writeUleb128(decl.src_column + 1); |
| | 785 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| | 786 | try dwarf.strx(di_nw, nav.name.toSlice(ip)); |
| | 787 | } |
| | 788 | try dwarf.strx(di_nw, switch (decl.linkage) { |
| 694 | .normal => nav.fqn, | 789 | .normal => nav.fqn, |
| 695 | .@"extern", .@"export" => nav.name, | 790 | .@"extern", .@"export" => nav.name, |
| 696 | }.toSlice(ip)); | 791 | }.toSlice(ip)); |
| 697 | try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type)); | 792 | try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type)); |
| 698 | try dwarf.addrSym(di_nw, debug.wip_nav.func_si, 0); | 793 | try dwarf.addrxSym(di_w, debug.wip_func.func_si); |
| 699 | debug.info_func_length_offset = di_w.end; | 794 | debug.info_func_length_offset = di_w.end; |
| 700 | try di_w.writeInt(u32, undefined, dwarf.endian); | 795 | try di_w.writeInt(u32, undefined, dwarf.endian); |
| 701 | try di_w.writeUleb128( | 796 | try di_w.writeUleb128( |
| 702 | target_info.minFunctionAlignment(target).max(nav.resolved.?.@"align").toByteUnits().?, | 797 | target_info.minFunctionAlignment(target).max(nav.resolved.?.@"align").toByteUnits().?, |
| 703 | ); | 798 | ); |
| 704 | try di_w.writeByte(@intFromBool(decl.linkage != .normal)); | 799 | try di_w.writeAll(&.{ |
| 705 | try di_w.writeByte(@intFromBool(Type.fromInterned(func_type.return_type).isNoReturn(zcu))); | 800 | @intFromBool(decl.linkage != .normal), |
| | 801 | @intFromBool(Type.fromInterned(func_type.return_type).isNoReturn(zcu)), |
| | 802 | }); |
| 706 | } | 803 | } |
| 707 | | 804 | |
| 708 | pub fn startDebugLine(debug: *Debug) link.Error!void { | 805 | pub fn startDebugLine(debug: *Debug) link.Error!void { |
| 709 | assert(debug.wip_nav.func != .none); | | |
| 710 | debug.startDebugLineInner() catch |err| switch (err) { | 806 | debug.startDebugLineInner() catch |err| switch (err) { |
| 711 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.line_writer), | | |
| 712 | else => |e| return e, | 807 | else => |e| return e, |
| | 808 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.line_writer), |
| 713 | }; | 809 | }; |
| 714 | } | 810 | } |
| 715 | fn startDebugLineInner(debug: *Debug) link.EmitError!void { | 811 | fn startDebugLineInner(debug: *Debug) link.EmitError!void { |
| 716 | const dwarf = debug.wip_nav.dwarf; | 812 | const dwarf = debug.wip_func.dwarf; |
| 717 | const zcu = debug.pt.zcu; | 813 | const zcu = debug.pt.zcu; |
| 718 | const ip = &zcu.intern_pool; | 814 | const ip = &zcu.intern_pool; |
| 719 | const func = zcu.funcInfo(debug.wip_nav.func); | 815 | const func = zcu.funcInfo(debug.wip_func.func); |
| 720 | const inst_info = ip.getNav(func.owner_nav).srcInst(ip).resolveFull(ip).?; | 816 | const inst_info = ip.getNav(func.owner_nav).srcInst(ip).resolveFull(ip).?; |
| 721 | const zf = zcu.fileByIndex(inst_info.file); | 817 | const zf = zcu.fileByIndex(inst_info.file); |
| 722 | const decl = zf.zir.?.getDeclaration(inst_info.inst); | 818 | const decl = zf.zir.?.getDeclaration(inst_info.inst); |
| ... | @@ -735,10 +831,10 @@ pub const WipNav = struct { | ... | @@ -735,10 +831,10 @@ pub const WipNav = struct { |
| 735 | } else { | 831 | } else { |
| 736 | try dl_w.writeUleb128(1 + @backingInt(dwarf.address_size)); | 832 | try dl_w.writeUleb128(1 + @backingInt(dwarf.address_size)); |
| 737 | try dl_w.writeByte(DW.LNE.set_address); | 833 | try dl_w.writeByte(DW.LNE.set_address); |
| 738 | try dwarf.addrSym(dl_nw, debug.wip_nav.func_si, 0); | 834 | try dwarf.addrSym(dl_nw, debug.wip_func.func_si, 0); |
| 739 | | 835 | |
| 740 | const unit = dwarf.getUnit(zf.mod.?); | 836 | const ui = dwarf.getUnit(zf.mod.?); |
| 741 | _, const fi = try unit.get(dwarf).getFile(zcu.gpa, unit, inst_info.file); | 837 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, inst_info.file); |
| 742 | try dl_w.writeByte(DW.LNS.set_file); | 838 | try dl_w.writeByte(DW.LNS.set_file); |
| 743 | try dl_w.writeUleb128(@backingInt(fi)); | 839 | try dl_w.writeUleb128(@backingInt(fi)); |
| 744 | | 840 | |
| ... | @@ -749,28 +845,32 @@ pub const WipNav = struct { | ... | @@ -749,28 +845,32 @@ pub const WipNav = struct { |
| 749 | } | 845 | } |
| 750 | } | 846 | } |
| 751 | | 847 | |
| 752 | pub fn finishFunc(debug: *Debug, func_length: u64) link.Error!void { | 848 | pub fn finish(debug: *Debug, func_length: u64) link.Error!void { |
| 753 | assert(debug.wip_nav.func != .none); | | |
| 754 | const di_nw = &debug.info_writer; | 849 | const di_nw = &debug.info_writer; |
| 755 | debug.finishDebugInfo(func_length) catch |err| switch (err) { | 850 | debug.finishDebugInfo(func_length) catch |err| switch (err) { |
| 756 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(di_nw), | | |
| 757 | else => |e| return e, | 851 | else => |e| return e, |
| | 852 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(di_nw), |
| 758 | }; | 853 | }; |
| 759 | debug.finishDebugLine() catch |err| switch (err) { | 854 | debug.finishDebugLine() catch |err| switch (err) { |
| 760 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(di_nw), | | |
| 761 | else => |e| return e, | 855 | else => |e| return e, |
| | 856 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(di_nw), |
| 762 | }; | 857 | }; |
| 763 | } | 858 | } |
| 764 | fn finishDebugInfo(debug: *Debug, func_length: u64) link.EmitError!void { | 859 | fn finishDebugInfo(debug: *Debug, func_length: u64) link.EmitError!void { |
| 765 | const dwarf = debug.wip_nav.dwarf; | 860 | const dwarf = debug.wip_func.dwarf; |
| 766 | const di_w = &debug.info_writer.interface; | 861 | const di_nw = &debug.info_writer; |
| | 862 | const di_w = &di_nw.interface; |
| 767 | std.mem.writeInt( | 863 | std.mem.writeInt( |
| 768 | u32, | 864 | u32, |
| 769 | di_w.buffered()[debug.info_func_length_offset..][0..4], | 865 | di_w.buffered()[debug.info_func_length_offset..][0..4], |
| 770 | @intCast(func_length), | 866 | @intCast(func_length), |
| 771 | dwarf.endian, | 867 | dwarf.endian, |
| 772 | ); | 868 | ); |
| 773 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | 869 | if (debug.is_empty) std.leb.writeUnsignedFixed( |
| | 870 | AbbrevCode.decl_size, |
| | 871 | di_w.buffered()[0..AbbrevCode.decl_size], |
| | 872 | @intCast(try dwarf.refAbbrevCode(di_nw.mf, debug.empty_abbrev_code)), |
| | 873 | ) else try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 774 | try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen()); | 874 | try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen()); |
| 775 | } | 875 | } |
| 776 | fn finishDebugLine(debug: *Debug) link.EmitError!void { | 876 | fn finishDebugLine(debug: *Debug) link.EmitError!void { |
| ... | @@ -787,8 +887,8 @@ pub const WipNav = struct { | ... | @@ -787,8 +887,8 @@ pub const WipNav = struct { |
| 787 | loc: Loc, | 887 | loc: Loc, |
| 788 | ) link.Error!void { | 888 | ) link.Error!void { |
| 789 | return debug.genLocalVarDebugInfoInner(tag, opt_name, ty, loc) catch |err| switch (err) { | 889 | return debug.genLocalVarDebugInfoInner(tag, opt_name, ty, loc) catch |err| switch (err) { |
| 790 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.info_writer), | | |
| 791 | else => |e| e, | 890 | else => |e| e, |
| | 891 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.info_writer), |
| 792 | }; | 892 | }; |
| 793 | } | 893 | } |
| 794 | fn genLocalVarDebugInfoInner( | 894 | fn genLocalVarDebugInfoInner( |
| ... | @@ -798,17 +898,16 @@ pub const WipNav = struct { | ... | @@ -798,17 +898,16 @@ pub const WipNav = struct { |
| 798 | ty: Type, | 898 | ty: Type, |
| 799 | loc: Loc, | 899 | loc: Loc, |
| 800 | ) link.EmitError!void { | 900 | ) link.EmitError!void { |
| 801 | assert(debug.wip_nav.func != .none); | 901 | const dwarf = debug.wip_func.dwarf; |
| 802 | const dwarf = debug.wip_nav.dwarf; | | |
| 803 | const di_nw = &debug.info_writer; | 902 | const di_nw = &debug.info_writer; |
| 804 | try dwarf.abbrevCode(di_nw, switch (tag) { | 903 | try dwarf.abbrevCode(di_nw, switch (tag) { |
| 805 | .arg => if (opt_name) |_| .arg else .unnamed_arg, | 904 | .arg => if (opt_name) |_| .arg else .unnamed_arg, |
| 806 | .local_var => if (opt_name) |_| .local_var else unreachable, | 905 | .local_var => if (opt_name) |_| .local_var else unreachable, |
| 807 | }); | 906 | }); |
| 808 | if (opt_name) |name| try dwarf.strp(&dwarf.debug_str, di_nw, name); | 907 | if (opt_name) |name| try dwarf.strx(di_nw, name); |
| 809 | try dwarf.refType(debug.pt, di_nw, ty); | 908 | try dwarf.refType(debug.pt, di_nw, ty); |
| 810 | try dwarf.exprLoc(di_nw, loc); | 909 | try dwarf.exprLoc(di_nw, loc); |
| 811 | debug.any_children = true; | 910 | debug.is_empty = false; |
| 812 | } | 911 | } |
| 813 | | 912 | |
| 814 | pub const LocalConstTag = enum { comptime_arg, local_const }; | 913 | pub const LocalConstTag = enum { comptime_arg, local_const }; |
| ... | @@ -819,8 +918,8 @@ pub const WipNav = struct { | ... | @@ -819,8 +918,8 @@ pub const WipNav = struct { |
| 819 | val: Value, | 918 | val: Value, |
| 820 | ) link.Error!void { | 919 | ) link.Error!void { |
| 821 | return debug.genLocalConstDebugInfoInner(tag, opt_name, val) catch |err| switch (err) { | 920 | return debug.genLocalConstDebugInfoInner(tag, opt_name, val) catch |err| switch (err) { |
| 822 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.info_writer), | | |
| 823 | else => |e| e, | 921 | else => |e| e, |
| | 922 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.info_writer), |
| 824 | }; | 923 | }; |
| 825 | } | 924 | } |
| 826 | fn genLocalConstDebugInfoInner( | 925 | fn genLocalConstDebugInfoInner( |
| ... | @@ -829,8 +928,7 @@ pub const WipNav = struct { | ... | @@ -829,8 +928,7 @@ pub const WipNav = struct { |
| 829 | opt_name: ?[]const u8, | 928 | opt_name: ?[]const u8, |
| 830 | val: Value, | 929 | val: Value, |
| 831 | ) link.EmitError!void { | 930 | ) link.EmitError!void { |
| 832 | assert(debug.wip_nav.func != .none); | 931 | const dwarf = debug.wip_func.dwarf; |
| 833 | const dwarf = debug.wip_nav.dwarf; | | |
| 834 | const pt = debug.pt; | 932 | const pt = debug.pt; |
| 835 | const zcu = debug.pt.zcu; | 933 | const zcu = debug.pt.zcu; |
| 836 | const ty = val.typeOf(zcu); | 934 | const ty = val.typeOf(zcu); |
| ... | @@ -858,23 +956,22 @@ pub const WipNav = struct { | ... | @@ -858,23 +956,22 @@ pub const WipNav = struct { |
| 858 | .fully_comptime => .local_const_fully_comptime, | 956 | .fully_comptime => .local_const_fully_comptime, |
| 859 | } else unreachable, | 957 | } else unreachable, |
| 860 | }); | 958 | }); |
| 861 | if (opt_name) |name| try dwarf.strp(&dwarf.debug_str, di_nw, name); | 959 | if (opt_name) |name| try dwarf.strx(di_nw, name); |
| 862 | try dwarf.refType(pt, di_nw, ty); | 960 | try dwarf.refType(pt, di_nw, ty); |
| 863 | if (ty_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, val); | 961 | if (ty_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, val); |
| 864 | if (ty_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, val); | 962 | if (ty_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, val); |
| 865 | debug.any_children = true; | 963 | debug.is_empty = false; |
| 866 | } | 964 | } |
| 867 | | 965 | |
| 868 | pub fn genVarArgsDebugInfo(debug: *Debug) link.Error!void { | 966 | pub fn genVarArgsDebugInfo(debug: *Debug) link.Error!void { |
| 869 | return debug.genVarArgsDebugInfoInner() catch |err| switch (err) { | 967 | return debug.genVarArgsDebugInfoInner() catch |err| switch (err) { |
| 870 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.info_writer), | | |
| 871 | else => |e| e, | 968 | else => |e| e, |
| | 969 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.info_writer), |
| 872 | }; | 970 | }; |
| 873 | } | 971 | } |
| 874 | fn genVarArgsDebugInfoInner(debug: *Debug) link.EmitError!void { | 972 | fn genVarArgsDebugInfoInner(debug: *Debug) link.EmitError!void { |
| 875 | assert(debug.wip_nav.func != .none); | 973 | try debug.wip_func.dwarf.abbrevCode(&debug.info_writer, .is_var_args); |
| 876 | try debug.wip_nav.dwarf.abbrevCode(&debug.info_writer, .is_var_args); | 974 | debug.is_empty = false; |
| 877 | debug.any_children = true; | | |
| 878 | } | 975 | } |
| 879 | | 976 | |
| 880 | pub fn advanceLineAndPc( | 977 | pub fn advanceLineAndPc( |
| ... | @@ -884,7 +981,7 @@ pub const WipNav = struct { | ... | @@ -884,7 +981,7 @@ pub const WipNav = struct { |
| 884 | end: bool, | 981 | end: bool, |
| 885 | ) link.Error!void { | 982 | ) link.Error!void { |
| 886 | return debug.advanceLineAndPcInner(delta_line, delta_pc, end) catch |err| switch (err) { | 983 | return debug.advanceLineAndPcInner(delta_line, delta_pc, end) catch |err| switch (err) { |
| 887 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.line_writer), | 984 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.line_writer), |
| 888 | }; | 985 | }; |
| 889 | } | 986 | } |
| 890 | fn advanceLineAndPcInner( | 987 | fn advanceLineAndPcInner( |
| ... | @@ -895,7 +992,7 @@ pub const WipNav = struct { | ... | @@ -895,7 +992,7 @@ pub const WipNav = struct { |
| 895 | ) std.Io.Writer.Error!void { | 992 | ) std.Io.Writer.Error!void { |
| 896 | const dl_w = &debug.line_writer.interface; | 993 | const dl_w = &debug.line_writer.interface; |
| 897 | | 994 | |
| 898 | const header = debug.wip_nav.dwarf.debug_line.header; | 995 | const header = debug.wip_func.dwarf.debug_line.header; |
| 899 | assert(header.maximum_operations_per_instruction == 1); | 996 | assert(header.maximum_operations_per_instruction == 1); |
| 900 | const delta_op: u64 = 0; | 997 | const delta_op: u64 = 0; |
| 901 | | 998 | |
| ... | @@ -939,7 +1036,7 @@ pub const WipNav = struct { | ... | @@ -939,7 +1036,7 @@ pub const WipNav = struct { |
| 939 | | 1036 | |
| 940 | pub fn setColumn(debug: *Debug, column: u32) link.Error!void { | 1037 | pub fn setColumn(debug: *Debug, column: u32) link.Error!void { |
| 941 | return debug.setColumnInner(column) catch |err| switch (err) { | 1038 | return debug.setColumnInner(column) catch |err| switch (err) { |
| 942 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.line_writer), | 1039 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.line_writer), |
| 943 | }; | 1040 | }; |
| 944 | } | 1041 | } |
| 945 | fn setColumnInner(debug: *Debug, column: u32) std.Io.Writer.Error!void { | 1042 | fn setColumnInner(debug: *Debug, column: u32) std.Io.Writer.Error!void { |
| ... | @@ -950,7 +1047,7 @@ pub const WipNav = struct { | ... | @@ -950,7 +1047,7 @@ pub const WipNav = struct { |
| 950 | | 1047 | |
| 951 | pub fn negateStmt(debug: *Debug) link.Error!void { | 1048 | pub fn negateStmt(debug: *Debug) link.Error!void { |
| 952 | return debug.negateStmtInner() catch |err| switch (err) { | 1049 | return debug.negateStmtInner() catch |err| switch (err) { |
| 953 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.line_writer), | 1050 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.line_writer), |
| 954 | }; | 1051 | }; |
| 955 | } | 1052 | } |
| 956 | fn negateStmtInner(debug: *Debug) std.Io.Writer.Error!void { | 1053 | fn negateStmtInner(debug: *Debug) std.Io.Writer.Error!void { |
| ... | @@ -959,7 +1056,7 @@ pub const WipNav = struct { | ... | @@ -959,7 +1056,7 @@ pub const WipNav = struct { |
| 959 | | 1056 | |
| 960 | pub fn setPrologueEnd(debug: *Debug) link.Error!void { | 1057 | pub fn setPrologueEnd(debug: *Debug) link.Error!void { |
| 961 | return debug.setPrologueEndInner() catch |err| switch (err) { | 1058 | return debug.setPrologueEndInner() catch |err| switch (err) { |
| 962 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.line_writer), | 1059 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.line_writer), |
| 963 | }; | 1060 | }; |
| 964 | } | 1061 | } |
| 965 | fn setPrologueEndInner(debug: *Debug) std.Io.Writer.Error!void { | 1062 | fn setPrologueEndInner(debug: *Debug) std.Io.Writer.Error!void { |
| ... | @@ -968,151 +1065,155 @@ pub const WipNav = struct { | ... | @@ -968,151 +1065,155 @@ pub const WipNav = struct { |
| 968 | | 1065 | |
| 969 | pub fn setEpilogueBegin(debug: *Debug) link.Error!void { | 1066 | pub fn setEpilogueBegin(debug: *Debug) link.Error!void { |
| 970 | return debug.setEpilogueBeginInner() catch |err| switch (err) { | 1067 | return debug.setEpilogueBeginInner() catch |err| switch (err) { |
| 971 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.line_writer), | 1068 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.line_writer), |
| 972 | }; | 1069 | }; |
| 973 | } | 1070 | } |
| 974 | fn setEpilogueBeginInner(debug: *Debug) std.Io.Writer.Error!void { | 1071 | fn setEpilogueBeginInner(debug: *Debug) std.Io.Writer.Error!void { |
| 975 | try debug.line_writer.interface.writeByte(DW.LNS.set_epilogue_begin); | 1072 | try debug.line_writer.interface.writeByte(DW.LNS.set_epilogue_begin); |
| 976 | } | 1073 | } |
| 977 | | 1074 | |
| 978 | pub fn enterBlock(debug: *Debug, code_off: usize) link.Error!void { | 1075 | pub fn enterBlock(debug: *Debug, code_offset: usize) link.Error!void { |
| 979 | return debug.enterBlockInner(code_off) catch |err| switch (err) { | 1076 | return debug.enterBlockInner(code_offset) catch |err| switch (err) { |
| 980 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.info_writer), | | |
| 981 | else => |e| e, | 1077 | else => |e| e, |
| | 1078 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.info_writer), |
| 982 | }; | 1079 | }; |
| 983 | } | 1080 | } |
| 984 | fn enterBlockInner(debug: *Debug, code_off: usize) link.EmitError!void { | 1081 | fn enterBlockInner(debug: *Debug, code_offset: usize) link.EmitError!void { |
| 985 | const dwarf = debug.wip_nav.dwarf; | 1082 | const dwarf = debug.wip_func.dwarf; |
| 986 | const block = try debug.blocks.addOne(dwarf.lf.comp.gpa); | 1083 | const block = try debug.blocks.addOne(dwarf.lf.comp.gpa); |
| 987 | | 1084 | |
| 988 | const di_nw = &debug.info_writer; | 1085 | const di_nw = &debug.info_writer; |
| 989 | const di_w = &di_nw.interface; | 1086 | const di_w = &di_nw.interface; |
| 990 | block.abbrev_code = @intCast(di_w.end); | 1087 | block.abbrev_code_offset = di_w.end; |
| 991 | try dwarf.abbrevCode(di_nw, .block); | 1088 | try dwarf.abbrevCode(di_nw, .block); |
| 992 | block.low_pc_off = code_off; | 1089 | block.low_pc = code_offset; |
| 993 | try dwarf.addrSym(di_nw, debug.wip_nav.func_si, code_off); | 1090 | try dwarf.addrSym(di_nw, debug.wip_func.func_si, code_offset); |
| 994 | block.high_pc = @intCast(di_w.end); | 1091 | block.high_pc_offset = di_w.end; |
| 995 | try di_w.writeInt(u32, 0, dwarf.endian); | 1092 | try di_w.writeInt(u32, 0, dwarf.endian); |
| 996 | debug.any_children = false; | 1093 | debug.is_empty = true; |
| 997 | } | 1094 | } |
| 998 | | 1095 | |
| 999 | pub fn leaveBlock(debug: *Debug, code_off: usize) link.Error!void { | 1096 | pub fn leaveBlock(debug: *Debug, code_offset: usize) link.Error!void { |
| 1000 | return debug.leaveBlockInner(code_off) catch |err| switch (err) { | 1097 | return debug.leaveBlockInner(code_offset) catch |err| switch (err) { |
| 1001 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.info_writer), | | |
| 1002 | else => |e| e, | 1098 | else => |e| e, |
| | 1099 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.info_writer), |
| 1003 | }; | 1100 | }; |
| 1004 | } | 1101 | } |
| 1005 | fn leaveBlockInner(debug: *Debug, code_off: usize) link.EmitError!void { | 1102 | fn leaveBlockInner(debug: *Debug, code_offset: usize) link.EmitError!void { |
| 1006 | const dwarf = debug.wip_nav.dwarf; | 1103 | const dwarf = debug.wip_func.dwarf; |
| 1007 | const block_size = comptime uleb128Size(@backingInt(AbbrevCode.block)); | | |
| 1008 | const block = debug.blocks.pop().?; | 1104 | const block = debug.blocks.pop().?; |
| 1009 | | 1105 | |
| 1010 | const di_nw = &debug.info_writer; | 1106 | const di_nw = &debug.info_writer; |
| 1011 | const di_w = &di_nw.interface; | 1107 | const di_w = &di_nw.interface; |
| 1012 | if (debug.any_children) | 1108 | const block_size = comptime uleb128Size(@backingInt(AbbrevCode.block)); |
| 1013 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)) | 1109 | if (debug.is_empty) std.leb.writeUnsignedFixed( |
| 1014 | else | 1110 | block_size, |
| 1015 | std.leb.writeUnsignedFixed( | 1111 | di_w.buffered()[block.abbrev_code_offset..][0..block_size], |
| 1016 | block_size, | 1112 | @intCast(try dwarf.refAbbrevCode(di_nw.mf, .empty_block)), |
| 1017 | di_w.buffered()[block.abbrev_code..][0..block_size], | 1113 | ) else try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 1018 | @intCast(try dwarf.refAbbrevCode(di_nw.mf, .empty_block)), | | |
| 1019 | ); | | |
| 1020 | std.mem.writeInt( | 1114 | std.mem.writeInt( |
| 1021 | u32, | 1115 | u32, |
| 1022 | di_nw.interface.buffered()[block.high_pc..][0..4], | 1116 | di_nw.interface.buffered()[block.high_pc_offset..][0..4], |
| 1023 | @intCast(code_off - block.low_pc_off), | 1117 | @intCast(code_offset - block.low_pc), |
| 1024 | dwarf.endian, | 1118 | dwarf.endian, |
| 1025 | ); | 1119 | ); |
| 1026 | debug.any_children = true; | 1120 | debug.is_empty = false; |
| 1027 | } | 1121 | } |
| 1028 | | 1122 | |
| 1029 | pub fn enterInlineFunc( | 1123 | pub fn enterInlineFunc( |
| 1030 | debug: *Debug, | 1124 | debug: *Debug, |
| 1031 | func: InternPool.Index, | 1125 | func: InternPool.Index, |
| 1032 | code_off: usize, | 1126 | code_offset: usize, |
| 1033 | line: u32, | 1127 | line: u32, |
| 1034 | column: u32, | 1128 | column: u32, |
| 1035 | ) link.Error!void { | 1129 | ) link.Error!void { |
| 1036 | return debug.enterInlineFuncInner(func, code_off, line, column) catch |err| switch (err) { | 1130 | return debug.enterInlineFuncInner( |
| 1037 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.info_writer), | 1131 | func, |
| | 1132 | code_offset, |
| | 1133 | line, |
| | 1134 | column, |
| | 1135 | ) catch |err| switch (err) { |
| 1038 | else => |e| e, | 1136 | else => |e| e, |
| | 1137 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.info_writer), |
| 1039 | }; | 1138 | }; |
| 1040 | } | 1139 | } |
| 1041 | fn enterInlineFuncInner( | 1140 | fn enterInlineFuncInner( |
| 1042 | debug: *Debug, | 1141 | debug: *Debug, |
| 1043 | func: InternPool.Index, | 1142 | func: InternPool.Index, |
| 1044 | code_off: usize, | 1143 | code_offset: usize, |
| 1045 | line: u32, | 1144 | line: u32, |
| 1046 | column: u32, | 1145 | column: u32, |
| 1047 | ) link.EmitError!void { | 1146 | ) link.EmitError!void { |
| 1048 | const dwarf = debug.wip_nav.dwarf; | 1147 | const dwarf = debug.wip_func.dwarf; |
| 1049 | const zcu = debug.pt.zcu; | 1148 | const pt = debug.pt; |
| | 1149 | const zcu = pt.zcu; |
| 1050 | const block = try debug.blocks.addOne(zcu.gpa); | 1150 | const block = try debug.blocks.addOne(zcu.gpa); |
| 1051 | | 1151 | |
| 1052 | const di_nw = &debug.info_writer; | 1152 | const di_nw = &debug.info_writer; |
| 1053 | const di_w = &di_nw.interface; | 1153 | const di_w = &di_nw.interface; |
| 1054 | block.abbrev_code = @intCast(di_w.end); | 1154 | block.abbrev_code_offset = di_w.end; |
| 1055 | try dwarf.abbrevCode(di_nw, .inlined_func); | 1155 | try dwarf.abbrevCode(di_nw, .inlined_func); |
| 1056 | try debug.refFunc(func); | 1156 | try dwarf.refConst(pt, di_nw, .fromInterned(func)); |
| 1057 | try di_w.writeUleb128((if (zcu.comp.config.incremental) | 1157 | try di_w.writeUleb128((if (zcu.comp.config.incremental) |
| 1058 | 0 | 1158 | 0 |
| 1059 | else | 1159 | else |
| 1060 | zcu.navSrcLine(zcu.funcInfo(debug.wip_nav.func).owner_nav) + 1) + line); | 1160 | zcu.navSrcLine(zcu.funcInfo(debug.wip_func.func).owner_nav) + 1) + line); |
| 1061 | try di_w.writeUleb128(column + 1); | 1161 | try di_w.writeUleb128(column + 1); |
| 1062 | block.low_pc_off = code_off; | 1162 | block.low_pc = code_offset; |
| 1063 | try dwarf.addrSym(di_nw, debug.wip_nav.func_si, code_off); | 1163 | try dwarf.addrSym(di_nw, debug.wip_func.func_si, code_offset); |
| 1064 | block.high_pc = @intCast(di_w.end); | 1164 | block.high_pc_offset = di_w.end; |
| 1065 | try di_w.writeInt(u32, 0, dwarf.endian); | 1165 | try di_w.writeInt(u32, 0, dwarf.endian); |
| 1066 | try debug.setInlineFunc(func); | 1166 | try debug.setInlineFunc(func); |
| 1067 | debug.any_children = false; | 1167 | debug.is_empty = true; |
| 1068 | } | 1168 | } |
| 1069 | | 1169 | |
| 1070 | pub fn leaveInlineFunc(debug: *Debug, func: InternPool.Index, code_off: usize) link.Error!void { | 1170 | pub fn leaveInlineFunc( |
| 1071 | return debug.leaveInlineFuncInner(func, code_off) catch |err| switch (err) { | 1171 | debug: *Debug, |
| 1072 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.info_writer), | 1172 | func: InternPool.Index, |
| | 1173 | code_offset: usize, |
| | 1174 | ) link.Error!void { |
| | 1175 | return debug.leaveInlineFuncInner(func, code_offset) catch |err| switch (err) { |
| 1073 | else => |e| e, | 1176 | else => |e| e, |
| | 1177 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.info_writer), |
| 1074 | }; | 1178 | }; |
| 1075 | } | 1179 | } |
| 1076 | fn leaveInlineFuncInner( | 1180 | fn leaveInlineFuncInner( |
| 1077 | debug: *Debug, | 1181 | debug: *Debug, |
| 1078 | func: InternPool.Index, | 1182 | func: InternPool.Index, |
| 1079 | code_off: usize, | 1183 | code_offset: usize, |
| 1080 | ) link.EmitError!void { | 1184 | ) link.EmitError!void { |
| 1081 | const dwarf = debug.wip_nav.dwarf; | 1185 | const dwarf = debug.wip_func.dwarf; |
| 1082 | const inlined_func_size = comptime uleb128Size(@backingInt(AbbrevCode.inlined_func)); | | |
| 1083 | const block = debug.blocks.pop().?; | 1186 | const block = debug.blocks.pop().?; |
| 1084 | | 1187 | |
| 1085 | const di_nw = &debug.info_writer; | 1188 | const di_nw = &debug.info_writer; |
| 1086 | const di_w = &di_nw.interface; | 1189 | const di_w = &di_nw.interface; |
| 1087 | if (debug.any_children) | 1190 | const inlined_func_size = comptime uleb128Size(@backingInt(AbbrevCode.inlined_func)); |
| 1088 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)) | 1191 | if (debug.is_empty) std.leb.writeUnsignedFixed( |
| 1089 | else | 1192 | inlined_func_size, |
| 1090 | std.leb.writeUnsignedFixed( | 1193 | di_w.buffered()[block.abbrev_code_offset..][0..inlined_func_size], |
| 1091 | inlined_func_size, | 1194 | @intCast(try dwarf.refAbbrevCode(di_nw.mf, .empty_inlined_func)), |
| 1092 | di_w.buffered()[block.abbrev_code..][0..inlined_func_size], | 1195 | ) else try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 1093 | @intCast(try dwarf.refAbbrevCode(di_nw.mf, .empty_inlined_func)), | | |
| 1094 | ); | | |
| 1095 | std.mem.writeInt( | 1196 | std.mem.writeInt( |
| 1096 | u32, | 1197 | u32, |
| 1097 | di_w.buffered()[block.high_pc..][0..4], | 1198 | di_w.buffered()[block.high_pc_offset..][0..4], |
| 1098 | @intCast(code_off - block.low_pc_off), | 1199 | @intCast(code_offset - block.low_pc), |
| 1099 | dwarf.endian, | 1200 | dwarf.endian, |
| 1100 | ); | 1201 | ); |
| 1101 | try debug.setInlineFunc(func); | 1202 | try debug.setInlineFunc(func); |
| 1102 | debug.any_children = true; | 1203 | debug.is_empty = false; |
| 1103 | } | 1204 | } |
| 1104 | | 1205 | |
| 1105 | pub fn setInlineFunc(debug: *Debug, func: InternPool.Index) link.Error!void { | 1206 | pub fn setInlineFunc(debug: *Debug, func: InternPool.Index) link.Error!void { |
| 1106 | return debug.setInlineFuncInner(func) catch |err| switch (err) { | 1207 | return debug.setInlineFuncInner(func) catch |err| switch (err) { |
| 1107 | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.line_writer), | | |
| 1108 | else => |e| e, | 1208 | else => |e| e, |
| | 1209 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.line_writer), |
| 1109 | }; | 1210 | }; |
| 1110 | } | 1211 | } |
| 1111 | fn setInlineFuncInner(debug: *Debug, func: InternPool.Index) link.EmitError!void { | 1212 | fn setInlineFuncInner(debug: *Debug, func: InternPool.Index) link.EmitError!void { |
| 1112 | const zcu = debug.pt.zcu; | 1213 | const zcu = debug.pt.zcu; |
| 1113 | const ip = &zcu.intern_pool; | 1214 | const ip = &zcu.intern_pool; |
| 1114 | const dwarf = debug.wip_nav.dwarf; | 1215 | const dwarf = debug.wip_func.dwarf; |
| 1115 | if (debug.wip_nav.func == func) return; | 1216 | if (debug.wip_func.func == func) return; |
| 1116 | | 1217 | |
| 1117 | const dl_nw = &debug.line_writer; | 1218 | const dl_nw = &debug.line_writer; |
| 1118 | const dl_w = &dl_nw.interface; | 1219 | const dl_w = &dl_nw.interface; |
| ... | @@ -1126,7 +1227,7 @@ pub const WipNav = struct { | ... | @@ -1126,7 +1227,7 @@ pub const WipNav = struct { |
| 1126 | return; | 1227 | return; |
| 1127 | } | 1228 | } |
| 1128 | | 1229 | |
| 1129 | const old_owner_nav = zcu.funcInfo(debug.wip_nav.func).owner_nav; | 1230 | const old_owner_nav = zcu.funcInfo(debug.wip_func.func).owner_nav; |
| 1130 | const old_inst_info = ip.getNav(old_owner_nav).srcInst(ip).resolveFull(ip).?; | 1231 | const old_inst_info = ip.getNav(old_owner_nav).srcInst(ip).resolveFull(ip).?; |
| 1131 | const old_zf = zcu.fileByIndex(old_inst_info.file); | 1232 | const old_zf = zcu.fileByIndex(old_inst_info.file); |
| 1132 | const new_inst_info = ip.getNav(new_owner_nav).srcInst(ip).resolveFull(ip).?; | 1233 | const new_inst_info = ip.getNav(new_owner_nav).srcInst(ip).resolveFull(ip).?; |
| ... | @@ -1134,7 +1235,7 @@ pub const WipNav = struct { | ... | @@ -1134,7 +1235,7 @@ pub const WipNav = struct { |
| 1134 | if (old_inst_info.file != new_inst_info.file) { | 1235 | if (old_inst_info.file != new_inst_info.file) { |
| 1135 | const new_ui = dwarf.getUnit(new_zf.mod.?); | 1236 | const new_ui = dwarf.getUnit(new_zf.mod.?); |
| 1136 | _, const new_fi = | 1237 | _, const new_fi = |
| 1137 | try debug.wip_nav.unit.get(dwarf).getFile(zcu.gpa, new_ui, new_inst_info.file); | 1238 | try debug.wip_func.unit.get(dwarf).getFile(zcu.gpa, new_ui, new_inst_info.file); |
| 1138 | | 1239 | |
| 1139 | try dl_w.writeByte(DW.LNS.set_file); | 1240 | try dl_w.writeByte(DW.LNS.set_file); |
| 1140 | try dl_w.writeUleb128(@backingInt(new_fi)); | 1241 | try dl_w.writeUleb128(@backingInt(new_fi)); |
| ... | @@ -1147,38 +1248,27 @@ pub const WipNav = struct { | ... | @@ -1147,38 +1248,27 @@ pub const WipNav = struct { |
| 1147 | try dl_w.writeSleb128(new_src_line - old_src_line); | 1248 | try dl_w.writeSleb128(new_src_line - old_src_line); |
| 1148 | } | 1249 | } |
| 1149 | | 1250 | |
| 1150 | debug.wip_nav.func = func; | 1251 | debug.wip_func.func = func; |
| 1151 | } | | |
| 1152 | | | |
| 1153 | fn refFunc(debug: *Debug, func: InternPool.Index) link.EmitError!void { | | |
| 1154 | const dwarf = debug.wip_nav.dwarf; | | |
| 1155 | const fi = try dwarf.getFunc(debug.pt.zcu.funcInfo(func).owner_nav); | | |
| 1156 | try debug.wip_nav.dwarf.secOffset( | | |
| 1157 | &debug.info_writer, | | |
| 1158 | fi.get(dwarf).debug_info_ni.unwrap().?, | | |
| 1159 | 0, | | |
| 1160 | ); | | |
| 1161 | } | 1252 | } |
| 1162 | }; | 1253 | }; |
| 1163 | | 1254 | |
| 1164 | pub fn deinit(wip_nav: *WipNav) void { | 1255 | pub fn deinit(wip_func: *WipFunc) void { |
| 1165 | wip_nav.fde_writer.deinit(); | 1256 | wip_func.fde_writer.deinit(); |
| 1166 | wip_nav.* = undefined; | 1257 | wip_func.* = undefined; |
| 1167 | } | 1258 | } |
| 1168 | | 1259 | |
| 1169 | pub fn genDebugFrameHeader(wip_nav: *WipNav) link.Error!void { | 1260 | pub fn genDebugFrameHeader(wip_func: *WipFunc) link.Error!void { |
| 1170 | wip_nav.genDebugFrameHeaderInner() catch |err| switch (err) { | 1261 | wip_func.genDebugFrameHeaderInner() catch |err| switch (err) { |
| 1171 | error.WriteFailed => return wip_nav.dwarf.reportWriteError(&wip_nav.fde_writer), | | |
| 1172 | else => |e| return e, | 1262 | else => |e| return e, |
| | 1263 | error.WriteFailed => return wip_func.dwarf.reportWriteError(&wip_func.fde_writer), |
| 1173 | }; | 1264 | }; |
| 1174 | } | 1265 | } |
| 1175 | fn genDebugFrameHeaderInner(wip_nav: *WipNav) link.EmitError!void { | 1266 | fn genDebugFrameHeaderInner(wip_func: *WipFunc) link.EmitError!void { |
| 1176 | assert(wip_nav.func != .none); | 1267 | const dwarf = wip_func.dwarf; |
| 1177 | const dwarf = wip_nav.dwarf; | 1268 | const df_nw = &wip_func.fde_writer; |
| 1178 | const df_nw = &wip_nav.fde_writer; | | |
| 1179 | const df_w = &df_nw.interface; | 1269 | const df_w = &df_nw.interface; |
| 1180 | try dwarf.genUnitLength(df_w); | 1270 | try dwarf.genUnitLength(df_w); |
| 1181 | switch (wip_nav.frame_format) { | 1271 | switch (wip_func.frame_format) { |
| 1182 | .eh_frame => { | 1272 | .eh_frame => { |
| 1183 | try df_w.writeInt(u32, undefined, dwarf.endian); | 1273 | try df_w.writeInt(u32, undefined, dwarf.endian); |
| 1184 | { | 1274 | { |
| ... | @@ -1187,51 +1277,50 @@ pub const WipNav = struct { | ... | @@ -1187,51 +1277,50 @@ pub const WipNav = struct { |
| 1187 | if (dwarf.lf.cast(.elf2)) |elf| try elf.addReloc( | 1277 | if (dwarf.lf.cast(.elf2)) |elf| try elf.addReloc( |
| 1188 | @bitCast(df_nw.ni), | 1278 | @bitCast(df_nw.ni), |
| 1189 | offset, | 1279 | offset, |
| 1190 | wip_nav.func_si, | 1280 | wip_func.func_si, |
| 1191 | 0, | 1281 | 0, |
| 1192 | .rel32(elf), | 1282 | .rel32(elf), |
| 1193 | ) else unreachable; | 1283 | ) else unreachable; |
| 1194 | } | 1284 | } |
| 1195 | wip_nav.frame_func_length = .{ .offset = df_w.end, .size = .@"32" }; | 1285 | wip_func.frame_func_length = .{ .offset = df_w.end, .size = .@"32" }; |
| 1196 | try df_w.writeInt(u32, undefined, dwarf.endian); | 1286 | try df_w.writeInt(u32, undefined, dwarf.endian); |
| 1197 | try df_w.writeUleb128(0); | 1287 | try df_w.writeUleb128(0); |
| 1198 | }, | 1288 | }, |
| 1199 | .debug_frame => { | 1289 | .debug_frame => { |
| 1200 | try dwarf.secOffset(df_nw, wip_nav.unit.get(dwarf).cie_ni.unwrap().?, 0); | 1290 | try dwarf.secOffset(df_nw, wip_func.unit.get(dwarf).cie_ni.unwrap().?, 0); |
| 1201 | try dwarf.addrSym(df_nw, wip_nav.func_si, 0); | 1291 | try dwarf.addrSym(df_nw, wip_func.func_si, 0); |
| 1202 | wip_nav.frame_func_length = .{ .offset = df_w.end, .size = dwarf.address_size }; | 1292 | wip_func.frame_func_length = .{ .offset = df_w.end, .size = dwarf.address_size }; |
| 1203 | try dwarf.addrPlaceholder(df_w); | 1293 | try dwarf.addrPlaceholder(df_w); |
| 1204 | }, | 1294 | }, |
| 1205 | } | 1295 | } |
| 1206 | } | 1296 | } |
| 1207 | | 1297 | |
| 1208 | pub fn genDebugFrame(wip_nav: *WipNav, loc: u32, cfa: Cfa) link.Error!void { | 1298 | pub fn genDebugFrame(wip_func: *WipFunc, loc: u32, cfa: Cfa) link.Error!void { |
| 1209 | return wip_nav.genDebugFrameInner(loc, cfa) catch |err| switch (err) { | 1299 | return wip_func.genDebugFrameInner(loc, cfa) catch |err| switch (err) { |
| 1210 | error.WriteFailed => return wip_nav.dwarf.reportWriteError(&wip_nav.fde_writer), | | |
| 1211 | else => |e| return e, | 1300 | else => |e| return e, |
| | 1301 | error.WriteFailed => return wip_func.dwarf.reportWriteError(&wip_func.fde_writer), |
| 1212 | }; | 1302 | }; |
| 1213 | } | 1303 | } |
| 1214 | fn genDebugFrameInner(wip_nav: *WipNav, loc: u32, cfa: Cfa) link.EmitError!void { | 1304 | fn genDebugFrameInner(wip_func: *WipFunc, loc: u32, cfa: Cfa) link.EmitError!void { |
| 1215 | assert(wip_nav.func != .none); | | |
| 1216 | const loc_cfa: Cfa = .{ .advance_loc = loc }; | 1305 | const loc_cfa: Cfa = .{ .advance_loc = loc }; |
| 1217 | try loc_cfa.write(wip_nav); | 1306 | try loc_cfa.write(wip_func); |
| 1218 | try cfa.write(wip_nav); | 1307 | try cfa.write(wip_func); |
| 1219 | } | 1308 | } |
| 1220 | | 1309 | |
| 1221 | pub fn finishDebugFrameFde(wip_nav: *WipNav, func_length: u64) void { | 1310 | pub fn finishDebugFrameFde(wip_func: *WipFunc, func_length: u64) void { |
| 1222 | const dwarf = wip_nav.dwarf; | 1311 | const dwarf = wip_func.dwarf; |
| 1223 | const df_w = &wip_nav.fde_writer.interface; | 1312 | const df_w = &wip_func.fde_writer.interface; |
| 1224 | switch (wip_nav.frame_func_length.size) { | 1313 | switch (wip_func.frame_func_length.size) { |
| 1225 | _ => unreachable, | 1314 | _ => unreachable, |
| 1226 | .@"32" => std.mem.writeInt( | 1315 | .@"32" => std.mem.writeInt( |
| 1227 | u32, | 1316 | u32, |
| 1228 | df_w.buffered()[wip_nav.frame_func_length.offset..][0..4], | 1317 | df_w.buffered()[wip_func.frame_func_length.offset..][0..4], |
| 1229 | @intCast(func_length), | 1318 | @intCast(func_length), |
| 1230 | dwarf.endian, | 1319 | dwarf.endian, |
| 1231 | ), | 1320 | ), |
| 1232 | .@"64" => std.mem.writeInt( | 1321 | .@"64" => std.mem.writeInt( |
| 1233 | u64, | 1322 | u64, |
| 1234 | df_w.buffered()[wip_nav.frame_func_length.offset..][0..8], | 1323 | df_w.buffered()[wip_func.frame_func_length.offset..][0..8], |
| 1235 | func_length, | 1324 | func_length, |
| 1236 | dwarf.endian, | 1325 | dwarf.endian, |
| 1237 | ), | 1326 | ), |
| ... | @@ -1258,13 +1347,18 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf { | ... | @@ -1258,13 +1347,18 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf { |
| 1258 | .globals = .empty, | 1347 | .globals = .empty, |
| 1259 | .funcs = .empty, | 1348 | .funcs = .empty, |
| 1260 | .decls = .empty, | 1349 | .decls = .empty, |
| 1261 | .pending_decl = .{ .di = undefined, .instance_val = .none }, | 1350 | .pending_decl = .{ .di = undefined, .instance = .none }, |
| 1262 | | 1351 | |
| 1263 | .debug_abbrev = .{ | 1352 | .debug_abbrev = .{ |
| 1264 | .ni = .none, | 1353 | .ni = .none, |
| 1265 | .end = 0, | 1354 | .end = 0, |
| 1266 | .set = .empty, | 1355 | .set = .empty, |
| 1267 | }, | 1356 | }, |
| | 1357 | .debug_addr = .{ |
| | 1358 | .ni = .none, |
| | 1359 | .pending_index = 0, |
| | 1360 | .map = .empty, |
| | 1361 | }, |
| 1268 | .frame = .{ | 1362 | .frame = .{ |
| 1269 | .header = if (target.cpu.arch == .x86_64 and target.ofmt == .elf) header: { | 1363 | .header = if (target.cpu.arch == .x86_64 and target.ofmt == .elf) header: { |
| 1270 | dev.checkAny(&.{ .llvm_backend, .x86_64_backend }); | 1364 | dev.checkAny(&.{ .llvm_backend, .x86_64_backend }); |
| ... | @@ -1308,18 +1402,19 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf { | ... | @@ -1308,18 +1402,19 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf { |
| 1308 | }, | 1402 | }, |
| 1309 | .debug_line_str = .{ | 1403 | .debug_line_str = .{ |
| 1310 | .ni = .none, | 1404 | .ni = .none, |
| 1311 | .offset = 0, | 1405 | .end = 0, |
| 1312 | .map = .empty, | 1406 | .map = .empty, |
| 1313 | }, | 1407 | }, |
| 1314 | .debug_rnglists = .{}, | 1408 | .debug_rnglists = .{}, |
| 1315 | .debug_str = .{ | 1409 | .debug_str = .{ |
| 1316 | .ni = .none, | 1410 | .ni = .none, |
| 1317 | .offset = 0, | 1411 | .end = 0, |
| 1318 | .map = .empty, | 1412 | .map = .empty, |
| 1319 | }, | 1413 | }, |
| 1320 | .debug_str_offsets = .{ | 1414 | .debug_str_offsets = .{ |
| 1321 | .ni = .none, | 1415 | .ni = .none, |
| 1322 | .offset = 0, | 1416 | .pending_index = 0, |
| | 1417 | .map = .empty, |
| 1323 | }, | 1418 | }, |
| 1324 | }; | 1419 | }; |
| 1325 | } | 1420 | } |
| ... | @@ -1333,8 +1428,10 @@ pub fn deinit(dwarf: *Dwarf) void { | ... | @@ -1333,8 +1428,10 @@ pub fn deinit(dwarf: *Dwarf) void { |
| 1333 | dwarf.globals.deinit(gpa); | 1428 | dwarf.globals.deinit(gpa); |
| 1334 | dwarf.funcs.deinit(gpa); | 1429 | dwarf.funcs.deinit(gpa); |
| 1335 | dwarf.decls.deinit(gpa); | 1430 | dwarf.decls.deinit(gpa); |
| | 1431 | dwarf.debug_addr.map.deinit(gpa); |
| 1336 | dwarf.debug_line_str.map.deinit(gpa); | 1432 | dwarf.debug_line_str.map.deinit(gpa); |
| 1337 | dwarf.debug_str.map.deinit(gpa); | 1433 | dwarf.debug_str.map.deinit(gpa); |
| | 1434 | dwarf.debug_str_offsets.map.deinit(gpa); |
| 1338 | dwarf.* = undefined; | 1435 | dwarf.* = undefined; |
| 1339 | } | 1436 | } |
| 1340 | | 1437 | |
| ... | @@ -1389,8 +1486,7 @@ pub fn getConst(dwarf: *Dwarf, pt: Zcu.PerThread, val: Value) link.Error!link.Co | ... | @@ -1389,8 +1486,7 @@ pub fn getConst(dwarf: *Dwarf, pt: Zcu.PerThread, val: Value) link.Error!link.Co |
| 1389 | | 1486 | |
| 1390 | pub fn getGlobal(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Global.Index { | 1487 | pub fn getGlobal(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Global.Index { |
| 1391 | const comp = dwarf.lf.comp; | 1488 | const comp = dwarf.lf.comp; |
| 1392 | const gpa = comp.gpa; | 1489 | const global_gop = try dwarf.globals.getOrPut(comp.gpa, nav); |
| 1393 | const global_gop = try dwarf.globals.getOrPut(gpa, nav); | | |
| 1394 | if (!global_gop.found_existing) global_gop.value_ptr.* = .{ | 1490 | if (!global_gop.found_existing) global_gop.value_ptr.* = .{ |
| 1395 | .debug_info_ni = .none, | 1491 | .debug_info_ni = .none, |
| 1396 | }; | 1492 | }; |
| ... | @@ -1398,25 +1494,26 @@ pub fn getGlobal(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Global.Ind | ... | @@ -1398,25 +1494,26 @@ pub fn getGlobal(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Global.Ind |
| 1398 | if (global_gop.value_ptr.debug_info_ni != .none) return gi; | 1494 | if (global_gop.value_ptr.debug_info_ni != .none) return gi; |
| 1399 | const mod = comp.zcu.?.navFileScope(nav).mod.?; | 1495 | const mod = comp.zcu.?.navFileScope(nav).mod.?; |
| 1400 | assert(!mod.strip); | 1496 | assert(!mod.strip); |
| 1401 | const elf = dwarf.lf.cast(.elf2).?; | 1497 | if (dwarf.lf.cast(.elf2)) |elf| { |
| 1402 | try elf.nodes.ensureUnusedCapacity(gpa, 1); | 1498 | try elf.nodes.ensureUnusedCapacity(comp.gpa, 1); |
| 1403 | try elf.dwarf_globals.append(gpa, .{ | 1499 | try elf.dwarf_globals.append(comp.gpa, .{ |
| 1404 | .debug_info_first_target_reloc = .none, | 1500 | .debug_info_first_target_reloc = .none, |
| 1405 | .debug_info_first_node_reloc = .none, | 1501 | .debug_info_first_node_reloc = .none, |
| 1406 | .debug_info_first_symbol_reloc = .none, | 1502 | .debug_info_first_symbol_reloc = .none, |
| 1407 | }); | 1503 | }); |
| 1408 | const unit = dwarf.getUnit(mod).get(dwarf); | 1504 | const unit = dwarf.getUnit(mod).get(dwarf); |
| 1409 | global_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( | 1505 | global_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( |
| 1410 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ | 1506 | unit.debug_info_ni.unwrap().?.addFloatingChild(comp.gpa, &elf.mf, .{ |
| 1411 | .enable_next_moved = true, | 1507 | .enable_next_moved = true, |
| 1412 | }) catch |err| switch (err) { | 1508 | }) catch |err| switch (err) { |
| 1413 | else => |e| return e, | 1509 | else => |e| return e, |
| 1414 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ | 1510 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| 1415 | elf.mf.io_err.?, | 1511 | elf.mf.io_err.?, |
| 1416 | }), | 1512 | }), |
| 1417 | }, | 1513 | }, |
| 1418 | .{ .global_debug_info = gi }, | 1514 | .{ .global_debug_info = gi }, |
| 1419 | )); | 1515 | )); |
| | 1516 | } else unreachable; |
| 1420 | return gi; | 1517 | return gi; |
| 1421 | } | 1518 | } |
| 1422 | pub fn getGlobalIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Global.Index { | 1519 | pub fn getGlobalIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Global.Index { |
| ... | @@ -1436,118 +1533,150 @@ pub fn getFunc(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Func.Index { | ... | @@ -1436,118 +1533,150 @@ pub fn getFunc(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Func.Index { |
| 1436 | const fi: Func.Index = @fromBackingInt(@intCast(func_gop.index)); | 1533 | const fi: Func.Index = @fromBackingInt(@intCast(func_gop.index)); |
| 1437 | if (func_gop.value_ptr.debug_info_ni != .none) return fi; | 1534 | if (func_gop.value_ptr.debug_info_ni != .none) return fi; |
| 1438 | const mod = comp.zcu.?.navFileScope(nav).mod.?; | 1535 | const mod = comp.zcu.?.navFileScope(nav).mod.?; |
| 1439 | const elf = dwarf.lf.cast(.elf2).?; | 1536 | if (dwarf.lf.cast(.elf2)) |elf| { |
| 1440 | try elf.nodes.ensureUnusedCapacity(gpa, 1); | 1537 | try elf.nodes.ensureUnusedCapacity(gpa, 1); |
| 1441 | try elf.dwarf_funcs.append(gpa, .{ | 1538 | try elf.dwarf_funcs.append(gpa, .{ |
| 1442 | .frame_fde_first_symbol_reloc = .none, | 1539 | .frame_fde_first_symbol_reloc = .none, |
| 1443 | .frame_fde_first_node_reloc = .none, | 1540 | .frame_fde_first_node_reloc = .none, |
| 1444 | .debug_info_first_target_reloc = .none, | 1541 | .debug_info_first_target_reloc = .none, |
| 1445 | .debug_info_first_symbol_reloc = .none, | 1542 | .debug_info_first_symbol_reloc = .none, |
| 1446 | .debug_info_first_node_reloc = .none, | 1543 | .debug_info_first_node_reloc = .none, |
| 1447 | .debug_line_first_symbol_reloc = .none, | 1544 | .debug_line_first_symbol_reloc = .none, |
| 1448 | .debug_line_first_node_reloc = .none, | 1545 | .debug_line_first_node_reloc = .none, |
| 1449 | }); | 1546 | }); |
| 1450 | if (mod.strip) return fi; | 1547 | if (mod.strip) return fi; |
| 1451 | const unit = dwarf.getUnit(mod).get(dwarf); | 1548 | const unit = dwarf.getUnit(mod).get(dwarf); |
| 1452 | func_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( | 1549 | func_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( |
| 1453 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ | 1550 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ |
| 1454 | .enable_next_moved = true, | 1551 | .enable_next_moved = true, |
| 1455 | }) catch |err| switch (err) { | 1552 | }) catch |err| switch (err) { |
| 1456 | else => |e| return e, | 1553 | else => |e| return e, |
| 1457 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ | 1554 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| 1458 | elf.mf.io_err.?, | 1555 | elf.mf.io_err.?, |
| 1459 | }), | 1556 | }), |
| 1460 | }, | 1557 | }, |
| 1461 | .{ .func_debug_info = fi }, | 1558 | .{ .func_debug_info = fi }, |
| 1462 | )); | 1559 | )); |
| | 1560 | } else unreachable; |
| 1463 | return fi; | 1561 | return fi; |
| 1464 | } | 1562 | } |
| 1465 | pub fn getFuncIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Func.Index { | 1563 | pub fn getFuncIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Func.Index { |
| 1466 | return @fromBackingInt(@intCast(dwarf.funcs.getIndex(nav) orelse return null)); | 1564 | return @fromBackingInt(@intCast(dwarf.funcs.getIndex(nav) orelse return null)); |
| 1467 | } | 1565 | } |
| 1468 | | 1566 | |
| 1469 | fn getDeclInst(dwarf: *Dwarf, val: InternPool.Index) ?InternPool.TrackedInst.Index { | 1567 | fn getConstDeclInst(dwarf: *Dwarf, @"const": InternPool.Index) union(enum) { |
| 1470 | const ip = &dwarf.lf.comp.zcu.?.intern_pool; | 1568 | @"const": InternPool.Index, |
| 1471 | switch (ip.indexToKey(val)) { | 1569 | src_inst: InternPool.TrackedInst.Index, |
| | 1570 | } { |
| | 1571 | const zcu = dwarf.lf.comp.zcu.?; |
| | 1572 | const ip = &zcu.intern_pool; |
| | 1573 | switch (ip.indexToKey(@"const")) { |
| 1472 | else => unreachable, | 1574 | else => unreachable, |
| 1473 | .struct_type, .union_type, .enum_type, .opaque_type => |container, tag| switch (container) { | 1575 | .struct_type, .union_type, .enum_type, .opaque_type => |container, tag| switch (container) { |
| 1474 | .declared => |declared| switch (declared.captures.owned.len) { | 1576 | .declared => |declared| switch (declared.captures.owned.len) { |
| 1475 | 0 => return null, | 1577 | 0 => return .{ .@"const" = @"const" }, |
| 1476 | else => switch (tag) { | 1578 | else => return .{ .src_inst = src_inst: switch (tag) { |
| 1477 | else => unreachable, | 1579 | else => unreachable, |
| 1478 | .struct_type => { | 1580 | .struct_type => { |
| 1479 | const loaded_struct = ip.loadStructType(val); | 1581 | const loaded_struct = ip.loadStructType(@"const"); |
| 1480 | return ip.getNav(loaded_struct.name_nav.unwrap() orelse | 1582 | break :src_inst ip.getNav(loaded_struct.name_nav.unwrap() orelse |
| 1481 | return loaded_struct.zir_index).srcInst(ip); | 1583 | break :src_inst loaded_struct.zir_index).srcInst(ip); |
| 1482 | }, | 1584 | }, |
| 1483 | .union_type => { | 1585 | .union_type => { |
| 1484 | const loaded_union = ip.loadUnionType(val); | 1586 | const loaded_union = ip.loadUnionType(@"const"); |
| 1485 | return ip.getNav(loaded_union.name_nav.unwrap() orelse | 1587 | break :src_inst ip.getNav(loaded_union.name_nav.unwrap() orelse |
| 1486 | return loaded_union.zir_index).srcInst(ip); | 1588 | break :src_inst loaded_union.zir_index).srcInst(ip); |
| 1487 | }, | 1589 | }, |
| 1488 | .enum_type => { | 1590 | .enum_type => { |
| 1489 | const loaded_enum = ip.loadEnumType(val); | 1591 | const loaded_enum = ip.loadEnumType(@"const"); |
| 1490 | return ip.getNav(loaded_enum.name_nav.unwrap() orelse | 1592 | break :src_inst ip.getNav(loaded_enum.name_nav.unwrap() orelse |
| 1491 | return loaded_enum.zir_index.unwrap().?).srcInst(ip); | 1593 | break :src_inst loaded_enum.zir_index.unwrap().?).srcInst(ip); |
| 1492 | }, | 1594 | }, |
| 1493 | .opaque_type => { | 1595 | .opaque_type => { |
| 1494 | const loaded_opaque = ip.loadOpaqueType(val); | 1596 | const loaded_opaque = ip.loadOpaqueType(@"const"); |
| 1495 | return ip.getNav(loaded_opaque.name_nav.unwrap() orelse | 1597 | break :src_inst ip.getNav(loaded_opaque.name_nav.unwrap() orelse |
| 1496 | return loaded_opaque.zir_index).srcInst(ip); | 1598 | break :src_inst loaded_opaque.zir_index).srcInst(ip); |
| 1497 | }, | 1599 | }, |
| 1498 | }, | 1600 | } }, |
| 1499 | }, | 1601 | }, |
| 1500 | .reified => |reified| { | 1602 | .reified => |reified| { |
| 1501 | assert(reified.zir_index.resolve(ip).? != .main_struct_inst); | 1603 | assert(reified.zir_index.resolve(ip).? != .main_struct_inst); |
| 1502 | return reified.zir_index; | 1604 | return .{ .src_inst = reified.zir_index }; |
| 1503 | }, | 1605 | }, |
| 1504 | .generated_union_tag => unreachable, | 1606 | .generated_union_tag => unreachable, |
| 1505 | }, | 1607 | }, |
| 1506 | .func => |func| return ip.getNav(switch (func.generic_owner) { | 1608 | .func => |func| switch (func.generic_owner) { |
| 1507 | .none => func.owner_nav, | 1609 | else => |generic_owner| return .{ .@"const" = generic_owner }, |
| 1508 | else => |generic_owner| ip.indexToKey(generic_owner).func.owner_nav, | 1610 | .none => { |
| 1509 | }).srcInst(ip), | 1611 | const owner_nav = ip.getNav(func.owner_nav); |
| | 1612 | return switch (Type.fromInterned( |
| | 1613 | ip.namespacePtr(owner_nav.analysis.?.namespace).owner_type, |
| | 1614 | ).getCaptures(zcu).len) { |
| | 1615 | 0 => .{ .@"const" = @"const" }, |
| | 1616 | else => .{ .src_inst = owner_nav.srcInst(ip) }, |
| | 1617 | }; |
| | 1618 | }, |
| | 1619 | }, |
| | 1620 | } |
| | 1621 | } |
| | 1622 | pub fn getConstDecl( |
| | 1623 | dwarf: *Dwarf, |
| | 1624 | pt: Zcu.PerThread, |
| | 1625 | instance_const: InternPool.Index, |
| | 1626 | ) link.Error!link.MappedFile.Node.Index { |
| | 1627 | switch (dwarf.getConstDeclInst(instance_const)) { |
| | 1628 | .@"const" => |@"const"| { |
| | 1629 | const cpi = try dwarf.getConst(pt, .fromInterned(@"const")); |
| | 1630 | return Const.get(cpi, dwarf).debug_info_ni.unwrap().?; |
| | 1631 | }, |
| | 1632 | .src_inst => |src_inst| return dwarf.getDecl(pt, src_inst, .{ .@"const" = instance_const }), |
| 1510 | } | 1633 | } |
| 1511 | } | 1634 | } |
| 1512 | pub fn getDecl( | 1635 | pub fn getGlobalDecl( |
| | 1636 | dwarf: *Dwarf, |
| | 1637 | pt: Zcu.PerThread, |
| | 1638 | instance_global: InternPool.Nav.Index, |
| | 1639 | ) link.Error!link.MappedFile.Node.Index { |
| | 1640 | const ip = &pt.zcu.intern_pool; |
| | 1641 | return dwarf.getDecl(pt, ip.getNav(instance_global).srcInst(ip), .{ .global = instance_global }); |
| | 1642 | } |
| | 1643 | fn getDecl( |
| 1513 | dwarf: *Dwarf, | 1644 | dwarf: *Dwarf, |
| 1514 | pt: Zcu.PerThread, | 1645 | pt: Zcu.PerThread, |
| 1515 | instance_val: InternPool.Index, | 1646 | inst: InternPool.TrackedInst.Index, |
| | 1647 | instance: Decl.Instance, |
| 1516 | ) link.Error!link.MappedFile.Node.Index { | 1648 | ) link.Error!link.MappedFile.Node.Index { |
| 1517 | assert(dwarf.pending_decl.instance_val == .none); | | |
| 1518 | const comp = dwarf.lf.comp; | 1649 | const comp = dwarf.lf.comp; |
| 1519 | const gpa = comp.gpa; | 1650 | const gpa = comp.gpa; |
| 1520 | const zcu = pt.zcu; | 1651 | const zcu = pt.zcu; |
| 1521 | const ip = &zcu.intern_pool; | 1652 | const ip = &zcu.intern_pool; |
| 1522 | const inst = dwarf.getDeclInst(instance_val) orelse { | | |
| 1523 | const cpi = try dwarf.getConst(pt, .fromInterned(instance_val)); | | |
| 1524 | return Const.get(cpi, dwarf).debug_info_ni.unwrap().?; | | |
| 1525 | }; | | |
| 1526 | const decl_gop = try dwarf.decls.getOrPut(gpa, inst); | 1653 | const decl_gop = try dwarf.decls.getOrPut(gpa, inst); |
| 1527 | if (!decl_gop.found_existing) decl_gop.value_ptr.* = .{ | 1654 | if (!decl_gop.found_existing) decl_gop.value_ptr.* = .{ |
| 1528 | .debug_info_ni = .none, | 1655 | .debug_info_ni = .none, |
| 1529 | }; | 1656 | }; |
| 1530 | const di: Decl.Index = @fromBackingInt(@intCast(decl_gop.index)); | 1657 | const di: Decl.Index = @fromBackingInt(@intCast(decl_gop.index)); |
| 1531 | if (decl_gop.value_ptr.debug_info_ni.unwrap()) |debug_info_ni| return debug_info_ni; | 1658 | if (decl_gop.value_ptr.debug_info_ni.unwrap()) |debug_info_ni| return debug_info_ni; |
| 1532 | dwarf.pending_decl = .{ .di = di, .instance_val = instance_val }; | 1659 | dwarf.pending_decl = .{ .di = di, .instance = instance }; |
| 1533 | const elf = dwarf.lf.cast(.elf2).?; | 1660 | const debug_info_ni = if (dwarf.lf.cast(.elf2)) |elf| debug_info_ni: { |
| 1534 | try elf.nodes.ensureUnusedCapacity(gpa, 1); | 1661 | try elf.nodes.ensureUnusedCapacity(gpa, 1); |
| 1535 | try elf.dwarf_decls.putNoClobber(gpa, di, .{ | 1662 | try elf.dwarf_decls.putNoClobber(gpa, di, .{ |
| 1536 | .debug_info_first_target_reloc = .none, | 1663 | .debug_info_first_target_reloc = .none, |
| 1537 | .debug_info_first_node_reloc = .none, | 1664 | .debug_info_first_node_reloc = .none, |
| 1538 | }); | 1665 | }); |
| 1539 | const unit = dwarf.getUnit(zcu.fileByIndex(di.srcInst(dwarf).resolveFile(ip)).mod.?).get(dwarf); | 1666 | const unit = dwarf.getUnit(zcu.fileByIndex(di.srcInst(dwarf).resolveFile(ip)).mod.?).get(dwarf); |
| 1540 | const debug_info_ni = elf.addNodeAssumeCapacity( | 1667 | const debug_info_ni = elf.addNodeAssumeCapacity( |
| 1541 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ | 1668 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ |
| 1542 | .enable_next_moved = true, | 1669 | .enable_next_moved = true, |
| 1543 | }) catch |err| switch (err) { | 1670 | }) catch |err| switch (err) { |
| 1544 | else => |e| return e, | 1671 | else => |e| return e, |
| 1545 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ | 1672 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| 1546 | elf.mf.io_err.?, | 1673 | elf.mf.io_err.?, |
| 1547 | }), | 1674 | }), |
| 1548 | }, | 1675 | }, |
| 1549 | .{ .decl_debug_info = di }, | 1676 | .{ .decl_debug_info = di }, |
| 1550 | ); | 1677 | ); |
| | 1678 | break :debug_info_ni debug_info_ni; |
| | 1679 | } else unreachable; |
| 1551 | decl_gop.value_ptr.debug_info_ni = .wrap(debug_info_ni); | 1680 | decl_gop.value_ptr.debug_info_ni = .wrap(debug_info_ni); |
| 1552 | return debug_info_ni; | 1681 | return debug_info_ni; |
| 1553 | } | 1682 | } |
| ... | @@ -1561,7 +1690,7 @@ pub fn unitLengthSize(dwarf: *Dwarf) usize { | ... | @@ -1561,7 +1690,7 @@ pub fn unitLengthSize(dwarf: *Dwarf) usize { |
| 1561 | .@"64" => 4 + 8, | 1690 | .@"64" => 4 + 8, |
| 1562 | }; | 1691 | }; |
| 1563 | } | 1692 | } |
| 1564 | pub fn genUnitLength(dwarf: *Dwarf, w: *std.Io.Writer) std.Io.Writer.Error!void { | 1693 | fn genUnitLength(dwarf: *Dwarf, w: *std.Io.Writer) std.Io.Writer.Error!void { |
| 1565 | switch (dwarf.format) { | 1694 | switch (dwarf.format) { |
| 1566 | .@"32" => try w.writeInt(u32, undefined, dwarf.endian), | 1695 | .@"32" => try w.writeInt(u32, undefined, dwarf.endian), |
| 1567 | .@"64" => { | 1696 | .@"64" => { |
| ... | @@ -1582,6 +1711,24 @@ pub fn genUnitPadding(dwarf: *Dwarf, w: *std.Io.Writer) std.Io.Writer.Error!void | ... | @@ -1582,6 +1711,24 @@ pub fn genUnitPadding(dwarf: *Dwarf, w: *std.Io.Writer) std.Io.Writer.Error!void |
| 1582 | try w.writeInt(u16, 0, dwarf.endian); | 1711 | try w.writeInt(u16, 0, dwarf.endian); |
| 1583 | } | 1712 | } |
| 1584 | | 1713 | |
| | 1714 | pub fn genDebugAddrHeader(dwarf: *Dwarf, dah_w: *std.Io.Writer) std.Io.Writer.Error!void { |
| | 1715 | try dwarf.genUnitLength(dah_w); |
| | 1716 | try dah_w.writeInt(u16, 5, dwarf.endian); |
| | 1717 | try dah_w.writeAll(&.{ @backingInt(dwarf.address_size), 0 }); |
| | 1718 | assert(dah_w.end == Addr.tableOffset(dwarf)); |
| | 1719 | } |
| | 1720 | |
| | 1721 | pub fn genPendingDebugAddr(dwarf: *Dwarf, da_nw: *link.MappedFile.Node.Writer) link.Error!void { |
| | 1722 | da_nw.interface.end = dwarf.debug_addr.size(dwarf); |
| | 1723 | for (dwarf.debug_addr.map.keys()[dwarf.debug_addr.pending_index..]) |si| { |
| | 1724 | dwarf.addrSym(da_nw, si, 0) catch |err| switch (err) { |
| | 1725 | else => |e| return e, |
| | 1726 | error.WriteFailed => return dwarf.reportWriteError(da_nw), |
| | 1727 | }; |
| | 1728 | dwarf.debug_addr.pending_index += 1; |
| | 1729 | } |
| | 1730 | } |
| | 1731 | |
| 1585 | pub const EhFrameHdr = extern struct { | 1732 | pub const EhFrameHdr = extern struct { |
| 1586 | version: u8, | 1733 | version: u8, |
| 1587 | eh_frame_ptr_enc: std.dwarf.EH.PE, | 1734 | eh_frame_ptr_enc: std.dwarf.EH.PE, |
| ... | @@ -1637,11 +1784,7 @@ pub fn genDebugFrameCie( | ... | @@ -1637,11 +1784,7 @@ pub fn genDebugFrameCie( |
| 1637 | const Register = @import("../codegen/x86_64/bits.zig").Register; | 1784 | const Register = @import("../codegen/x86_64/bits.zig").Register; |
| 1638 | switch (format) { | 1785 | switch (format) { |
| 1639 | .eh_frame => try df_w.writeAll("zR\x00"), | 1786 | .eh_frame => try df_w.writeAll("zR\x00"), |
| 1640 | .debug_frame => { | 1787 | .debug_frame => try df_w.writeAll("\x00" ++ .{ @backingInt(dwarf.address_size), 0 }), |
| 1641 | try df_w.writeAll("\x00"); | | |
| 1642 | try df_w.writeByte(@backingInt(dwarf.address_size)); | | |
| 1643 | try df_w.writeByte(0); | | |
| 1644 | }, | | |
| 1645 | } | 1788 | } |
| 1646 | try df_w.writeUleb128(dwarf.frame.header.code_alignment_factor); | 1789 | try df_w.writeUleb128(dwarf.frame.header.code_alignment_factor); |
| 1647 | try df_w.writeSleb128(dwarf.frame.header.data_alignment_factor); | 1790 | try df_w.writeSleb128(dwarf.frame.header.data_alignment_factor); |
| ... | @@ -1688,28 +1831,29 @@ pub fn genDebugInfoHeader( | ... | @@ -1688,28 +1831,29 @@ pub fn genDebugInfoHeader( |
| 1688 | if (!unit.alive) return dwarf.genUnitPadding(dih_w); | 1831 | if (!unit.alive) return dwarf.genUnitPadding(dih_w); |
| 1689 | try dwarf.genUnitLength(dih_w); | 1832 | try dwarf.genUnitLength(dih_w); |
| 1690 | try dih_w.writeInt(u16, 5, dwarf.endian); | 1833 | try dih_w.writeInt(u16, 5, dwarf.endian); |
| 1691 | try dih_w.writeByte(DW.UT.compile); | 1834 | try dih_w.writeAll(&.{ DW.UT.compile, @backingInt(dwarf.address_size) }); |
| 1692 | try dih_w.writeByte(@backingInt(dwarf.address_size)); | | |
| 1693 | try dwarf.secOffset(dih_nw, dwarf.debug_abbrev.ni.unwrap().?, 0); | 1835 | try dwarf.secOffset(dih_nw, dwarf.debug_abbrev.ni.unwrap().?, 0); |
| 1694 | const compile_unit_offset = dih_w.end; | 1836 | const compile_unit_offset = dih_w.end; |
| 1695 | try dwarf.abbrevCode(dih_nw, .compile_unit); | 1837 | try dwarf.abbrevCode(dih_nw, .compile_unit); |
| 1696 | try dih_w.writeByte(DW.LANG.Zig); | 1838 | try dih_w.writeByte(DW.LANG.Zig); |
| 1697 | try dwarf.strp(&dwarf.debug_str, dih_nw, "zig " ++ @import("build_options").version); | | |
| 1698 | const root_dir_path = try mod.root.toAbsolute(&comp.dirs, comp.gpa); | | |
| 1699 | defer comp.gpa.free(root_dir_path); | | |
| 1700 | try dwarf.strp(&dwarf.debug_line_str, dih_nw, root_dir_path); | | |
| 1701 | try dwarf.strp(&dwarf.debug_line_str, dih_nw, mod.root_src_path); | | |
| 1702 | try dwarf.secOffset( | 1839 | try dwarf.secOffset( |
| 1703 | dih_nw, | 1840 | dih_nw, |
| 1704 | dwarf.getUnit(zcu.root_mod).get(dwarf).debug_info_header_ni.unwrap().?, | 1841 | dwarf.getUnit(zcu.root_mod).get(dwarf).debug_info_header_ni.unwrap().?, |
| 1705 | compile_unit_offset, | 1842 | compile_unit_offset, |
| 1706 | ); | 1843 | ); |
| 1707 | try dwarf.secOffset(dih_nw, unit.debug_line_header_ni.unwrap().?, 0); | 1844 | try dwarf.secOffset(dih_nw, unit.debug_line_header_ni.unwrap().?, 0); |
| 1708 | try dwarf.secOffset(dih_nw, unit.debug_rnglists_ni.unwrap().?, Rnglists.offsetsTableOffset(dwarf)); | 1845 | try dwarf.secOffset(dih_nw, dwarf.debug_addr.ni.unwrap().?, Addr.tableOffset(dwarf)); |
| | 1846 | try dwarf.secOffset(dih_nw, unit.debug_rnglists_ni.unwrap().?, Rnglists.tableOffset(dwarf)); |
| | 1847 | try dwarf.secOffset(dih_nw, dwarf.debug_str_offsets.ni.unwrap().?, StrOffsets.tableOffset(dwarf)); |
| | 1848 | try dwarf.strx1(dih_nw, "zig " ++ @import("build_options").version); |
| | 1849 | const root_dir_path = try mod.root.toAbsolute(&comp.dirs, comp.gpa); |
| | 1850 | defer comp.gpa.free(root_dir_path); |
| | 1851 | try dwarf.strp(&dwarf.debug_line_str, dih_nw, root_dir_path); |
| | 1852 | try dwarf.strp(&dwarf.debug_line_str, dih_nw, mod.root_src_path); |
| 1709 | try dih_w.writeUleb128(0); | 1853 | try dih_w.writeUleb128(0); |
| 1710 | const module_offset = dih_w.end; | 1854 | const module_offset = dih_w.end; |
| 1711 | try dwarf.abbrevCode(dih_nw, .module); | 1855 | try dwarf.abbrevCode(dih_nw, .module); |
| 1712 | try dwarf.strp(&dwarf.debug_str, dih_nw, mod.fully_qualified_name); | 1856 | try dwarf.strx(dih_nw, mod.fully_qualified_name); |
| 1713 | try dih_w.writeUleb128(0); | 1857 | try dih_w.writeUleb128(0); |
| 1714 | try dwarf.genModuleDependency( | 1858 | try dwarf.genModuleDependency( |
| 1715 | dih_nw, | 1859 | dih_nw, |
| ... | @@ -1735,7 +1879,7 @@ fn genModuleDependency( | ... | @@ -1735,7 +1879,7 @@ fn genModuleDependency( |
| 1735 | const dep_unit = dwarf.getUnit(dep).get(dwarf); | 1879 | const dep_unit = dwarf.getUnit(dep).get(dwarf); |
| 1736 | if (!dep_unit.alive) return; | 1880 | if (!dep_unit.alive) return; |
| 1737 | try dwarf.abbrevCode(di_nw, .module_dependency); | 1881 | try dwarf.abbrevCode(di_nw, .module_dependency); |
| 1738 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 1882 | try dwarf.strx(di_nw, name); |
| 1739 | try dwarf.secOffset(di_nw, dep_unit.debug_info_header_ni.unwrap().?, module_offset); | 1883 | try dwarf.secOffset(di_nw, dep_unit.debug_info_header_ni.unwrap().?, module_offset); |
| 1740 | } | 1884 | } |
| 1741 | | 1885 | |
| ... | @@ -1779,8 +1923,7 @@ pub fn genDebugLineHeader( | ... | @@ -1779,8 +1923,7 @@ pub fn genDebugLineHeader( |
| 1779 | const dlh_w = &dlh_nw.interface; | 1923 | const dlh_w = &dlh_nw.interface; |
| 1780 | try dwarf.genUnitLength(dlh_w); | 1924 | try dwarf.genUnitLength(dlh_w); |
| 1781 | try dlh_w.writeInt(u16, 5, dwarf.endian); | 1925 | try dlh_w.writeInt(u16, 5, dwarf.endian); |
| 1782 | try dlh_w.writeByte(@backingInt(dwarf.address_size)); | 1926 | try dlh_w.writeAll(&.{ @backingInt(dwarf.address_size), 0 }); |
| 1783 | try dlh_w.writeByte(0); | | |
| 1784 | const header_length_offset = dlh_w.end; | 1927 | const header_length_offset = dlh_w.end; |
| 1785 | switch (dwarf.format) { | 1928 | switch (dwarf.format) { |
| 1786 | .@"32" => try dlh_w.writeInt(u32, undefined, dwarf.endian), | 1929 | .@"32" => try dlh_w.writeInt(u32, undefined, dwarf.endian), |
| ... | @@ -1852,11 +1995,7 @@ pub fn genDebugLineHeader( | ... | @@ -1852,11 +1995,7 @@ pub fn genDebugLineHeader( |
| 1852 | } | 1995 | } |
| 1853 | try dlh_w.writeInt(i64, @truncate(zf.stat.mtime.nanoseconds), dwarf.endian); | 1996 | try dlh_w.writeInt(i64, @truncate(zf.stat.mtime.nanoseconds), dwarf.endian); |
| 1854 | try dlh_w.writeInt(u64, zf.stat.size, dwarf.endian); | 1997 | try dlh_w.writeInt(u64, zf.stat.size, dwarf.endian); |
| 1855 | try dwarf.strp( | 1998 | try dwarf.strp(&dwarf.debug_line_str, dlh_nw, if (zf.is_builtin) zf.source.? else ""); |
| 1856 | &dwarf.debug_line_str, | | |
| 1857 | dlh_nw, | | |
| 1858 | if (zf.is_builtin) zf.source.? else "", | | |
| 1859 | ); | | |
| 1860 | } | 1999 | } |
| 1861 | switch (dwarf.format) { | 2000 | switch (dwarf.format) { |
| 1862 | .@"32" => std.mem.writeInt( | 2001 | .@"32" => std.mem.writeInt( |
| ... | @@ -1915,10 +2054,9 @@ pub fn genDebugRnglistsHeader( | ... | @@ -1915,10 +2054,9 @@ pub fn genDebugRnglistsHeader( |
| 1915 | const drh_w = &drh_nw.interface; | 2054 | const drh_w = &drh_nw.interface; |
| 1916 | try dwarf.genUnitLength(drh_w); | 2055 | try dwarf.genUnitLength(drh_w); |
| 1917 | try drh_w.writeInt(u16, 5, dwarf.endian); | 2056 | try drh_w.writeInt(u16, 5, dwarf.endian); |
| 1918 | try drh_w.writeByte(@backingInt(dwarf.address_size)); | 2057 | try drh_w.writeAll(&.{ @backingInt(dwarf.address_size), 0 }); |
| 1919 | try drh_w.writeByte(0); | | |
| 1920 | try drh_w.writeInt(u32, 1, dwarf.endian); | 2058 | try drh_w.writeInt(u32, 1, dwarf.endian); |
| 1921 | assert(drh_w.end == Rnglists.offsetsTableOffset(dwarf)); | 2059 | assert(drh_w.end == Rnglists.tableOffset(dwarf)); |
| 1922 | switch (dwarf.format) { | 2060 | switch (dwarf.format) { |
| 1923 | .@"32" => try drh_w.writeInt(u32, 4, dwarf.endian), | 2061 | .@"32" => try drh_w.writeInt(u32, 4, dwarf.endian), |
| 1924 | .@"64" => try drh_w.writeInt(u64, 8, dwarf.endian), | 2062 | .@"64" => try drh_w.writeInt(u64, 8, dwarf.endian), |
| ... | @@ -1927,7 +2065,7 @@ pub fn genDebugRnglistsHeader( | ... | @@ -1927,7 +2065,7 @@ pub fn genDebugRnglistsHeader( |
| 1927 | try drh_w.writeByte(DW.RLE.end_of_list); | 2065 | try drh_w.writeByte(DW.RLE.end_of_list); |
| 1928 | } | 2066 | } |
| 1929 | | 2067 | |
| 1930 | pub fn genDebugRnglists( | 2068 | pub fn genDebugRnglistsRange( |
| 1931 | dwarf: *Dwarf, | 2069 | dwarf: *Dwarf, |
| 1932 | unit: *Unit, | 2070 | unit: *Unit, |
| 1933 | dr_nw: *link.MappedFile.Node.Writer, | 2071 | dr_nw: *link.MappedFile.Node.Writer, |
| ... | @@ -1936,74 +2074,396 @@ pub fn genDebugRnglists( | ... | @@ -1936,74 +2074,396 @@ pub fn genDebugRnglists( |
| 1936 | ) link.EmitError!void { | 2074 | ) link.EmitError!void { |
| 1937 | const dr_w = &dr_nw.interface; | 2075 | const dr_w = &dr_nw.interface; |
| 1938 | dr_w.end = unit.debug_rnglists_end; | 2076 | dr_w.end = unit.debug_rnglists_end; |
| 1939 | try dr_w.writeByte(DW.RLE.start_length); | 2077 | try dr_w.writeByte(DW.RLE.startx_length); |
| 1940 | try dwarf.addrSym(dr_nw, func_si, 0); | 2078 | try dwarf.addrxSym(dr_w, func_si); |
| 1941 | try dr_w.writeUleb128(func_length); | 2079 | try dr_w.writeUleb128(func_length); |
| 1942 | unit.debug_rnglists_end = dr_w.end; | 2080 | unit.debug_rnglists_end = dr_w.end; |
| 1943 | try dr_w.writeByte(DW.RLE.end_of_list); | 2081 | try dr_w.writeByte(DW.RLE.end_of_list); |
| 1944 | } | 2082 | } |
| 1945 | | 2083 | |
| 1946 | pub fn updateComptimeNav( | 2084 | pub fn genDebugStrOffsetsHeader(dwarf: *Dwarf, dsoh_w: *std.Io.Writer) std.Io.Writer.Error!void { |
| | 2085 | try dwarf.genUnitLength(dsoh_w); |
| | 2086 | try dsoh_w.writeInt(u16, 5, dwarf.endian); |
| | 2087 | try dsoh_w.writeInt(u16, 0, dwarf.endian); |
| | 2088 | assert(dsoh_w.end == StrOffsets.tableOffset(dwarf)); |
| | 2089 | } |
| | 2090 | |
| | 2091 | pub fn genPendingDebugStrOffsets(dwarf: *Dwarf, dso_nw: *link.MappedFile.Node.Writer) link.Error!void { |
| | 2092 | const debug_str_ni = dwarf.debug_str.ni.unwrap().?; |
| | 2093 | dso_nw.interface.end = dwarf.debug_str_offsets.size(dwarf); |
| | 2094 | for (dwarf.debug_str_offsets.map.keys()[dwarf.debug_str_offsets.pending_index..]) |offset| { |
| | 2095 | dwarf.secOffset(dso_nw, debug_str_ni, offset) catch |err| switch (err) { |
| | 2096 | else => |e| return e, |
| | 2097 | error.WriteFailed => return dwarf.reportWriteError(dso_nw), |
| | 2098 | }; |
| | 2099 | dwarf.debug_str_offsets.pending_index += 1; |
| | 2100 | } |
| | 2101 | } |
| | 2102 | |
| | 2103 | pub fn updateExtern( |
| | 2104 | dwarf: *Dwarf, |
| | 2105 | pt: Zcu.PerThread, |
| | 2106 | di_nw: *link.MappedFile.Node.Writer, |
| | 2107 | arch: std.Target.Cpu.Arch, |
| | 2108 | si: link.File.SymbolId, |
| | 2109 | global: InternPool.Nav.Index, |
| | 2110 | ) link.Error!void { |
| | 2111 | dwarf.updateExternInner(pt, di_nw, arch, si, global) catch |err| switch (err) { |
| | 2112 | else => |e| return e, |
| | 2113 | error.WriteFailed => return dwarf.reportWriteError(di_nw), |
| | 2114 | }; |
| | 2115 | } |
| | 2116 | fn updateExternInner( |
| | 2117 | dwarf: *Dwarf, |
| | 2118 | pt: Zcu.PerThread, |
| | 2119 | di_nw: *link.MappedFile.Node.Writer, |
| | 2120 | arch: std.Target.Cpu.Arch, |
| | 2121 | si: link.File.SymbolId, |
| | 2122 | global: InternPool.Nav.Index, |
| | 2123 | ) link.EmitError!void { |
| | 2124 | const zcu = pt.zcu; |
| | 2125 | const ip = &zcu.intern_pool; |
| | 2126 | const nav = ip.getNav(global); |
| | 2127 | log.debug("updateExtern({f})", .{nav.fqn.fmt(ip)}); |
| | 2128 | const nav_align, const nav_const, const nav_threadlocal, const nav_extern = nav_resolved: { |
| | 2129 | const nav_resolved = nav.resolved.?; |
| | 2130 | break :nav_resolved .{ |
| | 2131 | nav_resolved.@"align", |
| | 2132 | nav_resolved.@"const", |
| | 2133 | nav_resolved.@"threadlocal", |
| | 2134 | ip.indexToKey(nav_resolved.value).@"extern", |
| | 2135 | }; |
| | 2136 | }; |
| | 2137 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; |
| | 2138 | const decl = switch (nav_extern.source) { |
| | 2139 | .builtin => undefined, |
| | 2140 | .syntax => zcu.fileByIndex(inst_info.file).zir.?.getDeclaration(inst_info.inst), |
| | 2141 | }; |
| | 2142 | const maybe_func_type = switch (ip.indexToKey(nav_extern.ty)) { |
| | 2143 | .func_type => |func_type| func_type, |
| | 2144 | else => null, |
| | 2145 | }; |
| | 2146 | const is_empty = if (maybe_func_type) |func_type| func_type.param_types.len == 0 and |
| | 2147 | !func_type.is_var_args else undefined; |
| | 2148 | const di_w = &di_nw.interface; |
| | 2149 | switch (nav_extern.source) { |
| | 2150 | .builtin => { |
| | 2151 | try dwarf.abbrevCode(di_nw, if (maybe_func_type) |_| |
| | 2152 | if (is_empty) .builtin_extern_empty_func else .builtin_extern_func |
| | 2153 | else |
| | 2154 | .builtin_extern_var); |
| | 2155 | try dwarf.refType(pt, di_nw, .fromInterned(zcu.fileRootType(inst_info.file))); |
| | 2156 | }, |
| | 2157 | .syntax => if (maybe_func_type) |_| { |
| | 2158 | try dwarf.abbrevCode( |
| | 2159 | di_nw, |
| | 2160 | if (is_empty) .decl_extern_empty_func else .decl_extern_func, |
| | 2161 | ); |
| | 2162 | try dwarf.refType(pt, di_nw, .fromInterned(zcu.fileRootType(inst_info.file))); |
| | 2163 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 2164 | try di_w.writeUleb128(decl.src_column + 1); |
| | 2165 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| | 2166 | try dwarf.strx(di_nw, nav.name.toSlice(ip)); |
| | 2167 | } else { |
| | 2168 | try dwarf.abbrevCode(di_nw, .decl_var); |
| | 2169 | try dwarf.refType(pt, di_nw, .fromInterned(zcu.fileRootType(inst_info.file))); |
| | 2170 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 2171 | try di_w.writeUleb128(decl.src_column + 1); |
| | 2172 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| | 2173 | try dwarf.strx(di_nw, nav.name.toSlice(ip)); |
| | 2174 | }, |
| | 2175 | } |
| | 2176 | try dwarf.strx(di_nw, nav_extern.name.toSlice(ip)); |
| | 2177 | if (maybe_func_type) |func_type| { |
| | 2178 | try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type)); |
| | 2179 | try dwarf.addrSym(di_nw, si, 0); |
| | 2180 | try di_w.writeByte(@intFromBool(Type.fromInterned(func_type.return_type).isNoReturn(zcu))); |
| | 2181 | for (func_type.param_types.get(ip)) |param_type| { |
| | 2182 | try dwarf.abbrevCode(di_nw, .extern_param); |
| | 2183 | try dwarf.refType(pt, di_nw, .fromInterned(param_type)); |
| | 2184 | } |
| | 2185 | if (func_type.is_var_args) try dwarf.abbrevCode(di_nw, .is_var_args); |
| | 2186 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 2187 | } else { |
| | 2188 | const addr: Loc = .{ .addr_sym = .{ .si = si } }; |
| | 2189 | const loc: Loc = if (nav_threadlocal) switch (arch) { |
| | 2190 | .x86_64 => .{ .form_tls_address = &addr }, |
| | 2191 | else => unreachable, |
| | 2192 | } else addr; |
| | 2193 | const type_offset = di_w.end; |
| | 2194 | if (nav_const) |
| | 2195 | try dwarf.secOffsetPlaceholder(di_w) |
| | 2196 | else |
| | 2197 | try dwarf.refType(pt, di_nw, .fromInterned(nav_extern.ty)); |
| | 2198 | try dwarf.exprLoc(di_nw, loc); |
| | 2199 | try di_w.writeUleb128(nav_align.toByteUnits() orelse |
| | 2200 | Type.fromInterned(nav_extern.ty).abiAlignment(zcu).toByteUnits().?); |
| | 2201 | switch (nav_extern.source) { |
| | 2202 | .builtin => {}, |
| | 2203 | .syntax => try di_w.writeByte(@intFromBool(decl.linkage != .normal)), |
| | 2204 | } |
| | 2205 | if (nav_const) { |
| | 2206 | try dwarf.secOffsetFinish(di_nw, type_offset, di_nw.ni, di_w.end); |
| | 2207 | try dwarf.abbrevCode(di_nw, .is_const); |
| | 2208 | try dwarf.refType(pt, di_nw, .fromInterned(nav_extern.ty)); |
| | 2209 | } |
| | 2210 | } |
| | 2211 | try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen()); |
| | 2212 | } |
| | 2213 | |
| | 2214 | pub fn updateGlobal( |
| | 2215 | dwarf: *Dwarf, |
| | 2216 | pt: Zcu.PerThread, |
| | 2217 | di_nw: *link.MappedFile.Node.Writer, |
| | 2218 | arch: std.Target.Cpu.Arch, |
| | 2219 | si: link.File.SymbolId, |
| | 2220 | global: InternPool.Nav.Index, |
| | 2221 | ) link.Error!void { |
| | 2222 | const ip = &pt.zcu.intern_pool; |
| | 2223 | log.debug("updateGlobal({f})", .{ip.getNav(global).fqn.fmt(ip)}); |
| | 2224 | dwarf.updateGlobalInner(pt, di_nw, arch, si, global) catch |err| switch (err) { |
| | 2225 | else => |e| return e, |
| | 2226 | error.WriteFailed => return dwarf.reportWriteError(di_nw), |
| | 2227 | }; |
| | 2228 | } |
| | 2229 | fn updateGlobalInner( |
| | 2230 | dwarf: *Dwarf, |
| | 2231 | pt: Zcu.PerThread, |
| | 2232 | di_nw: *link.MappedFile.Node.Writer, |
| | 2233 | arch: std.Target.Cpu.Arch, |
| | 2234 | si: link.File.SymbolId, |
| | 2235 | global: InternPool.Nav.Index, |
| | 2236 | ) link.EmitError!void { |
| | 2237 | const zcu = pt.zcu; |
| | 2238 | const ip = &zcu.intern_pool; |
| | 2239 | const nav = ip.getNav(global); |
| | 2240 | const nav_ty: Type, const nav_align, const nav_const, const nav_threadlocal = nav_resolved: { |
| | 2241 | const nav_resolved = nav.resolved.?; |
| | 2242 | break :nav_resolved .{ |
| | 2243 | .fromInterned(nav_resolved.type), |
| | 2244 | nav_resolved.@"align", |
| | 2245 | nav_resolved.@"const", |
| | 2246 | nav_resolved.@"threadlocal", |
| | 2247 | }; |
| | 2248 | }; |
| | 2249 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; |
| | 2250 | const decl = zcu.fileByIndex(inst_info.file).zir.?.getDeclaration(inst_info.inst); |
| | 2251 | switch (decl.kind) { |
| | 2252 | .unnamed_test, .@"test", .decltest, .@"comptime" => unreachable, |
| | 2253 | .@"const" => assert(nav_const), |
| | 2254 | .@"var" => assert(!nav_const), |
| | 2255 | } |
| | 2256 | const parent_ty: Type = .fromInterned(ip.namespacePtr(nav.analysis.?.namespace).owner_type); |
| | 2257 | const di_w = &di_nw.interface; |
| | 2258 | if (parent_ty.getCaptures(zcu).len > 0) { |
| | 2259 | try dwarf.abbrevCode(di_nw, .decl_instance_var); |
| | 2260 | try dwarf.refType(pt, di_nw, parent_ty); |
| | 2261 | try dwarf.secOffset(di_nw, try dwarf.getGlobalDecl(pt, global), 0); |
| | 2262 | } else { |
| | 2263 | const parent_ni = try dwarf.getConstDecl(pt, parent_ty.toIntern()); |
| | 2264 | try dwarf.abbrevCode(di_nw, .decl_var); |
| | 2265 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| | 2266 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 2267 | try di_w.writeUleb128(decl.src_column + 1); |
| | 2268 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| | 2269 | try dwarf.strx(di_nw, nav.name.toSlice(ip)); |
| | 2270 | } |
| | 2271 | try dwarf.strx(di_nw, switch (decl.linkage) { |
| | 2272 | .normal => nav.fqn, |
| | 2273 | .@"extern" => unreachable, |
| | 2274 | .@"export" => nav.name, |
| | 2275 | }.toSlice(ip)); |
| | 2276 | const addr: Loc = .{ .addr_sym = .{ .si = si } }; |
| | 2277 | const loc: Loc = if (nav_threadlocal) switch (arch) { |
| | 2278 | .x86_64 => .{ .form_tls_address = &addr }, |
| | 2279 | else => unreachable, |
| | 2280 | } else addr; |
| | 2281 | const type_offset = di_w.end; |
| | 2282 | if (nav_const) try dwarf.secOffsetPlaceholder(di_w) else try dwarf.refType(pt, di_nw, nav_ty); |
| | 2283 | try dwarf.exprLoc(di_nw, loc); |
| | 2284 | try di_w.writeUleb128(nav_align.toByteUnits() orelse nav_ty.abiAlignment(zcu).toByteUnits().?); |
| | 2285 | try di_w.writeByte(@intFromBool(decl.linkage != .normal)); |
| | 2286 | if (nav_const) { |
| | 2287 | try dwarf.secOffsetFinish(di_nw, type_offset, di_nw.ni, di_w.end); |
| | 2288 | try dwarf.abbrevCode(di_nw, .is_const); |
| | 2289 | try dwarf.refType(pt, di_nw, nav_ty); |
| | 2290 | } |
| | 2291 | try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen()); |
| | 2292 | } |
| | 2293 | |
| | 2294 | pub fn updateComptimeGlobal( |
| 1947 | dwarf: *Dwarf, | 2295 | dwarf: *Dwarf, |
| 1948 | pt: Zcu.PerThread, | 2296 | pt: Zcu.PerThread, |
| 1949 | nav_index: InternPool.Nav.Index, | 2297 | global: InternPool.Nav.Index, |
| 1950 | ) link.Error!void { | 2298 | ) link.Error!void { |
| 1951 | const zcu = pt.zcu; | 2299 | const zcu = pt.zcu; |
| 1952 | const ip = &zcu.intern_pool; | 2300 | const ip = &zcu.intern_pool; |
| 1953 | const nav = ip.getNav(nav_index); | 2301 | const nav = ip.getNav(global); |
| 1954 | log.debug("updateComptimeNav({f})", .{nav.fqn.fmt(ip)}); | 2302 | log.debug("updateComptimeGlobal({f})", .{nav.fqn.fmt(ip)}); |
| 1955 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; | 2303 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; |
| 1956 | const nav_val: Value = .fromInterned(nav.resolved.?.value); | 2304 | const nav_val: Value = .fromInterned(nav.resolved.?.value); |
| 1957 | const zf = zcu.fileByIndex(inst_info.file); | 2305 | const decl = zcu.fileByIndex(inst_info.file).zir.?.getDeclaration(inst_info.inst); |
| 1958 | const decl = zf.zir.?.getDeclaration(inst_info.inst); | | |
| 1959 | switch (decl.kind) { | 2306 | switch (decl.kind) { |
| 1960 | .unnamed_test, .@"test", .decltest => return, | 2307 | .unnamed_test, .@"test", .decltest => return, |
| 1961 | .@"comptime", .@"const", .@"var" => {}, | 2308 | .@"comptime", .@"const", .@"var" => {}, |
| 1962 | } | 2309 | } |
| 1963 | done: switch (ip.indexToKey(nav_val.toIntern())) { | 2310 | switch (ip.indexToKey(nav_val.toIntern())) { |
| | 2311 | .int_type, |
| | 2312 | .ptr_type, |
| | 2313 | .array_type, |
| | 2314 | .vector_type, |
| | 2315 | .opt_type, |
| | 2316 | .error_union_type, |
| | 2317 | .anyframe_type, |
| | 2318 | .simple_type, |
| | 2319 | .tuple_type, |
| | 2320 | .func_type, |
| | 2321 | .error_set_type, |
| | 2322 | .inferred_error_set_type, |
| | 2323 | .spirv_type, |
| | 2324 | .undef, |
| | 2325 | .simple_value, |
| | 2326 | .int, |
| | 2327 | .err, |
| | 2328 | .error_union, |
| | 2329 | .enum_literal, |
| | 2330 | .enum_tag, |
| | 2331 | .float, |
| | 2332 | .ptr, |
| | 2333 | .slice, |
| | 2334 | .opt, |
| | 2335 | .aggregate, |
| | 2336 | .un, |
| | 2337 | .bitpack, |
| | 2338 | => try dwarf.genComptimeGlobal(pt, global, &decl), |
| 1964 | .struct_type => { | 2339 | .struct_type => { |
| 1965 | const loaded_struct = ip.loadStructType(nav_val.toIntern()); | 2340 | const loaded_struct = ip.loadStructType(nav_val.toIntern()); |
| 1966 | if (nav_index.toOptional() == loaded_struct.name_nav) { | 2341 | if (loaded_struct.name_nav == global.toOptional()) { |
| 1967 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); | 2342 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); |
| 1968 | break :done; | 2343 | } else try dwarf.genComptimeGlobal(pt, global, &decl); |
| 1969 | } | | |
| 1970 | return; | | |
| 1971 | }, | 2344 | }, |
| 1972 | .enum_type => { | 2345 | .enum_type => { |
| 1973 | const loaded_enum = ip.loadEnumType(nav_val.toIntern()); | 2346 | const loaded_enum = ip.loadEnumType(nav_val.toIntern()); |
| 1974 | if (nav_index.toOptional() == loaded_enum.name_nav) { | 2347 | if (loaded_enum.name_nav == global.toOptional()) { |
| 1975 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); | 2348 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); |
| 1976 | break :done; | 2349 | } else try dwarf.genComptimeGlobal(pt, global, &decl); |
| 1977 | } | | |
| 1978 | return; | | |
| 1979 | }, | 2350 | }, |
| 1980 | .union_type => { | 2351 | .union_type => { |
| 1981 | const loaded_union = ip.loadUnionType(nav_val.toIntern()); | 2352 | const loaded_union = ip.loadUnionType(nav_val.toIntern()); |
| 1982 | if (nav_index.toOptional() == loaded_union.name_nav) { | 2353 | if (loaded_union.name_nav == global.toOptional()) { |
| 1983 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); | 2354 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); |
| 1984 | break :done; | 2355 | } else try dwarf.genComptimeGlobal(pt, global, &decl); |
| 1985 | } | | |
| 1986 | return; | | |
| 1987 | }, | 2356 | }, |
| 1988 | .opaque_type => { | 2357 | .opaque_type => { |
| 1989 | const loaded_opaque = ip.loadOpaqueType(nav_val.toIntern()); | 2358 | const loaded_opaque = ip.loadOpaqueType(nav_val.toIntern()); |
| 1990 | if (nav_index.toOptional() == loaded_opaque.name_nav) { | 2359 | if (loaded_opaque.name_nav == global.toOptional()) { |
| 1991 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); | 2360 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); |
| 1992 | break :done; | 2361 | } else try dwarf.genComptimeGlobal(pt, global, &decl); |
| 1993 | } | | |
| 1994 | return; | | |
| 1995 | }, | 2362 | }, |
| 1996 | .func => |func| if (func.owner_nav == nav_index and func.generic_owner == .none) { | 2363 | .@"extern" => unreachable, |
| | 2364 | .func => |func| if (func.owner_nav == global) { |
| 1997 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); | 2365 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); |
| 1998 | break :done; | 2366 | } else try dwarf.genComptimeGlobal(pt, global, &decl), |
| 1999 | } else return, | 2367 | .memoized_call => unreachable, // not a value |
| 2000 | | 2368 | } |
| 2001 | else => return, | 2369 | } |
| 2002 | | 2370 | fn genComptimeGlobal( |
| 2003 | // memoization, not values | 2371 | dwarf: *Dwarf, |
| 2004 | .memoized_call => unreachable, | 2372 | pt: Zcu.PerThread, |
| | 2373 | global: InternPool.Nav.Index, |
| | 2374 | decl: *const std.zig.Zir.Inst.Declaration.Unwrapped, |
| | 2375 | ) link.Error!void { |
| | 2376 | const gpa = pt.zcu.gpa; |
| | 2377 | const gi = try dwarf.getGlobal(global); |
| | 2378 | const debug_info_ni = gi.get(dwarf).debug_info_ni.unwrap().?; |
| | 2379 | var di_nw: link.MappedFile.Node.Writer = undefined; |
| | 2380 | if (dwarf.lf.cast(.elf2)) |elf| { |
| | 2381 | try debug_info_ni.moved(gpa, &elf.mf); |
| | 2382 | debug_info_ni.writer(gpa, &elf.mf, &di_nw); |
| | 2383 | elf.resetNodeRelocs(debug_info_ni); |
| | 2384 | } else unreachable; |
| | 2385 | defer di_nw.deinit(); |
| | 2386 | dwarf.genComptimeGlobalInner(pt, &di_nw, global, decl) catch |err| switch (err) { |
| | 2387 | else => |e| return e, |
| | 2388 | error.WriteFailed => return dwarf.reportWriteError(&di_nw), |
| | 2389 | }; |
| | 2390 | } |
| | 2391 | fn genComptimeGlobalInner( |
| | 2392 | dwarf: *Dwarf, |
| | 2393 | pt: Zcu.PerThread, |
| | 2394 | di_nw: *link.MappedFile.Node.Writer, |
| | 2395 | global: InternPool.Nav.Index, |
| | 2396 | decl: *const std.zig.Zir.Inst.Declaration.Unwrapped, |
| | 2397 | ) link.EmitError!void { |
| | 2398 | const zcu = pt.zcu; |
| | 2399 | const ip = &zcu.intern_pool; |
| | 2400 | const nav = ip.getNav(global); |
| | 2401 | const nav_ty: Type, const nav_align, const nav_const, const nav_val: Value = nav_resolved: { |
| | 2402 | const nav_resolved = nav.resolved.?; |
| | 2403 | break :nav_resolved .{ |
| | 2404 | .fromInterned(nav_resolved.type), |
| | 2405 | nav_resolved.@"align", |
| | 2406 | nav_resolved.@"const", |
| | 2407 | .fromInterned(nav_resolved.value), |
| | 2408 | }; |
| | 2409 | }; |
| | 2410 | const nav_class = nav_ty.classify(zcu); |
| | 2411 | const parent_ty: Type = .fromInterned(ip.namespacePtr(nav.analysis.?.namespace).owner_type); |
| | 2412 | const di_w = &di_nw.interface; |
| | 2413 | if (parent_ty.getCaptures(zcu).len > 0) { |
| | 2414 | try dwarf.abbrevCode(di_nw, switch (nav_ty.toIntern()) { |
| | 2415 | .type_type => .decl_instance_type, |
| | 2416 | else => switch (nav_class) { |
| | 2417 | .no_possible_value, .one_possible_value => .decl_instance_const, |
| | 2418 | .runtime => .decl_instance_const_fully_runtime, |
| | 2419 | .partially_comptime => .decl_instance_const_partially_comptime, |
| | 2420 | .fully_comptime => .decl_instance_const_fully_comptime, |
| | 2421 | }, |
| | 2422 | }); |
| | 2423 | try dwarf.refType(pt, di_nw, parent_ty); |
| | 2424 | try dwarf.secOffset(di_nw, try dwarf.getGlobalDecl(pt, global), 0); |
| | 2425 | } else { |
| | 2426 | const parent_ni = try dwarf.getConstDecl(pt, parent_ty.toIntern()); |
| | 2427 | try dwarf.abbrevCode(di_nw, switch (nav_ty.toIntern()) { |
| | 2428 | .type_type => .decl_type, |
| | 2429 | else => switch (nav_class) { |
| | 2430 | .no_possible_value, .one_possible_value => .decl_const, |
| | 2431 | .runtime => .decl_const_fully_runtime, |
| | 2432 | .partially_comptime => .decl_const_partially_comptime, |
| | 2433 | .fully_comptime => .decl_const_fully_comptime, |
| | 2434 | }, |
| | 2435 | }); |
| | 2436 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| | 2437 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 2438 | try di_w.writeUleb128(decl.src_column + 1); |
| | 2439 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| | 2440 | try dwarf.strx(di_nw, nav.name.toSlice(ip)); |
| | 2441 | } |
| | 2442 | switch (nav_ty.toIntern()) { |
| | 2443 | .type_type => try dwarf.refConst(pt, di_nw, nav_val), |
| | 2444 | else => { |
| | 2445 | try dwarf.strx(di_nw, switch (decl.linkage) { |
| | 2446 | .normal => nav.fqn, |
| | 2447 | .@"extern", .@"export" => nav.name, |
| | 2448 | }.toSlice(ip)); |
| | 2449 | const type_offset = di_w.end; |
| | 2450 | if (nav_const) |
| | 2451 | try dwarf.secOffsetPlaceholder(di_w) |
| | 2452 | else |
| | 2453 | try dwarf.refType(pt, di_nw, nav_ty); |
| | 2454 | try di_w.writeUleb128(nav_align.toByteUnits() orelse |
| | 2455 | nav_ty.abiAlignment(zcu).toByteUnits().?); |
| | 2456 | try di_w.writeByte(@intFromBool(decl.linkage != .normal)); |
| | 2457 | if (nav_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, nav_val); |
| | 2458 | if (nav_class.comptimeOnly()) try dwarf.refConst(pt, di_nw, nav_val); |
| | 2459 | if (nav_const) { |
| | 2460 | try dwarf.secOffsetFinish(di_nw, type_offset, di_nw.ni, di_w.end); |
| | 2461 | try dwarf.abbrevCode(di_nw, .is_const); |
| | 2462 | try dwarf.refType(pt, di_nw, nav_ty); |
| | 2463 | } |
| | 2464 | }, |
| 2005 | } | 2465 | } |
| 2006 | try dwarf.const_pool.flushPending(pt, dwarf.constPoolUser()); | 2466 | try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen()); |
| 2007 | } | 2467 | } |
| 2008 | | 2468 | |
| 2009 | pub fn addConst( | 2469 | pub fn addConst( |
| ... | @@ -2041,9 +2501,11 @@ pub fn addConst( | ... | @@ -2041,9 +2501,11 @@ pub fn addConst( |
| 2041 | const name_gi = try dwarf.getGlobal(name_nav); | 2501 | const name_gi = try dwarf.getGlobal(name_nav); |
| 2042 | break :debug_info_ni name_gi.get(dwarf).debug_info_ni.unwrap().?; | 2502 | break :debug_info_ni name_gi.get(dwarf).debug_info_ni.unwrap().?; |
| 2043 | } | 2503 | } |
| 2044 | break :debug_info_ni try addConstNode(dwarf.lf, dwarf.getUnit(zcu.fileByIndex( | 2504 | const mod = zcu.fileByIndex( |
| 2045 | Type.fromInterned(val).typeDeclInstAllowGeneratedTag(zcu).?.resolveFile(ip), | 2505 | Type.fromInterned(val).typeDeclInstAllowGeneratedTag(zcu).?.resolveFile(ip), |
| 2046 | ).mod.?), cpi); | 2506 | ).mod.?; |
| | 2507 | assert(!mod.strip); |
| | 2508 | break :debug_info_ni try addConstNode(dwarf.lf, dwarf.getUnit(mod), cpi); |
| 2047 | }, | 2509 | }, |
| 2048 | }.toOptional(), | 2510 | }.toOptional(), |
| 2049 | }); | 2511 | }); |
| ... | @@ -2068,17 +2530,17 @@ fn updateConstInner( | ... | @@ -2068,17 +2530,17 @@ fn updateConstInner( |
| 2068 | dwarf: *Dwarf, | 2530 | dwarf: *Dwarf, |
| 2069 | pt: Zcu.PerThread, | 2531 | pt: Zcu.PerThread, |
| 2070 | di_nw: *link.MappedFile.Node.Writer, | 2532 | di_nw: *link.MappedFile.Node.Writer, |
| 2071 | val: InternPool.Index, | 2533 | @"const": InternPool.Index, |
| 2072 | ) link.EmitError!void { | 2534 | ) link.EmitError!void { |
| 2073 | const zcu = pt.zcu; | 2535 | const zcu = pt.zcu; |
| 2074 | const ip = &zcu.intern_pool; | 2536 | const ip = &zcu.intern_pool; |
| 2075 | const di_w = &di_nw.interface; | 2537 | const di_w = &di_nw.interface; |
| 2076 | switch (ip.indexToKey(val)) { | 2538 | switch (ip.indexToKey(@"const")) { |
| 2077 | .int_type => |int_type| { | 2539 | .int_type => |int_type| { |
| 2078 | const ty: Type = .fromInterned(val); | 2540 | const ty: Type = .fromInterned(@"const"); |
| 2079 | try dwarf.abbrevCode(di_nw, .numeric_type); | 2541 | try dwarf.abbrevCode(di_nw, .numeric_type); |
| 2080 | var name_buf: [std.fmt.count("i{d}", .{std.math.maxInt(u16)})]u8 = undefined; | 2542 | var name_buf: [std.fmt.count("i{d}", .{std.math.maxInt(u16)})]u8 = undefined; |
| 2081 | try dwarf.strp(&dwarf.debug_str, di_nw, std.mem.print(&name_buf, "{f}", .{ | 2543 | try dwarf.strx(di_nw, std.mem.print(&name_buf, "{f}", .{ |
| 2082 | ty.fmt(pt), | 2544 | ty.fmt(pt), |
| 2083 | }) catch unreachable); | 2545 | }) catch unreachable); |
| 2084 | try di_w.writeByte(switch (int_type.signedness) { | 2546 | try di_w.writeByte(switch (int_type.signedness) { |
| ... | @@ -2091,56 +2553,54 @@ fn updateConstInner( | ... | @@ -2091,56 +2553,54 @@ fn updateConstInner( |
| 2091 | }, | 2553 | }, |
| 2092 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { | 2554 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 2093 | .one, .many, .c => { | 2555 | .one, .many, .c => { |
| 2094 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); | 2556 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(pt)}); |
| 2095 | defer zcu.gpa.free(name); | 2557 | defer zcu.gpa.free(name); |
| 2096 | try dwarf.abbrevCode(di_nw, switch (ptr_type.sentinel) { | 2558 | try dwarf.abbrevCode(di_nw, switch (ptr_type.sentinel) { |
| 2097 | .none => switch (ptr_type.flags.alignment) { | 2559 | .none => .ptr_type, |
| 2098 | .none => .ptr_type, | 2560 | else => .ptr_sentinel_type, |
| 2099 | else => .ptr_aligned_type, | | |
| 2100 | }, | | |
| 2101 | else => switch (ptr_type.flags.alignment) { | | |
| 2102 | .none => .ptr_sentinel_type, | | |
| 2103 | else => .ptr_aligned_sentinel_type, | | |
| 2104 | }, | | |
| 2105 | }); | 2561 | }); |
| 2106 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 2562 | try dwarf.strx(di_nw, name); |
| 2107 | switch (ptr_type.sentinel) { | 2563 | switch (ptr_type.sentinel) { |
| 2108 | .none => {}, | 2564 | .none => {}, |
| 2109 | else => |sentinel| try dwarf.blockConst(pt, di_nw, .fromInterned(sentinel)), | 2565 | else => |sentinel| try dwarf.blockConst(pt, di_nw, .fromInterned(sentinel)), |
| 2110 | } | 2566 | } |
| 2111 | if (ptr_type.flags.alignment.toByteUnits()) |a| try di_w.writeUleb128(a); | | |
| 2112 | try di_w.writeByte(@backingInt(ptr_type.flags.address_space)); | 2567 | try di_w.writeByte(@backingInt(ptr_type.flags.address_space)); |
| 2113 | if (ptr_type.flags.is_const or ptr_type.flags.is_volatile) try dwarf.secOffset( | 2568 | if (ptr_type.flags.alignment.toByteUnits()) |a| { |
| 2114 | di_nw, | 2569 | const type_offset = di_w.end; |
| 2115 | di_nw.ni, | 2570 | try dwarf.secOffsetPlaceholder(di_w); |
| 2116 | di_w.end + dwarf.secOffsetSize(), | 2571 | try dwarf.secOffsetFinish(di_nw, type_offset, di_nw.ni, di_w.end); |
| 2117 | ); | 2572 | try dwarf.abbrevCode(di_nw, .is_aligned); |
| | 2573 | try di_w.writeUleb128(a); |
| | 2574 | } |
| 2118 | if (ptr_type.flags.is_const) { | 2575 | if (ptr_type.flags.is_const) { |
| | 2576 | const type_offset = di_w.end; |
| | 2577 | try dwarf.secOffsetPlaceholder(di_w); |
| | 2578 | try dwarf.secOffsetFinish(di_nw, type_offset, di_nw.ni, di_w.end); |
| 2119 | try dwarf.abbrevCode(di_nw, .is_const); | 2579 | try dwarf.abbrevCode(di_nw, .is_const); |
| 2120 | if (ptr_type.flags.is_volatile) try dwarf.secOffset( | | |
| 2121 | di_nw, | | |
| 2122 | di_nw.ni, | | |
| 2123 | di_w.end + dwarf.secOffsetSize(), | | |
| 2124 | ); | | |
| 2125 | } | 2580 | } |
| 2126 | if (ptr_type.flags.is_volatile) try dwarf.abbrevCode(di_nw, .is_volatile); | 2581 | if (ptr_type.flags.is_volatile) { |
| | 2582 | const type_offset = di_w.end; |
| | 2583 | try dwarf.secOffsetPlaceholder(di_w); |
| | 2584 | try dwarf.secOffsetFinish(di_nw, type_offset, di_nw.ni, di_w.end); |
| | 2585 | try dwarf.abbrevCode(di_nw, .is_volatile); |
| | 2586 | } |
| 2127 | try dwarf.refType(pt, di_nw, .fromInterned(ptr_type.child)); | 2587 | try dwarf.refType(pt, di_nw, .fromInterned(ptr_type.child)); |
| 2128 | }, | 2588 | }, |
| 2129 | .slice => { | 2589 | .slice => { |
| 2130 | const ty: Type = .fromInterned(val); | 2590 | const ty: Type = .fromInterned(@"const"); |
| 2131 | const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)}); | 2591 | const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)}); |
| 2132 | defer zcu.gpa.free(name); | 2592 | defer zcu.gpa.free(name); |
| 2133 | try dwarf.abbrevCode(di_nw, .generated_struct_type); | 2593 | try dwarf.abbrevCode(di_nw, .generated_struct_type); |
| 2134 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 2594 | try dwarf.strx(di_nw, name); |
| 2135 | try di_w.writeUleb128(ty.abiSize(zcu)); | 2595 | try di_w.writeUleb128(ty.abiSize(zcu)); |
| 2136 | try di_w.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); | 2596 | try di_w.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); |
| 2137 | try dwarf.abbrevCode(di_nw, .generated_field); | 2597 | try dwarf.abbrevCode(di_nw, .generated_field); |
| 2138 | try dwarf.strp(&dwarf.debug_str, di_nw, "ptr"); | 2598 | try dwarf.strx(di_nw, "ptr"); |
| 2139 | const ptr_field_ty = ty.slicePtrFieldType(zcu); | 2599 | const ptr_field_ty = ty.slicePtrFieldType(zcu); |
| 2140 | try dwarf.refType(pt, di_nw, ptr_field_ty); | 2600 | try dwarf.refType(pt, di_nw, ptr_field_ty); |
| 2141 | try di_w.writeUleb128(0); | 2601 | try di_w.writeUleb128(0); |
| 2142 | try dwarf.abbrevCode(di_nw, .generated_field); | 2602 | try dwarf.abbrevCode(di_nw, .generated_field); |
| 2143 | try dwarf.strp(&dwarf.debug_str, di_nw, "len"); | 2603 | try dwarf.strx(di_nw, "len"); |
| 2144 | const len_field_ty: Type = .usize; | 2604 | const len_field_ty: Type = .usize; |
| 2145 | try dwarf.refType(pt, di_nw, len_field_ty); | 2605 | try dwarf.refType(pt, di_nw, len_field_ty); |
| 2146 | try di_w.writeUleb128(len_field_ty.abiAlignment(zcu).forward(ptr_field_ty.abiSize(zcu))); | 2606 | try di_w.writeUleb128(len_field_ty.abiAlignment(zcu).forward(ptr_field_ty.abiSize(zcu))); |
| ... | @@ -2148,13 +2608,13 @@ fn updateConstInner( | ... | @@ -2148,13 +2608,13 @@ fn updateConstInner( |
| 2148 | }, | 2608 | }, |
| 2149 | }, | 2609 | }, |
| 2150 | .array_type => |array_type| { | 2610 | .array_type => |array_type| { |
| 2151 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); | 2611 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(pt)}); |
| 2152 | defer zcu.gpa.free(name); | 2612 | defer zcu.gpa.free(name); |
| 2153 | try dwarf.abbrevCode( | 2613 | try dwarf.abbrevCode( |
| 2154 | di_nw, | 2614 | di_nw, |
| 2155 | if (array_type.sentinel == .none) .array_type else .array_sentinel_type, | 2615 | if (array_type.sentinel == .none) .array_type else .array_sentinel_type, |
| 2156 | ); | 2616 | ); |
| 2157 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 2617 | try dwarf.strx(di_nw, name); |
| 2158 | if (array_type.sentinel != .none) | 2618 | if (array_type.sentinel != .none) |
| 2159 | try dwarf.blockConst(pt, di_nw, .fromInterned(array_type.sentinel)); | 2619 | try dwarf.blockConst(pt, di_nw, .fromInterned(array_type.sentinel)); |
| 2160 | try dwarf.refType(pt, di_nw, .fromInterned(array_type.child)); | 2620 | try dwarf.refType(pt, di_nw, .fromInterned(array_type.child)); |
| ... | @@ -2164,10 +2624,10 @@ fn updateConstInner( | ... | @@ -2164,10 +2624,10 @@ fn updateConstInner( |
| 2164 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | 2624 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2165 | }, | 2625 | }, |
| 2166 | .vector_type => |vector_type| { | 2626 | .vector_type => |vector_type| { |
| 2167 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); | 2627 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(pt)}); |
| 2168 | defer zcu.gpa.free(name); | 2628 | defer zcu.gpa.free(name); |
| 2169 | try dwarf.abbrevCode(di_nw, .vector_type); | 2629 | try dwarf.abbrevCode(di_nw, .vector_type); |
| 2170 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 2630 | try dwarf.strx(di_nw, name); |
| 2171 | try dwarf.refType(pt, di_nw, .fromInterned(vector_type.child)); | 2631 | try dwarf.refType(pt, di_nw, .fromInterned(vector_type.child)); |
| 2172 | try dwarf.abbrevCode(di_nw, .array_len); | 2632 | try dwarf.abbrevCode(di_nw, .array_len); |
| 2173 | try dwarf.refType(pt, di_nw, .usize); | 2633 | try dwarf.refType(pt, di_nw, .usize); |
| ... | @@ -2175,28 +2635,30 @@ fn updateConstInner( | ... | @@ -2175,28 +2635,30 @@ fn updateConstInner( |
| 2175 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | 2635 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2176 | }, | 2636 | }, |
| 2177 | .opt_type => |opt_child_type_index| { | 2637 | .opt_type => |opt_child_type_index| { |
| 2178 | const opt_ty: Type = .fromInterned(val); | 2638 | const opt_ty: Type = .fromInterned(@"const"); |
| 2179 | const opt_child_ty: Type = .fromInterned(opt_child_type_index); | 2639 | const opt_child_ty: Type = .fromInterned(opt_child_type_index); |
| 2180 | const opt_repr = optRepr(opt_child_ty, zcu); | 2640 | const opt_repr = optRepr(opt_child_ty, zcu); |
| 2181 | const name = try zcu.gpa.print("{f}", .{opt_ty.fmt(pt)}); | 2641 | const name = try zcu.gpa.print("{f}", .{opt_ty.fmt(pt)}); |
| 2182 | defer zcu.gpa.free(name); | 2642 | defer zcu.gpa.free(name); |
| 2183 | try dwarf.abbrevCode(di_nw, .generated_union_type); | 2643 | try dwarf.abbrevCode(di_nw, .generated_union_type); |
| 2184 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 2644 | try dwarf.strx(di_nw, name); |
| 2185 | try di_w.writeUleb128(opt_ty.abiSize(zcu)); | 2645 | try di_w.writeUleb128(opt_ty.abiSize(zcu)); |
| 2186 | try di_w.writeUleb128(opt_ty.abiAlignment(zcu).toByteUnits().?); | 2646 | try di_w.writeUleb128(opt_ty.abiAlignment(zcu).toByteUnits().?); |
| 2187 | switch (opt_repr) { | 2647 | switch (opt_repr) { |
| 2188 | .opv_null => { | 2648 | .opv_null => { |
| 2189 | try dwarf.abbrevCode(di_nw, .generated_field); | 2649 | try dwarf.abbrevCode(di_nw, .generated_field); |
| 2190 | try dwarf.strp(&dwarf.debug_str, di_nw, "null"); | 2650 | try dwarf.strx(di_nw, "null"); |
| 2191 | try dwarf.refType(pt, di_nw, .null); | 2651 | try dwarf.refType(pt, di_nw, .null); |
| 2192 | try di_w.writeUleb128(0); | 2652 | try di_w.writeUleb128(0); |
| 2193 | }, | 2653 | }, |
| 2194 | .unpacked, .error_set, .pointer => { | 2654 | .unpacked, .error_set, .pointer => { |
| 2195 | try dwarf.abbrevCode(di_nw, .tagged_union); | 2655 | try dwarf.abbrevCode(di_nw, .tagged_union); |
| 2196 | try dwarf.secOffset(di_nw, di_nw.ni, di_w.end + dwarf.secOffsetSize()); | 2656 | const discr_offset = di_w.end; |
| | 2657 | try dwarf.secOffsetPlaceholder(di_w); |
| 2197 | { | 2658 | { |
| | 2659 | try dwarf.secOffsetFinish(di_nw, discr_offset, di_nw.ni, di_w.end); |
| 2198 | try dwarf.abbrevCode(di_nw, .generated_field); | 2660 | try dwarf.abbrevCode(di_nw, .generated_field); |
| 2199 | try dwarf.strp(&dwarf.debug_str, di_nw, "has_value"); | 2661 | try dwarf.strx(di_nw, "has_value"); |
| 2200 | switch (opt_repr) { | 2662 | switch (opt_repr) { |
| 2201 | .opv_null => unreachable, | 2663 | .opv_null => unreachable, |
| 2202 | .unpacked => { | 2664 | .unpacked => { |
| ... | @@ -2207,7 +2669,10 @@ fn updateConstInner( | ... | @@ -2207,7 +2669,10 @@ fn updateConstInner( |
| 2207 | 0); | 2669 | 0); |
| 2208 | }, | 2670 | }, |
| 2209 | .error_set => { | 2671 | .error_set => { |
| 2210 | try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits())); | 2672 | try dwarf.refType(pt, di_nw, try pt.intType( |
| | 2673 | .unsigned, |
| | 2674 | zcu.errorSetBits(), |
| | 2675 | )); |
| 2211 | try di_w.writeUleb128(0); | 2676 | try di_w.writeUleb128(0); |
| 2212 | }, | 2677 | }, |
| 2213 | .pointer => { | 2678 | .pointer => { |
| ... | @@ -2221,7 +2686,7 @@ fn updateConstInner( | ... | @@ -2221,7 +2686,7 @@ fn updateConstInner( |
| 2221 | try di_w.writeByte(0); | 2686 | try di_w.writeByte(0); |
| 2222 | { | 2687 | { |
| 2223 | try dwarf.abbrevCode(di_nw, .generated_field); | 2688 | try dwarf.abbrevCode(di_nw, .generated_field); |
| 2224 | try dwarf.strp(&dwarf.debug_str, di_nw, "null"); | 2689 | try dwarf.strx(di_nw, "null"); |
| 2225 | try dwarf.refType(pt, di_nw, .null); | 2690 | try dwarf.refType(pt, di_nw, .null); |
| 2226 | try di_w.writeUleb128(0); | 2691 | try di_w.writeUleb128(0); |
| 2227 | } | 2692 | } |
| ... | @@ -2230,7 +2695,7 @@ fn updateConstInner( | ... | @@ -2230,7 +2695,7 @@ fn updateConstInner( |
| 2230 | try dwarf.abbrevCode(di_nw, .tagged_union_default_field); | 2695 | try dwarf.abbrevCode(di_nw, .tagged_union_default_field); |
| 2231 | { | 2696 | { |
| 2232 | try dwarf.abbrevCode(di_nw, .generated_field); | 2697 | try dwarf.abbrevCode(di_nw, .generated_field); |
| 2233 | try dwarf.strp(&dwarf.debug_str, di_nw, "?"); | 2698 | try dwarf.strx(di_nw, "?"); |
| 2234 | try dwarf.refType(pt, di_nw, opt_child_ty); | 2699 | try dwarf.refType(pt, di_nw, opt_child_ty); |
| 2235 | try di_w.writeUleb128(0); | 2700 | try di_w.writeUleb128(0); |
| 2236 | } | 2701 | } |
| ... | @@ -2243,7 +2708,7 @@ fn updateConstInner( | ... | @@ -2243,7 +2708,7 @@ fn updateConstInner( |
| 2243 | }, | 2708 | }, |
| 2244 | .anyframe_type => unreachable, | 2709 | .anyframe_type => unreachable, |
| 2245 | .error_union_type => |error_union_type| { | 2710 | .error_union_type => |error_union_type| { |
| 2246 | const eu_ty: Type = .fromInterned(val); | 2711 | const eu_ty: Type = .fromInterned(@"const"); |
| 2247 | const eu_error_set_ty: Type = .fromInterned(error_union_type.error_set_type); | 2712 | const eu_error_set_ty: Type = .fromInterned(error_union_type.error_set_type); |
| 2248 | const eu_payload_ty: Type = .fromInterned(error_union_type.payload_type); | 2713 | const eu_payload_ty: Type = .fromInterned(error_union_type.payload_type); |
| 2249 | const eu_error_set_offset, const eu_payload_offset = switch (error_union_type.payload_type) { | 2714 | const eu_error_set_offset, const eu_payload_offset = switch (error_union_type.payload_type) { |
| ... | @@ -2257,7 +2722,7 @@ fn updateConstInner( | ... | @@ -2257,7 +2722,7 @@ fn updateConstInner( |
| 2257 | defer zcu.gpa.free(name); | 2722 | defer zcu.gpa.free(name); |
| 2258 | | 2723 | |
| 2259 | try dwarf.abbrevCode(di_nw, .generated_union_type); | 2724 | try dwarf.abbrevCode(di_nw, .generated_union_type); |
| 2260 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 2725 | try dwarf.strx(di_nw, name); |
| 2261 | if (error_union_type.error_set_type != .generic_poison_type and | 2726 | if (error_union_type.error_set_type != .generic_poison_type and |
| 2262 | error_union_type.payload_type != .generic_poison_type) | 2727 | error_union_type.payload_type != .generic_poison_type) |
| 2263 | { | 2728 | { |
| ... | @@ -2269,10 +2734,12 @@ fn updateConstInner( | ... | @@ -2269,10 +2734,12 @@ fn updateConstInner( |
| 2269 | } | 2734 | } |
| 2270 | { | 2735 | { |
| 2271 | try dwarf.abbrevCode(di_nw, .tagged_union); | 2736 | try dwarf.abbrevCode(di_nw, .tagged_union); |
| 2272 | try dwarf.secOffset(di_nw, di_nw.ni, di_w.end + dwarf.secOffsetSize()); | 2737 | const discr_offset = di_w.end; |
| | 2738 | try dwarf.secOffsetPlaceholder(di_w); |
| 2273 | { | 2739 | { |
| | 2740 | try dwarf.secOffsetFinish(di_nw, discr_offset, di_nw.ni, di_w.end); |
| 2274 | try dwarf.abbrevCode(di_nw, .generated_field); | 2741 | try dwarf.abbrevCode(di_nw, .generated_field); |
| 2275 | try dwarf.strp(&dwarf.debug_str, di_nw, "is_error"); | 2742 | try dwarf.strx(di_nw, "is_error"); |
| 2276 | try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits())); | 2743 | try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits())); |
| 2277 | try di_w.writeUleb128(eu_error_set_offset); | 2744 | try di_w.writeUleb128(eu_error_set_offset); |
| 2278 | | 2745 | |
| ... | @@ -2281,7 +2748,7 @@ fn updateConstInner( | ... | @@ -2281,7 +2748,7 @@ fn updateConstInner( |
| 2281 | try di_w.writeUleb128(0); | 2748 | try di_w.writeUleb128(0); |
| 2282 | { | 2749 | { |
| 2283 | try dwarf.abbrevCode(di_nw, .generated_field); | 2750 | try dwarf.abbrevCode(di_nw, .generated_field); |
| 2284 | try dwarf.strp(&dwarf.debug_str, di_nw, "value"); | 2751 | try dwarf.strx(di_nw, "value"); |
| 2285 | try dwarf.refType(pt, di_nw, eu_payload_ty); | 2752 | try dwarf.refType(pt, di_nw, eu_payload_ty); |
| 2286 | try di_w.writeUleb128(eu_payload_offset); | 2753 | try di_w.writeUleb128(eu_payload_offset); |
| 2287 | } | 2754 | } |
| ... | @@ -2290,7 +2757,7 @@ fn updateConstInner( | ... | @@ -2290,7 +2757,7 @@ fn updateConstInner( |
| 2290 | try dwarf.abbrevCode(di_nw, .tagged_union_default_field); | 2757 | try dwarf.abbrevCode(di_nw, .tagged_union_default_field); |
| 2291 | { | 2758 | { |
| 2292 | try dwarf.abbrevCode(di_nw, .generated_field); | 2759 | try dwarf.abbrevCode(di_nw, .generated_field); |
| 2293 | try dwarf.strp(&dwarf.debug_str, di_nw, "error"); | 2760 | try dwarf.strx(di_nw, "error"); |
| 2294 | try dwarf.refType(pt, di_nw, eu_error_set_ty); | 2761 | try dwarf.refType(pt, di_nw, eu_error_set_ty); |
| 2295 | try di_w.writeUleb128(eu_error_set_offset); | 2762 | try di_w.writeUleb128(eu_error_set_offset); |
| 2296 | } | 2763 | } |
| ... | @@ -2320,10 +2787,10 @@ fn updateConstInner( | ... | @@ -2320,10 +2787,10 @@ fn updateConstInner( |
| 2320 | .c_longdouble, | 2787 | .c_longdouble, |
| 2321 | .bool, | 2788 | .bool, |
| 2322 | => { | 2789 | => { |
| 2323 | const ty: Type = .fromInterned(val); | 2790 | const ty: Type = .fromInterned(@"const"); |
| 2324 | try dwarf.abbrevCode(di_nw, .numeric_type); | 2791 | try dwarf.abbrevCode(di_nw, .numeric_type); |
| 2325 | try dwarf.strp(&dwarf.debug_str, di_nw, @tagName(simple_type)); | 2792 | try dwarf.strx(di_nw, @tagName(simple_type)); |
| 2326 | try di_w.writeByte(if (val == .bool_type) | 2793 | try di_w.writeByte(if (@"const" == .bool_type) |
| 2327 | DW.ATE.boolean | 2794 | DW.ATE.boolean |
| 2328 | else if (ty.isRuntimeFloat()) | 2795 | else if (ty.isRuntimeFloat()) |
| 2329 | DW.ATE.float | 2796 | DW.ATE.float |
| ... | @@ -2339,7 +2806,7 @@ fn updateConstInner( | ... | @@ -2339,7 +2806,7 @@ fn updateConstInner( |
| 2339 | }, | 2806 | }, |
| 2340 | .generic_poison => { | 2807 | .generic_poison => { |
| 2341 | try dwarf.abbrevCode(di_nw, .void_type); | 2808 | try dwarf.abbrevCode(di_nw, .void_type); |
| 2342 | try dwarf.strp(&dwarf.debug_str, di_nw, "anytype"); | 2809 | try dwarf.strx(di_nw, "anytype"); |
| 2343 | }, | 2810 | }, |
| 2344 | .anyopaque, | 2811 | .anyopaque, |
| 2345 | .void, | 2812 | .void, |
| ... | @@ -2351,10 +2818,10 @@ fn updateConstInner( | ... | @@ -2351,10 +2818,10 @@ fn updateConstInner( |
| 2351 | .undefined, | 2818 | .undefined, |
| 2352 | .enum_literal, | 2819 | .enum_literal, |
| 2353 | => { | 2820 | => { |
| 2354 | const ty: Type = .fromInterned(val); | 2821 | const ty: Type = .fromInterned(@"const"); |
| 2355 | try dwarf.abbrevCode(di_nw, .void_type); | 2822 | try dwarf.abbrevCode(di_nw, .void_type); |
| 2356 | var name_buf: ["@TypeOf(undefined)".len]u8 = undefined; | 2823 | var name_buf: ["@TypeOf(undefined)".len]u8 = undefined; |
| 2357 | try dwarf.strp(&dwarf.debug_str, di_nw, std.mem.print(&name_buf, "{f}", .{ | 2824 | try dwarf.strx(di_nw, std.mem.print(&name_buf, "{f}", .{ |
| 2358 | ty.fmt(pt), | 2825 | ty.fmt(pt), |
| 2359 | }) catch unreachable); | 2826 | }) catch unreachable); |
| 2360 | }, | 2827 | }, |
| ... | @@ -2364,29 +2831,29 @@ fn updateConstInner( | ... | @@ -2364,29 +2831,29 @@ fn updateConstInner( |
| 2364 | .generated_enum_type | 2831 | .generated_enum_type |
| 2365 | else | 2832 | else |
| 2366 | .generated_empty_enum_type); | 2833 | .generated_empty_enum_type); |
| 2367 | try dwarf.strp(&dwarf.debug_str, di_nw, "anyerror"); | 2834 | try dwarf.strx(di_nw, "anyerror"); |
| 2368 | try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits())); | 2835 | try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits())); |
| 2369 | for (global_error_set_names, 1..) |name, value| { | 2836 | for (global_error_set_names, 1..) |err_name, err_value| { |
| 2370 | try dwarf.abbrevCode(di_nw, .enum_field); | 2837 | try dwarf.abbrevCode(di_nw, .enum_field); |
| 2371 | try di_w.writeUleb128(DW.FORM.udata); | 2838 | try di_w.writeUleb128(DW.FORM.udata); |
| 2372 | try di_w.writeUleb128(value); | 2839 | try di_w.writeUleb128(err_value); |
| 2373 | try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip)); | 2840 | try dwarf.strx(di_nw, err_name.toSlice(ip)); |
| 2374 | } | 2841 | } |
| 2375 | if (global_error_set_names.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | 2842 | if (global_error_set_names.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2376 | }, | 2843 | }, |
| 2377 | .adhoc_inferred_error_set => unreachable, | 2844 | .adhoc_inferred_error_set => unreachable, |
| 2378 | }, | 2845 | }, |
| 2379 | .tuple_type => |tuple_type| { | 2846 | .tuple_type => |tuple_type| { |
| 2380 | const ty: Type = .fromInterned(val); | 2847 | const ty: Type = .fromInterned(@"const"); |
| 2381 | const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)}); | 2848 | const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)}); |
| 2382 | defer zcu.gpa.free(name); | 2849 | defer zcu.gpa.free(name); |
| 2383 | if (tuple_type.types.len == 0) { | 2850 | if (tuple_type.types.len == 0) { |
| 2384 | try dwarf.abbrevCode(di_nw, .generated_empty_struct_type); | 2851 | try dwarf.abbrevCode(di_nw, .generated_empty_struct_type); |
| 2385 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 2852 | try dwarf.strx(di_nw, name); |
| 2386 | try di_w.writeByte(@intFromBool(false)); | 2853 | try di_w.writeByte(@intFromBool(false)); |
| 2387 | } else { | 2854 | } else { |
| 2388 | try dwarf.abbrevCode(di_nw, .generated_struct_type); | 2855 | try dwarf.abbrevCode(di_nw, .generated_struct_type); |
| 2389 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 2856 | try dwarf.strx(di_nw, name); |
| 2390 | try di_w.writeUleb128(ty.abiSize(zcu)); | 2857 | try di_w.writeUleb128(ty.abiSize(zcu)); |
| 2391 | try di_w.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); | 2858 | try di_w.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); |
| 2392 | var field_byte_offset: u64 = 0; | 2859 | var field_byte_offset: u64 = 0; |
| ... | @@ -2407,7 +2874,7 @@ fn updateConstInner( | ... | @@ -2407,7 +2874,7 @@ fn updateConstInner( |
| 2407 | }, | 2874 | }, |
| 2408 | }); | 2875 | }); |
| 2409 | var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined; | 2876 | var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = undefined; |
| 2410 | try dwarf.strp(&dwarf.debug_str, di_nw, std.mem.print(&field_name_buf, "{d}", .{ | 2877 | try dwarf.strx(di_nw, std.mem.print(&field_name_buf, "{d}", .{ |
| 2411 | field_index, | 2878 | field_index, |
| 2412 | }) catch unreachable); | 2879 | }) catch unreachable); |
| 2413 | try dwarf.refType(pt, di_nw, field_ty); | 2880 | try dwarf.refType(pt, di_nw, field_ty); |
| ... | @@ -2427,72 +2894,81 @@ fn updateConstInner( | ... | @@ -2427,72 +2894,81 @@ fn updateConstInner( |
| 2427 | } | 2894 | } |
| 2428 | }, | 2895 | }, |
| 2429 | .struct_type => { | 2896 | .struct_type => { |
| 2430 | const loaded_struct = ip.loadStructType(val); | 2897 | const loaded_struct = ip.loadStructType(@"const"); |
| 2431 | const zfi = loaded_struct.zir_index.resolveFile(ip); | 2898 | const src_inst = loaded_struct.zir_index.resolveFull(ip).?; |
| 2432 | const zf = zcu.fileByIndex(zfi); | 2899 | const zf = zcu.fileByIndex(src_inst.file); |
| 2433 | const src_inst = loaded_struct.zir_index.resolve(ip); | 2900 | const is_empty = loaded_struct.captures.len == 0 and loaded_struct.field_types.len == 0; |
| 2434 | if (src_inst == .main_struct_inst) { | 2901 | if (src_inst.inst == .main_struct_inst) { |
| 2435 | assert(loaded_struct.captures.len == 0); | 2902 | assert(loaded_struct.captures.len == 0); |
| 2436 | const ui = dwarf.getUnit(zf.mod.?); | 2903 | const ui = dwarf.getUnit(zf.mod.?); |
| 2437 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, zfi); | 2904 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file); |
| 2438 | try dwarf.abbrevCode(di_nw, switch (loaded_struct.layout) { | 2905 | try dwarf.abbrevCode(di_nw, switch (loaded_struct.layout) { |
| 2439 | .auto => if (loaded_struct.field_types.len > 0) .file else .empty_file, | 2906 | .auto => if (is_empty) .empty_file else .file, |
| 2440 | .@"extern", .@"packed" => unreachable, | 2907 | .@"extern", .@"packed" => unreachable, |
| 2441 | }); | 2908 | }); |
| 2442 | try di_w.writeUleb128(@backingInt(fi)); | 2909 | try di_w.writeUleb128(@backingInt(fi)); |
| 2443 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.name.toSlice(ip)); | 2910 | try dwarf.strx(di_nw, loaded_struct.name.toSlice(ip)); |
| 2444 | } else if (loaded_struct.captures.len > 0 or loaded_struct.is_reified) { | 2911 | } else if (loaded_struct.captures.len > 0 or loaded_struct.is_reified) { |
| 2445 | try dwarf.abbrevCode(di_nw, if (loaded_struct.captures.len > 0 or | 2912 | try dwarf.abbrevCode(di_nw, switch (loaded_struct.name_nav) { |
| 2446 | loaded_struct.field_types.len > 0) switch (loaded_struct.layout) { | 2913 | else => if (is_empty) switch (loaded_struct.layout) { |
| 2447 | .auto, .@"extern" => .decl_instance_struct, | 2914 | .auto, .@"extern" => .decl_instance_empty_struct, |
| 2448 | .@"packed" => .decl_instance_packed_struct, | 2915 | .@"packed" => .decl_instance_empty_packed_struct, |
| 2449 | } else switch (loaded_struct.layout) { | 2916 | } else switch (loaded_struct.layout) { |
| 2450 | .auto, .@"extern" => .decl_instance_empty_struct, | 2917 | .auto, .@"extern" => .decl_instance_struct, |
| 2451 | .@"packed" => .decl_instance_empty_packed_struct, | 2918 | .@"packed" => .decl_instance_packed_struct, |
| | 2919 | }, |
| | 2920 | .none => if (is_empty) switch (loaded_struct.layout) { |
| | 2921 | .auto, .@"extern" => .type_decl_instance_empty_struct, |
| | 2922 | .@"packed" => .type_decl_instance_empty_packed_struct, |
| | 2923 | } else switch (loaded_struct.layout) { |
| | 2924 | .auto, .@"extern" => .type_decl_instance_struct, |
| | 2925 | .@"packed" => .type_decl_instance_packed_struct, |
| | 2926 | }, |
| 2452 | }); | 2927 | }); |
| 2453 | try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0); | 2928 | try dwarf.refType(pt, di_nw, .fromInterned(ip.namespacePtr( |
| | 2929 | ip.namespacePtr(loaded_struct.namespace).parent.unwrap().?, |
| | 2930 | ).owner_type)); |
| | 2931 | try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, @"const"), 0); |
| | 2932 | if (loaded_struct.name_nav == .none) |
| | 2933 | try dwarf.strx(di_nw, loaded_struct.name.toSlice(ip)); |
| 2454 | } else if (loaded_struct.name_nav.unwrap()) |name_ni| { | 2934 | } else if (loaded_struct.name_nav.unwrap()) |name_ni| { |
| 2455 | const name_nav = ip.getNav(name_ni); | 2935 | const name_nav = ip.getNav(name_ni); |
| 2456 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); | 2936 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 2457 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 2937 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 2458 | name_nav.analysis.?.namespace, | 2938 | name_nav.analysis.?.namespace, |
| 2459 | ).owner_type); | 2939 | ).owner_type); |
| 2460 | try dwarf.abbrevCode(di_nw, if (loaded_struct.field_types.len > 0) | 2940 | try dwarf.abbrevCode(di_nw, if (is_empty) switch (loaded_struct.layout) { |
| 2461 | switch (loaded_struct.layout) { | | |
| 2462 | .auto, .@"extern" => .decl_struct, | | |
| 2463 | .@"packed" => .decl_packed_struct, | | |
| 2464 | } | | |
| 2465 | else switch (loaded_struct.layout) { | | |
| 2466 | .auto, .@"extern" => .decl_empty_struct, | 2941 | .auto, .@"extern" => .decl_empty_struct, |
| 2467 | .@"packed" => .decl_empty_packed_struct, | 2942 | .@"packed" => .decl_empty_packed_struct, |
| | 2943 | } else switch (loaded_struct.layout) { |
| | 2944 | .auto, .@"extern" => .decl_struct, |
| | 2945 | .@"packed" => .decl_packed_struct, |
| 2468 | }); | 2946 | }); |
| 2469 | try dwarf.secOffset(di_nw, parent_ni, 0); | 2947 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2470 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 2948 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2471 | try di_w.writeUleb128(decl.src_column + 1); | 2949 | try di_w.writeUleb128(decl.src_column + 1); |
| 2472 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 2950 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 2473 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); | 2951 | try dwarf.strx(di_nw, name_nav.name.toSlice(ip)); |
| 2474 | } else { | 2952 | } else { |
| 2475 | const decl = zf.zir.?.getStructDecl(src_inst.?); | 2953 | const decl = zf.zir.?.getStructDecl(src_inst.inst); |
| 2476 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 2954 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 2477 | ip.namespacePtr(loaded_struct.namespace).parent.unwrap().?, | 2955 | ip.namespacePtr(loaded_struct.namespace).parent.unwrap().?, |
| 2478 | ).owner_type); | 2956 | ).owner_type); |
| 2479 | try dwarf.abbrevCode(di_nw, if (loaded_struct.field_types.len > 0) | 2957 | try dwarf.abbrevCode(di_nw, if (is_empty) switch (loaded_struct.layout) { |
| 2480 | switch (loaded_struct.layout) { | | |
| 2481 | .auto, .@"extern" => .type_decl_struct, | | |
| 2482 | .@"packed" => .type_decl_packed_struct, | | |
| 2483 | } | | |
| 2484 | else switch (loaded_struct.layout) { | | |
| 2485 | .auto, .@"extern" => .type_decl_empty_struct, | 2958 | .auto, .@"extern" => .type_decl_empty_struct, |
| 2486 | .@"packed" => .type_decl_empty_packed_struct, | 2959 | .@"packed" => .type_decl_empty_packed_struct, |
| | 2960 | } else switch (loaded_struct.layout) { |
| | 2961 | .auto, .@"extern" => .type_decl_struct, |
| | 2962 | .@"packed" => .type_decl_packed_struct, |
| 2487 | }); | 2963 | }); |
| 2488 | try dwarf.secOffset(di_nw, parent_ni, 0); | 2964 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2489 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 2965 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2490 | try di_w.writeUleb128(decl.src_column + 1); | 2966 | try di_w.writeUleb128(decl.src_column + 1); |
| 2491 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.name.toSlice(ip)); | 2967 | try dwarf.strx(di_nw, loaded_struct.name.toSlice(ip)); |
| 2492 | } | 2968 | } |
| 2493 | switch (loaded_struct.layout) { | 2969 | switch (loaded_struct.layout) { |
| 2494 | .auto, .@"extern" => { | 2970 | .auto, .@"extern" => { |
| 2495 | const ty: Type = .fromInterned(val); | 2971 | const ty: Type = .fromInterned(@"const"); |
| 2496 | try di_w.writeUleb128(ty.abiSize(zcu)); | 2972 | try di_w.writeUleb128(ty.abiSize(zcu)); |
| 2497 | try di_w.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); | 2973 | try di_w.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); |
| 2498 | try dwarf.genCaptures(pt, di_nw, loaded_struct.captures); | 2974 | try dwarf.genCaptures(pt, di_nw, loaded_struct.captures); |
| ... | @@ -2528,8 +3004,7 @@ fn updateConstInner( | ... | @@ -2528,8 +3004,7 @@ fn updateConstInner( |
| 2528 | .partially_comptime => .field_default_partially_comptime, | 3004 | .partially_comptime => .field_default_partially_comptime, |
| 2529 | .fully_comptime => .field_default_fully_comptime, | 3005 | .fully_comptime => .field_default_fully_comptime, |
| 2530 | }); | 3006 | }); |
| 2531 | try dwarf.strp( | 3007 | try dwarf.strx( |
| 2532 | &dwarf.debug_str, | | |
| 2533 | di_nw, | 3008 | di_nw, |
| 2534 | loaded_struct.field_names.get(ip)[field_index].toSlice(ip), | 3009 | loaded_struct.field_names.get(ip)[field_index].toSlice(ip), |
| 2535 | ); | 3010 | ); |
| ... | @@ -2553,8 +3028,7 @@ fn updateConstInner( | ... | @@ -2553,8 +3028,7 @@ fn updateConstInner( |
| 2553 | var field_bit_offset: u16 = 0; | 3028 | var field_bit_offset: u16 = 0; |
| 2554 | for (0..loaded_struct.field_types.len) |field_index| { | 3029 | for (0..loaded_struct.field_types.len) |field_index| { |
| 2555 | try dwarf.abbrevCode(di_nw, .packed_field); | 3030 | try dwarf.abbrevCode(di_nw, .packed_field); |
| 2556 | try dwarf.strp( | 3031 | try dwarf.strx( |
| 2557 | &dwarf.debug_str, | | |
| 2558 | di_nw, | 3032 | di_nw, |
| 2559 | loaded_struct.field_names.get(ip)[field_index].toSlice(ip), | 3033 | loaded_struct.field_names.get(ip)[field_index].toSlice(ip), |
| 2560 | ); | 3034 | ); |
| ... | @@ -2566,62 +3040,71 @@ fn updateConstInner( | ... | @@ -2566,62 +3040,71 @@ fn updateConstInner( |
| 2566 | } | 3040 | } |
| 2567 | }, | 3041 | }, |
| 2568 | } | 3042 | } |
| 2569 | if (loaded_struct.captures.len > 0 or loaded_struct.field_types.len > 0) | 3043 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2570 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | | |
| 2571 | }, | 3044 | }, |
| 2572 | .union_type => { | 3045 | .union_type => { |
| 2573 | const loaded_union = ip.loadUnionType(val); | 3046 | const loaded_union = ip.loadUnionType(@"const"); |
| 2574 | const loaded_tag = ip.loadEnumType(loaded_union.enum_tag_type); | 3047 | const loaded_tag = ip.loadEnumType(loaded_union.enum_tag_type); |
| 2575 | const zfi = loaded_union.zir_index.resolveFile(ip); | 3048 | const zfi = loaded_union.zir_index.resolveFile(ip); |
| 2576 | const zf = zcu.fileByIndex(zfi); | 3049 | const zf = zcu.fileByIndex(zfi); |
| | 3050 | const is_empty = loaded_union.captures.len == 0 and loaded_union.field_types.len == 0; |
| 2577 | if (loaded_union.captures.len > 0 or loaded_union.is_reified) { | 3051 | if (loaded_union.captures.len > 0 or loaded_union.is_reified) { |
| 2578 | try dwarf.abbrevCode(di_nw, if (loaded_union.captures.len > 0 or | 3052 | try dwarf.abbrevCode(di_nw, switch (loaded_union.name_nav) { |
| 2579 | loaded_union.field_types.len > 0) switch (loaded_union.layout) { | 3053 | else => if (is_empty) switch (loaded_union.layout) { |
| 2580 | .auto, .@"extern" => .decl_instance_union, | 3054 | .auto, .@"extern" => .decl_instance_empty_union, |
| 2581 | .@"packed" => .decl_instance_packed_union, | 3055 | .@"packed" => .decl_instance_empty_packed_union, |
| 2582 | } else switch (loaded_union.layout) { | 3056 | } else switch (loaded_union.layout) { |
| 2583 | .auto, .@"extern" => .decl_instance_empty_union, | 3057 | .auto, .@"extern" => .decl_instance_union, |
| 2584 | .@"packed" => .decl_instance_empty_packed_union, | 3058 | .@"packed" => .decl_instance_packed_union, |
| | 3059 | }, |
| | 3060 | .none => if (is_empty) switch (loaded_union.layout) { |
| | 3061 | .auto, .@"extern" => .type_decl_instance_empty_union, |
| | 3062 | .@"packed" => .type_decl_instance_empty_packed_union, |
| | 3063 | } else switch (loaded_union.layout) { |
| | 3064 | .auto, .@"extern" => .type_decl_instance_union, |
| | 3065 | .@"packed" => .type_decl_instance_packed_union, |
| | 3066 | }, |
| 2585 | }); | 3067 | }); |
| 2586 | try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0); | 3068 | try dwarf.refType(pt, di_nw, .fromInterned(ip.namespacePtr( |
| | 3069 | ip.namespacePtr(loaded_union.namespace).parent.unwrap().?, |
| | 3070 | ).owner_type)); |
| | 3071 | try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, @"const"), 0); |
| | 3072 | if (loaded_union.name_nav == .none) |
| | 3073 | try dwarf.strx(di_nw, loaded_union.name.toSlice(ip)); |
| 2587 | } else if (loaded_union.name_nav.unwrap()) |name_ni| { | 3074 | } else if (loaded_union.name_nav.unwrap()) |name_ni| { |
| 2588 | const name_nav = ip.getNav(name_ni); | 3075 | const name_nav = ip.getNav(name_ni); |
| 2589 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); | 3076 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 2590 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 3077 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 2591 | name_nav.analysis.?.namespace, | 3078 | name_nav.analysis.?.namespace, |
| 2592 | ).owner_type); | 3079 | ).owner_type); |
| 2593 | try dwarf.abbrevCode(di_nw, if (loaded_union.field_types.len > 0) | 3080 | try dwarf.abbrevCode(di_nw, if (is_empty) switch (loaded_union.layout) { |
| 2594 | switch (loaded_union.layout) { | | |
| 2595 | .auto, .@"extern" => .decl_union, | | |
| 2596 | .@"packed" => .decl_packed_union, | | |
| 2597 | } | | |
| 2598 | else switch (loaded_union.layout) { | | |
| 2599 | .auto, .@"extern" => .decl_empty_union, | 3081 | .auto, .@"extern" => .decl_empty_union, |
| 2600 | .@"packed" => .decl_empty_packed_union, | 3082 | .@"packed" => .decl_empty_packed_union, |
| | 3083 | } else switch (loaded_union.layout) { |
| | 3084 | .auto, .@"extern" => .decl_union, |
| | 3085 | .@"packed" => .decl_packed_union, |
| 2601 | }); | 3086 | }); |
| 2602 | try dwarf.secOffset(di_nw, parent_ni, 0); | 3087 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2603 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 3088 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2604 | try di_w.writeUleb128(decl.src_column + 1); | 3089 | try di_w.writeUleb128(decl.src_column + 1); |
| 2605 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 3090 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 2606 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); | 3091 | try dwarf.strx(di_nw, name_nav.name.toSlice(ip)); |
| 2607 | } else { | 3092 | } else { |
| 2608 | const decl = zf.zir.?.getUnionDecl(loaded_union.zir_index.resolve(ip).?); | 3093 | const decl = zf.zir.?.getUnionDecl(loaded_union.zir_index.resolve(ip).?); |
| 2609 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 3094 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 2610 | ip.namespacePtr(loaded_union.namespace).parent.unwrap().?, | 3095 | ip.namespacePtr(loaded_union.namespace).parent.unwrap().?, |
| 2611 | ).owner_type); | 3096 | ).owner_type); |
| 2612 | try dwarf.abbrevCode(di_nw, if (loaded_union.field_types.len > 0) | 3097 | try dwarf.abbrevCode(di_nw, if (is_empty) switch (loaded_union.layout) { |
| 2613 | switch (loaded_union.layout) { | | |
| 2614 | .auto, .@"extern" => .type_decl_union, | | |
| 2615 | .@"packed" => .type_decl_packed_union, | | |
| 2616 | } | | |
| 2617 | else switch (loaded_union.layout) { | | |
| 2618 | .auto, .@"extern" => .type_decl_empty_union, | 3098 | .auto, .@"extern" => .type_decl_empty_union, |
| 2619 | .@"packed" => .type_decl_empty_packed_union, | 3099 | .@"packed" => .type_decl_empty_packed_union, |
| | 3100 | } else switch (loaded_union.layout) { |
| | 3101 | .auto, .@"extern" => .type_decl_union, |
| | 3102 | .@"packed" => .type_decl_packed_union, |
| 2620 | }); | 3103 | }); |
| 2621 | try dwarf.secOffset(di_nw, parent_ni, 0); | 3104 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2622 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 3105 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2623 | try di_w.writeUleb128(decl.src_column + 1); | 3106 | try di_w.writeUleb128(decl.src_column + 1); |
| 2624 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_union.name.toSlice(ip)); | 3107 | try dwarf.strx(di_nw, loaded_union.name.toSlice(ip)); |
| 2625 | } | 3108 | } |
| 2626 | switch (loaded_union.layout) { | 3109 | switch (loaded_union.layout) { |
| 2627 | .auto, .@"extern" => { | 3110 | .auto, .@"extern" => { |
| ... | @@ -2631,10 +3114,12 @@ fn updateConstInner( | ... | @@ -2631,10 +3114,12 @@ fn updateConstInner( |
| 2631 | try dwarf.genCaptures(pt, di_nw, loaded_union.captures); | 3114 | try dwarf.genCaptures(pt, di_nw, loaded_union.captures); |
| 2632 | if (loaded_union.has_runtime_tag) { | 3115 | if (loaded_union.has_runtime_tag) { |
| 2633 | try dwarf.abbrevCode(di_nw, .tagged_union); | 3116 | try dwarf.abbrevCode(di_nw, .tagged_union); |
| 2634 | try dwarf.secOffset(di_nw, di_nw.ni, di_w.end + dwarf.secOffsetSize()); | 3117 | const discr_offset = di_w.end; |
| | 3118 | try dwarf.secOffsetPlaceholder(di_w); |
| 2635 | { | 3119 | { |
| | 3120 | try dwarf.secOffsetFinish(di_nw, discr_offset, di_nw.ni, di_w.end); |
| 2636 | try dwarf.abbrevCode(di_nw, .generated_field); | 3121 | try dwarf.abbrevCode(di_nw, .generated_field); |
| 2637 | try dwarf.strp(&dwarf.debug_str, di_nw, "tag"); | 3122 | try dwarf.strx(di_nw, "tag"); |
| 2638 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_union.enum_tag_type)); | 3123 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_union.enum_tag_type)); |
| 2639 | try di_w.writeUleb128(union_layout.tagOffset()); | 3124 | try di_w.writeUleb128(union_layout.tagOffset()); |
| 2640 | | 3125 | |
| ... | @@ -2643,8 +3128,7 @@ fn updateConstInner( | ... | @@ -2643,8 +3128,7 @@ fn updateConstInner( |
| 2643 | try dwarf.enumConstValue(di_w, loaded_tag, field_index); | 3128 | try dwarf.enumConstValue(di_w, loaded_tag, field_index); |
| 2644 | { | 3129 | { |
| 2645 | try dwarf.abbrevCode(di_nw, .field); | 3130 | try dwarf.abbrevCode(di_nw, .field); |
| 2646 | try dwarf.strp( | 3131 | try dwarf.strx( |
| 2647 | &dwarf.debug_str, | | |
| 2648 | di_nw, | 3132 | di_nw, |
| 2649 | loaded_tag.field_names.get(ip)[field_index].toSlice(ip), | 3133 | loaded_tag.field_names.get(ip)[field_index].toSlice(ip), |
| 2650 | ); | 3134 | ); |
| ... | @@ -2666,8 +3150,7 @@ fn updateConstInner( | ... | @@ -2666,8 +3150,7 @@ fn updateConstInner( |
| 2666 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | 3150 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2667 | } else for (0..loaded_union.field_types.len) |field_index| { | 3151 | } else for (0..loaded_union.field_types.len) |field_index| { |
| 2668 | try dwarf.abbrevCode(di_nw, .field); | 3152 | try dwarf.abbrevCode(di_nw, .field); |
| 2669 | try dwarf.strp( | 3153 | try dwarf.strx( |
| 2670 | &dwarf.debug_str, | | |
| 2671 | di_nw, | 3154 | di_nw, |
| 2672 | loaded_tag.field_names.get(ip)[field_index].toSlice(ip), | 3155 | loaded_tag.field_names.get(ip)[field_index].toSlice(ip), |
| 2673 | ); | 3156 | ); |
| ... | @@ -2688,8 +3171,7 @@ fn updateConstInner( | ... | @@ -2688,8 +3171,7 @@ fn updateConstInner( |
| 2688 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_union.packed_backing_int_type)); | 3171 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_union.packed_backing_int_type)); |
| 2689 | for (0..loaded_union.field_types.len) |field_index| { | 3172 | for (0..loaded_union.field_types.len) |field_index| { |
| 2690 | try dwarf.abbrevCode(di_nw, .packed_field); | 3173 | try dwarf.abbrevCode(di_nw, .packed_field); |
| 2691 | try dwarf.strp( | 3174 | try dwarf.strx( |
| 2692 | &dwarf.debug_str, | | |
| 2693 | di_nw, | 3175 | di_nw, |
| 2694 | loaded_tag.field_names.get(ip)[field_index].toSlice(ip), | 3176 | loaded_tag.field_names.get(ip)[field_index].toSlice(ip), |
| 2695 | ); | 3177 | ); |
| ... | @@ -2700,83 +3182,86 @@ fn updateConstInner( | ... | @@ -2700,83 +3182,86 @@ fn updateConstInner( |
| 2700 | } | 3182 | } |
| 2701 | }, | 3183 | }, |
| 2702 | } | 3184 | } |
| 2703 | if (loaded_union.captures.len > 0 or loaded_union.field_types.len > 0) | 3185 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2704 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | | |
| 2705 | }, | 3186 | }, |
| 2706 | .enum_type => { | 3187 | .enum_type => { |
| 2707 | const loaded_enum = ip.loadEnumType(val); | 3188 | const loaded_enum = ip.loadEnumType(@"const"); |
| | 3189 | const is_empty = loaded_enum.captures.len == 0 and loaded_enum.field_names.len == 0; |
| 2708 | switch (loaded_enum.owner_union) { | 3190 | switch (loaded_enum.owner_union) { |
| 2709 | .none => { | 3191 | .none => { |
| 2710 | const zfi = loaded_enum.zir_index.unwrap().?.resolveFile(ip); | 3192 | const zfi = loaded_enum.zir_index.unwrap().?.resolveFile(ip); |
| 2711 | const zf = zcu.fileByIndex(zfi); | 3193 | const zf = zcu.fileByIndex(zfi); |
| | 3194 | const zir = &zf.zir.?; |
| 2712 | if (loaded_enum.captures.len > 0 or loaded_enum.is_reified) { | 3195 | if (loaded_enum.captures.len > 0 or loaded_enum.is_reified) { |
| 2713 | try dwarf.abbrevCode(di_nw, if (loaded_enum.captures.len > 0 or | 3196 | try dwarf.abbrevCode(di_nw, switch (loaded_enum.name_nav) { |
| 2714 | loaded_enum.field_names.len > 0) | 3197 | else => if (is_empty) .decl_instance_empty_enum else .decl_instance_enum, |
| 2715 | .decl_instance_enum | 3198 | .none => if (is_empty) |
| 2716 | else | 3199 | .type_decl_instance_empty_enum |
| 2717 | .decl_instance_empty_enum); | 3200 | else |
| 2718 | try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0); | 3201 | .type_decl_instance_enum, |
| | 3202 | }); |
| | 3203 | try dwarf.refType(pt, di_nw, .fromInterned(ip.namespacePtr( |
| | 3204 | ip.namespacePtr(loaded_enum.namespace).parent.unwrap().?, |
| | 3205 | ).owner_type)); |
| | 3206 | try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, @"const"), 0); |
| | 3207 | if (loaded_enum.name_nav == .none) |
| | 3208 | try dwarf.strx(di_nw, loaded_enum.name.toSlice(ip)); |
| 2719 | } else if (loaded_enum.name_nav.unwrap()) |name_ni| { | 3209 | } else if (loaded_enum.name_nav.unwrap()) |name_ni| { |
| 2720 | const name_nav = ip.getNav(name_ni); | 3210 | const name_nav = ip.getNav(name_ni); |
| 2721 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); | 3211 | const decl = zir.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 2722 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 3212 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 2723 | name_nav.analysis.?.namespace, | 3213 | name_nav.analysis.?.namespace, |
| 2724 | ).owner_type); | 3214 | ).owner_type); |
| 2725 | try dwarf.abbrevCode( | 3215 | try dwarf.abbrevCode( |
| 2726 | di_nw, | 3216 | di_nw, |
| 2727 | if (loaded_enum.field_names.len > 0) .decl_enum else .decl_empty_enum, | 3217 | if (is_empty) .decl_empty_enum else .decl_enum, |
| 2728 | ); | 3218 | ); |
| 2729 | try dwarf.secOffset(di_nw, parent_ni, 0); | 3219 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2730 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 3220 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2731 | try di_w.writeUleb128(decl.src_column + 1); | 3221 | try di_w.writeUleb128(decl.src_column + 1); |
| 2732 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 3222 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 2733 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); | 3223 | try dwarf.strx(di_nw, name_nav.name.toSlice(ip)); |
| 2734 | } else { | 3224 | } else { |
| 2735 | const decl = | 3225 | const decl = zir.getEnumDecl(loaded_enum.zir_index.unwrap().?.resolve(ip).?); |
| 2736 | zf.zir.?.getEnumDecl(loaded_enum.zir_index.unwrap().?.resolve(ip).?); | 3226 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 2737 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | | |
| 2738 | ip.namespacePtr(loaded_enum.namespace).parent.unwrap().?, | 3227 | ip.namespacePtr(loaded_enum.namespace).parent.unwrap().?, |
| 2739 | ).owner_type); | 3228 | ).owner_type); |
| 2740 | try dwarf.abbrevCode(di_nw, if (loaded_enum.field_names.len > 0) | 3229 | try dwarf.abbrevCode( |
| 2741 | .type_decl_enum | 3230 | di_nw, |
| 2742 | else | 3231 | if (is_empty) .type_decl_empty_enum else .type_decl_enum, |
| 2743 | .type_decl_empty_enum); | 3232 | ); |
| 2744 | try dwarf.secOffset(di_nw, parent_ni, 0); | 3233 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2745 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 3234 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2746 | try di_w.writeUleb128(decl.src_column + 1); | 3235 | try di_w.writeUleb128(decl.src_column + 1); |
| 2747 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.name.toSlice(ip)); | 3236 | try dwarf.strx(di_nw, loaded_enum.name.toSlice(ip)); |
| 2748 | } | 3237 | } |
| 2749 | }, | 3238 | }, |
| 2750 | else => { | 3239 | else => { |
| 2751 | try dwarf.abbrevCode(di_nw, if (loaded_enum.field_names.len > 0) | 3240 | try dwarf.abbrevCode( |
| 2752 | .generated_enum_type | 3241 | di_nw, |
| 2753 | else | 3242 | if (is_empty) .generated_empty_enum_type else .generated_enum_type, |
| 2754 | .generated_empty_enum_type); | 3243 | ); |
| 2755 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.fqn.toSlice(ip)); | 3244 | try dwarf.strx(di_nw, loaded_enum.fqn.toSlice(ip)); |
| 2756 | }, | 3245 | }, |
| 2757 | } | 3246 | } |
| 2758 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_enum.int_tag_type)); | 3247 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_enum.int_tag_type)); |
| | 3248 | try dwarf.genCaptures(pt, di_nw, loaded_enum.captures); |
| 2759 | for (0..loaded_enum.field_names.len) |field_index| { | 3249 | for (0..loaded_enum.field_names.len) |field_index| { |
| 2760 | try dwarf.abbrevCode(di_nw, .enum_field); | 3250 | try dwarf.abbrevCode(di_nw, .enum_field); |
| 2761 | try dwarf.enumConstValue(di_w, loaded_enum, field_index); | 3251 | try dwarf.enumConstValue(di_w, loaded_enum, field_index); |
| 2762 | try dwarf.strp( | 3252 | try dwarf.strx(di_nw, loaded_enum.field_names.get(ip)[field_index].toSlice(ip)); |
| 2763 | &dwarf.debug_str, | | |
| 2764 | di_nw, | | |
| 2765 | loaded_enum.field_names.get(ip)[field_index].toSlice(ip), | | |
| 2766 | ); | | |
| 2767 | } | 3253 | } |
| 2768 | if (loaded_enum.captures.len > 0 or loaded_enum.field_names.len > 0) | 3254 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2769 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | | |
| 2770 | }, | 3255 | }, |
| 2771 | // no defined size, so lowered the same as incomplete struct types | 3256 | // no defined size, so lowered the same as incomplete struct types |
| 2772 | .opaque_type => return dwarf.updateConstIncompleteInner(pt, di_nw, val), | 3257 | .opaque_type => return dwarf.updateConstIncompleteInner(pt, di_nw, @"const"), |
| 2773 | .spirv_type => unreachable, | 3258 | .spirv_type => unreachable, |
| 2774 | .func_type => |func_type| { | 3259 | .func_type => |func_type| { |
| 2775 | const is_nullary = func_type.param_types.len == 0 and !func_type.is_var_args; | 3260 | const is_empty = func_type.param_types.len == 0 and !func_type.is_var_args; |
| 2776 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); | 3261 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(pt)}); |
| 2777 | defer zcu.gpa.free(name); | 3262 | defer zcu.gpa.free(name); |
| 2778 | try dwarf.abbrevCode(di_nw, if (is_nullary) .nullary_func_type else .func_type); | 3263 | try dwarf.abbrevCode(di_nw, if (is_empty) .empty_func_type else .func_type); |
| 2779 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 3264 | try dwarf.strx(di_nw, name); |
| 2780 | const cc: DW.CC = cc: { | 3265 | const cc: DW.CC = cc: { |
| 2781 | if (zcu.getTarget().cCallingConvention()) |cc| { | 3266 | if (zcu.getTarget().cCallingConvention()) |cc| { |
| 2782 | if (@as(std.lang.CallingConvention.Tag, cc) == func_type.cc) { | 3267 | if (@as(std.lang.CallingConvention.Tag, cc) == func_type.cc) { |
| ... | @@ -2848,40 +3333,38 @@ fn updateConstInner( | ... | @@ -2848,40 +3333,38 @@ fn updateConstInner( |
| 2848 | }; | 3333 | }; |
| 2849 | try di_w.writeByte(@backingInt(cc)); | 3334 | try di_w.writeByte(@backingInt(cc)); |
| 2850 | try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type)); | 3335 | try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type)); |
| 2851 | if (!is_nullary) { | 3336 | for (0..func_type.param_types.len) |param_index| { |
| 2852 | for (0..func_type.param_types.len) |param_index| { | 3337 | try dwarf.abbrevCode(di_nw, .unnamed_param); |
| 2853 | try dwarf.abbrevCode(di_nw, .unnamed_param); | 3338 | try dwarf.refType(pt, di_nw, .fromInterned( |
| 2854 | try dwarf.refType(pt, di_nw, .fromInterned( | 3339 | func_type.param_types.get(ip)[param_index], |
| 2855 | func_type.param_types.get(ip)[param_index], | 3340 | )); |
| 2856 | )); | | |
| 2857 | } | | |
| 2858 | if (func_type.is_var_args) try dwarf.abbrevCode(di_nw, .is_var_args); | | |
| 2859 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | | |
| 2860 | } | 3341 | } |
| | 3342 | if (func_type.is_var_args) try dwarf.abbrevCode(di_nw, .is_var_args); |
| | 3343 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2861 | }, | 3344 | }, |
| 2862 | .error_set_type => |error_set_type| { | 3345 | .error_set_type => |error_set_type| { |
| 2863 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); | 3346 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(pt)}); |
| 2864 | defer zcu.gpa.free(name); | 3347 | defer zcu.gpa.free(name); |
| 2865 | try dwarf.abbrevCode( | 3348 | try dwarf.abbrevCode( |
| 2866 | di_nw, | 3349 | di_nw, |
| 2867 | if (error_set_type.names.len > 0) .generated_enum_type else .generated_empty_enum_type, | 3350 | if (error_set_type.names.len > 0) .generated_enum_type else .generated_empty_enum_type, |
| 2868 | ); | 3351 | ); |
| 2869 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 3352 | try dwarf.strx(di_nw, name); |
| 2870 | try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits())); | 3353 | try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits())); |
| 2871 | for (0..error_set_type.names.len) |field_index| { | 3354 | for (0..error_set_type.names.len) |field_index| { |
| 2872 | const field_name = error_set_type.names.get(ip)[field_index]; | 3355 | const field_name = error_set_type.names.get(ip)[field_index]; |
| 2873 | try dwarf.abbrevCode(di_nw, .enum_field); | 3356 | try dwarf.abbrevCode(di_nw, .enum_field); |
| 2874 | try di_w.writeUleb128(DW.FORM.udata); | 3357 | try di_w.writeUleb128(DW.FORM.udata); |
| 2875 | try di_w.writeUleb128(ip.getErrorValueIfExists(field_name).?); | 3358 | try di_w.writeUleb128(ip.getErrorValueIfExists(field_name).?); |
| 2876 | try dwarf.strp(&dwarf.debug_str, di_nw, field_name.toSlice(ip)); | 3359 | try dwarf.strx(di_nw, field_name.toSlice(ip)); |
| 2877 | } | 3360 | } |
| 2878 | if (error_set_type.names.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | 3361 | if (error_set_type.names.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2879 | }, | 3362 | }, |
| 2880 | .inferred_error_set_type => |func| { | 3363 | .inferred_error_set_type => |func| { |
| 2881 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); | 3364 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(pt)}); |
| 2882 | defer zcu.gpa.free(name); | 3365 | defer zcu.gpa.free(name); |
| 2883 | try dwarf.abbrevCode(di_nw, .inferred_error_set_type); | 3366 | try dwarf.abbrevCode(di_nw, .inferred_error_set_type); |
| 2884 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 3367 | try dwarf.strx(di_nw, name); |
| 2885 | try dwarf.refType(pt, di_nw, switch (ies: { | 3368 | try dwarf.refType(pt, di_nw, switch (ies: { |
| 2886 | const fi = dwarf.getFuncIfExists(ip.indexToKey(func).func.owner_nav) orelse | 3369 | const fi = dwarf.getFuncIfExists(ip.indexToKey(func).func.owner_nav) orelse |
| 2887 | break :ies .none; | 3370 | break :ies .none; |
| ... | @@ -2895,38 +3378,468 @@ fn updateConstInner( | ... | @@ -2895,38 +3378,468 @@ fn updateConstInner( |
| 2895 | }); | 3378 | }); |
| 2896 | }, | 3379 | }, |
| 2897 | | 3380 | |
| 2898 | else => return, | 3381 | .undef => |ty| { |
| | 3382 | try dwarf.abbrevCode(di_nw, .undefined_comptime_value); |
| | 3383 | try dwarf.refType(pt, di_nw, .fromInterned(ty)); |
| | 3384 | }, |
| | 3385 | .simple_value => |simple_value| switch (simple_value) { |
| | 3386 | .void => unreachable, // opv state |
| | 3387 | .true, .false => unreachable, // runtime bits |
| | 3388 | .@"unreachable" => unreachable, // not a value |
| | 3389 | .null => { |
| | 3390 | // TODO: proper representation for this |
| | 3391 | try dwarf.abbrevCode(di_nw, .undefined_comptime_value); |
| | 3392 | try dwarf.refType(pt, di_nw, .null); |
| | 3393 | }, |
| | 3394 | }, |
| | 3395 | .@"extern" => unreachable, |
| 2899 | .func => |func| { | 3396 | .func => |func| { |
| 2900 | const fn_ty = ip.indexToKey(func.ty).func_type; | 3397 | const func_type = ip.indexToKey(func.ty).func_type; |
| 2901 | const nav = ip.getNav(func.owner_nav); | 3398 | const nav = ip.getNav(func.owner_nav); |
| 2902 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; | 3399 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; |
| 2903 | const zf = zcu.fileByIndex(inst_info.file); | 3400 | const zir = &zcu.fileByIndex(inst_info.file).zir.?; |
| 2904 | const decl = zf.zir.?.getDeclaration(inst_info.inst); | 3401 | const decl = zir.getDeclaration(inst_info.inst); |
| | 3402 | const is_empty = func_type.param_types.len == 0 and !func_type.is_var_args; |
| 2905 | const parent_ty: Type = .fromInterned(ip.namespacePtr(nav.analysis.?.namespace).owner_type); | 3403 | const parent_ty: Type = .fromInterned(ip.namespacePtr(nav.analysis.?.namespace).owner_type); |
| 2906 | try dwarf.abbrevCode(di_nw, .decl_func_generic); | 3404 | if (func.generic_owner != .none or parent_ty.getCaptures(zcu).len > 0) { |
| 2907 | try dwarf.refType(pt, di_nw, parent_ty); | 3405 | try dwarf.abbrevCode( |
| 2908 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 3406 | di_nw, |
| 2909 | try di_w.writeUleb128(decl.src_column + 1); | 3407 | if (is_empty) .decl_instance_empty_func_generic else .decl_instance_func_generic, |
| 2910 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 3408 | ); |
| 2911 | try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip)); | 3409 | try dwarf.refType(pt, di_nw, parent_ty); |
| 2912 | try dwarf.refType(pt, di_nw, .fromInterned(fn_ty.return_type)); | 3410 | try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, @"const"), 0); |
| 2913 | var param_index: u32 = 0; | 3411 | } else { |
| 2914 | for (zf.zir.?.getParamBody(func.zir_body_inst.resolve(ip).?)) |param_inst| { | 3412 | try dwarf.abbrevCode( |
| 2915 | switch (zf.zir.?.getParamName(param_inst) orelse break) { | 3413 | di_nw, |
| | 3414 | if (is_empty) .decl_empty_func_generic else .decl_func_generic, |
| | 3415 | ); |
| | 3416 | try dwarf.refType(pt, di_nw, parent_ty); |
| | 3417 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 3418 | try di_w.writeUleb128(decl.src_column + 1); |
| | 3419 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| | 3420 | try dwarf.strx(di_nw, nav.name.toSlice(ip)); |
| | 3421 | } |
| | 3422 | try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type)); |
| | 3423 | for ( |
| | 3424 | zir.getParamBody(func.zir_body_inst.resolve(ip).?)[0..func_type.param_types.len], |
| | 3425 | func_type.param_types.get(&zcu.intern_pool), |
| | 3426 | ) |param_inst, param_ty| { |
| | 3427 | switch (zir.getParamName(param_inst).?) { |
| 2916 | .empty => try dwarf.abbrevCode(di_nw, .unnamed_param), | 3428 | .empty => try dwarf.abbrevCode(di_nw, .unnamed_param), |
| 2917 | else => |param_name| { | 3429 | else => |param_name| { |
| 2918 | try dwarf.abbrevCode(di_nw, .param); | 3430 | try dwarf.abbrevCode(di_nw, .param); |
| 2919 | try dwarf.strp(&dwarf.debug_str, di_nw, zf.zir.?.nullTerminatedString( | 3431 | try dwarf.strx(di_nw, zir.nullTerminatedString(param_name)); |
| 2920 | param_name, | | |
| 2921 | )); | | |
| 2922 | }, | 3432 | }, |
| 2923 | } | 3433 | } |
| 2924 | try dwarf.refType(pt, di_nw, .fromInterned( | 3434 | try dwarf.refType(pt, di_nw, .fromInterned(param_ty)); |
| 2925 | fn_ty.param_types.get(&zcu.intern_pool)[param_index], | 3435 | } |
| 2926 | )); | 3436 | if (func_type.is_var_args) try dwarf.abbrevCode(di_nw, .is_var_args); |
| 2927 | param_index += 1; | 3437 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 3438 | }, |
| | 3439 | .int => |int| { |
| | 3440 | var big_int_space: Value.BigIntSpace = undefined; |
| | 3441 | try dwarf.abbrevCode(di_nw, .comptime_value); |
| | 3442 | try dwarf.refType(pt, di_nw, .fromInterned(int.ty)); |
| | 3443 | try dwarf.bigIntConstValue( |
| | 3444 | di_w, |
| | 3445 | .fromInterned(int.ty), |
| | 3446 | Value.fromInterned(@"const").toBigInt(&big_int_space, zcu), |
| | 3447 | ); |
| | 3448 | }, |
| | 3449 | .bitpack => |bitpack| { |
| | 3450 | var big_int_space: Value.BigIntSpace = undefined; |
| | 3451 | const backing_int_val: Value = .fromInterned(bitpack.backing_int_val); |
| | 3452 | try dwarf.abbrevCode(di_nw, .comptime_value); |
| | 3453 | try dwarf.refType(pt, di_nw, .fromInterned(bitpack.ty)); |
| | 3454 | try dwarf.bigIntConstValue( |
| | 3455 | di_w, |
| | 3456 | backing_int_val.typeOf(zcu), |
| | 3457 | backing_int_val.toBigInt(&big_int_space, zcu), |
| | 3458 | ); |
| | 3459 | }, |
| | 3460 | .err => |err| { |
| | 3461 | try dwarf.abbrevCode(di_nw, .comptime_value); |
| | 3462 | try dwarf.refType(pt, di_nw, .fromInterned(err.ty)); |
| | 3463 | try di_w.writeUleb128(DW.FORM.udata); |
| | 3464 | try di_w.writeUleb128(try pt.getErrorValue(err.name)); |
| | 3465 | }, |
| | 3466 | .error_union => |error_union| { |
| | 3467 | try dwarf.abbrevCode(di_nw, .aggregate_undefined_comptime_value); |
| | 3468 | try dwarf.refType(pt, di_nw, .fromInterned(error_union.ty)); |
| | 3469 | var err_buf: [4]u8 = undefined; |
| | 3470 | const err_bytes = err_buf[0..@divCeil(zcu.errorSetBits(), 8)]; |
| | 3471 | const err_val = switch (error_union.val) { |
| | 3472 | .err_name => |err_name| try pt.getErrorValue(err_name), |
| | 3473 | .payload => 0, |
| | 3474 | }; |
| | 3475 | switch (err_bytes.len) { |
| | 3476 | else => unreachable, |
| | 3477 | inline 0...4 => |len| std.mem.writeInt( |
| | 3478 | @Int(.unsigned, 8 * len), |
| | 3479 | err_bytes[0..len], |
| | 3480 | @intCast(err_val), |
| | 3481 | dwarf.endian, |
| | 3482 | ), |
| | 3483 | } |
| | 3484 | { |
| | 3485 | try dwarf.abbrevCode(di_nw, .comptime_value_field_runtime); |
| | 3486 | try dwarf.strx(di_nw, "is_error"); |
| | 3487 | try di_w.writeUleb128(err_bytes.len); |
| | 3488 | try di_w.writeAll(err_bytes); |
| | 3489 | } |
| | 3490 | payload_field: switch (error_union.val) { |
| | 3491 | .err_name => {}, |
| | 3492 | .payload => |payload_val| { |
| | 3493 | const payload_ty: Type = .fromInterned(ip.typeOf(payload_val)); |
| | 3494 | const payload_class = payload_ty.classify(zcu); |
| | 3495 | try dwarf.abbrevCode(di_nw, if (payload_class.comptimeOnly()) |
| | 3496 | .comptime_value_field_comptime |
| | 3497 | else if (payload_class.hasRuntimeBits()) |
| | 3498 | .comptime_value_field_runtime |
| | 3499 | else |
| | 3500 | break :payload_field); |
| | 3501 | try dwarf.strx(di_nw, "value"); |
| | 3502 | if (payload_class.comptimeOnly()) |
| | 3503 | try dwarf.refConst(pt, di_nw, .fromInterned(payload_val)) |
| | 3504 | else if (payload_class.hasRuntimeBits()) |
| | 3505 | try dwarf.blockConst(pt, di_nw, .fromInterned(payload_val)) |
| | 3506 | else |
| | 3507 | unreachable; |
| | 3508 | }, |
| | 3509 | } |
| | 3510 | { |
| | 3511 | try dwarf.abbrevCode(di_nw, .comptime_value_field_runtime); |
| | 3512 | try dwarf.strx(di_nw, "error"); |
| | 3513 | try di_w.writeUleb128(err_bytes.len); |
| | 3514 | try di_w.writeAll(err_bytes); |
| | 3515 | } |
| | 3516 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 3517 | }, |
| | 3518 | .enum_literal => |enum_literal| { |
| | 3519 | try dwarf.abbrevCode(di_nw, .comptime_value); |
| | 3520 | try dwarf.refType(pt, di_nw, .enum_literal); |
| | 3521 | try di_w.writeUleb128(DW.FORM.strx); |
| | 3522 | try dwarf.strx(di_nw, enum_literal.toSlice(ip)); |
| | 3523 | }, |
| | 3524 | .enum_tag => |enum_tag| { |
| | 3525 | var big_int_space: Value.BigIntSpace = undefined; |
| | 3526 | const int = ip.indexToKey(enum_tag.int).int; |
| | 3527 | try dwarf.abbrevCode(di_nw, .comptime_value); |
| | 3528 | try dwarf.refType(pt, di_nw, .fromInterned(enum_tag.ty)); |
| | 3529 | try dwarf.bigIntConstValue( |
| | 3530 | di_w, |
| | 3531 | .fromInterned(int.ty), |
| | 3532 | Value.fromInterned(@"const").toBigInt(&big_int_space, zcu), |
| | 3533 | ); |
| | 3534 | }, |
| | 3535 | .float => |float| { |
| | 3536 | try dwarf.abbrevCode(di_nw, .comptime_value); |
| | 3537 | try dwarf.refType(pt, di_nw, .fromInterned(float.ty)); |
| | 3538 | switch (float.storage) { |
| | 3539 | .f16 => |f16_val| { |
| | 3540 | try di_w.writeUleb128(DW.FORM.data2); |
| | 3541 | try di_w.writeInt(u16, @bitCast(f16_val), dwarf.endian); |
| | 3542 | }, |
| | 3543 | .f32 => |f32_val| { |
| | 3544 | try di_w.writeUleb128(DW.FORM.data4); |
| | 3545 | try di_w.writeInt(u32, @bitCast(f32_val), dwarf.endian); |
| | 3546 | }, |
| | 3547 | .f64 => |f64_val| { |
| | 3548 | try di_w.writeUleb128(DW.FORM.data8); |
| | 3549 | try di_w.writeInt(u64, @bitCast(f64_val), dwarf.endian); |
| | 3550 | }, |
| | 3551 | .f80 => |f80_val| { |
| | 3552 | try di_w.writeUleb128(DW.FORM.block); |
| | 3553 | try di_w.writeUleb128(@divExact(80, 8)); |
| | 3554 | try di_w.writeInt(u80, @bitCast(f80_val), dwarf.endian); |
| | 3555 | }, |
| | 3556 | .f128 => |f128_val| { |
| | 3557 | try di_w.writeUleb128(DW.FORM.data16); |
| | 3558 | try di_w.writeInt(u128, @bitCast(f128_val), dwarf.endian); |
| | 3559 | }, |
| | 3560 | } |
| | 3561 | }, |
| | 3562 | .ptr => |ptr| { |
| | 3563 | const Access = union(enum) { |
| | 3564 | index: u64, |
| | 3565 | field: InternPool.NullTerminatedString, |
| | 3566 | synthetic_field: []const u8, |
| | 3567 | tuple_index: u32, |
| | 3568 | }; |
| | 3569 | var zero_bit_accesses: std.ArrayList(Access) = .empty; |
| | 3570 | defer zero_bit_accesses.deinit(zcu.gpa); |
| | 3571 | location: { |
| | 3572 | var base_addr = ptr.base_addr; |
| | 3573 | var byte_offset = ptr.byte_offset; |
| | 3574 | const base_ni = while (true) { |
| | 3575 | const base_ptr, const access: Access = base_ptr_access: switch (base_addr) { |
| | 3576 | .nav => |ni| break (try dwarf.getGlobal(ni)).get(dwarf).debug_info_ni, |
| | 3577 | .comptime_alloc, .comptime_field => unreachable, |
| | 3578 | .uav => |uav| { |
| | 3579 | const uav_ty: Type = .fromInterned(ip.typeOf(uav.val)); |
| | 3580 | if (uav_ty.classify(zcu) == .one_possible_value) { |
| | 3581 | try dwarf.abbrevCode(di_nw, if (zero_bit_accesses.items.len > 0) |
| | 3582 | .aggregate_comptime_value |
| | 3583 | else |
| | 3584 | .comptime_value); |
| | 3585 | try dwarf.refType(pt, di_nw, .fromInterned(ptr.ty)); |
| | 3586 | try di_w.writeUleb128(DW.FORM.udata); |
| | 3587 | try di_w.writeUleb128(ip.indexToKey(uav.orig_ty) |
| | 3588 | .ptr_type.flags.alignment.toByteUnits() orelse |
| | 3589 | uav_ty.abiAlignment(zcu).toByteUnits().?); |
| | 3590 | break :location; |
| | 3591 | } else break Const.get(try dwarf.getConst(pt, .fromInterned( |
| | 3592 | uav.val, |
| | 3593 | )), dwarf).debug_info_ni; |
| | 3594 | }, |
| | 3595 | .int => { |
| | 3596 | try dwarf.abbrevCode(di_nw, if (zero_bit_accesses.items.len > 0) |
| | 3597 | .aggregate_comptime_value |
| | 3598 | else |
| | 3599 | .comptime_value); |
| | 3600 | try dwarf.refType(pt, di_nw, .fromInterned(ptr.ty)); |
| | 3601 | try di_w.writeUleb128(DW.FORM.udata); |
| | 3602 | try di_w.writeUleb128(byte_offset); |
| | 3603 | break :location; |
| | 3604 | }, |
| | 3605 | .eu_payload => |eu_ptr| { |
| | 3606 | const base_ptr = ip.indexToKey(eu_ptr).ptr; |
| | 3607 | byte_offset += codegen.errUnionPayloadOffset(.fromInterned(ip.indexToKey( |
| | 3608 | ip.indexToKey(base_ptr.ty).ptr_type.child, |
| | 3609 | ).error_union_type.payload_type), zcu); |
| | 3610 | break :base_ptr_access .{ base_ptr, .{ .synthetic_field = "value" } }; |
| | 3611 | }, |
| | 3612 | .opt_payload => |opt_ptr| .{ ip.indexToKey(opt_ptr).ptr, .{ |
| | 3613 | .synthetic_field = "?", |
| | 3614 | } }, |
| | 3615 | .field => |field| { |
| | 3616 | const base_ptr = ip.indexToKey(field.base).ptr; |
| | 3617 | const agg_ty: Type = |
| | 3618 | .fromInterned(ip.indexToKey(base_ptr.ty).ptr_type.child); |
| | 3619 | break :base_ptr_access .{ |
| | 3620 | base_ptr, |
| | 3621 | if (agg_ty.isSlice(zcu)) .{ .synthetic_field = switch (field.index) { |
| | 3622 | Value.slice_ptr_index => "ptr", |
| | 3623 | Value.slice_len_index => "len", |
| | 3624 | else => unreachable, |
| | 3625 | } } else if (agg_ty.structFieldName( |
| | 3626 | @intCast(field.index), |
| | 3627 | zcu, |
| | 3628 | ).unwrap()) |field_name| |
| | 3629 | .{ .field = field_name } |
| | 3630 | else |
| | 3631 | .{ .tuple_index = @intCast(field.index) }, |
| | 3632 | }; |
| | 3633 | }, |
| | 3634 | .arr_elem => |arr_elem| .{ |
| | 3635 | ip.indexToKey(arr_elem.base).ptr, |
| | 3636 | .{ .index = arr_elem.index }, |
| | 3637 | }, |
| | 3638 | }; |
| | 3639 | base_addr = base_ptr.base_addr; |
| | 3640 | byte_offset += base_ptr.byte_offset; |
| | 3641 | if (Type.fromInterned( |
| | 3642 | ip.indexToKey(base_ptr.ty).ptr_type.child, |
| | 3643 | ).hasRuntimeBits(zcu)) |
| | 3644 | assert(access != .index) |
| | 3645 | else |
| | 3646 | try zero_bit_accesses.append(zcu.gpa, access); |
| | 3647 | }; |
| | 3648 | try dwarf.abbrevCode(di_nw, if (zero_bit_accesses.items.len > 0) |
| | 3649 | .aggregate_location_comptime_value |
| | 3650 | else |
| | 3651 | .location_comptime_value); |
| | 3652 | try dwarf.refType(pt, di_nw, .fromInterned(ptr.ty)); |
| | 3653 | try dwarf.exprLoc(di_nw, .{ .implicit_pointer = .{ |
| | 3654 | .node = base_ni.unwrap().?, |
| | 3655 | .offset = byte_offset, |
| | 3656 | } }); |
| | 3657 | } |
| | 3658 | if (zero_bit_accesses.items.len > 0) { |
| | 3659 | for (zero_bit_accesses.items) |access| switch (access) { |
| | 3660 | .index => |index| { |
| | 3661 | try dwarf.abbrevCode(di_nw, .array_index); |
| | 3662 | try di_w.writeUleb128(index); |
| | 3663 | }, |
| | 3664 | .field => |field| { |
| | 3665 | try dwarf.abbrevCode(di_nw, .access); |
| | 3666 | try dwarf.strx(di_nw, field.toSlice(ip)); |
| | 3667 | }, |
| | 3668 | .synthetic_field => |field| { |
| | 3669 | try dwarf.abbrevCode(di_nw, .access); |
| | 3670 | try dwarf.strx(di_nw, field); |
| | 3671 | }, |
| | 3672 | .tuple_index => |index| { |
| | 3673 | try dwarf.abbrevCode(di_nw, .access); |
| | 3674 | var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = |
| | 3675 | undefined; |
| | 3676 | const field_name = std.mem.print(&field_name_buf, "{d}", .{index}) catch |
| | 3677 | unreachable; |
| | 3678 | try dwarf.strx(di_nw, field_name); |
| | 3679 | }, |
| | 3680 | }; |
| | 3681 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 3682 | } |
| | 3683 | }, |
| | 3684 | .slice => |slice| { |
| | 3685 | try dwarf.abbrevCode(di_nw, .aggregate_undefined_comptime_value); |
| | 3686 | try dwarf.refType(pt, di_nw, .fromInterned(slice.ty)); |
| | 3687 | { |
| | 3688 | try dwarf.abbrevCode(di_nw, .comptime_value_field_comptime); |
| | 3689 | try dwarf.strx(di_nw, "ptr"); |
| | 3690 | try dwarf.refConst(pt, di_nw, .fromInterned(slice.ptr)); |
| | 3691 | } |
| | 3692 | { |
| | 3693 | try dwarf.abbrevCode(di_nw, .comptime_value_field_runtime); |
| | 3694 | try dwarf.strx(di_nw, "len"); |
| | 3695 | try dwarf.blockConst(pt, di_nw, .fromInterned(slice.len)); |
| | 3696 | } |
| | 3697 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 3698 | }, |
| | 3699 | .opt => |opt| { |
| | 3700 | const opt_child_ty: Type = .fromInterned(ip.indexToKey(opt.ty).opt_type); |
| | 3701 | try dwarf.abbrevCode(di_nw, .aggregate_undefined_comptime_value); |
| | 3702 | try dwarf.refType(pt, di_nw, .fromInterned(opt.ty)); |
| | 3703 | { |
| | 3704 | try dwarf.abbrevCode(di_nw, .comptime_value_field_runtime); |
| | 3705 | try dwarf.strx(di_nw, "has_value"); |
| | 3706 | switch (optRepr(opt_child_ty, zcu)) { |
| | 3707 | .opv_null => try di_w.writeUleb128(0), |
| | 3708 | .unpacked => try dwarf.blockConst(pt, di_nw, .makeBool(opt.val != .none)), |
| | 3709 | .error_set, .pointer => try dwarf.blockConst(pt, di_nw, .fromInterned(@"const")), |
| | 3710 | } |
| | 3711 | } |
| | 3712 | if (opt.val != .none) child_field: { |
| | 3713 | const opt_child_class = opt_child_ty.classify(zcu); |
| | 3714 | try dwarf.abbrevCode(di_nw, if (opt_child_class.comptimeOnly()) |
| | 3715 | .comptime_value_field_comptime |
| | 3716 | else if (opt_child_class.hasRuntimeBits()) |
| | 3717 | .comptime_value_field_runtime |
| | 3718 | else |
| | 3719 | break :child_field); |
| | 3720 | try dwarf.strx(di_nw, "?"); |
| | 3721 | if (opt_child_class.comptimeOnly()) |
| | 3722 | try dwarf.refConst(pt, di_nw, .fromInterned(opt.val)) |
| | 3723 | else if (opt_child_class.hasRuntimeBits()) |
| | 3724 | try dwarf.blockConst(pt, di_nw, .fromInterned(opt.val)) |
| | 3725 | else |
| | 3726 | unreachable; |
| | 3727 | } |
| | 3728 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 3729 | }, |
| | 3730 | .aggregate => |aggregate| { |
| | 3731 | try dwarf.abbrevCode(di_nw, .aggregate_undefined_comptime_value); |
| | 3732 | try dwarf.refType(pt, di_nw, .fromInterned(aggregate.ty)); |
| | 3733 | switch (ip.indexToKey(aggregate.ty)) { |
| | 3734 | .struct_type => { |
| | 3735 | const loaded_struct = ip.loadStructType(aggregate.ty); |
| | 3736 | assert(loaded_struct.layout == .auto); |
| | 3737 | for (0..loaded_struct.field_types.len) |field_index| { |
| | 3738 | if (loaded_struct.field_is_comptime_bits.get(ip, field_index)) continue; |
| | 3739 | const field_ty: Type = |
| | 3740 | .fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| | 3741 | const field_class = field_ty.classify(zcu); |
| | 3742 | try dwarf.abbrevCode(di_nw, if (field_class.comptimeOnly()) |
| | 3743 | .comptime_value_field_comptime |
| | 3744 | else if (field_class.hasRuntimeBits()) |
| | 3745 | .comptime_value_field_runtime |
| | 3746 | else |
| | 3747 | continue); |
| | 3748 | try dwarf.strx( |
| | 3749 | di_nw, |
| | 3750 | loaded_struct.field_names.get(ip)[field_index].toSlice(ip), |
| | 3751 | ); |
| | 3752 | const field_value: Value = .fromInterned(switch (aggregate.storage) { |
| | 3753 | .bytes => unreachable, |
| | 3754 | .elems => |elems| elems[field_index], |
| | 3755 | .repeated_elem => |repeated_elem| repeated_elem, |
| | 3756 | }); |
| | 3757 | if (field_class.comptimeOnly()) |
| | 3758 | try dwarf.refConst(pt, di_nw, field_value) |
| | 3759 | else if (field_class.hasRuntimeBits()) |
| | 3760 | try dwarf.blockConst(pt, di_nw, field_value) |
| | 3761 | else |
| | 3762 | unreachable; |
| | 3763 | } |
| | 3764 | }, |
| | 3765 | .tuple_type => |tuple_type| for (0..tuple_type.types.len) |field_index| { |
| | 3766 | if (tuple_type.values.get(ip)[field_index] != .none) continue; |
| | 3767 | const field_ty: Type = .fromInterned(tuple_type.types.get(ip)[field_index]); |
| | 3768 | const field_class = field_ty.classify(zcu); |
| | 3769 | try dwarf.abbrevCode(di_nw, if (field_class.comptimeOnly()) |
| | 3770 | .comptime_value_field_comptime |
| | 3771 | else if (field_class.hasRuntimeBits()) |
| | 3772 | .comptime_value_field_runtime |
| | 3773 | else |
| | 3774 | continue); |
| | 3775 | { |
| | 3776 | var field_name_buf: [std.fmt.count("{d}", .{std.math.maxInt(u32)})]u8 = |
| | 3777 | undefined; |
| | 3778 | const field_name = std.mem.print(&field_name_buf, "{d}", .{field_index}) catch |
| | 3779 | unreachable; |
| | 3780 | try dwarf.strx(di_nw, field_name); |
| | 3781 | } |
| | 3782 | const field_value: Value = .fromInterned(switch (aggregate.storage) { |
| | 3783 | .bytes => unreachable, |
| | 3784 | .elems => |elems| elems[field_index], |
| | 3785 | .repeated_elem => |repeated_elem| repeated_elem, |
| | 3786 | }); |
| | 3787 | if (field_class.comptimeOnly()) |
| | 3788 | try dwarf.refConst(pt, di_nw, field_value) |
| | 3789 | else if (field_class.hasRuntimeBits()) |
| | 3790 | try dwarf.blockConst(pt, di_nw, field_value) |
| | 3791 | else |
| | 3792 | unreachable; |
| | 3793 | }, |
| | 3794 | inline .array_type, .vector_type => |sequence_type| { |
| | 3795 | const child_ty: Type = .fromInterned(sequence_type.child); |
| | 3796 | const child_class = child_ty.classify(zcu); |
| | 3797 | for (switch (aggregate.storage) { |
| | 3798 | .bytes => unreachable, |
| | 3799 | .elems => |elems| elems, |
| | 3800 | .repeated_elem => |*repeated_elem| repeated_elem[0..1], |
| | 3801 | }) |elem| { |
| | 3802 | try dwarf.abbrevCode(di_nw, if (child_class.comptimeOnly()) |
| | 3803 | .comptime_value_elem_comptime |
| | 3804 | else if (child_class.hasRuntimeBits()) |
| | 3805 | .comptime_value_elem_runtime |
| | 3806 | else |
| | 3807 | break); |
| | 3808 | if (child_class.comptimeOnly()) |
| | 3809 | try dwarf.refConst(pt, di_nw, .fromInterned(elem)) |
| | 3810 | else if (child_class.hasRuntimeBits()) |
| | 3811 | try dwarf.blockConst(pt, di_nw, .fromInterned(elem)) |
| | 3812 | else |
| | 3813 | unreachable; |
| | 3814 | } |
| | 3815 | }, |
| | 3816 | else => unreachable, |
| | 3817 | } |
| | 3818 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 3819 | }, |
| | 3820 | .un => |un| { |
| | 3821 | try dwarf.abbrevCode(di_nw, .aggregate_undefined_comptime_value); |
| | 3822 | try dwarf.refType(pt, di_nw, .fromInterned(un.ty)); |
| | 3823 | { |
| | 3824 | const loaded_union = ip.loadUnionType(un.ty); |
| | 3825 | assert(loaded_union.layout == .auto); |
| | 3826 | const field_index = zcu.unionTagFieldIndex(loaded_union, Value.fromInterned(un.tag)).?; |
| | 3827 | const field_ty: Type = .fromInterned(loaded_union.field_types.get(ip)[field_index]); |
| | 3828 | const field_class = field_ty.classify(zcu); |
| | 3829 | const field_name = |
| | 3830 | ip.loadEnumType(loaded_union.enum_tag_type).field_names.get(ip)[field_index]; |
| | 3831 | try dwarf.abbrevCode(di_nw, if (field_class.comptimeOnly()) |
| | 3832 | .comptime_value_field_comptime |
| | 3833 | else if (field_class.hasRuntimeBits()) |
| | 3834 | .comptime_value_field_runtime |
| | 3835 | else |
| | 3836 | .access); |
| | 3837 | try dwarf.strx(di_nw, field_name.toSlice(ip)); |
| | 3838 | if (field_class.comptimeOnly()) |
| | 3839 | try dwarf.refConst(pt, di_nw, .fromInterned(un.val)) |
| | 3840 | else if (field_class.hasRuntimeBits()) |
| | 3841 | try dwarf.blockConst(pt, di_nw, .fromInterned(un.val)); |
| 2928 | } | 3842 | } |
| 2929 | if (fn_ty.is_var_args) try dwarf.abbrevCode(di_nw, .is_var_args); | | |
| 2930 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | 3843 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2931 | }, | 3844 | }, |
| 2932 | | 3845 | |
| ... | @@ -2935,11 +3848,11 @@ fn updateConstInner( | ... | @@ -2935,11 +3848,11 @@ fn updateConstInner( |
| 2935 | try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen()); | 3848 | try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen()); |
| 2936 | } | 3849 | } |
| 2937 | | 3850 | |
| 2938 | fn optRepr(opt_child_type: Type, zcu: *const Zcu) enum { unpacked, opv_null, error_set, pointer } { | 3851 | fn optRepr(opt_child_ty: Type, zcu: *const Zcu) enum { unpacked, opv_null, error_set, pointer } { |
| 2939 | if (opt_child_type.isNoReturn(zcu)) return .opv_null; | 3852 | if (opt_child_ty.isNoReturn(zcu)) return .opv_null; |
| 2940 | return switch (opt_child_type.toIntern()) { | 3853 | return switch (opt_child_ty.toIntern()) { |
| 2941 | .anyerror_type => .error_set, | 3854 | .anyerror_type => .error_set, |
| 2942 | else => switch (zcu.intern_pool.indexToKey(opt_child_type.toIntern())) { | 3855 | else => switch (zcu.intern_pool.indexToKey(opt_child_ty.toIntern())) { |
| 2943 | else => .unpacked, | 3856 | else => .unpacked, |
| 2944 | .error_set_type, .inferred_error_set_type => .error_set, | 3857 | .error_set_type, .inferred_error_set_type => .error_set, |
| 2945 | .ptr_type => |ptr_type| if (ptr_type.flags.is_allowzero) .unpacked else .pointer, | 3858 | .ptr_type => |ptr_type| if (ptr_type.flags.is_allowzero) .unpacked else .pointer, |
| ... | @@ -2983,21 +3896,21 @@ fn updateConstIncompleteInner( | ... | @@ -2983,21 +3896,21 @@ fn updateConstIncompleteInner( |
| 2983 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file); | 3896 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file); |
| 2984 | try dwarf.abbrevCode(di_nw, .empty_file); | 3897 | try dwarf.abbrevCode(di_nw, .empty_file); |
| 2985 | try di_w.writeUleb128(@backingInt(fi)); | 3898 | try di_w.writeUleb128(@backingInt(fi)); |
| 2986 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_struct.name.toSlice(ip)); | 3899 | try dwarf.strx(di_nw, loaded_struct.name.toSlice(ip)); |
| 2987 | try di_w.writeByte(@intFromBool(true)); | 3900 | try di_w.writeByte(@intFromBool(true)); |
| 2988 | break :done; | 3901 | break :done; |
| 2989 | }, | 3902 | }, |
| 2990 | else => { | 3903 | else => { |
| 2991 | const data = | 3904 | const zir = &zf.zir.?; |
| 2992 | zf.zir.?.instructions.items(.data)[@backingInt(src_inst.inst)].extended; | 3905 | const data = zir.instructions.items(.data)[@backingInt(src_inst.inst)].extended; |
| 2993 | const src_line, const src_column = src_loc: switch (data.opcode) { | 3906 | const src_line, const src_column = src_loc: switch (data.opcode) { |
| 2994 | else => unreachable, | 3907 | else => unreachable, |
| 2995 | .struct_decl => { | 3908 | .struct_decl => { |
| 2996 | const decl = zf.zir.?.getStructDecl(src_inst.inst); | 3909 | const decl = zir.getStructDecl(src_inst.inst); |
| 2997 | break :src_loc .{ decl.src_line, decl.src_column }; | 3910 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 2998 | }, | 3911 | }, |
| 2999 | .reify_struct => { | 3912 | .reify_struct => { |
| 3000 | const decl = zf.zir.?.extraData( | 3913 | const decl = zir.extraData( |
| 3001 | std.zig.Zir.Inst.ReifyStruct, | 3914 | std.zig.Zir.Inst.ReifyStruct, |
| 3002 | data.operand, | 3915 | data.operand, |
| 3003 | ).data; | 3916 | ).data; |
| ... | @@ -3025,15 +3938,16 @@ fn updateConstIncompleteInner( | ... | @@ -3025,15 +3938,16 @@ fn updateConstIncompleteInner( |
| 3025 | break :done; | 3938 | break :done; |
| 3026 | }; | 3939 | }; |
| 3027 | const zf = zcu.fileByIndex(src_inst.file); | 3940 | const zf = zcu.fileByIndex(src_inst.file); |
| 3028 | const data = zf.zir.?.instructions.items(.data)[@backingInt(src_inst.inst)].extended; | 3941 | const zir = &zf.zir.?; |
| | 3942 | const data = zir.instructions.items(.data)[@backingInt(src_inst.inst)].extended; |
| 3029 | const src_line, const src_column = src_loc: switch (data.opcode) { | 3943 | const src_line, const src_column = src_loc: switch (data.opcode) { |
| 3030 | else => unreachable, | 3944 | else => unreachable, |
| 3031 | .union_decl => { | 3945 | .union_decl => { |
| 3032 | const decl = zf.zir.?.getUnionDecl(src_inst.inst); | 3946 | const decl = zir.getUnionDecl(src_inst.inst); |
| 3033 | break :src_loc .{ decl.src_line, decl.src_column }; | 3947 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 3034 | }, | 3948 | }, |
| 3035 | .reify_union => { | 3949 | .reify_union => { |
| 3036 | const decl = zf.zir.?.extraData(std.zig.Zir.Inst.ReifyUnion, data.operand).data; | 3950 | const decl = zir.extraData(std.zig.Zir.Inst.ReifyUnion, data.operand).data; |
| 3037 | break :src_loc .{ decl.src_line, decl.src_column }; | 3951 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 3038 | }, | 3952 | }, |
| 3039 | }; | 3953 | }; |
| ... | @@ -3053,7 +3967,7 @@ fn updateConstIncompleteInner( | ... | @@ -3053,7 +3967,7 @@ fn updateConstIncompleteInner( |
| 3053 | const loaded_enum = ip.loadEnumType(val); | 3967 | const loaded_enum = ip.loadEnumType(val); |
| 3054 | const zir_index = loaded_enum.zir_index.unwrap() orelse { | 3968 | const zir_index = loaded_enum.zir_index.unwrap() orelse { |
| 3055 | try dwarf.abbrevCode(di_nw, .generated_empty_struct_type); | 3969 | try dwarf.abbrevCode(di_nw, .generated_empty_struct_type); |
| 3056 | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.name.toSlice(ip)); | 3970 | try dwarf.strx(di_nw, loaded_enum.name.toSlice(ip)); |
| 3057 | try di_w.writeByte(@intFromBool(true)); | 3971 | try di_w.writeByte(@intFromBool(true)); |
| 3058 | break :done; | 3972 | break :done; |
| 3059 | }; | 3973 | }; |
| ... | @@ -3062,15 +3976,16 @@ fn updateConstIncompleteInner( | ... | @@ -3062,15 +3976,16 @@ fn updateConstIncompleteInner( |
| 3062 | break :done; | 3976 | break :done; |
| 3063 | }; | 3977 | }; |
| 3064 | const zf = zcu.fileByIndex(src_inst.file); | 3978 | const zf = zcu.fileByIndex(src_inst.file); |
| 3065 | const data = zf.zir.?.instructions.items(.data)[@backingInt(src_inst.inst)].extended; | 3979 | const zir = &zf.zir.?; |
| | 3980 | const data = zir.instructions.items(.data)[@backingInt(src_inst.inst)].extended; |
| 3066 | const src_line, const src_column = src_loc: switch (data.opcode) { | 3981 | const src_line, const src_column = src_loc: switch (data.opcode) { |
| 3067 | else => unreachable, | 3982 | else => unreachable, |
| 3068 | .enum_decl => { | 3983 | .enum_decl => { |
| 3069 | const decl = zf.zir.?.getEnumDecl(src_inst.inst); | 3984 | const decl = zir.getEnumDecl(src_inst.inst); |
| 3070 | break :src_loc .{ decl.src_line, decl.src_column }; | 3985 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 3071 | }, | 3986 | }, |
| 3072 | .reify_enum => { | 3987 | .reify_enum => { |
| 3073 | const decl = zf.zir.?.extraData(std.zig.Zir.Inst.ReifyEnum, data.operand).data; | 3988 | const decl = zir.extraData(std.zig.Zir.Inst.ReifyEnum, data.operand).data; |
| 3074 | break :src_loc .{ decl.src_line, decl.src_column }; | 3989 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 3075 | }, | 3990 | }, |
| 3076 | }; | 3991 | }; |
| ... | @@ -3112,7 +4027,7 @@ fn updateConstIncompleteInner( | ... | @@ -3112,7 +4027,7 @@ fn updateConstIncompleteInner( |
| 3112 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); | 4027 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); |
| 3113 | defer zcu.gpa.free(name); | 4028 | defer zcu.gpa.free(name); |
| 3114 | try dwarf.abbrevCode(di_nw, .generated_empty_struct_type); | 4029 | try dwarf.abbrevCode(di_nw, .generated_empty_struct_type); |
| 3115 | try dwarf.strp(&dwarf.debug_str, di_nw, name); | 4030 | try dwarf.strx(di_nw, name); |
| 3116 | try di_w.writeByte(@intFromBool(true)); | 4031 | try di_w.writeByte(@intFromBool(true)); |
| 3117 | }, | 4032 | }, |
| 3118 | else => |ty| { | 4033 | else => |ty| { |
| ... | @@ -3131,13 +4046,15 @@ fn updateConstIncompleteInner( | ... | @@ -3131,13 +4046,15 @@ fn updateConstIncompleteInner( |
| 3131 | .@"union" => .decl_instance_empty_incomplete_union, | 4046 | .@"union" => .decl_instance_empty_incomplete_union, |
| 3132 | .@"enum" => .decl_instance_empty_incomplete_enum, | 4047 | .@"enum" => .decl_instance_empty_incomplete_enum, |
| 3133 | }); | 4048 | }); |
| 3134 | try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0); | 4049 | try dwarf.refType(pt, di_nw, .fromInterned(ip.namespacePtr( |
| | 4050 | ip.namespacePtr(namespace).parent.unwrap().?, |
| | 4051 | ).owner_type)); |
| | 4052 | try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, val), 0); |
| 3135 | } else if (maybe_name_nav.unwrap()) |name_ni| { | 4053 | } else if (maybe_name_nav.unwrap()) |name_ni| { |
| 3136 | const name_nav = ip.getNav(name_ni); | 4054 | const name_nav = ip.getNav(name_ni); |
| 3137 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); | 4055 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 3138 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 4056 | const parent_ni = |
| 3139 | name_nav.analysis.?.namespace, | 4057 | try dwarf.getConstDecl(pt, ip.namespacePtr(name_nav.analysis.?.namespace).owner_type); |
| 3140 | ).owner_type); | | |
| 3141 | try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) { | 4058 | try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) { |
| 3142 | .@"struct" => .decl_incomplete_struct, | 4059 | .@"struct" => .decl_incomplete_struct, |
| 3143 | .@"union" => .decl_incomplete_union, | 4060 | .@"union" => .decl_incomplete_union, |
| ... | @@ -3151,9 +4068,9 @@ fn updateConstIncompleteInner( | ... | @@ -3151,9 +4068,9 @@ fn updateConstIncompleteInner( |
| 3151 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 4068 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 3152 | try di_w.writeUleb128(decl.src_column + 1); | 4069 | try di_w.writeUleb128(decl.src_column + 1); |
| 3153 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 4070 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 3154 | try dwarf.strp(&dwarf.debug_str, di_nw, name_nav.name.toSlice(ip)); | 4071 | try dwarf.strx(di_nw, name_nav.name.toSlice(ip)); |
| 3155 | } else { | 4072 | } else { |
| 3156 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 4073 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 3157 | ip.namespacePtr(namespace).parent.unwrap().?, | 4074 | ip.namespacePtr(namespace).parent.unwrap().?, |
| 3158 | ).owner_type); | 4075 | ).owner_type); |
| 3159 | try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) { | 4076 | try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) { |
| ... | @@ -3168,7 +4085,7 @@ fn updateConstIncompleteInner( | ... | @@ -3168,7 +4085,7 @@ fn updateConstIncompleteInner( |
| 3168 | try dwarf.secOffset(di_nw, parent_ni, 0); | 4085 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 3169 | try di_w.writeInt(u32, src_line + 1, dwarf.endian); | 4086 | try di_w.writeInt(u32, src_line + 1, dwarf.endian); |
| 3170 | try di_w.writeUleb128(src_column + 1); | 4087 | try di_w.writeUleb128(src_column + 1); |
| 3171 | try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip)); | 4088 | try dwarf.strx(di_nw, name.toSlice(ip)); |
| 3172 | } | 4089 | } |
| 3173 | try dwarf.genCaptures(pt, di_nw, captures); | 4090 | try dwarf.genCaptures(pt, di_nw, captures); |
| 3174 | if (captures.len > 0) try di_w.writeByte(@backingInt(AbbrevCode.null)); | 4091 | if (captures.len > 0) try di_w.writeByte(@backingInt(AbbrevCode.null)); |
| ... | @@ -3224,10 +4141,16 @@ pub fn genDecl( | ... | @@ -3224,10 +4141,16 @@ pub fn genDecl( |
| 3224 | dwarf: *Dwarf, | 4141 | dwarf: *Dwarf, |
| 3225 | pt: Zcu.PerThread, | 4142 | pt: Zcu.PerThread, |
| 3226 | di_nw: *link.MappedFile.Node.Writer, | 4143 | di_nw: *link.MappedFile.Node.Writer, |
| 3227 | instance_val: InternPool.Index, | 4144 | instance: Decl.Instance, |
| 3228 | ) link.Error!void { | 4145 | ) link.Error!void { |
| 3229 | log.debug("genDecl({f})", .{Value.fromInterned(instance_val).fmtValue(pt)}); | 4146 | switch (instance) { |
| 3230 | dwarf.genDeclInner(pt, di_nw, instance_val) catch |err| switch (err) { | 4147 | .none => unreachable, |
| | 4148 | .@"const" => |@"const"| log.debug("genDecl({f})", .{Value.fromInterned(@"const").fmtValue(pt)}), |
| | 4149 | .global => |global| log.debug("genDecl({f})", .{ |
| | 4150 | pt.zcu.intern_pool.getNav(global).fqn.fmt(&pt.zcu.intern_pool), |
| | 4151 | }), |
| | 4152 | } |
| | 4153 | dwarf.genDeclInner(pt, di_nw, instance) catch |err| switch (err) { |
| 3231 | else => |e| return e, | 4154 | else => |e| return e, |
| 3232 | error.WriteFailed => return dwarf.reportWriteError(di_nw), | 4155 | error.WriteFailed => return dwarf.reportWriteError(di_nw), |
| 3233 | }; | 4156 | }; |
| ... | @@ -3236,216 +4159,255 @@ fn genDeclInner( | ... | @@ -3236,216 +4159,255 @@ fn genDeclInner( |
| 3236 | dwarf: *Dwarf, | 4159 | dwarf: *Dwarf, |
| 3237 | pt: Zcu.PerThread, | 4160 | pt: Zcu.PerThread, |
| 3238 | di_nw: *link.MappedFile.Node.Writer, | 4161 | di_nw: *link.MappedFile.Node.Writer, |
| 3239 | instance_val: InternPool.Index, | 4162 | instance: Decl.Instance, |
| 3240 | ) link.EmitError!void { | 4163 | ) link.EmitError!void { |
| 3241 | const zcu = pt.zcu; | 4164 | const zcu = pt.zcu; |
| 3242 | const ip = &zcu.intern_pool; | 4165 | const ip = &zcu.intern_pool; |
| 3243 | const di_w = &di_nw.interface; | 4166 | const di_w = &di_nw.interface; |
| 3244 | done: { | 4167 | done: switch (instance) { |
| 3245 | const kind: enum { @"struct", @"union", @"enum" }, const zf, const src_line, const src_column, const capture_names, const captures, const name, const maybe_name_nav, const namespace = container: switch (ip.indexToKey(instance_val)) { | 4168 | .none => unreachable, |
| 3246 | else => unreachable, | 4169 | .@"const" => |@"const"| { |
| 3247 | .struct_type => { | 4170 | const kind: enum { @"struct", @"union", @"enum" }, const zf, const src_line, const src_column, const capture_names, const captures, const maybe_name_nav, const namespace = container: switch (ip.indexToKey(instance.@"const")) { |
| 3248 | const loaded_struct = ip.loadStructType(instance_val); | 4171 | else => unreachable, |
| 3249 | const src_inst = loaded_struct.zir_index.resolveFull(ip) orelse { | 4172 | .struct_type => { |
| 3250 | try dwarf.lostTracking(di_nw); | 4173 | const loaded_struct = ip.loadStructType(@"const"); |
| 3251 | break :done; | 4174 | const src_inst = loaded_struct.zir_index.resolveFull(ip) orelse { |
| 3252 | }; | 4175 | try dwarf.lostTracking(di_nw); |
| 3253 | const zf = zcu.fileByIndex(src_inst.file); | 4176 | break :done; |
| 3254 | const inst = zf.zir.?.instructions.get(@backingInt(src_inst.inst)); | 4177 | }; |
| 3255 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { | 4178 | const zf = zcu.fileByIndex(src_inst.file); |
| 3256 | else => unreachable, | 4179 | const zir = &zf.zir.?; |
| 3257 | .struct_init, .struct_init_ref => { | 4180 | const inst = zir.instructions.get(@backingInt(src_inst.inst)); |
| 3258 | const decl = zf.zir.?.extraData( | 4181 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { |
| 3259 | std.zig.Zir.Inst.StructInit, | | |
| 3260 | inst.data.pl_node.payload_index, | | |
| 3261 | ).data; | | |
| 3262 | break :decl .{ decl.src_line, decl.src_column, &.{} }; | | |
| 3263 | }, | | |
| 3264 | .struct_init_anon => { | | |
| 3265 | const decl = zf.zir.?.extraData( | | |
| 3266 | std.zig.Zir.Inst.StructInitAnon, | | |
| 3267 | inst.data.pl_node.payload_index, | | |
| 3268 | ).data; | | |
| 3269 | break :decl .{ decl.src_line, decl.src_column, &.{} }; | | |
| 3270 | }, | | |
| 3271 | .extended => switch (inst.data.extended.opcode) { | | |
| 3272 | else => unreachable, | 4182 | else => unreachable, |
| 3273 | .struct_decl => { | 4183 | .struct_init, .struct_init_ref => { |
| 3274 | const decl = zf.zir.?.getStructDecl(src_inst.inst); | 4184 | const decl = zir.extraData( |
| 3275 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; | 4185 | std.zig.Zir.Inst.StructInit, |
| 3276 | }, | 4186 | inst.data.pl_node.payload_index, |
| 3277 | .reify_struct => { | | |
| 3278 | const decl = zf.zir.?.extraData( | | |
| 3279 | std.zig.Zir.Inst.ReifyStruct, | | |
| 3280 | inst.data.extended.operand, | | |
| 3281 | ).data; | 4187 | ).data; |
| 3282 | break :decl .{ decl.src_line, decl.src_column, &.{} }; | 4188 | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| 3283 | }, | 4189 | }, |
| 3284 | }, | 4190 | .struct_init_anon => { |
| 3285 | }; | 4191 | const decl = zir.extraData( |
| 3286 | break :container .{ | 4192 | std.zig.Zir.Inst.StructInitAnon, |
| 3287 | .@"struct", | 4193 | inst.data.pl_node.payload_index, |
| 3288 | zf, | | |
| 3289 | src_line, | | |
| 3290 | src_column, | | |
| 3291 | capture_names, | | |
| 3292 | loaded_struct.captures, | | |
| 3293 | loaded_struct.name, | | |
| 3294 | loaded_struct.name_nav, | | |
| 3295 | loaded_struct.namespace, | | |
| 3296 | }; | | |
| 3297 | }, | | |
| 3298 | .union_type => { | | |
| 3299 | const loaded_union = ip.loadUnionType(instance_val); | | |
| 3300 | const src_inst = loaded_union.zir_index.resolveFull(ip) orelse { | | |
| 3301 | try dwarf.lostTracking(di_nw); | | |
| 3302 | break :done; | | |
| 3303 | }; | | |
| 3304 | const zf = zcu.fileByIndex(src_inst.file); | | |
| 3305 | const inst = zf.zir.?.instructions.get(@backingInt(src_inst.inst)); | | |
| 3306 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { | | |
| 3307 | else => unreachable, | | |
| 3308 | .extended => switch (inst.data.extended.opcode) { | | |
| 3309 | else => unreachable, | | |
| 3310 | .union_decl => { | | |
| 3311 | const decl = zf.zir.?.getUnionDecl(src_inst.inst); | | |
| 3312 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; | | |
| 3313 | }, | | |
| 3314 | .reify_union => { | | |
| 3315 | const decl = zf.zir.?.extraData( | | |
| 3316 | std.zig.Zir.Inst.ReifyUnion, | | |
| 3317 | inst.data.extended.operand, | | |
| 3318 | ).data; | 4194 | ).data; |
| 3319 | break :decl .{ decl.src_line, decl.src_column, &.{} }; | 4195 | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| 3320 | }, | 4196 | }, |
| 3321 | }, | 4197 | .extended => switch (inst.data.extended.opcode) { |
| 3322 | }; | 4198 | else => unreachable, |
| 3323 | break :container .{ | 4199 | .struct_decl => { |
| 3324 | .@"union", | 4200 | const decl = zir.getStructDecl(src_inst.inst); |
| 3325 | zf, | 4201 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; |
| 3326 | src_line, | 4202 | }, |
| 3327 | src_column, | 4203 | .reify_struct => { |
| 3328 | capture_names, | 4204 | const decl = zir.extraData( |
| 3329 | loaded_union.captures, | 4205 | std.zig.Zir.Inst.ReifyStruct, |
| 3330 | loaded_union.name, | 4206 | inst.data.extended.operand, |
| 3331 | loaded_union.name_nav, | 4207 | ).data; |
| 3332 | loaded_union.namespace, | 4208 | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| 3333 | }; | 4209 | }, |
| 3334 | }, | 4210 | }, |
| 3335 | .enum_type => { | 4211 | }; |
| 3336 | const loaded_enum = ip.loadEnumType(instance_val); | 4212 | break :container .{ |
| 3337 | const src_inst = loaded_enum.zir_index.unwrap().?.resolveFull(ip) orelse { | 4213 | .@"struct", |
| 3338 | try dwarf.lostTracking(di_nw); | 4214 | zf, |
| 3339 | break :done; | 4215 | src_line, |
| 3340 | }; | 4216 | src_column, |
| 3341 | const zf = zcu.fileByIndex(src_inst.file); | 4217 | capture_names, |
| 3342 | const inst = zf.zir.?.instructions.get(@backingInt(src_inst.inst)); | 4218 | loaded_struct.captures, |
| 3343 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { | 4219 | loaded_struct.name_nav, |
| 3344 | else => unreachable, | 4220 | loaded_struct.namespace, |
| 3345 | .extended => switch (inst.data.extended.opcode) { | 4221 | }; |
| | 4222 | }, |
| | 4223 | .union_type => { |
| | 4224 | const loaded_union = ip.loadUnionType(@"const"); |
| | 4225 | const src_inst = loaded_union.zir_index.resolveFull(ip) orelse { |
| | 4226 | try dwarf.lostTracking(di_nw); |
| | 4227 | break :done; |
| | 4228 | }; |
| | 4229 | const zf = zcu.fileByIndex(src_inst.file); |
| | 4230 | const zir = &zf.zir.?; |
| | 4231 | const inst = zir.instructions.get(@backingInt(src_inst.inst)); |
| | 4232 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { |
| 3346 | else => unreachable, | 4233 | else => unreachable, |
| 3347 | .enum_decl => { | 4234 | .extended => switch (inst.data.extended.opcode) { |
| 3348 | const decl = zf.zir.?.getEnumDecl(src_inst.inst); | 4235 | else => unreachable, |
| 3349 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; | 4236 | .union_decl => { |
| | 4237 | const decl = zir.getUnionDecl(src_inst.inst); |
| | 4238 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; |
| | 4239 | }, |
| | 4240 | .reify_union => { |
| | 4241 | const decl = zir.extraData( |
| | 4242 | std.zig.Zir.Inst.ReifyUnion, |
| | 4243 | inst.data.extended.operand, |
| | 4244 | ).data; |
| | 4245 | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| | 4246 | }, |
| 3350 | }, | 4247 | }, |
| 3351 | .reify_enum => { | 4248 | }; |
| 3352 | const decl = zf.zir.?.extraData( | 4249 | break :container .{ |
| 3353 | std.zig.Zir.Inst.ReifyEnum, | 4250 | .@"union", |
| 3354 | inst.data.extended.operand, | 4251 | zf, |
| 3355 | ).data; | 4252 | src_line, |
| 3356 | break :decl .{ decl.src_line, decl.src_column, &.{} }; | 4253 | src_column, |
| | 4254 | capture_names, |
| | 4255 | loaded_union.captures, |
| | 4256 | loaded_union.name_nav, |
| | 4257 | loaded_union.namespace, |
| | 4258 | }; |
| | 4259 | }, |
| | 4260 | .enum_type => { |
| | 4261 | const loaded_enum = ip.loadEnumType(@"const"); |
| | 4262 | const src_inst = loaded_enum.zir_index.unwrap().?.resolveFull(ip) orelse { |
| | 4263 | try dwarf.lostTracking(di_nw); |
| | 4264 | break :done; |
| | 4265 | }; |
| | 4266 | const zf = zcu.fileByIndex(src_inst.file); |
| | 4267 | const zir = &zf.zir.?; |
| | 4268 | const inst = zir.instructions.get(@backingInt(src_inst.inst)); |
| | 4269 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { |
| | 4270 | else => unreachable, |
| | 4271 | .extended => switch (inst.data.extended.opcode) { |
| | 4272 | else => unreachable, |
| | 4273 | .enum_decl => { |
| | 4274 | const decl = zir.getEnumDecl(src_inst.inst); |
| | 4275 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; |
| | 4276 | }, |
| | 4277 | .reify_enum => { |
| | 4278 | const decl = zir.extraData( |
| | 4279 | std.zig.Zir.Inst.ReifyEnum, |
| | 4280 | inst.data.extended.operand, |
| | 4281 | ).data; |
| | 4282 | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| | 4283 | }, |
| 3357 | }, | 4284 | }, |
| 3358 | }, | 4285 | }; |
| 3359 | }; | 4286 | break :container .{ |
| 3360 | break :container .{ | 4287 | .@"enum", |
| 3361 | .@"enum", | 4288 | zf, |
| 3362 | zf, | 4289 | src_line, |
| 3363 | src_line, | 4290 | src_column, |
| 3364 | src_column, | 4291 | capture_names, |
| 3365 | capture_names, | 4292 | loaded_enum.captures, |
| 3366 | loaded_enum.captures, | 4293 | loaded_enum.name_nav, |
| 3367 | loaded_enum.name, | 4294 | loaded_enum.namespace, |
| 3368 | loaded_enum.name_nav, | 4295 | }; |
| 3369 | loaded_enum.namespace, | 4296 | }, |
| 3370 | }; | 4297 | .opaque_type => { |
| 3371 | }, | 4298 | const loaded_opaque = ip.loadOpaqueType(@"const"); |
| 3372 | .opaque_type => { | 4299 | const src_inst = loaded_opaque.zir_index.resolveFull(ip) orelse { |
| 3373 | const loaded_opaque = ip.loadOpaqueType(instance_val); | 4300 | try dwarf.lostTracking(di_nw); |
| 3374 | const src_inst = loaded_opaque.zir_index.resolveFull(ip) orelse { | 4301 | break :done; |
| 3375 | try dwarf.lostTracking(di_nw); | 4302 | }; |
| | 4303 | const zf = zcu.fileByIndex(src_inst.file); |
| | 4304 | const decl = zf.zir.?.getOpaqueDecl(src_inst.inst); |
| | 4305 | break :container .{ |
| | 4306 | .@"struct", |
| | 4307 | zf, |
| | 4308 | decl.src_line, |
| | 4309 | decl.src_column, |
| | 4310 | decl.capture_names, |
| | 4311 | loaded_opaque.captures, |
| | 4312 | loaded_opaque.name_nav, |
| | 4313 | loaded_opaque.namespace, |
| | 4314 | }; |
| | 4315 | }, |
| | 4316 | .func => |func| { |
| | 4317 | const owner_nav = ip.getNav(switch (func.generic_owner) { |
| | 4318 | else => |generic_owner| zcu.funcInfo(generic_owner).owner_nav, |
| | 4319 | .none => func.owner_nav, |
| | 4320 | }); |
| | 4321 | const inst_info = owner_nav.srcInst(ip).resolveFull(ip).?; |
| | 4322 | const decl = zcu.fileByIndex(inst_info.file).zir.?.getDeclaration(inst_info.inst); |
| | 4323 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| | 4324 | owner_nav.analysis.?.namespace, |
| | 4325 | ).owner_type); |
| | 4326 | try dwarf.abbrevCode(di_nw, .decl_specification_func); |
| | 4327 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| | 4328 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| | 4329 | try di_w.writeUleb128(decl.src_column + 1); |
| | 4330 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| | 4331 | try dwarf.strx(di_nw, owner_nav.name.toSlice(ip)); |
| 3376 | break :done; | 4332 | break :done; |
| 3377 | }; | 4333 | }, |
| 3378 | const zf = zcu.fileByIndex(src_inst.file); | 4334 | }; |
| 3379 | const decl = zf.zir.?.getOpaqueDecl(src_inst.inst); | 4335 | const zir = &zf.zir.?; |
| 3380 | break :container .{ | 4336 | if (maybe_name_nav.unwrap()) |name_ni| { |
| 3381 | .@"struct", | 4337 | const name_nav = ip.getNav(name_ni); |
| 3382 | zf, | 4338 | const decl = zir.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 3383 | decl.src_line, | 4339 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 3384 | decl.src_column, | 4340 | name_nav.analysis.?.namespace, |
| 3385 | decl.capture_names, | 4341 | ).owner_type); |
| 3386 | loaded_opaque.captures, | 4342 | try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) { |
| 3387 | loaded_opaque.name, | 4343 | .@"struct" => .decl_specification_struct, |
| 3388 | loaded_opaque.name_nav, | 4344 | .@"union" => .decl_specification_union, |
| 3389 | loaded_opaque.namespace, | 4345 | .@"enum" => .decl_specification_enum, |
| 3390 | }; | 4346 | } else switch (kind) { |
| 3391 | }, | 4347 | .@"struct" => .decl_specification_empty_struct, |
| 3392 | }; | 4348 | .@"union" => .decl_specification_empty_union, |
| 3393 | if (maybe_name_nav.unwrap()) |name_ni| { | 4349 | .@"enum" => .decl_specification_empty_enum, |
| 3394 | const name_nav = ip.getNav(name_ni); | 4350 | }); |
| 3395 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); | 4351 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 3396 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 4352 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 3397 | name_nav.analysis.?.namespace, | 4353 | try di_w.writeUleb128(decl.src_column + 1); |
| 3398 | ).owner_type); | 4354 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 3399 | try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) { | 4355 | try dwarf.strx(di_nw, name_nav.name.toSlice(ip)); |
| 3400 | .@"struct" => .decl_specification_struct, | 4356 | } else { |
| 3401 | .@"union" => .decl_specification_union, | 4357 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 3402 | .@"enum" => .decl_specification_enum, | 4358 | ip.namespacePtr(namespace).parent.unwrap().?, |
| 3403 | } else switch (kind) { | 4359 | ).owner_type); |
| 3404 | .@"struct" => .decl_specification_empty_struct, | 4360 | try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) { |
| 3405 | .@"union" => .decl_specification_empty_union, | 4361 | .@"struct" => .type_decl_specification_struct, |
| 3406 | .@"enum" => .decl_specification_empty_enum, | 4362 | .@"union" => .type_decl_specification_union, |
| 3407 | }); | 4363 | .@"enum" => .type_decl_specification_enum, |
| 3408 | try dwarf.secOffset(di_nw, parent_ni, 0); | 4364 | } else switch (kind) { |
| 3409 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); | 4365 | .@"struct" => .type_decl_specification_empty_struct, |
| 3410 | try di_w.writeUleb128(decl.src_column + 1); | 4366 | .@"union" => .type_decl_specification_empty_union, |
| 3411 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); | 4367 | .@"enum" => .type_decl_specification_empty_enum, |
| 3412 | try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip)); | 4368 | }); |
| 3413 | } else { | 4369 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 3414 | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( | 4370 | try di_w.writeInt(u32, src_line + 1, dwarf.endian); |
| 3415 | ip.namespacePtr(namespace).parent.unwrap().?, | 4371 | try di_w.writeUleb128(src_column + 1); |
| | 4372 | } |
| | 4373 | for (capture_names, captures.get(ip)) |capture_name, capture| { |
| | 4374 | try dwarf.abbrevCode(di_nw, .capture_specification); |
| | 4375 | switch (capture.unwrap()) { |
| | 4376 | .@"comptime", |
| | 4377 | .runtime, |
| | 4378 | .nav_val, |
| | 4379 | => try dwarf.strx(di_nw, zir.nullTerminatedString(capture_name)), |
| | 4380 | .nav_ref => { |
| | 4381 | const capture_name_slice = |
| | 4382 | try zcu.gpa.print("&{s}", .{zir.nullTerminatedString(capture_name)}); |
| | 4383 | defer zcu.gpa.free(capture_name_slice); |
| | 4384 | try dwarf.strx(di_nw, capture_name_slice); |
| | 4385 | }, |
| | 4386 | } |
| | 4387 | } |
| | 4388 | if (captures.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| | 4389 | }, |
| | 4390 | .global => |global| { |
| | 4391 | const nav = ip.getNav(global); |
| | 4392 | const nav_const, const nav_ty = nav_resolved: { |
| | 4393 | const nav_resolved = nav.resolved.?; |
| | 4394 | break :nav_resolved .{ nav_resolved.@"const", nav_resolved.type }; |
| | 4395 | }; |
| | 4396 | const src_inst = nav.srcInst(ip).resolveFull(ip).?; |
| | 4397 | const decl = zcu.fileByIndex(src_inst.file).zir.?.getDeclaration(src_inst.inst); |
| | 4398 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| | 4399 | nav.analysis.?.namespace, |
| 3416 | ).owner_type); | 4400 | ).owner_type); |
| 3417 | try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) { | 4401 | try dwarf.abbrevCode(di_nw, switch (nav_ty) { |
| 3418 | .@"struct" => .type_decl_specification_struct, | 4402 | .type_type => .decl_specification_type, |
| 3419 | .@"union" => .type_decl_specification_union, | 4403 | else => if (nav_const) .decl_specification_const else .decl_specification_var, |
| 3420 | .@"enum" => .type_decl_specification_enum, | | |
| 3421 | } else switch (kind) { | | |
| 3422 | .@"struct" => .type_decl_specification_empty_struct, | | |
| 3423 | .@"union" => .type_decl_specification_empty_union, | | |
| 3424 | .@"enum" => .type_decl_specification_empty_enum, | | |
| 3425 | }); | 4404 | }); |
| 3426 | try dwarf.secOffset(di_nw, parent_ni, 0); | 4405 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 3427 | try di_w.writeInt(u32, src_line + 1, dwarf.endian); | 4406 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 3428 | try di_w.writeUleb128(src_column + 1); | 4407 | try di_w.writeUleb128(decl.src_column + 1); |
| 3429 | try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip)); | 4408 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 3430 | } | 4409 | try dwarf.strx(di_nw, nav.name.toSlice(ip)); |
| 3431 | for (capture_names, captures.get(ip)) |capture_name, capture| { | 4410 | }, |
| 3432 | try dwarf.abbrevCode(di_nw, .capture_specification); | | |
| 3433 | switch (capture.unwrap()) { | | |
| 3434 | .@"comptime", .runtime, .nav_val => try dwarf.strp( | | |
| 3435 | &dwarf.debug_str, | | |
| 3436 | di_nw, | | |
| 3437 | zf.zir.?.nullTerminatedString(capture_name), | | |
| 3438 | ), | | |
| 3439 | .nav_ref => { | | |
| 3440 | const capture_name_slice = try zcu.gpa.print("&{s}", .{ | | |
| 3441 | zf.zir.?.nullTerminatedString(capture_name), | | |
| 3442 | }); | | |
| 3443 | defer zcu.gpa.free(capture_name_slice); | | |
| 3444 | try dwarf.strp(&dwarf.debug_str, di_nw, capture_name_slice); | | |
| 3445 | }, | | |
| 3446 | } | | |
| 3447 | } | | |
| 3448 | if (captures.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); | | |
| 3449 | } | 4411 | } |
| 3450 | try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen()); | 4412 | try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen()); |
| 3451 | } | 4413 | } |
| ... | @@ -3458,9 +4420,12 @@ pub fn updateLineNumber( | ... | @@ -3458,9 +4420,12 @@ pub fn updateLineNumber( |
| 3458 | ) void { | 4420 | ) void { |
| 3459 | const di = dwarf.getDeclIfExists(inst) orelse return; | 4421 | const di = dwarf.getDeclIfExists(inst) orelse return; |
| 3460 | const decl_ni = di.get(dwarf).debug_info_ni.unwrap().?; | 4422 | const decl_ni = di.get(dwarf).debug_info_ni.unwrap().?; |
| | 4423 | comptime assert(AbbrevCode.common_decl_attrs[0][1] == .ref_addr); |
| | 4424 | comptime assert(AbbrevCode.common_decl_attrs[1][0] == .decl_line); |
| | 4425 | comptime assert(AbbrevCode.common_decl_attrs[1][1] == .data4); |
| 3461 | std.mem.writeInt( | 4426 | std.mem.writeInt( |
| 3462 | u32, | 4427 | u32, |
| 3463 | decl_ni.slice(mf)[AbbrevCode.decl_size..][0..4], | 4428 | decl_ni.slice(mf)[AbbrevCode.decl_size + dwarf.secOffsetSize() ..][0..4], |
| 3464 | line + 1, | 4429 | line + 1, |
| 3465 | dwarf.endian, | 4430 | dwarf.endian, |
| 3466 | ); | 4431 | ); |
| ... | @@ -3486,8 +4451,11 @@ fn refAbbrevCode( | ... | @@ -3486,8 +4451,11 @@ fn refAbbrevCode( |
| 3486 | @branchHint(.likely); | 4451 | @branchHint(.likely); |
| 3487 | return backing_int; | 4452 | return backing_int; |
| 3488 | } | 4453 | } |
| | 4454 | const gpa = dwarf.lf.comp.gpa; |
| | 4455 | const debug_abbrev_ni = dwarf.debug_abbrev.ni.unwrap().?; |
| | 4456 | try debug_abbrev_ni.moved(gpa, mf); |
| 3489 | var da_nw: link.MappedFile.Node.Writer = undefined; | 4457 | var da_nw: link.MappedFile.Node.Writer = undefined; |
| 3490 | dwarf.debug_abbrev.ni.unwrap().?.writer(dwarf.lf.comp.gpa, mf, &da_nw); | 4458 | debug_abbrev_ni.writer(gpa, mf, &da_nw); |
| 3491 | defer da_nw.deinit(); | 4459 | defer da_nw.deinit(); |
| 3492 | dwarf.genDebugAbbrev(&da_nw, abbrev_code) catch |err| switch (err) { | 4460 | dwarf.genDebugAbbrev(&da_nw, abbrev_code) catch |err| switch (err) { |
| 3493 | else => |e| return e, | 4461 | else => |e| return e, |
| ... | @@ -3526,15 +4494,12 @@ fn genDebugAbbrev( | ... | @@ -3526,15 +4494,12 @@ fn genDebugAbbrev( |
| 3526 | dwarf.debug_abbrev.end = da_w.end; | 4494 | dwarf.debug_abbrev.end = da_w.end; |
| 3527 | } | 4495 | } |
| 3528 | | 4496 | |
| 3529 | pub fn secOffsetSize(dwarf: *Dwarf) usize { | 4497 | fn secOffsetSize(dwarf: *Dwarf) usize { |
| 3530 | return switch (dwarf.format) { | 4498 | return switch (dwarf.format) { |
| 3531 | .@"32" => 4, | 4499 | .@"32" => 4, |
| 3532 | .@"64" => 8, | 4500 | .@"64" => 8, |
| 3533 | }; | 4501 | }; |
| 3534 | } | 4502 | } |
| 3535 | fn secOffsetPlaceholder(dwarf: *Dwarf, w: *std.Io.Writer) std.Io.Writer.Error!void { | | |
| 3536 | @memset(try w.writableSlice(dwarf.secOffsetSize()), undefined); | | |
| 3537 | } | | |
| 3538 | fn secOffset( | 4503 | fn secOffset( |
| 3539 | dwarf: *Dwarf, | 4504 | dwarf: *Dwarf, |
| 3540 | nw: *link.MappedFile.Node.Writer, | 4505 | nw: *link.MappedFile.Node.Writer, |
| ... | @@ -3543,6 +4508,18 @@ fn secOffset( | ... | @@ -3543,6 +4508,18 @@ fn secOffset( |
| 3543 | ) link.EmitError!void { | 4508 | ) link.EmitError!void { |
| 3544 | const offset = nw.interface.end; | 4509 | const offset = nw.interface.end; |
| 3545 | try dwarf.secOffsetPlaceholder(&nw.interface); | 4510 | try dwarf.secOffsetPlaceholder(&nw.interface); |
| | 4511 | try dwarf.secOffsetFinish(nw, offset, target_ni, addend); |
| | 4512 | } |
| | 4513 | fn secOffsetPlaceholder(dwarf: *Dwarf, w: *std.Io.Writer) std.Io.Writer.Error!void { |
| | 4514 | @memset(try w.writableSlice(dwarf.secOffsetSize()), undefined); |
| | 4515 | } |
| | 4516 | fn secOffsetFinish( |
| | 4517 | dwarf: *Dwarf, |
| | 4518 | nw: *link.MappedFile.Node.Writer, |
| | 4519 | offset: usize, |
| | 4520 | target_ni: link.MappedFile.Node.Index, |
| | 4521 | addend: usize, |
| | 4522 | ) link.Error!void { |
| 3546 | if (dwarf.lf.cast(.elf2)) |elf| try elf.addNodeReloc( | 4523 | if (dwarf.lf.cast(.elf2)) |elf| try elf.addNodeReloc( |
| 3547 | nw.ni, | 4524 | nw.ni, |
| 3548 | offset, | 4525 | offset, |
| ... | @@ -3574,6 +4551,21 @@ fn addrSym( | ... | @@ -3574,6 +4551,21 @@ fn addrSym( |
| 3574 | .absAddr(elf), | 4551 | .absAddr(elf), |
| 3575 | ) else unreachable; | 4552 | ) else unreachable; |
| 3576 | } | 4553 | } |
| | 4554 | fn addrxSym(dwarf: *Dwarf, w: *std.Io.Writer, si: link.File.SymbolId) link.EmitError!void { |
| | 4555 | try w.writeUleb128(try dwarf.debug_addr.get(dwarf.lf.comp.gpa, si)); |
| | 4556 | } |
| | 4557 | fn addrx1Sym(dwarf: *Dwarf, w: *std.Io.Writer, si: link.File.SymbolId) link.EmitError!void { |
| | 4558 | try w.writeByte(@intCast(try dwarf.debug_addr.get(dwarf.lf.comp.gpa, si))); |
| | 4559 | } |
| | 4560 | fn addrx2Sym(dwarf: *Dwarf, w: *std.Io.Writer, si: link.File.SymbolId) link.EmitError!void { |
| | 4561 | try w.writeInt(u16, @intCast(try dwarf.debug_addr.get(dwarf.lf.comp.gpa, si)), dwarf.endian); |
| | 4562 | } |
| | 4563 | fn addrx3Sym(dwarf: *Dwarf, w: *std.Io.Writer, si: link.File.SymbolId) link.EmitError!void { |
| | 4564 | try w.writeInt(u24, @intCast(try dwarf.debug_addr.get(dwarf.lf.comp.gpa, si)), dwarf.endian); |
| | 4565 | } |
| | 4566 | fn addrx4Sym(dwarf: *Dwarf, w: *std.Io.Writer, si: link.File.SymbolId) link.EmitError!void { |
| | 4567 | try w.writeInt(u32, @intCast(try dwarf.debug_addr.get(dwarf.lf.comp.gpa, si)), dwarf.endian); |
| | 4568 | } |
| 3577 | | 4569 | |
| 3578 | fn blockConst( | 4570 | fn blockConst( |
| 3579 | dwarf: *Dwarf, | 4571 | dwarf: *Dwarf, |
| ... | @@ -3585,13 +4577,9 @@ fn blockConst( | ... | @@ -3585,13 +4577,9 @@ fn blockConst( |
| 3585 | const size = ty.abiSize(pt.zcu); | 4577 | const size = ty.abiSize(pt.zcu); |
| 3586 | try nw.interface.writeUleb128(size); | 4578 | try nw.interface.writeUleb128(size); |
| 3587 | const start = nw.interface.end; | 4579 | const start = nw.interface.end; |
| 3588 | if (size > 0) try codegen.generateSymbol( | 4580 | if (size > 0) try codegen.generateSymbol(dwarf.lf, pt, val, &nw.interface, .{ |
| 3589 | dwarf.lf, | 4581 | .atom_index = @bitCast(nw.ni), |
| 3590 | pt, | 4582 | }); |
| 3591 | val, | | |
| 3592 | &nw.interface, | | |
| 3593 | .{ .atom_index = @bitCast(nw.ni) }, | | |
| 3594 | ); | | |
| 3595 | assert(start + size == nw.interface.end); | 4583 | assert(start + size == nw.interface.end); |
| 3596 | } | 4584 | } |
| 3597 | | 4585 | |
| ... | @@ -3691,13 +4679,37 @@ fn exprLoc(dwarf: *Dwarf, nw: *link.MappedFile.Node.Writer, loc: Loc) link.EmitE | ... | @@ -3691,13 +4679,37 @@ fn exprLoc(dwarf: *Dwarf, nw: *link.MappedFile.Node.Writer, loc: Loc) link.EmitE |
| 3691 | fn strp(dwarf: *Dwarf, s: *Str, nw: *link.MappedFile.Node.Writer, str: []const u8) link.EmitError!void { | 4679 | fn strp(dwarf: *Dwarf, s: *Str, nw: *link.MappedFile.Node.Writer, str: []const u8) link.EmitError!void { |
| 3692 | const comp = dwarf.lf.comp; | 4680 | const comp = dwarf.lf.comp; |
| 3693 | try dwarf.secOffset(nw, s.ni.unwrap().?, s.get(comp.gpa, nw.mf, str) catch |err| switch (err) { | 4681 | try dwarf.secOffset(nw, s.ni.unwrap().?, s.get(comp.gpa, nw.mf, str) catch |err| switch (err) { |
| | 4682 | else => |e| return e, |
| 3694 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ | 4683 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| 3695 | nw.mf.io_err.?, | 4684 | nw.mf.io_err.?, |
| 3696 | }), | 4685 | }), |
| 3697 | else => |e| return e, | | |
| 3698 | }); | 4686 | }); |
| 3699 | } | 4687 | } |
| 3700 | | 4688 | |
| | 4689 | fn strx(dwarf: *Dwarf, nw: *link.MappedFile.Node.Writer, str: []const u8) link.EmitError!void { |
| | 4690 | try nw.interface.writeUleb128(try dwarf.debug_str_offsets.get(dwarf, &dwarf.debug_str, nw.mf, str)); |
| | 4691 | } |
| | 4692 | fn strx1(dwarf: *Dwarf, nw: *link.MappedFile.Node.Writer, str: []const u8) link.EmitError!void { |
| | 4693 | try nw.interface.writeByte(@intCast( |
| | 4694 | try dwarf.debug_str_offsets.get(dwarf, &dwarf.debug_str, nw.mf, str), |
| | 4695 | )); |
| | 4696 | } |
| | 4697 | fn strx2(dwarf: *Dwarf, nw: *link.MappedFile.Node.Writer, str: []const u8) link.EmitError!void { |
| | 4698 | try nw.interface.writeInt(u16, @intCast( |
| | 4699 | try dwarf.debug_str_offsets.get(dwarf, &dwarf.debug_str, nw.mf, str), |
| | 4700 | ), dwarf.endian); |
| | 4701 | } |
| | 4702 | fn strx3(dwarf: *Dwarf, nw: *link.MappedFile.Node.Writer, str: []const u8) link.EmitError!void { |
| | 4703 | try nw.interface.writeInt(u24, @intCast( |
| | 4704 | try dwarf.debug_str_offsets.get(dwarf, &dwarf.debug_str, nw.mf, str), |
| | 4705 | ), dwarf.endian); |
| | 4706 | } |
| | 4707 | fn strx4(dwarf: *Dwarf, nw: *link.MappedFile.Node.Writer, str: []const u8) link.EmitError!void { |
| | 4708 | try nw.interface.writeInt(u32, @intCast( |
| | 4709 | try dwarf.debug_str_offsets.get(dwarf, &dwarf.debug_str, nw.mf, str), |
| | 4710 | ), dwarf.endian); |
| | 4711 | } |
| | 4712 | |
| 3701 | fn reportWriteError(dwarf: *Dwarf, nw: *const link.MappedFile.Node.Writer) link.Error { | 4713 | fn reportWriteError(dwarf: *Dwarf, nw: *const link.MappedFile.Node.Writer) link.Error { |
| 3702 | switch (nw.err.?) { | 4714 | switch (nw.err.?) { |
| 3703 | else => |e| return e, | 4715 | else => |e| return e, |
| ... | @@ -3744,7 +4756,6 @@ pub const AbbrevCode = enum { | ... | @@ -3744,7 +4756,6 @@ pub const AbbrevCode = enum { |
| 3744 | pad_n, | 4756 | pad_n, |
| 3745 | // decl, specification, and instance codes are assumed to all have the same uleb128 size | 4757 | // decl, specification, and instance codes are assumed to all have the same uleb128 size |
| 3746 | decl_lost, | 4758 | decl_lost, |
| 3747 | decl_alias, | | |
| 3748 | decl_empty_incomplete_enum, | 4759 | decl_empty_incomplete_enum, |
| 3749 | decl_incomplete_enum, | 4760 | decl_incomplete_enum, |
| 3750 | decl_empty_enum, | 4761 | decl_empty_enum, |
| ... | @@ -3777,16 +4788,17 @@ pub const AbbrevCode = enum { | ... | @@ -3777,16 +4788,17 @@ pub const AbbrevCode = enum { |
| 3777 | decl_packed_union, | 4788 | decl_packed_union, |
| 3778 | type_decl_empty_packed_union, | 4789 | type_decl_empty_packed_union, |
| 3779 | type_decl_packed_union, | 4790 | type_decl_packed_union, |
| 3780 | decl_var, | 4791 | decl_type, |
| 3781 | decl_const, | 4792 | decl_const, |
| 3782 | decl_const_runtime_bits, | 4793 | decl_const_fully_runtime, |
| 3783 | decl_const_comptime_state, | 4794 | decl_const_partially_comptime, |
| 3784 | decl_const_runtime_bits_comptime_state, | 4795 | decl_const_fully_comptime, |
| 3785 | decl_nullary_func, | 4796 | decl_var, |
| | 4797 | decl_empty_func, |
| 3786 | decl_func, | 4798 | decl_func, |
| 3787 | decl_nullary_func_generic, | 4799 | decl_empty_func_generic, |
| 3788 | decl_func_generic, | 4800 | decl_func_generic, |
| 3789 | decl_extern_nullary_func, | 4801 | decl_extern_empty_func, |
| 3790 | decl_extern_func, | 4802 | decl_extern_func, |
| 3791 | decl_specification_empty_struct, | 4803 | decl_specification_empty_struct, |
| 3792 | decl_specification_struct, | 4804 | decl_specification_struct, |
| ... | @@ -3800,40 +4812,48 @@ pub const AbbrevCode = enum { | ... | @@ -3800,40 +4812,48 @@ pub const AbbrevCode = enum { |
| 3800 | decl_specification_union, | 4812 | decl_specification_union, |
| 3801 | type_decl_specification_empty_union, | 4813 | type_decl_specification_empty_union, |
| 3802 | type_decl_specification_union, | 4814 | type_decl_specification_union, |
| | 4815 | decl_specification_type, |
| | 4816 | decl_specification_const, |
| | 4817 | decl_specification_var, |
| 3803 | decl_specification_func, | 4818 | decl_specification_func, |
| 3804 | decl_instance_alias, | | |
| 3805 | decl_instance_empty_incomplete_enum, | 4819 | decl_instance_empty_incomplete_enum, |
| 3806 | decl_instance_incomplete_enum, | 4820 | decl_instance_incomplete_enum, |
| 3807 | decl_instance_empty_enum, | 4821 | decl_instance_empty_enum, |
| 3808 | decl_instance_enum, | 4822 | decl_instance_enum, |
| | 4823 | type_decl_instance_empty_enum, |
| | 4824 | type_decl_instance_enum, |
| 3809 | decl_instance_empty_incomplete_struct, | 4825 | decl_instance_empty_incomplete_struct, |
| 3810 | decl_instance_incomplete_struct, | 4826 | decl_instance_incomplete_struct, |
| 3811 | decl_instance_empty_struct, | 4827 | decl_instance_empty_struct, |
| 3812 | decl_instance_struct, | 4828 | decl_instance_struct, |
| | 4829 | type_decl_instance_empty_struct, |
| | 4830 | type_decl_instance_struct, |
| 3813 | decl_instance_empty_packed_struct, | 4831 | decl_instance_empty_packed_struct, |
| 3814 | decl_instance_packed_struct, | 4832 | decl_instance_packed_struct, |
| | 4833 | type_decl_instance_empty_packed_struct, |
| | 4834 | type_decl_instance_packed_struct, |
| 3815 | decl_instance_empty_incomplete_union, | 4835 | decl_instance_empty_incomplete_union, |
| 3816 | decl_instance_incomplete_union, | 4836 | decl_instance_incomplete_union, |
| 3817 | decl_instance_empty_union, | 4837 | decl_instance_empty_union, |
| 3818 | decl_instance_union, | 4838 | decl_instance_union, |
| | 4839 | type_decl_instance_empty_union, |
| | 4840 | type_decl_instance_union, |
| 3819 | decl_instance_empty_packed_union, | 4841 | decl_instance_empty_packed_union, |
| 3820 | decl_instance_packed_union, | 4842 | decl_instance_packed_union, |
| 3821 | decl_instance_var, | 4843 | type_decl_instance_empty_packed_union, |
| | 4844 | type_decl_instance_packed_union, |
| | 4845 | decl_instance_type, |
| 3822 | decl_instance_const, | 4846 | decl_instance_const, |
| 3823 | decl_instance_const_runtime_bits, | 4847 | decl_instance_const_fully_runtime, |
| 3824 | decl_instance_const_comptime_state, | 4848 | decl_instance_const_partially_comptime, |
| 3825 | decl_instance_const_runtime_bits_comptime_state, | 4849 | decl_instance_const_fully_comptime, |
| 3826 | decl_instance_nullary_func, | 4850 | decl_instance_var, |
| | 4851 | decl_instance_empty_func, |
| 3827 | decl_instance_func, | 4852 | decl_instance_func, |
| 3828 | decl_instance_nullary_func_generic, | 4853 | decl_instance_empty_func_generic, |
| 3829 | decl_instance_func_generic, | 4854 | decl_instance_func_generic, |
| 3830 | decl_instance_extern_nullary_func, | | |
| 3831 | decl_instance_extern_func, | | |
| 3832 | // the rest are unrestricted other than empty variants must not be longer | 4855 | // the rest are unrestricted other than empty variants must not be longer |
| 3833 | // than the non-empty variant, and so should appear first | 4856 | // than the non-empty variant, and so should appear first |
| 3834 | compile_unit, | | |
| 3835 | module, | | |
| 3836 | module_dependency, | | |
| 3837 | empty_file, | 4857 | empty_file, |
| 3838 | file, | 4858 | file, |
| 3839 | access, | 4859 | access, |
| ... | @@ -3856,8 +4876,7 @@ pub const AbbrevCode = enum { | ... | @@ -3856,8 +4876,7 @@ pub const AbbrevCode = enum { |
| 3856 | inferred_error_set_type, | 4876 | inferred_error_set_type, |
| 3857 | ptr_type, | 4877 | ptr_type, |
| 3858 | ptr_sentinel_type, | 4878 | ptr_sentinel_type, |
| 3859 | ptr_aligned_type, | 4879 | is_aligned, |
| 3860 | ptr_aligned_sentinel_type, | | |
| 3861 | is_const, | 4880 | is_const, |
| 3862 | is_volatile, | 4881 | is_volatile, |
| 3863 | array_type, | 4882 | array_type, |
| ... | @@ -3865,7 +4884,7 @@ pub const AbbrevCode = enum { | ... | @@ -3865,7 +4884,7 @@ pub const AbbrevCode = enum { |
| 3865 | vector_type, | 4884 | vector_type, |
| 3866 | array_index, | 4885 | array_index, |
| 3867 | array_len, | 4886 | array_len, |
| 3868 | nullary_func_type, | 4887 | empty_func_type, |
| 3869 | func_type, | 4888 | func_type, |
| 3870 | param, | 4889 | param, |
| 3871 | unnamed_param, | 4890 | unnamed_param, |
| ... | @@ -3882,7 +4901,7 @@ pub const AbbrevCode = enum { | ... | @@ -3882,7 +4901,7 @@ pub const AbbrevCode = enum { |
| 3882 | comptime_capture_fully_comptime, | 4901 | comptime_capture_fully_comptime, |
| 3883 | runtime_capture, | 4902 | runtime_capture, |
| 3884 | nav_capture, | 4903 | nav_capture, |
| 3885 | builtin_extern_nullary_func, | 4904 | builtin_extern_empty_func, |
| 3886 | builtin_extern_func, | 4905 | builtin_extern_func, |
| 3887 | builtin_extern_var, | 4906 | builtin_extern_var, |
| 3888 | empty_block, | 4907 | empty_block, |
| ... | @@ -3911,44 +4930,51 @@ pub const AbbrevCode = enum { | ... | @@ -3911,44 +4930,51 @@ pub const AbbrevCode = enum { |
| 3911 | aggregate_undefined_comptime_value, | 4930 | aggregate_undefined_comptime_value, |
| 3912 | aggregate_comptime_value, | 4931 | aggregate_comptime_value, |
| 3913 | aggregate_location_comptime_value, | 4932 | aggregate_location_comptime_value, |
| 3914 | comptime_value_field_runtime_bits, | 4933 | comptime_value_field_runtime, |
| 3915 | comptime_value_field_comptime_state, | 4934 | comptime_value_field_comptime, |
| 3916 | comptime_value_elem_runtime_bits, | 4935 | comptime_value_elem_runtime, |
| 3917 | comptime_value_elem_comptime_state, | 4936 | comptime_value_elem_comptime, |
| | 4937 | // low-frequency should appear last |
| | 4938 | compile_unit, |
| | 4939 | module, |
| | 4940 | module_dependency, |
| 3918 | | 4941 | |
| 3919 | const decl_size = uleb128Size(@backingInt(AbbrevCode.decl_instance_extern_func)); | 4942 | const decl_size = uleb128Size(@backingInt(AbbrevCode.decl_func_generic)); |
| 3920 | comptime { | 4943 | comptime { |
| 3921 | assert(uleb128Size(@backingInt(AbbrevCode.pad_1)) == 1); | 4944 | assert(uleb128Size(@backingInt(AbbrevCode.pad_1)) == 1); |
| 3922 | assert(uleb128Size(@backingInt(AbbrevCode.pad_n)) == 1); | 4945 | assert(uleb128Size(@backingInt(AbbrevCode.pad_n)) == 1); |
| 3923 | assert(uleb128Size(@backingInt(AbbrevCode.decl_alias)) == decl_size); | 4946 | assert(uleb128Size(@backingInt(AbbrevCode.decl_lost)) == decl_size); |
| 3924 | } | 4947 | } |
| 3925 | | 4948 | |
| 3926 | const Attr = struct { | 4949 | const Attr = struct { |
| 3927 | DeclValEnum(DW.AT), | 4950 | DeclValEnum(DW.AT), |
| 3928 | DeclValEnum(DW.FORM), | 4951 | DeclValEnum(DW.FORM), |
| 3929 | }; | 4952 | }; |
| 3930 | const decl_attrs = &[_]Attr{ | 4953 | const common_decl_attrs = &[_]Attr{ |
| 3931 | .{ .ZIG_parent, .ref_addr }, | 4954 | .{ .ZIG_parent, .ref_addr }, |
| 3932 | .{ .decl_line, .data4 }, | 4955 | .{ .decl_line, .data4 }, |
| 3933 | .{ .decl_column, .udata }, | 4956 | .{ .decl_column, .udata }, |
| | 4957 | }; |
| | 4958 | const decl_attrs = common_decl_attrs ++ .{ |
| 3934 | .{ .accessibility, .data1 }, | 4959 | .{ .accessibility, .data1 }, |
| 3935 | .{ .name, .strp }, | 4960 | .{ .name, .strx }, |
| 3936 | }; | 4961 | }; |
| 3937 | const type_decl_attrs = &[_]Attr{ | 4962 | const type_decl_attrs = common_decl_attrs ++ .{ |
| 3938 | .{ .ZIG_parent, .ref_addr }, | 4963 | .{ .name, .strx }, |
| 3939 | .{ .decl_line, .data4 }, | | |
| 3940 | .{ .decl_column, .udata }, | | |
| 3941 | .{ .name, .strp }, | | |
| 3942 | }; | 4964 | }; |
| 3943 | const decl_specification_attrs = decl_attrs ++ &[_]Attr{ | 4965 | const decl_specification_attrs = decl_attrs ++ &[_]Attr{ |
| 3944 | .{ .declaration, .flag_present }, | 4966 | .{ .declaration, .flag_present }, |
| 3945 | }; | 4967 | }; |
| 3946 | const type_decl_specification_attrs = type_decl_attrs ++ &[_]Attr{ | 4968 | const type_decl_specification_attrs = common_decl_attrs ++ &[_]Attr{ |
| 3947 | .{ .declaration, .flag_present }, | 4969 | .{ .declaration, .flag_present }, |
| 3948 | }; | 4970 | }; |
| 3949 | const decl_instance_attrs = &[_]Attr{ | 4971 | const decl_instance_attrs = &[_]Attr{ |
| | 4972 | .{ .ZIG_parent, .ref_addr }, |
| 3950 | .{ .specification, .ref_addr }, | 4973 | .{ .specification, .ref_addr }, |
| 3951 | }; | 4974 | }; |
| | 4975 | const type_decl_instance_attrs = decl_instance_attrs ++ .{ |
| | 4976 | .{ .name, .strx }, |
| | 4977 | }; |
| 3952 | | 4978 | |
| 3953 | const abbrevs = std.EnumArray(AbbrevCode, struct { | 4979 | const abbrevs = std.EnumArray(AbbrevCode, struct { |
| 3954 | tag: DeclValEnum(DW.TAG), | 4980 | tag: DeclValEnum(DW.TAG), |
| ... | @@ -3968,12 +4994,6 @@ pub const AbbrevCode = enum { | ... | @@ -3968,12 +4994,6 @@ pub const AbbrevCode = enum { |
| 3968 | .decl_lost = .{ | 4994 | .decl_lost = .{ |
| 3969 | .tag = .ZIG_lost_declaration, | 4995 | .tag = .ZIG_lost_declaration, |
| 3970 | }, | 4996 | }, |
| 3971 | .decl_alias = .{ | | |
| 3972 | .tag = .imported_declaration, | | |
| 3973 | .attrs = decl_attrs ++ .{ | | |
| 3974 | .{ .import, .ref_addr }, | | |
| 3975 | }, | | |
| 3976 | }, | | |
| 3977 | .decl_empty_incomplete_enum = .{ | 4997 | .decl_empty_incomplete_enum = .{ |
| 3978 | .tag = .enumeration_type, | 4998 | .tag = .enumeration_type, |
| 3979 | .attrs = decl_attrs, | 4999 | .attrs = decl_attrs, |
| ... | @@ -4166,62 +5186,68 @@ pub const AbbrevCode = enum { | ... | @@ -4166,62 +5186,68 @@ pub const AbbrevCode = enum { |
| 4166 | .{ .type, .ref_addr }, | 5186 | .{ .type, .ref_addr }, |
| 4167 | }, | 5187 | }, |
| 4168 | }, | 5188 | }, |
| 4169 | .decl_var = .{ | 5189 | .decl_type = .{ |
| 4170 | .tag = .variable, | 5190 | .tag = .imported_declaration, |
| 4171 | .attrs = decl_attrs ++ .{ | 5191 | .attrs = decl_attrs ++ .{ |
| 4172 | .{ .linkage_name, .strp }, | 5192 | .{ .import, .ref_addr }, |
| 4173 | .{ .type, .ref_addr }, | | |
| 4174 | .{ .location, .exprloc }, | | |
| 4175 | .{ .alignment, .udata }, | | |
| 4176 | .{ .external, .flag }, | | |
| 4177 | }, | 5193 | }, |
| 4178 | }, | 5194 | }, |
| 4179 | .decl_const = .{ | 5195 | .decl_const = .{ |
| 4180 | .tag = .constant, | 5196 | .tag = .constant, |
| 4181 | .attrs = decl_attrs ++ .{ | 5197 | .attrs = decl_attrs ++ .{ |
| 4182 | .{ .linkage_name, .strp }, | 5198 | .{ .linkage_name, .strx }, |
| 4183 | .{ .type, .ref_addr }, | 5199 | .{ .type, .ref_addr }, |
| 4184 | .{ .alignment, .udata }, | 5200 | .{ .alignment, .udata }, |
| 4185 | .{ .external, .flag }, | 5201 | .{ .external, .flag }, |
| 4186 | }, | 5202 | }, |
| 4187 | }, | 5203 | }, |
| 4188 | .decl_const_runtime_bits = .{ | 5204 | .decl_const_fully_runtime = .{ |
| 4189 | .tag = .constant, | 5205 | .tag = .constant, |
| 4190 | .attrs = decl_attrs ++ .{ | 5206 | .attrs = decl_attrs ++ .{ |
| 4191 | .{ .linkage_name, .strp }, | 5207 | .{ .linkage_name, .strx }, |
| 4192 | .{ .type, .ref_addr }, | 5208 | .{ .type, .ref_addr }, |
| 4193 | .{ .alignment, .udata }, | 5209 | .{ .alignment, .udata }, |
| 4194 | .{ .external, .flag }, | 5210 | .{ .external, .flag }, |
| 4195 | .{ .const_value, .block }, | 5211 | .{ .const_value, .block }, |
| 4196 | }, | 5212 | }, |
| 4197 | }, | 5213 | }, |
| 4198 | .decl_const_comptime_state = .{ | 5214 | .decl_const_partially_comptime = .{ |
| 4199 | .tag = .constant, | 5215 | .tag = .constant, |
| 4200 | .attrs = decl_attrs ++ .{ | 5216 | .attrs = decl_attrs ++ .{ |
| 4201 | .{ .linkage_name, .strp }, | 5217 | .{ .linkage_name, .strx }, |
| 4202 | .{ .type, .ref_addr }, | 5218 | .{ .type, .ref_addr }, |
| 4203 | .{ .alignment, .udata }, | 5219 | .{ .alignment, .udata }, |
| 4204 | .{ .external, .flag }, | 5220 | .{ .external, .flag }, |
| | 5221 | .{ .const_value, .block }, |
| 4205 | .{ .ZIG_comptime_value, .ref_addr }, | 5222 | .{ .ZIG_comptime_value, .ref_addr }, |
| 4206 | }, | 5223 | }, |
| 4207 | }, | 5224 | }, |
| 4208 | .decl_const_runtime_bits_comptime_state = .{ | 5225 | .decl_const_fully_comptime = .{ |
| 4209 | .tag = .constant, | 5226 | .tag = .constant, |
| 4210 | .attrs = decl_attrs ++ .{ | 5227 | .attrs = decl_attrs ++ .{ |
| 4211 | .{ .linkage_name, .strp }, | 5228 | .{ .linkage_name, .strx }, |
| 4212 | .{ .type, .ref_addr }, | 5229 | .{ .type, .ref_addr }, |
| 4213 | .{ .alignment, .udata }, | 5230 | .{ .alignment, .udata }, |
| 4214 | .{ .external, .flag }, | 5231 | .{ .external, .flag }, |
| 4215 | .{ .const_value, .block }, | | |
| 4216 | .{ .ZIG_comptime_value, .ref_addr }, | 5232 | .{ .ZIG_comptime_value, .ref_addr }, |
| 4217 | }, | 5233 | }, |
| 4218 | }, | 5234 | }, |
| 4219 | .decl_nullary_func = .{ | 5235 | .decl_var = .{ |
| | 5236 | .tag = .variable, |
| | 5237 | .attrs = decl_attrs ++ .{ |
| | 5238 | .{ .linkage_name, .strx }, |
| | 5239 | .{ .type, .ref_addr }, |
| | 5240 | .{ .location, .exprloc }, |
| | 5241 | .{ .alignment, .udata }, |
| | 5242 | .{ .external, .flag }, |
| | 5243 | }, |
| | 5244 | }, |
| | 5245 | .decl_empty_func = .{ |
| 4220 | .tag = .subprogram, | 5246 | .tag = .subprogram, |
| 4221 | .attrs = decl_attrs ++ .{ | 5247 | .attrs = decl_attrs ++ .{ |
| 4222 | .{ .linkage_name, .strp }, | 5248 | .{ .linkage_name, .strx }, |
| 4223 | .{ .type, .ref_addr }, | 5249 | .{ .type, .ref_addr }, |
| 4224 | .{ .low_pc, .addr }, | 5250 | .{ .low_pc, .addrx }, |
| 4225 | .{ .high_pc, .data4 }, | 5251 | .{ .high_pc, .data4 }, |
| 4226 | .{ .alignment, .udata }, | 5252 | .{ .alignment, .udata }, |
| 4227 | .{ .external, .flag }, | 5253 | .{ .external, .flag }, |
| ... | @@ -4232,20 +5258,19 @@ pub const AbbrevCode = enum { | ... | @@ -4232,20 +5258,19 @@ pub const AbbrevCode = enum { |
| 4232 | .tag = .subprogram, | 5258 | .tag = .subprogram, |
| 4233 | .children = true, | 5259 | .children = true, |
| 4234 | .attrs = decl_attrs ++ .{ | 5260 | .attrs = decl_attrs ++ .{ |
| 4235 | .{ .linkage_name, .strp }, | 5261 | .{ .linkage_name, .strx }, |
| 4236 | .{ .type, .ref_addr }, | 5262 | .{ .type, .ref_addr }, |
| 4237 | .{ .low_pc, .addr }, | 5263 | .{ .low_pc, .addrx }, |
| 4238 | .{ .high_pc, .data4 }, | 5264 | .{ .high_pc, .data4 }, |
| 4239 | .{ .alignment, .udata }, | 5265 | .{ .alignment, .udata }, |
| 4240 | .{ .external, .flag }, | 5266 | .{ .external, .flag }, |
| 4241 | .{ .noreturn, .flag }, | 5267 | .{ .noreturn, .flag }, |
| 4242 | }, | 5268 | }, |
| 4243 | }, | 5269 | }, |
| 4244 | .decl_nullary_func_generic = .{ | 5270 | .decl_empty_func_generic = .{ |
| 4245 | .tag = .subprogram, | 5271 | .tag = .subprogram, |
| 4246 | .attrs = decl_attrs ++ .{ | 5272 | .attrs = decl_attrs ++ .{ |
| 4247 | .{ .type, .ref_addr }, | 5273 | .{ .type, .ref_addr }, |
| 4248 | .{ .noreturn, .flag }, | | |
| 4249 | }, | 5274 | }, |
| 4250 | }, | 5275 | }, |
| 4251 | .decl_func_generic = .{ | 5276 | .decl_func_generic = .{ |
| ... | @@ -4255,10 +5280,10 @@ pub const AbbrevCode = enum { | ... | @@ -4255,10 +5280,10 @@ pub const AbbrevCode = enum { |
| 4255 | .{ .type, .ref_addr }, | 5280 | .{ .type, .ref_addr }, |
| 4256 | }, | 5281 | }, |
| 4257 | }, | 5282 | }, |
| 4258 | .decl_extern_nullary_func = .{ | 5283 | .decl_extern_empty_func = .{ |
| 4259 | .tag = .subprogram, | 5284 | .tag = .subprogram, |
| 4260 | .attrs = decl_attrs ++ .{ | 5285 | .attrs = decl_attrs ++ .{ |
| 4261 | .{ .linkage_name, .strp }, | 5286 | .{ .linkage_name, .strx }, |
| 4262 | .{ .type, .ref_addr }, | 5287 | .{ .type, .ref_addr }, |
| 4263 | .{ .low_pc, .addr }, | 5288 | .{ .low_pc, .addr }, |
| 4264 | .{ .external, .flag_present }, | 5289 | .{ .external, .flag_present }, |
| ... | @@ -4269,7 +5294,7 @@ pub const AbbrevCode = enum { | ... | @@ -4269,7 +5294,7 @@ pub const AbbrevCode = enum { |
| 4269 | .tag = .subprogram, | 5294 | .tag = .subprogram, |
| 4270 | .children = true, | 5295 | .children = true, |
| 4271 | .attrs = decl_attrs ++ .{ | 5296 | .attrs = decl_attrs ++ .{ |
| 4272 | .{ .linkage_name, .strp }, | 5297 | .{ .linkage_name, .strx }, |
| 4273 | .{ .type, .ref_addr }, | 5298 | .{ .type, .ref_addr }, |
| 4274 | .{ .low_pc, .addr }, | 5299 | .{ .low_pc, .addr }, |
| 4275 | .{ .external, .flag_present }, | 5300 | .{ .external, .flag_present }, |
| ... | @@ -4330,16 +5355,22 @@ pub const AbbrevCode = enum { | ... | @@ -4330,16 +5355,22 @@ pub const AbbrevCode = enum { |
| 4330 | .children = true, | 5355 | .children = true, |
| 4331 | .attrs = type_decl_specification_attrs, | 5356 | .attrs = type_decl_specification_attrs, |
| 4332 | }, | 5357 | }, |
| | 5358 | .decl_specification_type = .{ |
| | 5359 | .tag = .imported_declaration, |
| | 5360 | .attrs = decl_specification_attrs, |
| | 5361 | }, |
| | 5362 | .decl_specification_const = .{ |
| | 5363 | .tag = .constant, |
| | 5364 | .attrs = decl_specification_attrs, |
| | 5365 | }, |
| | 5366 | .decl_specification_var = .{ |
| | 5367 | .tag = .variable, |
| | 5368 | .attrs = decl_specification_attrs, |
| | 5369 | }, |
| 4333 | .decl_specification_func = .{ | 5370 | .decl_specification_func = .{ |
| 4334 | .tag = .subprogram, | 5371 | .tag = .subprogram, |
| 4335 | .attrs = decl_specification_attrs, | 5372 | .attrs = decl_specification_attrs, |
| 4336 | }, | 5373 | }, |
| 4337 | .decl_instance_alias = .{ | | |
| 4338 | .tag = .imported_declaration, | | |
| 4339 | .attrs = decl_instance_attrs ++ .{ | | |
| 4340 | .{ .import, .ref_addr }, | | |
| 4341 | }, | | |
| 4342 | }, | | |
| 4343 | .decl_instance_empty_incomplete_enum = .{ | 5374 | .decl_instance_empty_incomplete_enum = .{ |
| 4344 | .tag = .enumeration_type, | 5375 | .tag = .enumeration_type, |
| 4345 | .attrs = decl_instance_attrs, | 5376 | .attrs = decl_instance_attrs, |
| ... | @@ -4362,6 +5393,19 @@ pub const AbbrevCode = enum { | ... | @@ -4362,6 +5393,19 @@ pub const AbbrevCode = enum { |
| 4362 | .{ .type, .ref_addr }, | 5393 | .{ .type, .ref_addr }, |
| 4363 | }, | 5394 | }, |
| 4364 | }, | 5395 | }, |
| | 5396 | .type_decl_instance_empty_enum = .{ |
| | 5397 | .tag = .enumeration_type, |
| | 5398 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5399 | .{ .type, .ref_addr }, |
| | 5400 | }, |
| | 5401 | }, |
| | 5402 | .type_decl_instance_enum = .{ |
| | 5403 | .tag = .enumeration_type, |
| | 5404 | .children = true, |
| | 5405 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5406 | .{ .type, .ref_addr }, |
| | 5407 | }, |
| | 5408 | }, |
| 4365 | .decl_instance_empty_incomplete_struct = .{ | 5409 | .decl_instance_empty_incomplete_struct = .{ |
| 4366 | .tag = .structure_type, | 5410 | .tag = .structure_type, |
| 4367 | .attrs = decl_instance_attrs, | 5411 | .attrs = decl_instance_attrs, |
| ... | @@ -4386,6 +5430,21 @@ pub const AbbrevCode = enum { | ... | @@ -4386,6 +5430,21 @@ pub const AbbrevCode = enum { |
| 4386 | .{ .alignment, .udata }, | 5430 | .{ .alignment, .udata }, |
| 4387 | }, | 5431 | }, |
| 4388 | }, | 5432 | }, |
| | 5433 | .type_decl_instance_empty_struct = .{ |
| | 5434 | .tag = .structure_type, |
| | 5435 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5436 | .{ .byte_size, .udata }, |
| | 5437 | .{ .alignment, .udata }, |
| | 5438 | }, |
| | 5439 | }, |
| | 5440 | .type_decl_instance_struct = .{ |
| | 5441 | .tag = .structure_type, |
| | 5442 | .children = true, |
| | 5443 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5444 | .{ .byte_size, .udata }, |
| | 5445 | .{ .alignment, .udata }, |
| | 5446 | }, |
| | 5447 | }, |
| 4389 | .decl_instance_empty_packed_struct = .{ | 5448 | .decl_instance_empty_packed_struct = .{ |
| 4390 | .tag = .structure_type, | 5449 | .tag = .structure_type, |
| 4391 | .attrs = decl_instance_attrs ++ .{ | 5450 | .attrs = decl_instance_attrs ++ .{ |
| ... | @@ -4399,6 +5458,19 @@ pub const AbbrevCode = enum { | ... | @@ -4399,6 +5458,19 @@ pub const AbbrevCode = enum { |
| 4399 | .{ .type, .ref_addr }, | 5458 | .{ .type, .ref_addr }, |
| 4400 | }, | 5459 | }, |
| 4401 | }, | 5460 | }, |
| | 5461 | .type_decl_instance_empty_packed_struct = .{ |
| | 5462 | .tag = .structure_type, |
| | 5463 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5464 | .{ .type, .ref_addr }, |
| | 5465 | }, |
| | 5466 | }, |
| | 5467 | .type_decl_instance_packed_struct = .{ |
| | 5468 | .tag = .structure_type, |
| | 5469 | .children = true, |
| | 5470 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5471 | .{ .type, .ref_addr }, |
| | 5472 | }, |
| | 5473 | }, |
| 4402 | .decl_instance_empty_incomplete_union = .{ | 5474 | .decl_instance_empty_incomplete_union = .{ |
| 4403 | .tag = .union_type, | 5475 | .tag = .union_type, |
| 4404 | .attrs = decl_instance_attrs, | 5476 | .attrs = decl_instance_attrs, |
| ... | @@ -4423,6 +5495,21 @@ pub const AbbrevCode = enum { | ... | @@ -4423,6 +5495,21 @@ pub const AbbrevCode = enum { |
| 4423 | .{ .alignment, .udata }, | 5495 | .{ .alignment, .udata }, |
| 4424 | }, | 5496 | }, |
| 4425 | }, | 5497 | }, |
| | 5498 | .type_decl_instance_empty_union = .{ |
| | 5499 | .tag = .union_type, |
| | 5500 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5501 | .{ .byte_size, .udata }, |
| | 5502 | .{ .alignment, .udata }, |
| | 5503 | }, |
| | 5504 | }, |
| | 5505 | .type_decl_instance_union = .{ |
| | 5506 | .tag = .union_type, |
| | 5507 | .children = true, |
| | 5508 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5509 | .{ .byte_size, .udata }, |
| | 5510 | .{ .alignment, .udata }, |
| | 5511 | }, |
| | 5512 | }, |
| 4426 | .decl_instance_empty_packed_union = .{ | 5513 | .decl_instance_empty_packed_union = .{ |
| 4427 | .tag = .union_type, | 5514 | .tag = .union_type, |
| 4428 | .attrs = decl_instance_attrs ++ .{ | 5515 | .attrs = decl_instance_attrs ++ .{ |
| ... | @@ -4436,150 +5523,118 @@ pub const AbbrevCode = enum { | ... | @@ -4436,150 +5523,118 @@ pub const AbbrevCode = enum { |
| 4436 | .{ .type, .ref_addr }, | 5523 | .{ .type, .ref_addr }, |
| 4437 | }, | 5524 | }, |
| 4438 | }, | 5525 | }, |
| 4439 | .decl_instance_var = .{ | 5526 | .type_decl_instance_empty_packed_union = .{ |
| 4440 | .tag = .variable, | 5527 | .tag = .union_type, |
| 4441 | .attrs = decl_instance_attrs ++ .{ | 5528 | .attrs = type_decl_instance_attrs ++ .{ |
| 4442 | .{ .linkage_name, .strp }, | | |
| 4443 | .{ .type, .ref_addr }, | 5529 | .{ .type, .ref_addr }, |
| 4444 | .{ .location, .exprloc }, | 5530 | }, |
| 4445 | .{ .alignment, .udata }, | 5531 | }, |
| 4446 | .{ .external, .flag }, | 5532 | .type_decl_instance_packed_union = .{ |
| | 5533 | .tag = .union_type, |
| | 5534 | .children = true, |
| | 5535 | .attrs = type_decl_instance_attrs ++ .{ |
| | 5536 | .{ .type, .ref_addr }, |
| | 5537 | }, |
| | 5538 | }, |
| | 5539 | .decl_instance_type = .{ |
| | 5540 | .tag = .imported_declaration, |
| | 5541 | .attrs = decl_instance_attrs ++ .{ |
| | 5542 | .{ .import, .ref_addr }, |
| 4447 | }, | 5543 | }, |
| 4448 | }, | 5544 | }, |
| 4449 | .decl_instance_const = .{ | 5545 | .decl_instance_const = .{ |
| 4450 | .tag = .constant, | 5546 | .tag = .constant, |
| 4451 | .attrs = decl_instance_attrs ++ .{ | 5547 | .attrs = decl_instance_attrs ++ .{ |
| 4452 | .{ .linkage_name, .strp }, | 5548 | .{ .linkage_name, .strx }, |
| 4453 | .{ .type, .ref_addr }, | 5549 | .{ .type, .ref_addr }, |
| 4454 | .{ .alignment, .udata }, | 5550 | .{ .alignment, .udata }, |
| 4455 | .{ .external, .flag }, | 5551 | .{ .external, .flag }, |
| 4456 | }, | 5552 | }, |
| 4457 | }, | 5553 | }, |
| 4458 | .decl_instance_const_runtime_bits = .{ | 5554 | .decl_instance_const_fully_runtime = .{ |
| 4459 | .tag = .constant, | 5555 | .tag = .constant, |
| 4460 | .attrs = decl_instance_attrs ++ .{ | 5556 | .attrs = decl_instance_attrs ++ .{ |
| 4461 | .{ .linkage_name, .strp }, | 5557 | .{ .linkage_name, .strx }, |
| 4462 | .{ .type, .ref_addr }, | 5558 | .{ .type, .ref_addr }, |
| 4463 | .{ .alignment, .udata }, | 5559 | .{ .alignment, .udata }, |
| 4464 | .{ .external, .flag }, | 5560 | .{ .external, .flag }, |
| 4465 | .{ .const_value, .block }, | 5561 | .{ .const_value, .block }, |
| 4466 | }, | 5562 | }, |
| 4467 | }, | 5563 | }, |
| 4468 | .decl_instance_const_comptime_state = .{ | 5564 | .decl_instance_const_partially_comptime = .{ |
| 4469 | .tag = .constant, | 5565 | .tag = .constant, |
| 4470 | .attrs = decl_instance_attrs ++ .{ | 5566 | .attrs = decl_instance_attrs ++ .{ |
| 4471 | .{ .linkage_name, .strp }, | 5567 | .{ .linkage_name, .strx }, |
| 4472 | .{ .type, .ref_addr }, | 5568 | .{ .type, .ref_addr }, |
| 4473 | .{ .alignment, .udata }, | 5569 | .{ .alignment, .udata }, |
| 4474 | .{ .external, .flag }, | 5570 | .{ .external, .flag }, |
| | 5571 | .{ .const_value, .block }, |
| 4475 | .{ .ZIG_comptime_value, .ref_addr }, | 5572 | .{ .ZIG_comptime_value, .ref_addr }, |
| 4476 | }, | 5573 | }, |
| 4477 | }, | 5574 | }, |
| 4478 | .decl_instance_const_runtime_bits_comptime_state = .{ | 5575 | .decl_instance_const_fully_comptime = .{ |
| 4479 | .tag = .constant, | 5576 | .tag = .constant, |
| 4480 | .attrs = decl_instance_attrs ++ .{ | 5577 | .attrs = decl_instance_attrs ++ .{ |
| 4481 | .{ .linkage_name, .strp }, | 5578 | .{ .linkage_name, .strx }, |
| 4482 | .{ .type, .ref_addr }, | 5579 | .{ .type, .ref_addr }, |
| 4483 | .{ .alignment, .udata }, | 5580 | .{ .alignment, .udata }, |
| 4484 | .{ .external, .flag }, | 5581 | .{ .external, .flag }, |
| 4485 | .{ .const_value, .block }, | | |
| 4486 | .{ .ZIG_comptime_value, .ref_addr }, | 5582 | .{ .ZIG_comptime_value, .ref_addr }, |
| 4487 | }, | 5583 | }, |
| 4488 | }, | 5584 | }, |
| 4489 | .decl_instance_nullary_func = .{ | 5585 | .decl_instance_var = .{ |
| 4490 | .tag = .subprogram, | 5586 | .tag = .variable, |
| 4491 | .attrs = decl_instance_attrs ++ .{ | 5587 | .attrs = decl_instance_attrs ++ .{ |
| 4492 | .{ .linkage_name, .strp }, | 5588 | .{ .linkage_name, .strx }, |
| 4493 | .{ .type, .ref_addr }, | 5589 | .{ .type, .ref_addr }, |
| 4494 | .{ .low_pc, .addr }, | 5590 | .{ .location, .exprloc }, |
| 4495 | .{ .high_pc, .data4 }, | | |
| 4496 | .{ .alignment, .udata }, | 5591 | .{ .alignment, .udata }, |
| 4497 | .{ .external, .flag }, | 5592 | .{ .external, .flag }, |
| 4498 | .{ .noreturn, .flag }, | | |
| 4499 | }, | 5593 | }, |
| 4500 | }, | 5594 | }, |
| 4501 | .decl_instance_func = .{ | 5595 | .decl_instance_empty_func = .{ |
| 4502 | .tag = .subprogram, | 5596 | .tag = .subprogram, |
| 4503 | .children = true, | | |
| 4504 | .attrs = decl_instance_attrs ++ .{ | 5597 | .attrs = decl_instance_attrs ++ .{ |
| 4505 | .{ .linkage_name, .strp }, | 5598 | .{ .linkage_name, .strx }, |
| 4506 | .{ .type, .ref_addr }, | 5599 | .{ .type, .ref_addr }, |
| 4507 | .{ .low_pc, .addr }, | 5600 | .{ .low_pc, .addrx }, |
| 4508 | .{ .high_pc, .data4 }, | 5601 | .{ .high_pc, .data4 }, |
| 4509 | .{ .alignment, .udata }, | 5602 | .{ .alignment, .udata }, |
| 4510 | .{ .external, .flag }, | 5603 | .{ .external, .flag }, |
| 4511 | .{ .noreturn, .flag }, | 5604 | .{ .noreturn, .flag }, |
| 4512 | }, | 5605 | }, |
| 4513 | }, | 5606 | }, |
| 4514 | .decl_instance_nullary_func_generic = .{ | 5607 | .decl_instance_func = .{ |
| 4515 | .tag = .subprogram, | | |
| 4516 | .attrs = decl_instance_attrs ++ .{ | | |
| 4517 | .{ .type, .ref_addr }, | | |
| 4518 | }, | | |
| 4519 | }, | | |
| 4520 | .decl_instance_func_generic = .{ | | |
| 4521 | .tag = .subprogram, | 5608 | .tag = .subprogram, |
| 4522 | .children = true, | 5609 | .children = true, |
| 4523 | .attrs = decl_instance_attrs ++ .{ | 5610 | .attrs = decl_instance_attrs ++ .{ |
| | 5611 | .{ .linkage_name, .strx }, |
| 4524 | .{ .type, .ref_addr }, | 5612 | .{ .type, .ref_addr }, |
| | 5613 | .{ .low_pc, .addrx }, |
| | 5614 | .{ .high_pc, .data4 }, |
| | 5615 | .{ .alignment, .udata }, |
| | 5616 | .{ .external, .flag }, |
| | 5617 | .{ .noreturn, .flag }, |
| 4525 | }, | 5618 | }, |
| 4526 | }, | 5619 | }, |
| 4527 | .decl_instance_extern_nullary_func = .{ | 5620 | .decl_instance_empty_func_generic = .{ |
| 4528 | .tag = .subprogram, | 5621 | .tag = .subprogram, |
| 4529 | .attrs = decl_instance_attrs ++ .{ | 5622 | .attrs = decl_instance_attrs ++ .{ |
| 4530 | .{ .linkage_name, .strp }, | | |
| 4531 | .{ .type, .ref_addr }, | 5623 | .{ .type, .ref_addr }, |
| 4532 | .{ .low_pc, .addr }, | | |
| 4533 | .{ .external, .flag_present }, | | |
| 4534 | .{ .noreturn, .flag }, | | |
| 4535 | }, | 5624 | }, |
| 4536 | }, | 5625 | }, |
| 4537 | .decl_instance_extern_func = .{ | 5626 | .decl_instance_func_generic = .{ |
| 4538 | .tag = .subprogram, | 5627 | .tag = .subprogram, |
| 4539 | .children = true, | 5628 | .children = true, |
| 4540 | .attrs = decl_instance_attrs ++ .{ | 5629 | .attrs = decl_instance_attrs ++ .{ |
| 4541 | .{ .linkage_name, .strp }, | | |
| 4542 | .{ .type, .ref_addr }, | 5630 | .{ .type, .ref_addr }, |
| 4543 | .{ .low_pc, .addr }, | | |
| 4544 | .{ .external, .flag_present }, | | |
| 4545 | .{ .noreturn, .flag }, | | |
| 4546 | }, | | |
| 4547 | }, | | |
| 4548 | .compile_unit = .{ | | |
| 4549 | .tag = .compile_unit, | | |
| 4550 | .children = true, | | |
| 4551 | .attrs = &.{ | | |
| 4552 | .{ .language, .data1 }, | | |
| 4553 | .{ .producer, .strp }, | | |
| 4554 | .{ .comp_dir, .line_strp }, | | |
| 4555 | .{ .name, .line_strp }, | | |
| 4556 | .{ .base_types, .ref_addr }, | | |
| 4557 | .{ .stmt_list, .sec_offset }, | | |
| 4558 | .{ .rnglists_base, .sec_offset }, | | |
| 4559 | .{ .ranges, .rnglistx }, | | |
| 4560 | .{ .use_UTF8, .flag_present }, | | |
| 4561 | }, | | |
| 4562 | }, | | |
| 4563 | .module = .{ | | |
| 4564 | .tag = .module, | | |
| 4565 | .children = true, | | |
| 4566 | .attrs = &.{ | | |
| 4567 | .{ .name, .strp }, | | |
| 4568 | .{ .ranges, .rnglistx }, | | |
| 4569 | }, | | |
| 4570 | }, | | |
| 4571 | .module_dependency = .{ | | |
| 4572 | .tag = .imported_module, | | |
| 4573 | .attrs = &.{ | | |
| 4574 | .{ .name, .strp }, | | |
| 4575 | .{ .import, .ref_addr }, | | |
| 4576 | }, | 5631 | }, |
| 4577 | }, | 5632 | }, |
| 4578 | .empty_file = .{ | 5633 | .empty_file = .{ |
| 4579 | .tag = .structure_type, | 5634 | .tag = .structure_type, |
| 4580 | .attrs = &.{ | 5635 | .attrs = &.{ |
| 4581 | .{ .decl_file, .udata }, | 5636 | .{ .decl_file, .udata }, |
| 4582 | .{ .name, .strp }, | 5637 | .{ .name, .strx }, |
| 4583 | .{ .declaration, .flag }, | 5638 | .{ .declaration, .flag }, |
| 4584 | }, | 5639 | }, |
| 4585 | }, | 5640 | }, |
| ... | @@ -4588,7 +5643,7 @@ pub const AbbrevCode = enum { | ... | @@ -4588,7 +5643,7 @@ pub const AbbrevCode = enum { |
| 4588 | .children = true, | 5643 | .children = true, |
| 4589 | .attrs = &.{ | 5644 | .attrs = &.{ |
| 4590 | .{ .decl_file, .udata }, | 5645 | .{ .decl_file, .udata }, |
| 4591 | .{ .name, .strp }, | 5646 | .{ .name, .strx }, |
| 4592 | .{ .byte_size, .udata }, | 5647 | .{ .byte_size, .udata }, |
| 4593 | .{ .alignment, .udata }, | 5648 | .{ .alignment, .udata }, |
| 4594 | }, | 5649 | }, |
| ... | @@ -4596,20 +5651,20 @@ pub const AbbrevCode = enum { | ... | @@ -4596,20 +5651,20 @@ pub const AbbrevCode = enum { |
| 4596 | .access = .{ | 5651 | .access = .{ |
| 4597 | .tag = .member, | 5652 | .tag = .member, |
| 4598 | .attrs = &.{ | 5653 | .attrs = &.{ |
| 4599 | .{ .name, .strp }, | 5654 | .{ .name, .strx }, |
| 4600 | }, | 5655 | }, |
| 4601 | }, | 5656 | }, |
| 4602 | .enum_field = .{ | 5657 | .enum_field = .{ |
| 4603 | .tag = .enumerator, | 5658 | .tag = .enumerator, |
| 4604 | .attrs = &.{ | 5659 | .attrs = &.{ |
| 4605 | .{ .const_value, .indirect }, | 5660 | .{ .const_value, .indirect }, |
| 4606 | .{ .name, .strp }, | 5661 | .{ .name, .strx }, |
| 4607 | }, | 5662 | }, |
| 4608 | }, | 5663 | }, |
| 4609 | .generated_field = .{ | 5664 | .generated_field = .{ |
| 4610 | .tag = .member, | 5665 | .tag = .member, |
| 4611 | .attrs = &.{ | 5666 | .attrs = &.{ |
| 4612 | .{ .name, .strp }, | 5667 | .{ .name, .strx }, |
| 4613 | .{ .type, .ref_addr }, | 5668 | .{ .type, .ref_addr }, |
| 4614 | .{ .data_member_location, .udata }, | 5669 | .{ .data_member_location, .udata }, |
| 4615 | .{ .artificial, .flag_present }, | 5670 | .{ .artificial, .flag_present }, |
| ... | @@ -4618,7 +5673,7 @@ pub const AbbrevCode = enum { | ... | @@ -4618,7 +5673,7 @@ pub const AbbrevCode = enum { |
| 4618 | .field = .{ | 5673 | .field = .{ |
| 4619 | .tag = .member, | 5674 | .tag = .member, |
| 4620 | .attrs = &.{ | 5675 | .attrs = &.{ |
| 4621 | .{ .name, .strp }, | 5676 | .{ .name, .strx }, |
| 4622 | .{ .type, .ref_addr }, | 5677 | .{ .type, .ref_addr }, |
| 4623 | .{ .data_member_location, .udata }, | 5678 | .{ .data_member_location, .udata }, |
| 4624 | .{ .alignment, .udata }, | 5679 | .{ .alignment, .udata }, |
| ... | @@ -4627,7 +5682,7 @@ pub const AbbrevCode = enum { | ... | @@ -4627,7 +5682,7 @@ pub const AbbrevCode = enum { |
| 4627 | .field_default_fully_runtime = .{ | 5682 | .field_default_fully_runtime = .{ |
| 4628 | .tag = .member, | 5683 | .tag = .member, |
| 4629 | .attrs = &.{ | 5684 | .attrs = &.{ |
| 4630 | .{ .name, .strp }, | 5685 | .{ .name, .strx }, |
| 4631 | .{ .type, .ref_addr }, | 5686 | .{ .type, .ref_addr }, |
| 4632 | .{ .data_member_location, .udata }, | 5687 | .{ .data_member_location, .udata }, |
| 4633 | .{ .alignment, .udata }, | 5688 | .{ .alignment, .udata }, |
| ... | @@ -4637,7 +5692,7 @@ pub const AbbrevCode = enum { | ... | @@ -4637,7 +5692,7 @@ pub const AbbrevCode = enum { |
| 4637 | .field_default_partially_comptime = .{ | 5692 | .field_default_partially_comptime = .{ |
| 4638 | .tag = .member, | 5693 | .tag = .member, |
| 4639 | .attrs = &.{ | 5694 | .attrs = &.{ |
| 4640 | .{ .name, .strp }, | 5695 | .{ .name, .strx }, |
| 4641 | .{ .type, .ref_addr }, | 5696 | .{ .type, .ref_addr }, |
| 4642 | .{ .data_member_location, .udata }, | 5697 | .{ .data_member_location, .udata }, |
| 4643 | .{ .alignment, .udata }, | 5698 | .{ .alignment, .udata }, |
| ... | @@ -4648,7 +5703,7 @@ pub const AbbrevCode = enum { | ... | @@ -4648,7 +5703,7 @@ pub const AbbrevCode = enum { |
| 4648 | .field_default_fully_comptime = .{ | 5703 | .field_default_fully_comptime = .{ |
| 4649 | .tag = .member, | 5704 | .tag = .member, |
| 4650 | .attrs = &.{ | 5705 | .attrs = &.{ |
| 4651 | .{ .name, .strp }, | 5706 | .{ .name, .strx }, |
| 4652 | .{ .type, .ref_addr }, | 5707 | .{ .type, .ref_addr }, |
| 4653 | .{ .data_member_location, .udata }, | 5708 | .{ .data_member_location, .udata }, |
| 4654 | .{ .alignment, .udata }, | 5709 | .{ .alignment, .udata }, |
| ... | @@ -4659,7 +5714,7 @@ pub const AbbrevCode = enum { | ... | @@ -4659,7 +5714,7 @@ pub const AbbrevCode = enum { |
| 4659 | .tag = .member, | 5714 | .tag = .member, |
| 4660 | .attrs = &.{ | 5715 | .attrs = &.{ |
| 4661 | .{ .const_expr, .flag_present }, | 5716 | .{ .const_expr, .flag_present }, |
| 4662 | .{ .name, .strp }, | 5717 | .{ .name, .strx }, |
| 4663 | .{ .type, .ref_addr }, | 5718 | .{ .type, .ref_addr }, |
| 4664 | }, | 5719 | }, |
| 4665 | }, | 5720 | }, |
| ... | @@ -4667,7 +5722,7 @@ pub const AbbrevCode = enum { | ... | @@ -4667,7 +5722,7 @@ pub const AbbrevCode = enum { |
| 4667 | .tag = .member, | 5722 | .tag = .member, |
| 4668 | .attrs = &.{ | 5723 | .attrs = &.{ |
| 4669 | .{ .const_expr, .flag_present }, | 5724 | .{ .const_expr, .flag_present }, |
| 4670 | .{ .name, .strp }, | 5725 | .{ .name, .strx }, |
| 4671 | .{ .type, .ref_addr }, | 5726 | .{ .type, .ref_addr }, |
| 4672 | .{ .const_value, .block }, | 5727 | .{ .const_value, .block }, |
| 4673 | }, | 5728 | }, |
| ... | @@ -4676,7 +5731,7 @@ pub const AbbrevCode = enum { | ... | @@ -4676,7 +5731,7 @@ pub const AbbrevCode = enum { |
| 4676 | .tag = .member, | 5731 | .tag = .member, |
| 4677 | .attrs = &.{ | 5732 | .attrs = &.{ |
| 4678 | .{ .const_expr, .flag_present }, | 5733 | .{ .const_expr, .flag_present }, |
| 4679 | .{ .name, .strp }, | 5734 | .{ .name, .strx }, |
| 4680 | .{ .type, .ref_addr }, | 5735 | .{ .type, .ref_addr }, |
| 4681 | .{ .const_value, .block }, | 5736 | .{ .const_value, .block }, |
| 4682 | .{ .ZIG_comptime_value, .ref_addr }, | 5737 | .{ .ZIG_comptime_value, .ref_addr }, |
| ... | @@ -4686,7 +5741,7 @@ pub const AbbrevCode = enum { | ... | @@ -4686,7 +5741,7 @@ pub const AbbrevCode = enum { |
| 4686 | .tag = .member, | 5741 | .tag = .member, |
| 4687 | .attrs = &.{ | 5742 | .attrs = &.{ |
| 4688 | .{ .const_expr, .flag_present }, | 5743 | .{ .const_expr, .flag_present }, |
| 4689 | .{ .name, .strp }, | 5744 | .{ .name, .strx }, |
| 4690 | .{ .type, .ref_addr }, | 5745 | .{ .type, .ref_addr }, |
| 4691 | .{ .ZIG_comptime_value, .ref_addr }, | 5746 | .{ .ZIG_comptime_value, .ref_addr }, |
| 4692 | }, | 5747 | }, |
| ... | @@ -4694,7 +5749,7 @@ pub const AbbrevCode = enum { | ... | @@ -4694,7 +5749,7 @@ pub const AbbrevCode = enum { |
| 4694 | .packed_field = .{ | 5749 | .packed_field = .{ |
| 4695 | .tag = .member, | 5750 | .tag = .member, |
| 4696 | .attrs = &.{ | 5751 | .attrs = &.{ |
| 4697 | .{ .name, .strp }, | 5752 | .{ .name, .strx }, |
| 4698 | .{ .type, .ref_addr }, | 5753 | .{ .type, .ref_addr }, |
| 4699 | .{ .data_bit_offset, .udata }, | 5754 | .{ .data_bit_offset, .udata }, |
| 4700 | }, | 5755 | }, |
| ... | @@ -4720,13 +5775,13 @@ pub const AbbrevCode = enum { | ... | @@ -4720,13 +5775,13 @@ pub const AbbrevCode = enum { |
| 4720 | .void_type = .{ | 5775 | .void_type = .{ |
| 4721 | .tag = .unspecified_type, | 5776 | .tag = .unspecified_type, |
| 4722 | .attrs = &.{ | 5777 | .attrs = &.{ |
| 4723 | .{ .name, .strp }, | 5778 | .{ .name, .strx }, |
| 4724 | }, | 5779 | }, |
| 4725 | }, | 5780 | }, |
| 4726 | .numeric_type = .{ | 5781 | .numeric_type = .{ |
| 4727 | .tag = .base_type, | 5782 | .tag = .base_type, |
| 4728 | .attrs = &.{ | 5783 | .attrs = &.{ |
| 4729 | .{ .name, .strp }, | 5784 | .{ .name, .strx }, |
| 4730 | .{ .encoding, .data1 }, | 5785 | .{ .encoding, .data1 }, |
| 4731 | .{ .bit_size, .udata }, | 5786 | .{ .bit_size, .udata }, |
| 4732 | .{ .byte_size, .udata }, | 5787 | .{ .byte_size, .udata }, |
| ... | @@ -4736,14 +5791,14 @@ pub const AbbrevCode = enum { | ... | @@ -4736,14 +5791,14 @@ pub const AbbrevCode = enum { |
| 4736 | .inferred_error_set_type = .{ | 5791 | .inferred_error_set_type = .{ |
| 4737 | .tag = .typedef, | 5792 | .tag = .typedef, |
| 4738 | .attrs = &.{ | 5793 | .attrs = &.{ |
| 4739 | .{ .name, .strp }, | 5794 | .{ .name, .strx }, |
| 4740 | .{ .type, .ref_addr }, | 5795 | .{ .type, .ref_addr }, |
| 4741 | }, | 5796 | }, |
| 4742 | }, | 5797 | }, |
| 4743 | .ptr_type = .{ | 5798 | .ptr_type = .{ |
| 4744 | .tag = .pointer_type, | 5799 | .tag = .pointer_type, |
| 4745 | .attrs = &.{ | 5800 | .attrs = &.{ |
| 4746 | .{ .name, .strp }, | 5801 | .{ .name, .strx }, |
| 4747 | .{ .address_class, .data1 }, | 5802 | .{ .address_class, .data1 }, |
| 4748 | .{ .type, .ref_addr }, | 5803 | .{ .type, .ref_addr }, |
| 4749 | }, | 5804 | }, |
| ... | @@ -4751,28 +5806,16 @@ pub const AbbrevCode = enum { | ... | @@ -4751,28 +5806,16 @@ pub const AbbrevCode = enum { |
| 4751 | .ptr_sentinel_type = .{ | 5806 | .ptr_sentinel_type = .{ |
| 4752 | .tag = .pointer_type, | 5807 | .tag = .pointer_type, |
| 4753 | .attrs = &.{ | 5808 | .attrs = &.{ |
| 4754 | .{ .name, .strp }, | 5809 | .{ .name, .strx }, |
| 4755 | .{ .ZIG_sentinel, .block }, | 5810 | .{ .ZIG_sentinel, .block }, |
| 4756 | .{ .address_class, .data1 }, | 5811 | .{ .address_class, .data1 }, |
| 4757 | .{ .type, .ref_addr }, | 5812 | .{ .type, .ref_addr }, |
| 4758 | }, | 5813 | }, |
| 4759 | }, | 5814 | }, |
| 4760 | .ptr_aligned_type = .{ | 5815 | .is_aligned = .{ |
| 4761 | .tag = .pointer_type, | 5816 | .tag = .typedef, |
| 4762 | .attrs = &.{ | | |
| 4763 | .{ .name, .strp }, | | |
| 4764 | .{ .alignment, .udata }, | | |
| 4765 | .{ .address_class, .data1 }, | | |
| 4766 | .{ .type, .ref_addr }, | | |
| 4767 | }, | | |
| 4768 | }, | | |
| 4769 | .ptr_aligned_sentinel_type = .{ | | |
| 4770 | .tag = .pointer_type, | | |
| 4771 | .attrs = &.{ | 5817 | .attrs = &.{ |
| 4772 | .{ .name, .strp }, | | |
| 4773 | .{ .ZIG_sentinel, .block }, | | |
| 4774 | .{ .alignment, .udata }, | 5818 | .{ .alignment, .udata }, |
| 4775 | .{ .address_class, .data1 }, | | |
| 4776 | .{ .type, .ref_addr }, | 5819 | .{ .type, .ref_addr }, |
| 4777 | }, | 5820 | }, |
| 4778 | }, | 5821 | }, |
| ... | @@ -4792,7 +5835,7 @@ pub const AbbrevCode = enum { | ... | @@ -4792,7 +5835,7 @@ pub const AbbrevCode = enum { |
| 4792 | .tag = .array_type, | 5835 | .tag = .array_type, |
| 4793 | .children = true, | 5836 | .children = true, |
| 4794 | .attrs = &.{ | 5837 | .attrs = &.{ |
| 4795 | .{ .name, .strp }, | 5838 | .{ .name, .strx }, |
| 4796 | .{ .type, .ref_addr }, | 5839 | .{ .type, .ref_addr }, |
| 4797 | }, | 5840 | }, |
| 4798 | }, | 5841 | }, |
| ... | @@ -4800,7 +5843,7 @@ pub const AbbrevCode = enum { | ... | @@ -4800,7 +5843,7 @@ pub const AbbrevCode = enum { |
| 4800 | .tag = .array_type, | 5843 | .tag = .array_type, |
| 4801 | .children = true, | 5844 | .children = true, |
| 4802 | .attrs = &.{ | 5845 | .attrs = &.{ |
| 4803 | .{ .name, .strp }, | 5846 | .{ .name, .strx }, |
| 4804 | .{ .ZIG_sentinel, .block }, | 5847 | .{ .ZIG_sentinel, .block }, |
| 4805 | .{ .type, .ref_addr }, | 5848 | .{ .type, .ref_addr }, |
| 4806 | }, | 5849 | }, |
| ... | @@ -4809,7 +5852,7 @@ pub const AbbrevCode = enum { | ... | @@ -4809,7 +5852,7 @@ pub const AbbrevCode = enum { |
| 4809 | .tag = .array_type, | 5852 | .tag = .array_type, |
| 4810 | .children = true, | 5853 | .children = true, |
| 4811 | .attrs = &.{ | 5854 | .attrs = &.{ |
| 4812 | .{ .name, .strp }, | 5855 | .{ .name, .strx }, |
| 4813 | .{ .type, .ref_addr }, | 5856 | .{ .type, .ref_addr }, |
| 4814 | .{ .GNU_vector, .flag_present }, | 5857 | .{ .GNU_vector, .flag_present }, |
| 4815 | }, | 5858 | }, |
| ... | @@ -4827,10 +5870,10 @@ pub const AbbrevCode = enum { | ... | @@ -4827,10 +5870,10 @@ pub const AbbrevCode = enum { |
| 4827 | .{ .count, .udata }, | 5870 | .{ .count, .udata }, |
| 4828 | }, | 5871 | }, |
| 4829 | }, | 5872 | }, |
| 4830 | .nullary_func_type = .{ | 5873 | .empty_func_type = .{ |
| 4831 | .tag = .subroutine_type, | 5874 | .tag = .subroutine_type, |
| 4832 | .attrs = &.{ | 5875 | .attrs = &.{ |
| 4833 | .{ .name, .strp }, | 5876 | .{ .name, .strx }, |
| 4834 | .{ .calling_convention, .data1 }, | 5877 | .{ .calling_convention, .data1 }, |
| 4835 | .{ .type, .ref_addr }, | 5878 | .{ .type, .ref_addr }, |
| 4836 | }, | 5879 | }, |
| ... | @@ -4839,7 +5882,7 @@ pub const AbbrevCode = enum { | ... | @@ -4839,7 +5882,7 @@ pub const AbbrevCode = enum { |
| 4839 | .tag = .subroutine_type, | 5882 | .tag = .subroutine_type, |
| 4840 | .children = true, | 5883 | .children = true, |
| 4841 | .attrs = &.{ | 5884 | .attrs = &.{ |
| 4842 | .{ .name, .strp }, | 5885 | .{ .name, .strx }, |
| 4843 | .{ .calling_convention, .data1 }, | 5886 | .{ .calling_convention, .data1 }, |
| 4844 | .{ .type, .ref_addr }, | 5887 | .{ .type, .ref_addr }, |
| 4845 | }, | 5888 | }, |
| ... | @@ -4847,7 +5890,7 @@ pub const AbbrevCode = enum { | ... | @@ -4847,7 +5890,7 @@ pub const AbbrevCode = enum { |
| 4847 | .param = .{ | 5890 | .param = .{ |
| 4848 | .tag = .formal_parameter, | 5891 | .tag = .formal_parameter, |
| 4849 | .attrs = &.{ | 5892 | .attrs = &.{ |
| 4850 | .{ .name, .strp }, | 5893 | .{ .name, .strx }, |
| 4851 | .{ .type, .ref_addr }, | 5894 | .{ .type, .ref_addr }, |
| 4852 | }, | 5895 | }, |
| 4853 | }, | 5896 | }, |
| ... | @@ -4863,7 +5906,7 @@ pub const AbbrevCode = enum { | ... | @@ -4863,7 +5906,7 @@ pub const AbbrevCode = enum { |
| 4863 | .generated_empty_enum_type = .{ | 5906 | .generated_empty_enum_type = .{ |
| 4864 | .tag = .enumeration_type, | 5907 | .tag = .enumeration_type, |
| 4865 | .attrs = &.{ | 5908 | .attrs = &.{ |
| 4866 | .{ .name, .strp }, | 5909 | .{ .name, .strx }, |
| 4867 | .{ .type, .ref_addr }, | 5910 | .{ .type, .ref_addr }, |
| 4868 | }, | 5911 | }, |
| 4869 | }, | 5912 | }, |
| ... | @@ -4871,14 +5914,14 @@ pub const AbbrevCode = enum { | ... | @@ -4871,14 +5914,14 @@ pub const AbbrevCode = enum { |
| 4871 | .tag = .enumeration_type, | 5914 | .tag = .enumeration_type, |
| 4872 | .children = true, | 5915 | .children = true, |
| 4873 | .attrs = &.{ | 5916 | .attrs = &.{ |
| 4874 | .{ .name, .strp }, | 5917 | .{ .name, .strx }, |
| 4875 | .{ .type, .ref_addr }, | 5918 | .{ .type, .ref_addr }, |
| 4876 | }, | 5919 | }, |
| 4877 | }, | 5920 | }, |
| 4878 | .generated_empty_struct_type = .{ | 5921 | .generated_empty_struct_type = .{ |
| 4879 | .tag = .structure_type, | 5922 | .tag = .structure_type, |
| 4880 | .attrs = &.{ | 5923 | .attrs = &.{ |
| 4881 | .{ .name, .strp }, | 5924 | .{ .name, .strx }, |
| 4882 | .{ .declaration, .flag }, | 5925 | .{ .declaration, .flag }, |
| 4883 | }, | 5926 | }, |
| 4884 | }, | 5927 | }, |
| ... | @@ -4886,7 +5929,7 @@ pub const AbbrevCode = enum { | ... | @@ -4886,7 +5929,7 @@ pub const AbbrevCode = enum { |
| 4886 | .tag = .structure_type, | 5929 | .tag = .structure_type, |
| 4887 | .children = true, | 5930 | .children = true, |
| 4888 | .attrs = &.{ | 5931 | .attrs = &.{ |
| 4889 | .{ .name, .strp }, | 5932 | .{ .name, .strx }, |
| 4890 | .{ .byte_size, .udata }, | 5933 | .{ .byte_size, .udata }, |
| 4891 | .{ .alignment, .udata }, | 5934 | .{ .alignment, .udata }, |
| 4892 | }, | 5935 | }, |
| ... | @@ -4895,7 +5938,7 @@ pub const AbbrevCode = enum { | ... | @@ -4895,7 +5938,7 @@ pub const AbbrevCode = enum { |
| 4895 | .tag = .union_type, | 5938 | .tag = .union_type, |
| 4896 | .children = true, | 5939 | .children = true, |
| 4897 | .attrs = &.{ | 5940 | .attrs = &.{ |
| 4898 | .{ .name, .strp }, | 5941 | .{ .name, .strx }, |
| 4899 | .{ .byte_size, .udata }, | 5942 | .{ .byte_size, .udata }, |
| 4900 | .{ .alignment, .udata }, | 5943 | .{ .alignment, .udata }, |
| 4901 | }, | 5944 | }, |
| ... | @@ -4903,7 +5946,7 @@ pub const AbbrevCode = enum { | ... | @@ -4903,7 +5946,7 @@ pub const AbbrevCode = enum { |
| 4903 | .capture_specification = .{ | 5946 | .capture_specification = .{ |
| 4904 | .tag = .template_value_parameter, | 5947 | .tag = .template_value_parameter, |
| 4905 | .attrs = &.{ | 5948 | .attrs = &.{ |
| 4906 | .{ .name, .strp }, | 5949 | .{ .name, .strx }, |
| 4907 | }, | 5950 | }, |
| 4908 | }, | 5951 | }, |
| 4909 | .comptime_capture = .{ | 5952 | .comptime_capture = .{ |
| ... | @@ -4946,11 +5989,11 @@ pub const AbbrevCode = enum { | ... | @@ -4946,11 +5989,11 @@ pub const AbbrevCode = enum { |
| 4946 | .{ .location, .exprloc }, | 5989 | .{ .location, .exprloc }, |
| 4947 | }, | 5990 | }, |
| 4948 | }, | 5991 | }, |
| 4949 | .builtin_extern_nullary_func = .{ | 5992 | .builtin_extern_empty_func = .{ |
| 4950 | .tag = .subprogram, | 5993 | .tag = .subprogram, |
| 4951 | .attrs = &.{ | 5994 | .attrs = &.{ |
| 4952 | .{ .ZIG_parent, .ref_addr }, | 5995 | .{ .ZIG_parent, .ref_addr }, |
| 4953 | .{ .linkage_name, .strp }, | 5996 | .{ .linkage_name, .strx }, |
| 4954 | .{ .type, .ref_addr }, | 5997 | .{ .type, .ref_addr }, |
| 4955 | .{ .low_pc, .addr }, | 5998 | .{ .low_pc, .addr }, |
| 4956 | .{ .external, .flag_present }, | 5999 | .{ .external, .flag_present }, |
| ... | @@ -4962,7 +6005,7 @@ pub const AbbrevCode = enum { | ... | @@ -4962,7 +6005,7 @@ pub const AbbrevCode = enum { |
| 4962 | .children = true, | 6005 | .children = true, |
| 4963 | .attrs = &.{ | 6006 | .attrs = &.{ |
| 4964 | .{ .ZIG_parent, .ref_addr }, | 6007 | .{ .ZIG_parent, .ref_addr }, |
| 4965 | .{ .linkage_name, .strp }, | 6008 | .{ .linkage_name, .strx }, |
| 4966 | .{ .type, .ref_addr }, | 6009 | .{ .type, .ref_addr }, |
| 4967 | .{ .low_pc, .addr }, | 6010 | .{ .low_pc, .addr }, |
| 4968 | .{ .external, .flag_present }, | 6011 | .{ .external, .flag_present }, |
| ... | @@ -4973,9 +6016,10 @@ pub const AbbrevCode = enum { | ... | @@ -4973,9 +6016,10 @@ pub const AbbrevCode = enum { |
| 4973 | .tag = .variable, | 6016 | .tag = .variable, |
| 4974 | .attrs = &.{ | 6017 | .attrs = &.{ |
| 4975 | .{ .ZIG_parent, .ref_addr }, | 6018 | .{ .ZIG_parent, .ref_addr }, |
| 4976 | .{ .linkage_name, .strp }, | 6019 | .{ .linkage_name, .strx }, |
| 4977 | .{ .type, .ref_addr }, | 6020 | .{ .type, .ref_addr }, |
| 4978 | .{ .location, .exprloc }, | 6021 | .{ .location, .exprloc }, |
| | 6022 | .{ .alignment, .udata }, |
| 4979 | .{ .external, .flag_present }, | 6023 | .{ .external, .flag_present }, |
| 4980 | }, | 6024 | }, |
| 4981 | }, | 6025 | }, |
| ... | @@ -5018,7 +6062,7 @@ pub const AbbrevCode = enum { | ... | @@ -5018,7 +6062,7 @@ pub const AbbrevCode = enum { |
| 5018 | .arg = .{ | 6062 | .arg = .{ |
| 5019 | .tag = .formal_parameter, | 6063 | .tag = .formal_parameter, |
| 5020 | .attrs = &.{ | 6064 | .attrs = &.{ |
| 5021 | .{ .name, .strp }, | 6065 | .{ .name, .strx }, |
| 5022 | .{ .type, .ref_addr }, | 6066 | .{ .type, .ref_addr }, |
| 5023 | .{ .location, .exprloc }, | 6067 | .{ .location, .exprloc }, |
| 5024 | }, | 6068 | }, |
| ... | @@ -5034,7 +6078,7 @@ pub const AbbrevCode = enum { | ... | @@ -5034,7 +6078,7 @@ pub const AbbrevCode = enum { |
| 5034 | .tag = .formal_parameter, | 6078 | .tag = .formal_parameter, |
| 5035 | .attrs = &.{ | 6079 | .attrs = &.{ |
| 5036 | .{ .const_expr, .flag_present }, | 6080 | .{ .const_expr, .flag_present }, |
| 5037 | .{ .name, .strp }, | 6081 | .{ .name, .strx }, |
| 5038 | .{ .type, .ref_addr }, | 6082 | .{ .type, .ref_addr }, |
| 5039 | }, | 6083 | }, |
| 5040 | }, | 6084 | }, |
| ... | @@ -5042,7 +6086,7 @@ pub const AbbrevCode = enum { | ... | @@ -5042,7 +6086,7 @@ pub const AbbrevCode = enum { |
| 5042 | .tag = .formal_parameter, | 6086 | .tag = .formal_parameter, |
| 5043 | .attrs = &.{ | 6087 | .attrs = &.{ |
| 5044 | .{ .const_expr, .flag_present }, | 6088 | .{ .const_expr, .flag_present }, |
| 5045 | .{ .name, .strp }, | 6089 | .{ .name, .strx }, |
| 5046 | .{ .type, .ref_addr }, | 6090 | .{ .type, .ref_addr }, |
| 5047 | .{ .const_value, .block }, | 6091 | .{ .const_value, .block }, |
| 5048 | }, | 6092 | }, |
| ... | @@ -5051,7 +6095,7 @@ pub const AbbrevCode = enum { | ... | @@ -5051,7 +6095,7 @@ pub const AbbrevCode = enum { |
| 5051 | .tag = .formal_parameter, | 6095 | .tag = .formal_parameter, |
| 5052 | .attrs = &.{ | 6096 | .attrs = &.{ |
| 5053 | .{ .const_expr, .flag_present }, | 6097 | .{ .const_expr, .flag_present }, |
| 5054 | .{ .name, .strp }, | 6098 | .{ .name, .strx }, |
| 5055 | .{ .type, .ref_addr }, | 6099 | .{ .type, .ref_addr }, |
| 5056 | .{ .const_value, .block }, | 6100 | .{ .const_value, .block }, |
| 5057 | .{ .ZIG_comptime_value, .ref_addr }, | 6101 | .{ .ZIG_comptime_value, .ref_addr }, |
| ... | @@ -5061,7 +6105,7 @@ pub const AbbrevCode = enum { | ... | @@ -5061,7 +6105,7 @@ pub const AbbrevCode = enum { |
| 5061 | .tag = .formal_parameter, | 6105 | .tag = .formal_parameter, |
| 5062 | .attrs = &.{ | 6106 | .attrs = &.{ |
| 5063 | .{ .const_expr, .flag_present }, | 6107 | .{ .const_expr, .flag_present }, |
| 5064 | .{ .name, .strp }, | 6108 | .{ .name, .strx }, |
| 5065 | .{ .type, .ref_addr }, | 6109 | .{ .type, .ref_addr }, |
| 5066 | .{ .ZIG_comptime_value, .ref_addr }, | 6110 | .{ .ZIG_comptime_value, .ref_addr }, |
| 5067 | }, | 6111 | }, |
| ... | @@ -5107,7 +6151,7 @@ pub const AbbrevCode = enum { | ... | @@ -5107,7 +6151,7 @@ pub const AbbrevCode = enum { |
| 5107 | .local_var = .{ | 6151 | .local_var = .{ |
| 5108 | .tag = .variable, | 6152 | .tag = .variable, |
| 5109 | .attrs = &.{ | 6153 | .attrs = &.{ |
| 5110 | .{ .name, .strp }, | 6154 | .{ .name, .strx }, |
| 5111 | .{ .type, .ref_addr }, | 6155 | .{ .type, .ref_addr }, |
| 5112 | .{ .location, .exprloc }, | 6156 | .{ .location, .exprloc }, |
| 5113 | }, | 6157 | }, |
| ... | @@ -5115,14 +6159,14 @@ pub const AbbrevCode = enum { | ... | @@ -5115,14 +6159,14 @@ pub const AbbrevCode = enum { |
| 5115 | .local_const = .{ | 6159 | .local_const = .{ |
| 5116 | .tag = .constant, | 6160 | .tag = .constant, |
| 5117 | .attrs = &.{ | 6161 | .attrs = &.{ |
| 5118 | .{ .name, .strp }, | 6162 | .{ .name, .strx }, |
| 5119 | .{ .type, .ref_addr }, | 6163 | .{ .type, .ref_addr }, |
| 5120 | }, | 6164 | }, |
| 5121 | }, | 6165 | }, |
| 5122 | .local_const_fully_runtime = .{ | 6166 | .local_const_fully_runtime = .{ |
| 5123 | .tag = .constant, | 6167 | .tag = .constant, |
| 5124 | .attrs = &.{ | 6168 | .attrs = &.{ |
| 5125 | .{ .name, .strp }, | 6169 | .{ .name, .strx }, |
| 5126 | .{ .type, .ref_addr }, | 6170 | .{ .type, .ref_addr }, |
| 5127 | .{ .const_value, .block }, | 6171 | .{ .const_value, .block }, |
| 5128 | }, | 6172 | }, |
| ... | @@ -5130,7 +6174,7 @@ pub const AbbrevCode = enum { | ... | @@ -5130,7 +6174,7 @@ pub const AbbrevCode = enum { |
| 5130 | .local_const_partially_comptime = .{ | 6174 | .local_const_partially_comptime = .{ |
| 5131 | .tag = .constant, | 6175 | .tag = .constant, |
| 5132 | .attrs = &.{ | 6176 | .attrs = &.{ |
| 5133 | .{ .name, .strp }, | 6177 | .{ .name, .strx }, |
| 5134 | .{ .type, .ref_addr }, | 6178 | .{ .type, .ref_addr }, |
| 5135 | .{ .const_value, .block }, | 6179 | .{ .const_value, .block }, |
| 5136 | .{ .ZIG_comptime_value, .ref_addr }, | 6180 | .{ .ZIG_comptime_value, .ref_addr }, |
| ... | @@ -5139,7 +6183,7 @@ pub const AbbrevCode = enum { | ... | @@ -5139,7 +6183,7 @@ pub const AbbrevCode = enum { |
| 5139 | .local_const_fully_comptime = .{ | 6183 | .local_const_fully_comptime = .{ |
| 5140 | .tag = .constant, | 6184 | .tag = .constant, |
| 5141 | .attrs = &.{ | 6185 | .attrs = &.{ |
| 5142 | .{ .name, .strp }, | 6186 | .{ .name, .strx }, |
| 5143 | .{ .type, .ref_addr }, | 6187 | .{ .type, .ref_addr }, |
| 5144 | .{ .ZIG_comptime_value, .ref_addr }, | 6188 | .{ .ZIG_comptime_value, .ref_addr }, |
| 5145 | }, | 6189 | }, |
| ... | @@ -5187,32 +6231,64 @@ pub const AbbrevCode = enum { | ... | @@ -5187,32 +6231,64 @@ pub const AbbrevCode = enum { |
| 5187 | .{ .location, .exprloc }, | 6231 | .{ .location, .exprloc }, |
| 5188 | }, | 6232 | }, |
| 5189 | }, | 6233 | }, |
| 5190 | .comptime_value_field_runtime_bits = .{ | 6234 | .comptime_value_field_runtime = .{ |
| 5191 | .tag = .member, | 6235 | .tag = .member, |
| 5192 | .attrs = &.{ | 6236 | .attrs = &.{ |
| 5193 | .{ .name, .strp }, | 6237 | .{ .name, .strx }, |
| 5194 | .{ .const_value, .block }, | 6238 | .{ .const_value, .block }, |
| 5195 | }, | 6239 | }, |
| 5196 | }, | 6240 | }, |
| 5197 | .comptime_value_field_comptime_state = .{ | 6241 | .comptime_value_field_comptime = .{ |
| 5198 | .tag = .member, | 6242 | .tag = .member, |
| 5199 | .attrs = &.{ | 6243 | .attrs = &.{ |
| 5200 | .{ .name, .strp }, | 6244 | .{ .name, .strx }, |
| 5201 | .{ .ZIG_comptime_value, .ref_addr }, | 6245 | .{ .ZIG_comptime_value, .ref_addr }, |
| 5202 | }, | 6246 | }, |
| 5203 | }, | 6247 | }, |
| 5204 | .comptime_value_elem_runtime_bits = .{ | 6248 | .comptime_value_elem_runtime = .{ |
| 5205 | .tag = .member, | 6249 | .tag = .member, |
| 5206 | .attrs = &.{ | 6250 | .attrs = &.{ |
| 5207 | .{ .const_value, .block }, | 6251 | .{ .const_value, .block }, |
| 5208 | }, | 6252 | }, |
| 5209 | }, | 6253 | }, |
| 5210 | .comptime_value_elem_comptime_state = .{ | 6254 | .comptime_value_elem_comptime = .{ |
| 5211 | .tag = .member, | 6255 | .tag = .member, |
| 5212 | .attrs = &.{ | 6256 | .attrs = &.{ |
| 5213 | .{ .ZIG_comptime_value, .ref_addr }, | 6257 | .{ .ZIG_comptime_value, .ref_addr }, |
| 5214 | }, | 6258 | }, |
| 5215 | }, | 6259 | }, |
| | 6260 | .compile_unit = .{ |
| | 6261 | .tag = .compile_unit, |
| | 6262 | .children = true, |
| | 6263 | .attrs = &.{ |
| | 6264 | .{ .language, .data1 }, |
| | 6265 | .{ .base_types, .ref_addr }, |
| | 6266 | .{ .stmt_list, .sec_offset }, |
| | 6267 | .{ .addr_base, .sec_offset }, |
| | 6268 | .{ .rnglists_base, .sec_offset }, |
| | 6269 | .{ .str_offsets_base, .sec_offset }, |
| | 6270 | .{ .producer, .strx1 }, |
| | 6271 | .{ .comp_dir, .line_strp }, |
| | 6272 | .{ .name, .line_strp }, |
| | 6273 | .{ .ranges, .rnglistx }, |
| | 6274 | .{ .use_UTF8, .flag_present }, |
| | 6275 | }, |
| | 6276 | }, |
| | 6277 | .module = .{ |
| | 6278 | .tag = .module, |
| | 6279 | .children = true, |
| | 6280 | .attrs = &.{ |
| | 6281 | .{ .name, .strx }, |
| | 6282 | .{ .ranges, .rnglistx }, |
| | 6283 | }, |
| | 6284 | }, |
| | 6285 | .module_dependency = .{ |
| | 6286 | .tag = .imported_module, |
| | 6287 | .attrs = &.{ |
| | 6288 | .{ .name, .strx }, |
| | 6289 | .{ .import, .ref_addr }, |
| | 6290 | }, |
| | 6291 | }, |
| 5216 | }); | 6292 | }); |
| 5217 | }; | 6293 | }; |
| 5218 | | 6294 | |