| ... | ... | @@ -10,9 +10,10 @@ consts: std.ArrayList(Const), |
| 10 | 10 | globals: std.array_hash_map.Auto(InternPool.Nav.Index, Global), |
| 11 | 11 | funcs: std.array_hash_map.Auto(InternPool.Nav.Index, Func), |
| 12 | 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 | 15 | debug_abbrev: Abbrev, |
| 16 | debug_addr: Addr, |
| 16 | 17 | frame: Frame, |
| 17 | 18 | debug_info: Info, |
| 18 | 19 | debug_line: Line, |
| ... | ... | @@ -81,6 +82,7 @@ pub const Unit = struct { |
| 81 | 82 | ui: Unit.Index, |
| 82 | 83 | zfi: Zcu.File.Index, |
| 83 | 84 | ) std.mem.Allocator.Error!struct { DirIndex, FileIndex } { |
| 85 | assert(unit.alive); |
| 84 | 86 | try unit.dirs.ensureUnusedCapacity(gpa, 1); |
| 85 | 87 | try unit.files.ensureUnusedCapacity(gpa, 1); |
| 86 | 88 | const dir_gop = unit.dirs.getOrPutAssumeCapacity(ui); |
| ... | ... | @@ -154,6 +156,12 @@ pub const Decl = struct { |
| 154 | 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 | 167 | pub const Frame = struct { |
| ... | ... | @@ -175,6 +183,29 @@ pub const Abbrev = struct { |
| 175 | 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 | 209 | pub const Info = struct {}; |
| 179 | 210 | |
| 180 | 211 | pub const Line = struct { |
| ... | ... | @@ -192,8 +223,8 @@ pub const Line = struct { |
| 192 | 223 | |
| 193 | 224 | pub const Str = struct { |
| 194 | 225 | ni: link.MappedFile.Node.Index.Optional, |
| 195 | | offset: usize, |
| 196 | | map: std.HashMapUnmanaged(usize, void, Context, std.hash_map.default_max_load_percentage), |
| 226 | end: usize, |
| 227 | map: std.array_hash_map.Custom(usize, void, Context, true), |
| 197 | 228 | |
| 198 | 229 | fn get( |
| 199 | 230 | s: *Str, |
| ... | ... | @@ -210,21 +241,21 @@ pub const Str = struct { |
| 210 | 241 | .{ .slice = slice }, |
| 211 | 242 | ); |
| 212 | 243 | if (!gop.found_existing) { |
| 213 | | gop.key_ptr.* = s.offset; |
| 214 | | try ni.ensureMinimumSize(gpa, mf, s.offset + str.len + 1); |
| 244 | gop.key_ptr.* = s.end; |
| 245 | try ni.ensureMinimumSize(gpa, mf, s.end + str.len + 1); |
| 215 | 246 | const slice_mut = ni.slice(mf); |
| 216 | | @memcpy(slice_mut[s.offset..][0..str.len], str); |
| 217 | | s.offset += str.len; |
| 218 | | slice_mut[s.offset] = 0; |
| 219 | | s.offset += 1; |
| 247 | @memcpy(slice_mut[s.end..][0..str.len], str); |
| 248 | s.end += str.len; |
| 249 | slice_mut[s.end] = 0; |
| 250 | s.end += 1; |
| 220 | 251 | } |
| 221 | 252 | return gop.key_ptr.*; |
| 222 | 253 | } |
| 223 | 254 | |
| 224 | 255 | const Context = struct { |
| 225 | 256 | slice: []const u8, |
| 226 | | pub fn hash(context: Context, offset: usize) u64 { |
| 227 | | return std.hash.Wyhash.hash(0, std.mem.sliceTo(context.slice[offset..], 0)); |
| 257 | pub fn hash(context: Context, offset: usize) u32 { |
| 258 | return @truncate(std.hash.Wyhash.hash(0, std.mem.sliceTo(context.slice[offset..], 0))); |
| 228 | 259 | } |
| 229 | 260 | pub fn eql(_: Context, lhs_offset: usize, rhs_offset: usize) bool { |
| 230 | 261 | return lhs_offset == rhs_offset; |
| ... | ... | @@ -233,10 +264,10 @@ pub const Str = struct { |
| 233 | 264 | |
| 234 | 265 | const Adapter = struct { |
| 235 | 266 | slice: []const u8, |
| 236 | | pub fn hash(_: Adapter, key: []const u8) u64 { |
| 237 | | return std.hash.Wyhash.hash(0, key); |
| 267 | pub fn hash(_: Adapter, key: []const u8) u32 { |
| 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 | 271 | return std.mem.startsWith(u8, adapter.slice[rhs_offset..], key) and |
| 241 | 272 | adapter.slice[rhs_offset + key.len] == 0; |
| 242 | 273 | } |
| ... | ... | @@ -244,21 +275,60 @@ pub const Str = struct { |
| 244 | 275 | }; |
| 245 | 276 | |
| 246 | 277 | pub const Rnglists = struct { |
| 247 | | fn offsetsTableOffset(dwarf: *Dwarf) usize { |
| 278 | fn tableOffset(dwarf: *Dwarf) usize { |
| 248 | 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 | 287 | pub const StrOffsets = struct { |
| 253 | 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 | 326 | pub const Loc = union(enum) { |
| 260 | 327 | empty, |
| 261 | | addr_reloc: link.File.SymbolId, |
| 328 | addr_sym: struct { |
| 329 | si: link.File.SymbolId, |
| 330 | offset: usize = 0, |
| 331 | }, |
| 262 | 332 | deref: *const Loc, |
| 263 | 333 | constu: u64, |
| 264 | 334 | consts: i64, |
| ... | ... | @@ -277,6 +347,8 @@ pub const Loc = union(enum) { |
| 277 | 347 | node: link.MappedFile.Node.Index, |
| 278 | 348 | offset: i65 = 0, |
| 279 | 349 | }, |
| 350 | addrx_sym: link.File.SymbolId, |
| 351 | constx_sym: link.File.SymbolId, |
| 280 | 352 | wasm_ext: union(enum) { |
| 281 | 353 | local: u32, |
| 282 | 354 | global: u32, |
| ... | ... | @@ -319,11 +391,11 @@ pub const Loc = union(enum) { |
| 319 | 391 | }; |
| 320 | 392 | switch (loc) { |
| 321 | 393 | .empty => {}, |
| 322 | | .addr_reloc => |si| { |
| 394 | .addr_sym => |sym| { |
| 323 | 395 | try w.writeByte(DW.OP.addr); |
| 324 | 396 | switch (writer) { |
| 325 | 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 | 401 | .deref => |addr| { |
| ... | ... | @@ -442,6 +514,14 @@ pub const Loc = union(enum) { |
| 442 | 514 | } |
| 443 | 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 | 525 | .wasm_ext => |wasm_ext| { |
| 446 | 526 | try w.writeByte(DW.OP.WASM_location); |
| 447 | 527 | switch (wasm_ext) { |
| ... | ... | @@ -490,33 +570,33 @@ pub const Cfa = union(enum) { |
| 490 | 570 | const RegOff = struct { reg: u32, off: i64 }; |
| 491 | 571 | const RegExpr = struct { reg: u32, expr: Loc }; |
| 492 | 572 | |
| 493 | | fn write(cfa: Cfa, wip_nav: *WipNav) link.EmitError!void { |
| 494 | | const df_nw = &wip_nav.fde_writer; |
| 573 | fn write(cfa: Cfa, wip_func: *WipFunc) link.EmitError!void { |
| 574 | const df_nw = &wip_func.fde_writer; |
| 495 | 575 | const df_w = &df_nw.interface; |
| 496 | 576 | switch (cfa) { |
| 497 | 577 | .nop => try df_w.writeByte(DW.CFA.nop), |
| 498 | 578 | .advance_loc => |loc| { |
| 499 | 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 | 581 | if (delta == 0) {} else if (std.math.cast(u6, delta)) |small_delta| |
| 502 | 582 | try df_w.writeByte(@as(u8, DW.CFA.advance_loc) + small_delta) |
| 503 | 583 | else if (std.math.cast(u8, delta)) |ubyte_delta| |
| 504 | 584 | try df_w.writeAll(&.{ DW.CFA.advance_loc1, ubyte_delta }) |
| 505 | 585 | else if (std.math.cast(u16, delta)) |uhalf_delta| { |
| 506 | 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 | 588 | } else if (std.math.cast(u32, delta)) |uword_delta| { |
| 509 | 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 | 594 | .offset, .rel_offset => |reg_off| { |
| 515 | 595 | const factored_off = @divExact(reg_off.off - switch (cfa) { |
| 516 | 596 | else => unreachable, |
| 517 | 597 | .offset => 0, |
| 518 | | .rel_offset => wip_nav.cfi.cfa.off, |
| 519 | | }, wip_nav.dwarf.frame.header.data_alignment_factor); |
| 598 | .rel_offset => wip_func.cfi.cfa.off, |
| 599 | }, wip_func.dwarf.frame.header.data_alignment_factor); |
| 520 | 600 | if (std.math.cast(u63, factored_off)) |unsigned_off| { |
| 521 | 601 | if (std.math.cast(u6, reg_off.reg)) |small_reg| { |
| 522 | 602 | try df_w.writeByte(@as(u8, DW.CFA.offset) + small_reg); |
| ... | ... | @@ -558,21 +638,21 @@ pub const Cfa = union(enum) { |
| 558 | 638 | const reg_off: RegOff = switch (cfa) { |
| 559 | 639 | else => unreachable, |
| 560 | 640 | .def_cfa => |reg_off| reg_off, |
| 561 | | .def_cfa_register => |reg| .{ .reg = reg, .off = wip_nav.cfi.cfa.off }, |
| 562 | | .def_cfa_offset => |off| .{ .reg = wip_nav.cfi.cfa.reg, .off = off }, |
| 641 | .def_cfa_register => |reg| .{ .reg = reg, .off = wip_func.cfi.cfa.off }, |
| 642 | .def_cfa_offset => |off| .{ .reg = wip_func.cfi.cfa.reg, .off = off }, |
| 563 | 643 | .adjust_cfa_offset => |off| .{ |
| 564 | | .reg = wip_nav.cfi.cfa.reg, |
| 565 | | .off = wip_nav.cfi.cfa.off + off, |
| 644 | .reg = wip_func.cfi.cfa.reg, |
| 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 | 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 | 651 | if (changed_reg) { |
| 572 | 652 | try df_w.writeByte(DW.CFA.def_cfa_register); |
| 573 | 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 | 656 | 0 => unreachable, |
| 577 | 657 | 1 => unsigned_off != null, |
| 578 | 658 | else => |data_alignment_factor| @rem(reg_off.off, data_alignment_factor) != 0, |
| ... | ... | @@ -584,23 +664,23 @@ pub const Cfa = union(enum) { |
| 584 | 664 | try df_w.writeByte(if (changed_reg) DW.CFA.def_cfa_sf else DW.CFA.def_cfa_offset_sf); |
| 585 | 665 | if (changed_reg) try df_w.writeUleb128(reg_off.reg); |
| 586 | 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 | 672 | .def_cfa_expression => |expr| { |
| 593 | 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 | 676 | .expression => |reg_expr| { |
| 597 | 677 | try df_w.writeByte(DW.CFA.expression); |
| 598 | 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 | 681 | .val_offset => |reg_off| { |
| 602 | 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 | 684 | if (std.math.cast(u63, factored_off)) |unsigned_off| { |
| 605 | 685 | try df_w.writeByte(DW.CFA.val_offset); |
| 606 | 686 | try df_w.writeUleb128(reg_off.reg); |
| ... | ... | @@ -614,14 +694,14 @@ pub const Cfa = union(enum) { |
| 614 | 694 | .val_expression => |reg_expr| { |
| 615 | 695 | try df_w.writeByte(DW.CFA.val_expression); |
| 616 | 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 | 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 | 705 | dwarf: *Dwarf, |
| 626 | 706 | unit: Unit.Index, |
| 627 | 707 | func: InternPool.Index, |
| ... | ... | @@ -635,44 +715,50 @@ pub const WipNav = struct { |
| 635 | 715 | frame_func_length: struct { offset: usize, size: AddressSize }, |
| 636 | 716 | |
| 637 | 717 | pub const Debug = struct { |
| 638 | | wip_nav: WipNav, |
| 718 | wip_func: WipFunc, |
| 639 | 719 | pt: Zcu.PerThread, |
| 640 | | any_children: bool, |
| 720 | is_empty: bool, |
| 721 | empty_abbrev_code: AbbrevCode, |
| 641 | 722 | blocks: std.ArrayList(struct { |
| 642 | | abbrev_code: u32, |
| 643 | | low_pc_off: usize, |
| 644 | | high_pc: u32, |
| 723 | abbrev_code_offset: usize, |
| 724 | low_pc: usize, |
| 725 | high_pc_offset: usize, |
| 645 | 726 | }), |
| 646 | 727 | info_writer: link.MappedFile.Node.Writer, |
| 647 | 728 | info_func_length_offset: usize, |
| 648 | 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 | 737 | pub fn deinit(debug: *Debug) void { |
| 651 | 738 | const gpa = debug.pt.zcu.gpa; |
| 652 | 739 | debug.line_writer.deinit(); |
| 653 | 740 | debug.info_writer.deinit(); |
| 654 | 741 | debug.blocks.deinit(gpa); |
| 655 | | debug.wip_nav.deinit(); |
| 742 | debug.wip_func.deinit(); |
| 656 | 743 | debug.* = undefined; |
| 657 | 744 | } |
| 658 | 745 | |
| 659 | 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 { |
| 664 | | assert(debug.wip_nav.func != .none); |
| 665 | | debug.startFuncDebugInfoInner() catch |err| switch (err) { |
| 666 | | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.info_writer), |
| 750 | pub fn startDebugInfo(debug: *Debug) link.Error!void { |
| 751 | debug.startDebugInfoInner() catch |err| switch (err) { |
| 667 | 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 { |
| 671 | | const dwarf = debug.wip_nav.dwarf; |
| 756 | fn startDebugInfoInner(debug: *Debug) link.EmitError!void { |
| 757 | const dwarf = debug.wip_func.dwarf; |
| 672 | 758 | const pt = debug.pt; |
| 673 | 759 | const zcu = pt.zcu; |
| 674 | 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 | 762 | const nav = ip.getNav(func.owner_nav); |
| 677 | 763 | const func_type = ip.indexToKey(func.ty).func_type; |
| 678 | 764 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; |
| ... | ... | @@ -681,42 +767,52 @@ pub const WipNav = struct { |
| 681 | 767 | const decl = zf.zir.?.getDeclaration(inst_info.inst); |
| 682 | 768 | const di_nw = &debug.info_writer; |
| 683 | 769 | const di_w = &di_nw.interface; |
| 684 | | try dwarf.abbrevCode(di_nw, .decl_func); |
| 685 | | try dwarf.refType(pt, di_nw, .fromInterned(ip.namespacePtr(switch (func.generic_owner) { |
| 686 | | .none => nav, |
| 770 | const parent_ty: Type = .fromInterned(ip.namespacePtr(switch (func.generic_owner) { |
| 687 | 771 | else => |generic_owner| ip.getNav(zcu.funcInfo(generic_owner).owner_nav), |
| 688 | | }.analysis.?.namespace).owner_type)); |
| 689 | | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 690 | | try di_w.writeUleb128(decl.src_column + 1); |
| 691 | | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 692 | | try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip)); |
| 693 | | try dwarf.strp(&dwarf.debug_str, di_nw, switch (decl.linkage) { |
| 772 | .none => nav, |
| 773 | }.analysis.?.namespace).owner_type); |
| 774 | if (func.generic_owner != .none or parent_ty.getCaptures(zcu).len > 0) { |
| 775 | debug.empty_abbrev_code = .decl_instance_empty_func; |
| 776 | try dwarf.abbrevCode(di_nw, .decl_instance_func); |
| 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 | 789 | .normal => nav.fqn, |
| 695 | 790 | .@"extern", .@"export" => nav.name, |
| 696 | 791 | }.toSlice(ip)); |
| 697 | 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 | 794 | debug.info_func_length_offset = di_w.end; |
| 700 | 795 | try di_w.writeInt(u32, undefined, dwarf.endian); |
| 701 | 796 | try di_w.writeUleb128( |
| 702 | 797 | target_info.minFunctionAlignment(target).max(nav.resolved.?.@"align").toByteUnits().?, |
| 703 | 798 | ); |
| 704 | | try di_w.writeByte(@intFromBool(decl.linkage != .normal)); |
| 705 | | try di_w.writeByte(@intFromBool(Type.fromInterned(func_type.return_type).isNoReturn(zcu))); |
| 799 | try di_w.writeAll(&.{ |
| 800 | @intFromBool(decl.linkage != .normal), |
| 801 | @intFromBool(Type.fromInterned(func_type.return_type).isNoReturn(zcu)), |
| 802 | }); |
| 706 | 803 | } |
| 707 | 804 | |
| 708 | 805 | pub fn startDebugLine(debug: *Debug) link.Error!void { |
| 709 | | assert(debug.wip_nav.func != .none); |
| 710 | 806 | debug.startDebugLineInner() catch |err| switch (err) { |
| 711 | | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.line_writer), |
| 712 | 807 | else => |e| return e, |
| 808 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.line_writer), |
| 713 | 809 | }; |
| 714 | 810 | } |
| 715 | 811 | fn startDebugLineInner(debug: *Debug) link.EmitError!void { |
| 716 | | const dwarf = debug.wip_nav.dwarf; |
| 812 | const dwarf = debug.wip_func.dwarf; |
| 717 | 813 | const zcu = debug.pt.zcu; |
| 718 | 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 | 816 | const inst_info = ip.getNav(func.owner_nav).srcInst(ip).resolveFull(ip).?; |
| 721 | 817 | const zf = zcu.fileByIndex(inst_info.file); |
| 722 | 818 | const decl = zf.zir.?.getDeclaration(inst_info.inst); |
| ... | ... | @@ -735,10 +831,10 @@ pub const WipNav = struct { |
| 735 | 831 | } else { |
| 736 | 832 | try dl_w.writeUleb128(1 + @backingInt(dwarf.address_size)); |
| 737 | 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.?); |
| 741 | | _, const fi = try unit.get(dwarf).getFile(zcu.gpa, unit, inst_info.file); |
| 836 | const ui = dwarf.getUnit(zf.mod.?); |
| 837 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, inst_info.file); |
| 742 | 838 | try dl_w.writeByte(DW.LNS.set_file); |
| 743 | 839 | try dl_w.writeUleb128(@backingInt(fi)); |
| 744 | 840 | |
| ... | ... | @@ -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 { |
| 753 | | assert(debug.wip_nav.func != .none); |
| 848 | pub fn finish(debug: *Debug, func_length: u64) link.Error!void { |
| 754 | 849 | const di_nw = &debug.info_writer; |
| 755 | 850 | debug.finishDebugInfo(func_length) catch |err| switch (err) { |
| 756 | | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(di_nw), |
| 757 | 851 | else => |e| return e, |
| 852 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(di_nw), |
| 758 | 853 | }; |
| 759 | 854 | debug.finishDebugLine() catch |err| switch (err) { |
| 760 | | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(di_nw), |
| 761 | 855 | else => |e| return e, |
| 856 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(di_nw), |
| 762 | 857 | }; |
| 763 | 858 | } |
| 764 | 859 | fn finishDebugInfo(debug: *Debug, func_length: u64) link.EmitError!void { |
| 765 | | const dwarf = debug.wip_nav.dwarf; |
| 766 | | const di_w = &debug.info_writer.interface; |
| 860 | const dwarf = debug.wip_func.dwarf; |
| 861 | const di_nw = &debug.info_writer; |
| 862 | const di_w = &di_nw.interface; |
| 767 | 863 | std.mem.writeInt( |
| 768 | 864 | u32, |
| 769 | 865 | di_w.buffered()[debug.info_func_length_offset..][0..4], |
| 770 | 866 | @intCast(func_length), |
| 771 | 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 | 874 | try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen()); |
| 775 | 875 | } |
| 776 | 876 | fn finishDebugLine(debug: *Debug) link.EmitError!void { |
| ... | ... | @@ -787,8 +887,8 @@ pub const WipNav = struct { |
| 787 | 887 | loc: Loc, |
| 788 | 888 | ) link.Error!void { |
| 789 | 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 | 890 | else => |e| e, |
| 891 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.info_writer), |
| 792 | 892 | }; |
| 793 | 893 | } |
| 794 | 894 | fn genLocalVarDebugInfoInner( |
| ... | ... | @@ -798,17 +898,16 @@ pub const WipNav = struct { |
| 798 | 898 | ty: Type, |
| 799 | 899 | loc: Loc, |
| 800 | 900 | ) link.EmitError!void { |
| 801 | | assert(debug.wip_nav.func != .none); |
| 802 | | const dwarf = debug.wip_nav.dwarf; |
| 901 | const dwarf = debug.wip_func.dwarf; |
| 803 | 902 | const di_nw = &debug.info_writer; |
| 804 | 903 | try dwarf.abbrevCode(di_nw, switch (tag) { |
| 805 | 904 | .arg => if (opt_name) |_| .arg else .unnamed_arg, |
| 806 | 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 | 908 | try dwarf.refType(debug.pt, di_nw, ty); |
| 810 | 909 | try dwarf.exprLoc(di_nw, loc); |
| 811 | | debug.any_children = true; |
| 910 | debug.is_empty = false; |
| 812 | 911 | } |
| 813 | 912 | |
| 814 | 913 | pub const LocalConstTag = enum { comptime_arg, local_const }; |
| ... | ... | @@ -819,8 +918,8 @@ pub const WipNav = struct { |
| 819 | 918 | val: Value, |
| 820 | 919 | ) link.Error!void { |
| 821 | 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 | 921 | else => |e| e, |
| 922 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.info_writer), |
| 824 | 923 | }; |
| 825 | 924 | } |
| 826 | 925 | fn genLocalConstDebugInfoInner( |
| ... | ... | @@ -829,8 +928,7 @@ pub const WipNav = struct { |
| 829 | 928 | opt_name: ?[]const u8, |
| 830 | 929 | val: Value, |
| 831 | 930 | ) link.EmitError!void { |
| 832 | | assert(debug.wip_nav.func != .none); |
| 833 | | const dwarf = debug.wip_nav.dwarf; |
| 931 | const dwarf = debug.wip_func.dwarf; |
| 834 | 932 | const pt = debug.pt; |
| 835 | 933 | const zcu = debug.pt.zcu; |
| 836 | 934 | const ty = val.typeOf(zcu); |
| ... | ... | @@ -858,23 +956,22 @@ pub const WipNav = struct { |
| 858 | 956 | .fully_comptime => .local_const_fully_comptime, |
| 859 | 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 | 960 | try dwarf.refType(pt, di_nw, ty); |
| 863 | 961 | if (ty_class.hasRuntimeBits()) try dwarf.blockConst(pt, di_nw, val); |
| 864 | 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 | 966 | pub fn genVarArgsDebugInfo(debug: *Debug) link.Error!void { |
| 869 | 967 | return debug.genVarArgsDebugInfoInner() catch |err| switch (err) { |
| 870 | | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.info_writer), |
| 871 | 968 | else => |e| e, |
| 969 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.info_writer), |
| 872 | 970 | }; |
| 873 | 971 | } |
| 874 | 972 | fn genVarArgsDebugInfoInner(debug: *Debug) link.EmitError!void { |
| 875 | | assert(debug.wip_nav.func != .none); |
| 876 | | try debug.wip_nav.dwarf.abbrevCode(&debug.info_writer, .is_var_args); |
| 877 | | debug.any_children = true; |
| 973 | try debug.wip_func.dwarf.abbrevCode(&debug.info_writer, .is_var_args); |
| 974 | debug.is_empty = false; |
| 878 | 975 | } |
| 879 | 976 | |
| 880 | 977 | pub fn advanceLineAndPc( |
| ... | ... | @@ -884,7 +981,7 @@ pub const WipNav = struct { |
| 884 | 981 | end: bool, |
| 885 | 982 | ) link.Error!void { |
| 886 | 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 | 987 | fn advanceLineAndPcInner( |
| ... | ... | @@ -895,7 +992,7 @@ pub const WipNav = struct { |
| 895 | 992 | ) std.Io.Writer.Error!void { |
| 896 | 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 | 996 | assert(header.maximum_operations_per_instruction == 1); |
| 900 | 997 | const delta_op: u64 = 0; |
| 901 | 998 | |
| ... | ... | @@ -939,7 +1036,7 @@ pub const WipNav = struct { |
| 939 | 1036 | |
| 940 | 1037 | pub fn setColumn(debug: *Debug, column: u32) link.Error!void { |
| 941 | 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 | 1042 | fn setColumnInner(debug: *Debug, column: u32) std.Io.Writer.Error!void { |
| ... | ... | @@ -950,7 +1047,7 @@ pub const WipNav = struct { |
| 950 | 1047 | |
| 951 | 1048 | pub fn negateStmt(debug: *Debug) link.Error!void { |
| 952 | 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 | 1053 | fn negateStmtInner(debug: *Debug) std.Io.Writer.Error!void { |
| ... | ... | @@ -959,7 +1056,7 @@ pub const WipNav = struct { |
| 959 | 1056 | |
| 960 | 1057 | pub fn setPrologueEnd(debug: *Debug) link.Error!void { |
| 961 | 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 | 1062 | fn setPrologueEndInner(debug: *Debug) std.Io.Writer.Error!void { |
| ... | ... | @@ -968,151 +1065,155 @@ pub const WipNav = struct { |
| 968 | 1065 | |
| 969 | 1066 | pub fn setEpilogueBegin(debug: *Debug) link.Error!void { |
| 970 | 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 | 1071 | fn setEpilogueBeginInner(debug: *Debug) std.Io.Writer.Error!void { |
| 975 | 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 { |
| 979 | | return debug.enterBlockInner(code_off) catch |err| switch (err) { |
| 980 | | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.info_writer), |
| 1075 | pub fn enterBlock(debug: *Debug, code_offset: usize) link.Error!void { |
| 1076 | return debug.enterBlockInner(code_offset) catch |err| switch (err) { |
| 981 | 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 { |
| 985 | | const dwarf = debug.wip_nav.dwarf; |
| 1081 | fn enterBlockInner(debug: *Debug, code_offset: usize) link.EmitError!void { |
| 1082 | const dwarf = debug.wip_func.dwarf; |
| 986 | 1083 | const block = try debug.blocks.addOne(dwarf.lf.comp.gpa); |
| 987 | 1084 | |
| 988 | 1085 | const di_nw = &debug.info_writer; |
| 989 | 1086 | const di_w = &di_nw.interface; |
| 990 | | block.abbrev_code = @intCast(di_w.end); |
| 1087 | block.abbrev_code_offset = di_w.end; |
| 991 | 1088 | try dwarf.abbrevCode(di_nw, .block); |
| 992 | | block.low_pc_off = code_off; |
| 993 | | try dwarf.addrSym(di_nw, debug.wip_nav.func_si, code_off); |
| 994 | | block.high_pc = @intCast(di_w.end); |
| 1089 | block.low_pc = code_offset; |
| 1090 | try dwarf.addrSym(di_nw, debug.wip_func.func_si, code_offset); |
| 1091 | block.high_pc_offset = di_w.end; |
| 995 | 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 { |
| 1000 | | return debug.leaveBlockInner(code_off) catch |err| switch (err) { |
| 1001 | | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.info_writer), |
| 1096 | pub fn leaveBlock(debug: *Debug, code_offset: usize) link.Error!void { |
| 1097 | return debug.leaveBlockInner(code_offset) catch |err| switch (err) { |
| 1002 | 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 { |
| 1006 | | const dwarf = debug.wip_nav.dwarf; |
| 1007 | | const block_size = comptime uleb128Size(@backingInt(AbbrevCode.block)); |
| 1102 | fn leaveBlockInner(debug: *Debug, code_offset: usize) link.EmitError!void { |
| 1103 | const dwarf = debug.wip_func.dwarf; |
| 1008 | 1104 | const block = debug.blocks.pop().?; |
| 1009 | 1105 | |
| 1010 | 1106 | const di_nw = &debug.info_writer; |
| 1011 | 1107 | const di_w = &di_nw.interface; |
| 1012 | | if (debug.any_children) |
| 1013 | | try di_w.writeUleb128(@backingInt(AbbrevCode.null)) |
| 1014 | | else |
| 1015 | | std.leb.writeUnsignedFixed( |
| 1016 | | block_size, |
| 1017 | | di_w.buffered()[block.abbrev_code..][0..block_size], |
| 1018 | | @intCast(try dwarf.refAbbrevCode(di_nw.mf, .empty_block)), |
| 1019 | | ); |
| 1108 | const block_size = comptime uleb128Size(@backingInt(AbbrevCode.block)); |
| 1109 | if (debug.is_empty) std.leb.writeUnsignedFixed( |
| 1110 | block_size, |
| 1111 | di_w.buffered()[block.abbrev_code_offset..][0..block_size], |
| 1112 | @intCast(try dwarf.refAbbrevCode(di_nw.mf, .empty_block)), |
| 1113 | ) else try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 1020 | 1114 | std.mem.writeInt( |
| 1021 | 1115 | u32, |
| 1022 | | di_nw.interface.buffered()[block.high_pc..][0..4], |
| 1023 | | @intCast(code_off - block.low_pc_off), |
| 1116 | di_nw.interface.buffered()[block.high_pc_offset..][0..4], |
| 1117 | @intCast(code_offset - block.low_pc), |
| 1024 | 1118 | dwarf.endian, |
| 1025 | 1119 | ); |
| 1026 | | debug.any_children = true; |
| 1120 | debug.is_empty = false; |
| 1027 | 1121 | } |
| 1028 | 1122 | |
| 1029 | 1123 | pub fn enterInlineFunc( |
| 1030 | 1124 | debug: *Debug, |
| 1031 | 1125 | func: InternPool.Index, |
| 1032 | | code_off: usize, |
| 1126 | code_offset: usize, |
| 1033 | 1127 | line: u32, |
| 1034 | 1128 | column: u32, |
| 1035 | 1129 | ) link.Error!void { |
| 1036 | | return debug.enterInlineFuncInner(func, code_off, line, column) catch |err| switch (err) { |
| 1037 | | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.info_writer), |
| 1130 | return debug.enterInlineFuncInner( |
| 1131 | func, |
| 1132 | code_offset, |
| 1133 | line, |
| 1134 | column, |
| 1135 | ) catch |err| switch (err) { |
| 1038 | 1136 | else => |e| e, |
| 1137 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.info_writer), |
| 1039 | 1138 | }; |
| 1040 | 1139 | } |
| 1041 | 1140 | fn enterInlineFuncInner( |
| 1042 | 1141 | debug: *Debug, |
| 1043 | 1142 | func: InternPool.Index, |
| 1044 | | code_off: usize, |
| 1143 | code_offset: usize, |
| 1045 | 1144 | line: u32, |
| 1046 | 1145 | column: u32, |
| 1047 | 1146 | ) link.EmitError!void { |
| 1048 | | const dwarf = debug.wip_nav.dwarf; |
| 1049 | | const zcu = debug.pt.zcu; |
| 1147 | const dwarf = debug.wip_func.dwarf; |
| 1148 | const pt = debug.pt; |
| 1149 | const zcu = pt.zcu; |
| 1050 | 1150 | const block = try debug.blocks.addOne(zcu.gpa); |
| 1051 | 1151 | |
| 1052 | 1152 | const di_nw = &debug.info_writer; |
| 1053 | 1153 | const di_w = &di_nw.interface; |
| 1054 | | block.abbrev_code = @intCast(di_w.end); |
| 1154 | block.abbrev_code_offset = di_w.end; |
| 1055 | 1155 | try dwarf.abbrevCode(di_nw, .inlined_func); |
| 1056 | | try debug.refFunc(func); |
| 1156 | try dwarf.refConst(pt, di_nw, .fromInterned(func)); |
| 1057 | 1157 | try di_w.writeUleb128((if (zcu.comp.config.incremental) |
| 1058 | 1158 | 0 |
| 1059 | 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 | 1161 | try di_w.writeUleb128(column + 1); |
| 1062 | | block.low_pc_off = code_off; |
| 1063 | | try dwarf.addrSym(di_nw, debug.wip_nav.func_si, code_off); |
| 1064 | | block.high_pc = @intCast(di_w.end); |
| 1162 | block.low_pc = code_offset; |
| 1163 | try dwarf.addrSym(di_nw, debug.wip_func.func_si, code_offset); |
| 1164 | block.high_pc_offset = di_w.end; |
| 1065 | 1165 | try di_w.writeInt(u32, 0, dwarf.endian); |
| 1066 | 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 { |
| 1071 | | return debug.leaveInlineFuncInner(func, code_off) catch |err| switch (err) { |
| 1072 | | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.info_writer), |
| 1170 | pub fn leaveInlineFunc( |
| 1171 | debug: *Debug, |
| 1172 | func: InternPool.Index, |
| 1173 | code_offset: usize, |
| 1174 | ) link.Error!void { |
| 1175 | return debug.leaveInlineFuncInner(func, code_offset) catch |err| switch (err) { |
| 1073 | 1176 | else => |e| e, |
| 1177 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.info_writer), |
| 1074 | 1178 | }; |
| 1075 | 1179 | } |
| 1076 | 1180 | fn leaveInlineFuncInner( |
| 1077 | 1181 | debug: *Debug, |
| 1078 | 1182 | func: InternPool.Index, |
| 1079 | | code_off: usize, |
| 1183 | code_offset: usize, |
| 1080 | 1184 | ) link.EmitError!void { |
| 1081 | | const dwarf = debug.wip_nav.dwarf; |
| 1082 | | const inlined_func_size = comptime uleb128Size(@backingInt(AbbrevCode.inlined_func)); |
| 1185 | const dwarf = debug.wip_func.dwarf; |
| 1083 | 1186 | const block = debug.blocks.pop().?; |
| 1084 | 1187 | |
| 1085 | 1188 | const di_nw = &debug.info_writer; |
| 1086 | 1189 | const di_w = &di_nw.interface; |
| 1087 | | if (debug.any_children) |
| 1088 | | try di_w.writeUleb128(@backingInt(AbbrevCode.null)) |
| 1089 | | else |
| 1090 | | std.leb.writeUnsignedFixed( |
| 1091 | | inlined_func_size, |
| 1092 | | di_w.buffered()[block.abbrev_code..][0..inlined_func_size], |
| 1093 | | @intCast(try dwarf.refAbbrevCode(di_nw.mf, .empty_inlined_func)), |
| 1094 | | ); |
| 1190 | const inlined_func_size = comptime uleb128Size(@backingInt(AbbrevCode.inlined_func)); |
| 1191 | if (debug.is_empty) std.leb.writeUnsignedFixed( |
| 1192 | inlined_func_size, |
| 1193 | di_w.buffered()[block.abbrev_code_offset..][0..inlined_func_size], |
| 1194 | @intCast(try dwarf.refAbbrevCode(di_nw.mf, .empty_inlined_func)), |
| 1195 | ) else try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 1095 | 1196 | std.mem.writeInt( |
| 1096 | 1197 | u32, |
| 1097 | | di_w.buffered()[block.high_pc..][0..4], |
| 1098 | | @intCast(code_off - block.low_pc_off), |
| 1198 | di_w.buffered()[block.high_pc_offset..][0..4], |
| 1199 | @intCast(code_offset - block.low_pc), |
| 1099 | 1200 | dwarf.endian, |
| 1100 | 1201 | ); |
| 1101 | 1202 | try debug.setInlineFunc(func); |
| 1102 | | debug.any_children = true; |
| 1203 | debug.is_empty = false; |
| 1103 | 1204 | } |
| 1104 | 1205 | |
| 1105 | 1206 | pub fn setInlineFunc(debug: *Debug, func: InternPool.Index) link.Error!void { |
| 1106 | 1207 | return debug.setInlineFuncInner(func) catch |err| switch (err) { |
| 1107 | | error.WriteFailed => return debug.wip_nav.dwarf.reportWriteError(&debug.line_writer), |
| 1108 | 1208 | else => |e| e, |
| 1209 | error.WriteFailed => return debug.wip_func.dwarf.reportWriteError(&debug.line_writer), |
| 1109 | 1210 | }; |
| 1110 | 1211 | } |
| 1111 | 1212 | fn setInlineFuncInner(debug: *Debug, func: InternPool.Index) link.EmitError!void { |
| 1112 | 1213 | const zcu = debug.pt.zcu; |
| 1113 | 1214 | const ip = &zcu.intern_pool; |
| 1114 | | const dwarf = debug.wip_nav.dwarf; |
| 1115 | | if (debug.wip_nav.func == func) return; |
| 1215 | const dwarf = debug.wip_func.dwarf; |
| 1216 | if (debug.wip_func.func == func) return; |
| 1116 | 1217 | |
| 1117 | 1218 | const dl_nw = &debug.line_writer; |
| 1118 | 1219 | const dl_w = &dl_nw.interface; |
| ... | ... | @@ -1126,7 +1227,7 @@ pub const WipNav = struct { |
| 1126 | 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 | 1231 | const old_inst_info = ip.getNav(old_owner_nav).srcInst(ip).resolveFull(ip).?; |
| 1131 | 1232 | const old_zf = zcu.fileByIndex(old_inst_info.file); |
| 1132 | 1233 | const new_inst_info = ip.getNav(new_owner_nav).srcInst(ip).resolveFull(ip).?; |
| ... | ... | @@ -1134,7 +1235,7 @@ pub const WipNav = struct { |
| 1134 | 1235 | if (old_inst_info.file != new_inst_info.file) { |
| 1135 | 1236 | const new_ui = dwarf.getUnit(new_zf.mod.?); |
| 1136 | 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 | 1240 | try dl_w.writeByte(DW.LNS.set_file); |
| 1140 | 1241 | try dl_w.writeUleb128(@backingInt(new_fi)); |
| ... | ... | @@ -1147,38 +1248,27 @@ pub const WipNav = struct { |
| 1147 | 1248 | try dl_w.writeSleb128(new_src_line - old_src_line); |
| 1148 | 1249 | } |
| 1149 | 1250 | |
| 1150 | | debug.wip_nav.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 | | ); |
| 1251 | debug.wip_func.func = func; |
| 1161 | 1252 | } |
| 1162 | 1253 | }; |
| 1163 | 1254 | |
| 1164 | | pub fn deinit(wip_nav: *WipNav) void { |
| 1165 | | wip_nav.fde_writer.deinit(); |
| 1166 | | wip_nav.* = undefined; |
| 1255 | pub fn deinit(wip_func: *WipFunc) void { |
| 1256 | wip_func.fde_writer.deinit(); |
| 1257 | wip_func.* = undefined; |
| 1167 | 1258 | } |
| 1168 | 1259 | |
| 1169 | | pub fn genDebugFrameHeader(wip_nav: *WipNav) link.Error!void { |
| 1170 | | wip_nav.genDebugFrameHeaderInner() catch |err| switch (err) { |
| 1171 | | error.WriteFailed => return wip_nav.dwarf.reportWriteError(&wip_nav.fde_writer), |
| 1260 | pub fn genDebugFrameHeader(wip_func: *WipFunc) link.Error!void { |
| 1261 | wip_func.genDebugFrameHeaderInner() catch |err| switch (err) { |
| 1172 | 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 { |
| 1176 | | assert(wip_nav.func != .none); |
| 1177 | | const dwarf = wip_nav.dwarf; |
| 1178 | | const df_nw = &wip_nav.fde_writer; |
| 1266 | fn genDebugFrameHeaderInner(wip_func: *WipFunc) link.EmitError!void { |
| 1267 | const dwarf = wip_func.dwarf; |
| 1268 | const df_nw = &wip_func.fde_writer; |
| 1179 | 1269 | const df_w = &df_nw.interface; |
| 1180 | 1270 | try dwarf.genUnitLength(df_w); |
| 1181 | | switch (wip_nav.frame_format) { |
| 1271 | switch (wip_func.frame_format) { |
| 1182 | 1272 | .eh_frame => { |
| 1183 | 1273 | try df_w.writeInt(u32, undefined, dwarf.endian); |
| 1184 | 1274 | { |
| ... | ... | @@ -1187,51 +1277,50 @@ pub const WipNav = struct { |
| 1187 | 1277 | if (dwarf.lf.cast(.elf2)) |elf| try elf.addReloc( |
| 1188 | 1278 | @bitCast(df_nw.ni), |
| 1189 | 1279 | offset, |
| 1190 | | wip_nav.func_si, |
| 1280 | wip_func.func_si, |
| 1191 | 1281 | 0, |
| 1192 | 1282 | .rel32(elf), |
| 1193 | 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 | 1286 | try df_w.writeInt(u32, undefined, dwarf.endian); |
| 1197 | 1287 | try df_w.writeUleb128(0); |
| 1198 | 1288 | }, |
| 1199 | 1289 | .debug_frame => { |
| 1200 | | try dwarf.secOffset(df_nw, wip_nav.unit.get(dwarf).cie_ni.unwrap().?, 0); |
| 1201 | | try dwarf.addrSym(df_nw, wip_nav.func_si, 0); |
| 1202 | | wip_nav.frame_func_length = .{ .offset = df_w.end, .size = dwarf.address_size }; |
| 1290 | try dwarf.secOffset(df_nw, wip_func.unit.get(dwarf).cie_ni.unwrap().?, 0); |
| 1291 | try dwarf.addrSym(df_nw, wip_func.func_si, 0); |
| 1292 | wip_func.frame_func_length = .{ .offset = df_w.end, .size = dwarf.address_size }; |
| 1203 | 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 { |
| 1209 | | return wip_nav.genDebugFrameInner(loc, cfa) catch |err| switch (err) { |
| 1210 | | error.WriteFailed => return wip_nav.dwarf.reportWriteError(&wip_nav.fde_writer), |
| 1298 | pub fn genDebugFrame(wip_func: *WipFunc, loc: u32, cfa: Cfa) link.Error!void { |
| 1299 | return wip_func.genDebugFrameInner(loc, cfa) catch |err| switch (err) { |
| 1211 | 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 { |
| 1215 | | assert(wip_nav.func != .none); |
| 1304 | fn genDebugFrameInner(wip_func: *WipFunc, loc: u32, cfa: Cfa) link.EmitError!void { |
| 1216 | 1305 | const loc_cfa: Cfa = .{ .advance_loc = loc }; |
| 1217 | | try loc_cfa.write(wip_nav); |
| 1218 | | try cfa.write(wip_nav); |
| 1306 | try loc_cfa.write(wip_func); |
| 1307 | try cfa.write(wip_func); |
| 1219 | 1308 | } |
| 1220 | 1309 | |
| 1221 | | pub fn finishDebugFrameFde(wip_nav: *WipNav, func_length: u64) void { |
| 1222 | | const dwarf = wip_nav.dwarf; |
| 1223 | | const df_w = &wip_nav.fde_writer.interface; |
| 1224 | | switch (wip_nav.frame_func_length.size) { |
| 1310 | pub fn finishDebugFrameFde(wip_func: *WipFunc, func_length: u64) void { |
| 1311 | const dwarf = wip_func.dwarf; |
| 1312 | const df_w = &wip_func.fde_writer.interface; |
| 1313 | switch (wip_func.frame_func_length.size) { |
| 1225 | 1314 | _ => unreachable, |
| 1226 | 1315 | .@"32" => std.mem.writeInt( |
| 1227 | 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 | 1318 | @intCast(func_length), |
| 1230 | 1319 | dwarf.endian, |
| 1231 | 1320 | ), |
| 1232 | 1321 | .@"64" => std.mem.writeInt( |
| 1233 | 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 | 1324 | func_length, |
| 1236 | 1325 | dwarf.endian, |
| 1237 | 1326 | ), |
| ... | ... | @@ -1258,13 +1347,18 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf { |
| 1258 | 1347 | .globals = .empty, |
| 1259 | 1348 | .funcs = .empty, |
| 1260 | 1349 | .decls = .empty, |
| 1261 | | .pending_decl = .{ .di = undefined, .instance_val = .none }, |
| 1350 | .pending_decl = .{ .di = undefined, .instance = .none }, |
| 1262 | 1351 | |
| 1263 | 1352 | .debug_abbrev = .{ |
| 1264 | 1353 | .ni = .none, |
| 1265 | 1354 | .end = 0, |
| 1266 | 1355 | .set = .empty, |
| 1267 | 1356 | }, |
| 1357 | .debug_addr = .{ |
| 1358 | .ni = .none, |
| 1359 | .pending_index = 0, |
| 1360 | .map = .empty, |
| 1361 | }, |
| 1268 | 1362 | .frame = .{ |
| 1269 | 1363 | .header = if (target.cpu.arch == .x86_64 and target.ofmt == .elf) header: { |
| 1270 | 1364 | dev.checkAny(&.{ .llvm_backend, .x86_64_backend }); |
| ... | ... | @@ -1308,18 +1402,19 @@ pub fn init(lf: *link.File, format: DW.Format) Dwarf { |
| 1308 | 1402 | }, |
| 1309 | 1403 | .debug_line_str = .{ |
| 1310 | 1404 | .ni = .none, |
| 1311 | | .offset = 0, |
| 1405 | .end = 0, |
| 1312 | 1406 | .map = .empty, |
| 1313 | 1407 | }, |
| 1314 | 1408 | .debug_rnglists = .{}, |
| 1315 | 1409 | .debug_str = .{ |
| 1316 | 1410 | .ni = .none, |
| 1317 | | .offset = 0, |
| 1411 | .end = 0, |
| 1318 | 1412 | .map = .empty, |
| 1319 | 1413 | }, |
| 1320 | 1414 | .debug_str_offsets = .{ |
| 1321 | 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 | 1428 | dwarf.globals.deinit(gpa); |
| 1334 | 1429 | dwarf.funcs.deinit(gpa); |
| 1335 | 1430 | dwarf.decls.deinit(gpa); |
| 1431 | dwarf.debug_addr.map.deinit(gpa); |
| 1336 | 1432 | dwarf.debug_line_str.map.deinit(gpa); |
| 1337 | 1433 | dwarf.debug_str.map.deinit(gpa); |
| 1434 | dwarf.debug_str_offsets.map.deinit(gpa); |
| 1338 | 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 | 1486 | |
| 1390 | 1487 | pub fn getGlobal(dwarf: *Dwarf, nav: InternPool.Nav.Index) link.Error!Global.Index { |
| 1391 | 1488 | const comp = dwarf.lf.comp; |
| 1392 | | const gpa = comp.gpa; |
| 1393 | | const global_gop = try dwarf.globals.getOrPut(gpa, nav); |
| 1489 | const global_gop = try dwarf.globals.getOrPut(comp.gpa, nav); |
| 1394 | 1490 | if (!global_gop.found_existing) global_gop.value_ptr.* = .{ |
| 1395 | 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 | 1494 | if (global_gop.value_ptr.debug_info_ni != .none) return gi; |
| 1399 | 1495 | const mod = comp.zcu.?.navFileScope(nav).mod.?; |
| 1400 | 1496 | assert(!mod.strip); |
| 1401 | | const elf = dwarf.lf.cast(.elf2).?; |
| 1402 | | try elf.nodes.ensureUnusedCapacity(gpa, 1); |
| 1403 | | try elf.dwarf_globals.append(gpa, .{ |
| 1404 | | .debug_info_first_target_reloc = .none, |
| 1405 | | .debug_info_first_node_reloc = .none, |
| 1406 | | .debug_info_first_symbol_reloc = .none, |
| 1407 | | }); |
| 1408 | | const unit = dwarf.getUnit(mod).get(dwarf); |
| 1409 | | global_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( |
| 1410 | | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ |
| 1411 | | .enable_next_moved = true, |
| 1412 | | }) catch |err| switch (err) { |
| 1413 | | else => |e| return e, |
| 1414 | | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| 1415 | | elf.mf.io_err.?, |
| 1416 | | }), |
| 1417 | | }, |
| 1418 | | .{ .global_debug_info = gi }, |
| 1419 | | )); |
| 1497 | if (dwarf.lf.cast(.elf2)) |elf| { |
| 1498 | try elf.nodes.ensureUnusedCapacity(comp.gpa, 1); |
| 1499 | try elf.dwarf_globals.append(comp.gpa, .{ |
| 1500 | .debug_info_first_target_reloc = .none, |
| 1501 | .debug_info_first_node_reloc = .none, |
| 1502 | .debug_info_first_symbol_reloc = .none, |
| 1503 | }); |
| 1504 | const unit = dwarf.getUnit(mod).get(dwarf); |
| 1505 | global_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( |
| 1506 | unit.debug_info_ni.unwrap().?.addFloatingChild(comp.gpa, &elf.mf, .{ |
| 1507 | .enable_next_moved = true, |
| 1508 | }) catch |err| switch (err) { |
| 1509 | else => |e| return e, |
| 1510 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| 1511 | elf.mf.io_err.?, |
| 1512 | }), |
| 1513 | }, |
| 1514 | .{ .global_debug_info = gi }, |
| 1515 | )); |
| 1516 | } else unreachable; |
| 1420 | 1517 | return gi; |
| 1421 | 1518 | } |
| 1422 | 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 | 1533 | const fi: Func.Index = @fromBackingInt(@intCast(func_gop.index)); |
| 1437 | 1534 | if (func_gop.value_ptr.debug_info_ni != .none) return fi; |
| 1438 | 1535 | const mod = comp.zcu.?.navFileScope(nav).mod.?; |
| 1439 | | const elf = dwarf.lf.cast(.elf2).?; |
| 1440 | | try elf.nodes.ensureUnusedCapacity(gpa, 1); |
| 1441 | | try elf.dwarf_funcs.append(gpa, .{ |
| 1442 | | .frame_fde_first_symbol_reloc = .none, |
| 1443 | | .frame_fde_first_node_reloc = .none, |
| 1444 | | .debug_info_first_target_reloc = .none, |
| 1445 | | .debug_info_first_symbol_reloc = .none, |
| 1446 | | .debug_info_first_node_reloc = .none, |
| 1447 | | .debug_line_first_symbol_reloc = .none, |
| 1448 | | .debug_line_first_node_reloc = .none, |
| 1449 | | }); |
| 1450 | | if (mod.strip) return fi; |
| 1451 | | const unit = dwarf.getUnit(mod).get(dwarf); |
| 1452 | | func_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( |
| 1453 | | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ |
| 1454 | | .enable_next_moved = true, |
| 1455 | | }) catch |err| switch (err) { |
| 1456 | | else => |e| return e, |
| 1457 | | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| 1458 | | elf.mf.io_err.?, |
| 1459 | | }), |
| 1460 | | }, |
| 1461 | | .{ .func_debug_info = fi }, |
| 1462 | | )); |
| 1536 | if (dwarf.lf.cast(.elf2)) |elf| { |
| 1537 | try elf.nodes.ensureUnusedCapacity(gpa, 1); |
| 1538 | try elf.dwarf_funcs.append(gpa, .{ |
| 1539 | .frame_fde_first_symbol_reloc = .none, |
| 1540 | .frame_fde_first_node_reloc = .none, |
| 1541 | .debug_info_first_target_reloc = .none, |
| 1542 | .debug_info_first_symbol_reloc = .none, |
| 1543 | .debug_info_first_node_reloc = .none, |
| 1544 | .debug_line_first_symbol_reloc = .none, |
| 1545 | .debug_line_first_node_reloc = .none, |
| 1546 | }); |
| 1547 | if (mod.strip) return fi; |
| 1548 | const unit = dwarf.getUnit(mod).get(dwarf); |
| 1549 | func_gop.value_ptr.debug_info_ni = .wrap(elf.addNodeAssumeCapacity( |
| 1550 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ |
| 1551 | .enable_next_moved = true, |
| 1552 | }) catch |err| switch (err) { |
| 1553 | else => |e| return e, |
| 1554 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| 1555 | elf.mf.io_err.?, |
| 1556 | }), |
| 1557 | }, |
| 1558 | .{ .func_debug_info = fi }, |
| 1559 | )); |
| 1560 | } else unreachable; |
| 1463 | 1561 | return fi; |
| 1464 | 1562 | } |
| 1465 | 1563 | pub fn getFuncIfExists(dwarf: *Dwarf, nav: InternPool.Nav.Index) ?Func.Index { |
| 1466 | 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 { |
| 1470 | | const ip = &dwarf.lf.comp.zcu.?.intern_pool; |
| 1471 | | switch (ip.indexToKey(val)) { |
| 1567 | fn getConstDeclInst(dwarf: *Dwarf, @"const": InternPool.Index) union(enum) { |
| 1568 | @"const": InternPool.Index, |
| 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 | 1574 | else => unreachable, |
| 1473 | 1575 | .struct_type, .union_type, .enum_type, .opaque_type => |container, tag| switch (container) { |
| 1474 | 1576 | .declared => |declared| switch (declared.captures.owned.len) { |
| 1475 | | 0 => return null, |
| 1476 | | else => switch (tag) { |
| 1577 | 0 => return .{ .@"const" = @"const" }, |
| 1578 | else => return .{ .src_inst = src_inst: switch (tag) { |
| 1477 | 1579 | else => unreachable, |
| 1478 | 1580 | .struct_type => { |
| 1479 | | const loaded_struct = ip.loadStructType(val); |
| 1480 | | return ip.getNav(loaded_struct.name_nav.unwrap() orelse |
| 1481 | | return loaded_struct.zir_index).srcInst(ip); |
| 1581 | const loaded_struct = ip.loadStructType(@"const"); |
| 1582 | break :src_inst ip.getNav(loaded_struct.name_nav.unwrap() orelse |
| 1583 | break :src_inst loaded_struct.zir_index).srcInst(ip); |
| 1482 | 1584 | }, |
| 1483 | 1585 | .union_type => { |
| 1484 | | const loaded_union = ip.loadUnionType(val); |
| 1485 | | return ip.getNav(loaded_union.name_nav.unwrap() orelse |
| 1486 | | return loaded_union.zir_index).srcInst(ip); |
| 1586 | const loaded_union = ip.loadUnionType(@"const"); |
| 1587 | break :src_inst ip.getNav(loaded_union.name_nav.unwrap() orelse |
| 1588 | break :src_inst loaded_union.zir_index).srcInst(ip); |
| 1487 | 1589 | }, |
| 1488 | 1590 | .enum_type => { |
| 1489 | | const loaded_enum = ip.loadEnumType(val); |
| 1490 | | return ip.getNav(loaded_enum.name_nav.unwrap() orelse |
| 1491 | | return loaded_enum.zir_index.unwrap().?).srcInst(ip); |
| 1591 | const loaded_enum = ip.loadEnumType(@"const"); |
| 1592 | break :src_inst ip.getNav(loaded_enum.name_nav.unwrap() orelse |
| 1593 | break :src_inst loaded_enum.zir_index.unwrap().?).srcInst(ip); |
| 1492 | 1594 | }, |
| 1493 | 1595 | .opaque_type => { |
| 1494 | | const loaded_opaque = ip.loadOpaqueType(val); |
| 1495 | | return ip.getNav(loaded_opaque.name_nav.unwrap() orelse |
| 1496 | | return loaded_opaque.zir_index).srcInst(ip); |
| 1596 | const loaded_opaque = ip.loadOpaqueType(@"const"); |
| 1597 | break :src_inst ip.getNav(loaded_opaque.name_nav.unwrap() orelse |
| 1598 | break :src_inst loaded_opaque.zir_index).srcInst(ip); |
| 1497 | 1599 | }, |
| 1498 | | }, |
| 1600 | } }, |
| 1499 | 1601 | }, |
| 1500 | 1602 | .reified => |reified| { |
| 1501 | 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 | 1606 | .generated_union_tag => unreachable, |
| 1505 | 1607 | }, |
| 1506 | | .func => |func| return ip.getNav(switch (func.generic_owner) { |
| 1507 | | .none => func.owner_nav, |
| 1508 | | else => |generic_owner| ip.indexToKey(generic_owner).func.owner_nav, |
| 1509 | | }).srcInst(ip), |
| 1608 | .func => |func| switch (func.generic_owner) { |
| 1609 | else => |generic_owner| return .{ .@"const" = generic_owner }, |
| 1610 | .none => { |
| 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 | 1644 | dwarf: *Dwarf, |
| 1514 | 1645 | pt: Zcu.PerThread, |
| 1515 | | instance_val: InternPool.Index, |
| 1646 | inst: InternPool.TrackedInst.Index, |
| 1647 | instance: Decl.Instance, |
| 1516 | 1648 | ) link.Error!link.MappedFile.Node.Index { |
| 1517 | | assert(dwarf.pending_decl.instance_val == .none); |
| 1518 | 1649 | const comp = dwarf.lf.comp; |
| 1519 | 1650 | const gpa = comp.gpa; |
| 1520 | 1651 | const zcu = pt.zcu; |
| 1521 | 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 | 1653 | const decl_gop = try dwarf.decls.getOrPut(gpa, inst); |
| 1527 | 1654 | if (!decl_gop.found_existing) decl_gop.value_ptr.* = .{ |
| 1528 | 1655 | .debug_info_ni = .none, |
| 1529 | 1656 | }; |
| 1530 | 1657 | const di: Decl.Index = @fromBackingInt(@intCast(decl_gop.index)); |
| 1531 | 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 }; |
| 1533 | | const elf = dwarf.lf.cast(.elf2).?; |
| 1534 | | try elf.nodes.ensureUnusedCapacity(gpa, 1); |
| 1535 | | try elf.dwarf_decls.putNoClobber(gpa, di, .{ |
| 1536 | | .debug_info_first_target_reloc = .none, |
| 1537 | | .debug_info_first_node_reloc = .none, |
| 1538 | | }); |
| 1539 | | const unit = dwarf.getUnit(zcu.fileByIndex(di.srcInst(dwarf).resolveFile(ip)).mod.?).get(dwarf); |
| 1540 | | const debug_info_ni = elf.addNodeAssumeCapacity( |
| 1541 | | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ |
| 1542 | | .enable_next_moved = true, |
| 1543 | | }) catch |err| switch (err) { |
| 1544 | | else => |e| return e, |
| 1545 | | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| 1546 | | elf.mf.io_err.?, |
| 1547 | | }), |
| 1548 | | }, |
| 1549 | | .{ .decl_debug_info = di }, |
| 1550 | | ); |
| 1659 | dwarf.pending_decl = .{ .di = di, .instance = instance }; |
| 1660 | const debug_info_ni = if (dwarf.lf.cast(.elf2)) |elf| debug_info_ni: { |
| 1661 | try elf.nodes.ensureUnusedCapacity(gpa, 1); |
| 1662 | try elf.dwarf_decls.putNoClobber(gpa, di, .{ |
| 1663 | .debug_info_first_target_reloc = .none, |
| 1664 | .debug_info_first_node_reloc = .none, |
| 1665 | }); |
| 1666 | const unit = dwarf.getUnit(zcu.fileByIndex(di.srcInst(dwarf).resolveFile(ip)).mod.?).get(dwarf); |
| 1667 | const debug_info_ni = elf.addNodeAssumeCapacity( |
| 1668 | unit.debug_info_ni.unwrap().?.addFloatingChild(gpa, &elf.mf, .{ |
| 1669 | .enable_next_moved = true, |
| 1670 | }) catch |err| switch (err) { |
| 1671 | else => |e| return e, |
| 1672 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| 1673 | elf.mf.io_err.?, |
| 1674 | }), |
| 1675 | }, |
| 1676 | .{ .decl_debug_info = di }, |
| 1677 | ); |
| 1678 | break :debug_info_ni debug_info_ni; |
| 1679 | } else unreachable; |
| 1551 | 1680 | decl_gop.value_ptr.debug_info_ni = .wrap(debug_info_ni); |
| 1552 | 1681 | return debug_info_ni; |
| 1553 | 1682 | } |
| ... | ... | @@ -1561,7 +1690,7 @@ pub fn unitLengthSize(dwarf: *Dwarf) usize { |
| 1561 | 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 | 1694 | switch (dwarf.format) { |
| 1566 | 1695 | .@"32" => try w.writeInt(u32, undefined, dwarf.endian), |
| 1567 | 1696 | .@"64" => { |
| ... | ... | @@ -1582,6 +1711,24 @@ pub fn genUnitPadding(dwarf: *Dwarf, w: *std.Io.Writer) std.Io.Writer.Error!void |
| 1582 | 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 | 1732 | pub const EhFrameHdr = extern struct { |
| 1586 | 1733 | version: u8, |
| 1587 | 1734 | eh_frame_ptr_enc: std.dwarf.EH.PE, |
| ... | ... | @@ -1637,11 +1784,7 @@ pub fn genDebugFrameCie( |
| 1637 | 1784 | const Register = @import("../codegen/x86_64/bits.zig").Register; |
| 1638 | 1785 | switch (format) { |
| 1639 | 1786 | .eh_frame => try df_w.writeAll("zR\x00"), |
| 1640 | | .debug_frame => { |
| 1641 | | try df_w.writeAll("\x00"); |
| 1642 | | try df_w.writeByte(@backingInt(dwarf.address_size)); |
| 1643 | | try df_w.writeByte(0); |
| 1644 | | }, |
| 1787 | .debug_frame => try df_w.writeAll("\x00" ++ .{ @backingInt(dwarf.address_size), 0 }), |
| 1645 | 1788 | } |
| 1646 | 1789 | try df_w.writeUleb128(dwarf.frame.header.code_alignment_factor); |
| 1647 | 1790 | try df_w.writeSleb128(dwarf.frame.header.data_alignment_factor); |
| ... | ... | @@ -1688,28 +1831,29 @@ pub fn genDebugInfoHeader( |
| 1688 | 1831 | if (!unit.alive) return dwarf.genUnitPadding(dih_w); |
| 1689 | 1832 | try dwarf.genUnitLength(dih_w); |
| 1690 | 1833 | try dih_w.writeInt(u16, 5, dwarf.endian); |
| 1691 | | try dih_w.writeByte(DW.UT.compile); |
| 1692 | | try dih_w.writeByte(@backingInt(dwarf.address_size)); |
| 1834 | try dih_w.writeAll(&.{ DW.UT.compile, @backingInt(dwarf.address_size) }); |
| 1693 | 1835 | try dwarf.secOffset(dih_nw, dwarf.debug_abbrev.ni.unwrap().?, 0); |
| 1694 | 1836 | const compile_unit_offset = dih_w.end; |
| 1695 | 1837 | try dwarf.abbrevCode(dih_nw, .compile_unit); |
| 1696 | 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 | 1839 | try dwarf.secOffset( |
| 1703 | 1840 | dih_nw, |
| 1704 | 1841 | dwarf.getUnit(zcu.root_mod).get(dwarf).debug_info_header_ni.unwrap().?, |
| 1705 | 1842 | compile_unit_offset, |
| 1706 | 1843 | ); |
| 1707 | 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 | 1853 | try dih_w.writeUleb128(0); |
| 1710 | 1854 | const module_offset = dih_w.end; |
| 1711 | 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 | 1857 | try dih_w.writeUleb128(0); |
| 1714 | 1858 | try dwarf.genModuleDependency( |
| 1715 | 1859 | dih_nw, |
| ... | ... | @@ -1735,7 +1879,7 @@ fn genModuleDependency( |
| 1735 | 1879 | const dep_unit = dwarf.getUnit(dep).get(dwarf); |
| 1736 | 1880 | if (!dep_unit.alive) return; |
| 1737 | 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 | 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 | 1923 | const dlh_w = &dlh_nw.interface; |
| 1780 | 1924 | try dwarf.genUnitLength(dlh_w); |
| 1781 | 1925 | try dlh_w.writeInt(u16, 5, dwarf.endian); |
| 1782 | | try dlh_w.writeByte(@backingInt(dwarf.address_size)); |
| 1783 | | try dlh_w.writeByte(0); |
| 1926 | try dlh_w.writeAll(&.{ @backingInt(dwarf.address_size), 0 }); |
| 1784 | 1927 | const header_length_offset = dlh_w.end; |
| 1785 | 1928 | switch (dwarf.format) { |
| 1786 | 1929 | .@"32" => try dlh_w.writeInt(u32, undefined, dwarf.endian), |
| ... | ... | @@ -1852,11 +1995,7 @@ pub fn genDebugLineHeader( |
| 1852 | 1995 | } |
| 1853 | 1996 | try dlh_w.writeInt(i64, @truncate(zf.stat.mtime.nanoseconds), dwarf.endian); |
| 1854 | 1997 | try dlh_w.writeInt(u64, zf.stat.size, dwarf.endian); |
| 1855 | | try dwarf.strp( |
| 1856 | | &dwarf.debug_line_str, |
| 1857 | | dlh_nw, |
| 1858 | | if (zf.is_builtin) zf.source.? else "", |
| 1859 | | ); |
| 1998 | try dwarf.strp(&dwarf.debug_line_str, dlh_nw, if (zf.is_builtin) zf.source.? else ""); |
| 1860 | 1999 | } |
| 1861 | 2000 | switch (dwarf.format) { |
| 1862 | 2001 | .@"32" => std.mem.writeInt( |
| ... | ... | @@ -1915,10 +2054,9 @@ pub fn genDebugRnglistsHeader( |
| 1915 | 2054 | const drh_w = &drh_nw.interface; |
| 1916 | 2055 | try dwarf.genUnitLength(drh_w); |
| 1917 | 2056 | try drh_w.writeInt(u16, 5, dwarf.endian); |
| 1918 | | try drh_w.writeByte(@backingInt(dwarf.address_size)); |
| 1919 | | try drh_w.writeByte(0); |
| 2057 | try drh_w.writeAll(&.{ @backingInt(dwarf.address_size), 0 }); |
| 1920 | 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 | 2060 | switch (dwarf.format) { |
| 1923 | 2061 | .@"32" => try drh_w.writeInt(u32, 4, dwarf.endian), |
| 1924 | 2062 | .@"64" => try drh_w.writeInt(u64, 8, dwarf.endian), |
| ... | ... | @@ -1927,7 +2065,7 @@ pub fn genDebugRnglistsHeader( |
| 1927 | 2065 | try drh_w.writeByte(DW.RLE.end_of_list); |
| 1928 | 2066 | } |
| 1929 | 2067 | |
| 1930 | | pub fn genDebugRnglists( |
| 2068 | pub fn genDebugRnglistsRange( |
| 1931 | 2069 | dwarf: *Dwarf, |
| 1932 | 2070 | unit: *Unit, |
| 1933 | 2071 | dr_nw: *link.MappedFile.Node.Writer, |
| ... | ... | @@ -1936,74 +2074,396 @@ pub fn genDebugRnglists( |
| 1936 | 2074 | ) link.EmitError!void { |
| 1937 | 2075 | const dr_w = &dr_nw.interface; |
| 1938 | 2076 | dr_w.end = unit.debug_rnglists_end; |
| 1939 | | try dr_w.writeByte(DW.RLE.start_length); |
| 1940 | | try dwarf.addrSym(dr_nw, func_si, 0); |
| 2077 | try dr_w.writeByte(DW.RLE.startx_length); |
| 2078 | try dwarf.addrxSym(dr_w, func_si); |
| 1941 | 2079 | try dr_w.writeUleb128(func_length); |
| 1942 | 2080 | unit.debug_rnglists_end = dr_w.end; |
| 1943 | 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 | 2295 | dwarf: *Dwarf, |
| 1948 | 2296 | pt: Zcu.PerThread, |
| 1949 | | nav_index: InternPool.Nav.Index, |
| 2297 | global: InternPool.Nav.Index, |
| 1950 | 2298 | ) link.Error!void { |
| 1951 | 2299 | const zcu = pt.zcu; |
| 1952 | 2300 | const ip = &zcu.intern_pool; |
| 1953 | | const nav = ip.getNav(nav_index); |
| 1954 | | log.debug("updateComptimeNav({f})", .{nav.fqn.fmt(ip)}); |
| 2301 | const nav = ip.getNav(global); |
| 2302 | log.debug("updateComptimeGlobal({f})", .{nav.fqn.fmt(ip)}); |
| 1955 | 2303 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; |
| 1956 | 2304 | const nav_val: Value = .fromInterned(nav.resolved.?.value); |
| 1957 | | const zf = zcu.fileByIndex(inst_info.file); |
| 1958 | | const decl = zf.zir.?.getDeclaration(inst_info.inst); |
| 2305 | const decl = zcu.fileByIndex(inst_info.file).zir.?.getDeclaration(inst_info.inst); |
| 1959 | 2306 | switch (decl.kind) { |
| 1960 | 2307 | .unnamed_test, .@"test", .decltest => return, |
| 1961 | 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 | 2339 | .struct_type => { |
| 1965 | 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 | 2342 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); |
| 1968 | | break :done; |
| 1969 | | } |
| 1970 | | return; |
| 2343 | } else try dwarf.genComptimeGlobal(pt, global, &decl); |
| 1971 | 2344 | }, |
| 1972 | 2345 | .enum_type => { |
| 1973 | 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 | 2348 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); |
| 1976 | | break :done; |
| 1977 | | } |
| 1978 | | return; |
| 2349 | } else try dwarf.genComptimeGlobal(pt, global, &decl); |
| 1979 | 2350 | }, |
| 1980 | 2351 | .union_type => { |
| 1981 | 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 | 2354 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); |
| 1984 | | break :done; |
| 1985 | | } |
| 1986 | | return; |
| 2355 | } else try dwarf.genComptimeGlobal(pt, global, &decl); |
| 1987 | 2356 | }, |
| 1988 | 2357 | .opaque_type => { |
| 1989 | 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 | 2360 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); |
| 1992 | | break :done; |
| 1993 | | } |
| 1994 | | return; |
| 2361 | } else try dwarf.genComptimeGlobal(pt, global, &decl); |
| 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 | 2365 | _ = try dwarf.const_pool.get(pt, dwarf.constPoolUser(), nav_val.toIntern()); |
| 1998 | | break :done; |
| 1999 | | } else return, |
| 2000 | | |
| 2001 | | else => return, |
| 2002 | | |
| 2003 | | // memoization, not values |
| 2004 | | .memoized_call => unreachable, |
| 2366 | } else try dwarf.genComptimeGlobal(pt, global, &decl), |
| 2367 | .memoized_call => unreachable, // not a value |
| 2368 | } |
| 2369 | } |
| 2370 | fn genComptimeGlobal( |
| 2371 | dwarf: *Dwarf, |
| 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 | 2469 | pub fn addConst( |
| ... | ... | @@ -2041,9 +2501,11 @@ pub fn addConst( |
| 2041 | 2501 | const name_gi = try dwarf.getGlobal(name_nav); |
| 2042 | 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 | 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 | 2510 | }.toOptional(), |
| 2049 | 2511 | }); |
| ... | ... | @@ -2068,17 +2530,17 @@ fn updateConstInner( |
| 2068 | 2530 | dwarf: *Dwarf, |
| 2069 | 2531 | pt: Zcu.PerThread, |
| 2070 | 2532 | di_nw: *link.MappedFile.Node.Writer, |
| 2071 | | val: InternPool.Index, |
| 2533 | @"const": InternPool.Index, |
| 2072 | 2534 | ) link.EmitError!void { |
| 2073 | 2535 | const zcu = pt.zcu; |
| 2074 | 2536 | const ip = &zcu.intern_pool; |
| 2075 | 2537 | const di_w = &di_nw.interface; |
| 2076 | | switch (ip.indexToKey(val)) { |
| 2538 | switch (ip.indexToKey(@"const")) { |
| 2077 | 2539 | .int_type => |int_type| { |
| 2078 | | const ty: Type = .fromInterned(val); |
| 2540 | const ty: Type = .fromInterned(@"const"); |
| 2079 | 2541 | try dwarf.abbrevCode(di_nw, .numeric_type); |
| 2080 | 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 | 2544 | ty.fmt(pt), |
| 2083 | 2545 | }) catch unreachable); |
| 2084 | 2546 | try di_w.writeByte(switch (int_type.signedness) { |
| ... | ... | @@ -2091,56 +2553,54 @@ fn updateConstInner( |
| 2091 | 2553 | }, |
| 2092 | 2554 | .ptr_type => |ptr_type| switch (ptr_type.flags.size) { |
| 2093 | 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 | 2557 | defer zcu.gpa.free(name); |
| 2096 | 2558 | try dwarf.abbrevCode(di_nw, switch (ptr_type.sentinel) { |
| 2097 | | .none => switch (ptr_type.flags.alignment) { |
| 2098 | | .none => .ptr_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 | | }, |
| 2559 | .none => .ptr_type, |
| 2560 | else => .ptr_sentinel_type, |
| 2105 | 2561 | }); |
| 2106 | | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| 2562 | try dwarf.strx(di_nw, name); |
| 2107 | 2563 | switch (ptr_type.sentinel) { |
| 2108 | 2564 | .none => {}, |
| 2109 | 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 | 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( |
| 2114 | | di_nw, |
| 2115 | | di_nw.ni, |
| 2116 | | di_w.end + dwarf.secOffsetSize(), |
| 2117 | | ); |
| 2568 | if (ptr_type.flags.alignment.toByteUnits()) |a| { |
| 2569 | const type_offset = di_w.end; |
| 2570 | try dwarf.secOffsetPlaceholder(di_w); |
| 2571 | try dwarf.secOffsetFinish(di_nw, type_offset, di_nw.ni, di_w.end); |
| 2572 | try dwarf.abbrevCode(di_nw, .is_aligned); |
| 2573 | try di_w.writeUleb128(a); |
| 2574 | } |
| 2118 | 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 | 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 | 2587 | try dwarf.refType(pt, di_nw, .fromInterned(ptr_type.child)); |
| 2128 | 2588 | }, |
| 2129 | 2589 | .slice => { |
| 2130 | | const ty: Type = .fromInterned(val); |
| 2590 | const ty: Type = .fromInterned(@"const"); |
| 2131 | 2591 | const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)}); |
| 2132 | 2592 | defer zcu.gpa.free(name); |
| 2133 | 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 | 2595 | try di_w.writeUleb128(ty.abiSize(zcu)); |
| 2136 | 2596 | try di_w.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); |
| 2137 | 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 | 2599 | const ptr_field_ty = ty.slicePtrFieldType(zcu); |
| 2140 | 2600 | try dwarf.refType(pt, di_nw, ptr_field_ty); |
| 2141 | 2601 | try di_w.writeUleb128(0); |
| 2142 | 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 | 2604 | const len_field_ty: Type = .usize; |
| 2145 | 2605 | try dwarf.refType(pt, di_nw, len_field_ty); |
| 2146 | 2606 | try di_w.writeUleb128(len_field_ty.abiAlignment(zcu).forward(ptr_field_ty.abiSize(zcu))); |
| ... | ... | @@ -2148,13 +2608,13 @@ fn updateConstInner( |
| 2148 | 2608 | }, |
| 2149 | 2609 | }, |
| 2150 | 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 | 2612 | defer zcu.gpa.free(name); |
| 2153 | 2613 | try dwarf.abbrevCode( |
| 2154 | 2614 | di_nw, |
| 2155 | 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 | 2618 | if (array_type.sentinel != .none) |
| 2159 | 2619 | try dwarf.blockConst(pt, di_nw, .fromInterned(array_type.sentinel)); |
| 2160 | 2620 | try dwarf.refType(pt, di_nw, .fromInterned(array_type.child)); |
| ... | ... | @@ -2164,10 +2624,10 @@ fn updateConstInner( |
| 2164 | 2624 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2165 | 2625 | }, |
| 2166 | 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 | 2628 | defer zcu.gpa.free(name); |
| 2169 | 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 | 2631 | try dwarf.refType(pt, di_nw, .fromInterned(vector_type.child)); |
| 2172 | 2632 | try dwarf.abbrevCode(di_nw, .array_len); |
| 2173 | 2633 | try dwarf.refType(pt, di_nw, .usize); |
| ... | ... | @@ -2175,28 +2635,30 @@ fn updateConstInner( |
| 2175 | 2635 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2176 | 2636 | }, |
| 2177 | 2637 | .opt_type => |opt_child_type_index| { |
| 2178 | | const opt_ty: Type = .fromInterned(val); |
| 2638 | const opt_ty: Type = .fromInterned(@"const"); |
| 2179 | 2639 | const opt_child_ty: Type = .fromInterned(opt_child_type_index); |
| 2180 | 2640 | const opt_repr = optRepr(opt_child_ty, zcu); |
| 2181 | 2641 | const name = try zcu.gpa.print("{f}", .{opt_ty.fmt(pt)}); |
| 2182 | 2642 | defer zcu.gpa.free(name); |
| 2183 | 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 | 2645 | try di_w.writeUleb128(opt_ty.abiSize(zcu)); |
| 2186 | 2646 | try di_w.writeUleb128(opt_ty.abiAlignment(zcu).toByteUnits().?); |
| 2187 | 2647 | switch (opt_repr) { |
| 2188 | 2648 | .opv_null => { |
| 2189 | 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 | 2651 | try dwarf.refType(pt, di_nw, .null); |
| 2192 | 2652 | try di_w.writeUleb128(0); |
| 2193 | 2653 | }, |
| 2194 | 2654 | .unpacked, .error_set, .pointer => { |
| 2195 | 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 | 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 | 2662 | switch (opt_repr) { |
| 2201 | 2663 | .opv_null => unreachable, |
| 2202 | 2664 | .unpacked => { |
| ... | ... | @@ -2207,7 +2669,10 @@ fn updateConstInner( |
| 2207 | 2669 | 0); |
| 2208 | 2670 | }, |
| 2209 | 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 | 2676 | try di_w.writeUleb128(0); |
| 2212 | 2677 | }, |
| 2213 | 2678 | .pointer => { |
| ... | ... | @@ -2221,7 +2686,7 @@ fn updateConstInner( |
| 2221 | 2686 | try di_w.writeByte(0); |
| 2222 | 2687 | { |
| 2223 | 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 | 2690 | try dwarf.refType(pt, di_nw, .null); |
| 2226 | 2691 | try di_w.writeUleb128(0); |
| 2227 | 2692 | } |
| ... | ... | @@ -2230,7 +2695,7 @@ fn updateConstInner( |
| 2230 | 2695 | try dwarf.abbrevCode(di_nw, .tagged_union_default_field); |
| 2231 | 2696 | { |
| 2232 | 2697 | try dwarf.abbrevCode(di_nw, .generated_field); |
| 2233 | | try dwarf.strp(&dwarf.debug_str, di_nw, "?"); |
| 2698 | try dwarf.strx(di_nw, "?"); |
| 2234 | 2699 | try dwarf.refType(pt, di_nw, opt_child_ty); |
| 2235 | 2700 | try di_w.writeUleb128(0); |
| 2236 | 2701 | } |
| ... | ... | @@ -2243,7 +2708,7 @@ fn updateConstInner( |
| 2243 | 2708 | }, |
| 2244 | 2709 | .anyframe_type => unreachable, |
| 2245 | 2710 | .error_union_type => |error_union_type| { |
| 2246 | | const eu_ty: Type = .fromInterned(val); |
| 2711 | const eu_ty: Type = .fromInterned(@"const"); |
| 2247 | 2712 | const eu_error_set_ty: Type = .fromInterned(error_union_type.error_set_type); |
| 2248 | 2713 | const eu_payload_ty: Type = .fromInterned(error_union_type.payload_type); |
| 2249 | 2714 | const eu_error_set_offset, const eu_payload_offset = switch (error_union_type.payload_type) { |
| ... | ... | @@ -2257,7 +2722,7 @@ fn updateConstInner( |
| 2257 | 2722 | defer zcu.gpa.free(name); |
| 2258 | 2723 | |
| 2259 | 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 | 2726 | if (error_union_type.error_set_type != .generic_poison_type and |
| 2262 | 2727 | error_union_type.payload_type != .generic_poison_type) |
| 2263 | 2728 | { |
| ... | ... | @@ -2269,10 +2734,12 @@ fn updateConstInner( |
| 2269 | 2734 | } |
| 2270 | 2735 | { |
| 2271 | 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 | 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 | 2743 | try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits())); |
| 2277 | 2744 | try di_w.writeUleb128(eu_error_set_offset); |
| 2278 | 2745 | |
| ... | ... | @@ -2281,7 +2748,7 @@ fn updateConstInner( |
| 2281 | 2748 | try di_w.writeUleb128(0); |
| 2282 | 2749 | { |
| 2283 | 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 | 2752 | try dwarf.refType(pt, di_nw, eu_payload_ty); |
| 2286 | 2753 | try di_w.writeUleb128(eu_payload_offset); |
| 2287 | 2754 | } |
| ... | ... | @@ -2290,7 +2757,7 @@ fn updateConstInner( |
| 2290 | 2757 | try dwarf.abbrevCode(di_nw, .tagged_union_default_field); |
| 2291 | 2758 | { |
| 2292 | 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 | 2761 | try dwarf.refType(pt, di_nw, eu_error_set_ty); |
| 2295 | 2762 | try di_w.writeUleb128(eu_error_set_offset); |
| 2296 | 2763 | } |
| ... | ... | @@ -2320,10 +2787,10 @@ fn updateConstInner( |
| 2320 | 2787 | .c_longdouble, |
| 2321 | 2788 | .bool, |
| 2322 | 2789 | => { |
| 2323 | | const ty: Type = .fromInterned(val); |
| 2790 | const ty: Type = .fromInterned(@"const"); |
| 2324 | 2791 | try dwarf.abbrevCode(di_nw, .numeric_type); |
| 2325 | | try dwarf.strp(&dwarf.debug_str, di_nw, @tagName(simple_type)); |
| 2326 | | try di_w.writeByte(if (val == .bool_type) |
| 2792 | try dwarf.strx(di_nw, @tagName(simple_type)); |
| 2793 | try di_w.writeByte(if (@"const" == .bool_type) |
| 2327 | 2794 | DW.ATE.boolean |
| 2328 | 2795 | else if (ty.isRuntimeFloat()) |
| 2329 | 2796 | DW.ATE.float |
| ... | ... | @@ -2339,7 +2806,7 @@ fn updateConstInner( |
| 2339 | 2806 | }, |
| 2340 | 2807 | .generic_poison => { |
| 2341 | 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 | 2811 | .anyopaque, |
| 2345 | 2812 | .void, |
| ... | ... | @@ -2351,10 +2818,10 @@ fn updateConstInner( |
| 2351 | 2818 | .undefined, |
| 2352 | 2819 | .enum_literal, |
| 2353 | 2820 | => { |
| 2354 | | const ty: Type = .fromInterned(val); |
| 2821 | const ty: Type = .fromInterned(@"const"); |
| 2355 | 2822 | try dwarf.abbrevCode(di_nw, .void_type); |
| 2356 | 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 | 2825 | ty.fmt(pt), |
| 2359 | 2826 | }) catch unreachable); |
| 2360 | 2827 | }, |
| ... | ... | @@ -2364,29 +2831,29 @@ fn updateConstInner( |
| 2364 | 2831 | .generated_enum_type |
| 2365 | 2832 | else |
| 2366 | 2833 | .generated_empty_enum_type); |
| 2367 | | try dwarf.strp(&dwarf.debug_str, di_nw, "anyerror"); |
| 2834 | try dwarf.strx(di_nw, "anyerror"); |
| 2368 | 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 | 2837 | try dwarf.abbrevCode(di_nw, .enum_field); |
| 2371 | 2838 | try di_w.writeUleb128(DW.FORM.udata); |
| 2372 | | try di_w.writeUleb128(value); |
| 2373 | | try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip)); |
| 2839 | try di_w.writeUleb128(err_value); |
| 2840 | try dwarf.strx(di_nw, err_name.toSlice(ip)); |
| 2374 | 2841 | } |
| 2375 | 2842 | if (global_error_set_names.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2376 | 2843 | }, |
| 2377 | 2844 | .adhoc_inferred_error_set => unreachable, |
| 2378 | 2845 | }, |
| 2379 | 2846 | .tuple_type => |tuple_type| { |
| 2380 | | const ty: Type = .fromInterned(val); |
| 2847 | const ty: Type = .fromInterned(@"const"); |
| 2381 | 2848 | const name = try zcu.gpa.print("{f}", .{ty.fmt(pt)}); |
| 2382 | 2849 | defer zcu.gpa.free(name); |
| 2383 | 2850 | if (tuple_type.types.len == 0) { |
| 2384 | 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 | 2853 | try di_w.writeByte(@intFromBool(false)); |
| 2387 | 2854 | } else { |
| 2388 | 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 | 2857 | try di_w.writeUleb128(ty.abiSize(zcu)); |
| 2391 | 2858 | try di_w.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); |
| 2392 | 2859 | var field_byte_offset: u64 = 0; |
| ... | ... | @@ -2407,7 +2874,7 @@ fn updateConstInner( |
| 2407 | 2874 | }, |
| 2408 | 2875 | }); |
| 2409 | 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 | 2878 | field_index, |
| 2412 | 2879 | }) catch unreachable); |
| 2413 | 2880 | try dwarf.refType(pt, di_nw, field_ty); |
| ... | ... | @@ -2427,72 +2894,81 @@ fn updateConstInner( |
| 2427 | 2894 | } |
| 2428 | 2895 | }, |
| 2429 | 2896 | .struct_type => { |
| 2430 | | const loaded_struct = ip.loadStructType(val); |
| 2431 | | const zfi = loaded_struct.zir_index.resolveFile(ip); |
| 2432 | | const zf = zcu.fileByIndex(zfi); |
| 2433 | | const src_inst = loaded_struct.zir_index.resolve(ip); |
| 2434 | | if (src_inst == .main_struct_inst) { |
| 2897 | const loaded_struct = ip.loadStructType(@"const"); |
| 2898 | const src_inst = loaded_struct.zir_index.resolveFull(ip).?; |
| 2899 | const zf = zcu.fileByIndex(src_inst.file); |
| 2900 | const is_empty = loaded_struct.captures.len == 0 and loaded_struct.field_types.len == 0; |
| 2901 | if (src_inst.inst == .main_struct_inst) { |
| 2435 | 2902 | assert(loaded_struct.captures.len == 0); |
| 2436 | 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 | 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 | 2907 | .@"extern", .@"packed" => unreachable, |
| 2441 | 2908 | }); |
| 2442 | 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 | 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 |
| 2446 | | loaded_struct.field_types.len > 0) switch (loaded_struct.layout) { |
| 2447 | | .auto, .@"extern" => .decl_instance_struct, |
| 2448 | | .@"packed" => .decl_instance_packed_struct, |
| 2449 | | } else switch (loaded_struct.layout) { |
| 2450 | | .auto, .@"extern" => .decl_instance_empty_struct, |
| 2451 | | .@"packed" => .decl_instance_empty_packed_struct, |
| 2912 | try dwarf.abbrevCode(di_nw, switch (loaded_struct.name_nav) { |
| 2913 | else => if (is_empty) switch (loaded_struct.layout) { |
| 2914 | .auto, .@"extern" => .decl_instance_empty_struct, |
| 2915 | .@"packed" => .decl_instance_empty_packed_struct, |
| 2916 | } else switch (loaded_struct.layout) { |
| 2917 | .auto, .@"extern" => .decl_instance_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 | 2934 | } else if (loaded_struct.name_nav.unwrap()) |name_ni| { |
| 2455 | 2935 | const name_nav = ip.getNav(name_ni); |
| 2456 | 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 | 2938 | name_nav.analysis.?.namespace, |
| 2459 | 2939 | ).owner_type); |
| 2460 | | try dwarf.abbrevCode(di_nw, if (loaded_struct.field_types.len > 0) |
| 2461 | | switch (loaded_struct.layout) { |
| 2462 | | .auto, .@"extern" => .decl_struct, |
| 2463 | | .@"packed" => .decl_packed_struct, |
| 2464 | | } |
| 2465 | | else switch (loaded_struct.layout) { |
| 2940 | try dwarf.abbrevCode(di_nw, if (is_empty) switch (loaded_struct.layout) { |
| 2466 | 2941 | .auto, .@"extern" => .decl_empty_struct, |
| 2467 | 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 | 2947 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2470 | 2948 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2471 | 2949 | try di_w.writeUleb128(decl.src_column + 1); |
| 2472 | 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 | 2952 | } else { |
| 2475 | | const decl = zf.zir.?.getStructDecl(src_inst.?); |
| 2476 | | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 2953 | const decl = zf.zir.?.getStructDecl(src_inst.inst); |
| 2954 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 2477 | 2955 | ip.namespacePtr(loaded_struct.namespace).parent.unwrap().?, |
| 2478 | 2956 | ).owner_type); |
| 2479 | | try dwarf.abbrevCode(di_nw, if (loaded_struct.field_types.len > 0) |
| 2480 | | switch (loaded_struct.layout) { |
| 2481 | | .auto, .@"extern" => .type_decl_struct, |
| 2482 | | .@"packed" => .type_decl_packed_struct, |
| 2483 | | } |
| 2484 | | else switch (loaded_struct.layout) { |
| 2957 | try dwarf.abbrevCode(di_nw, if (is_empty) switch (loaded_struct.layout) { |
| 2485 | 2958 | .auto, .@"extern" => .type_decl_empty_struct, |
| 2486 | 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 | 2964 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2489 | 2965 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2490 | 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 | 2969 | switch (loaded_struct.layout) { |
| 2494 | 2970 | .auto, .@"extern" => { |
| 2495 | | const ty: Type = .fromInterned(val); |
| 2971 | const ty: Type = .fromInterned(@"const"); |
| 2496 | 2972 | try di_w.writeUleb128(ty.abiSize(zcu)); |
| 2497 | 2973 | try di_w.writeUleb128(ty.abiAlignment(zcu).toByteUnits().?); |
| 2498 | 2974 | try dwarf.genCaptures(pt, di_nw, loaded_struct.captures); |
| ... | ... | @@ -2528,8 +3004,7 @@ fn updateConstInner( |
| 2528 | 3004 | .partially_comptime => .field_default_partially_comptime, |
| 2529 | 3005 | .fully_comptime => .field_default_fully_comptime, |
| 2530 | 3006 | }); |
| 2531 | | try dwarf.strp( |
| 2532 | | &dwarf.debug_str, |
| 3007 | try dwarf.strx( |
| 2533 | 3008 | di_nw, |
| 2534 | 3009 | loaded_struct.field_names.get(ip)[field_index].toSlice(ip), |
| 2535 | 3010 | ); |
| ... | ... | @@ -2553,8 +3028,7 @@ fn updateConstInner( |
| 2553 | 3028 | var field_bit_offset: u16 = 0; |
| 2554 | 3029 | for (0..loaded_struct.field_types.len) |field_index| { |
| 2555 | 3030 | try dwarf.abbrevCode(di_nw, .packed_field); |
| 2556 | | try dwarf.strp( |
| 2557 | | &dwarf.debug_str, |
| 3031 | try dwarf.strx( |
| 2558 | 3032 | di_nw, |
| 2559 | 3033 | loaded_struct.field_names.get(ip)[field_index].toSlice(ip), |
| 2560 | 3034 | ); |
| ... | ... | @@ -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) |
| 2570 | | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 3043 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2571 | 3044 | }, |
| 2572 | 3045 | .union_type => { |
| 2573 | | const loaded_union = ip.loadUnionType(val); |
| 3046 | const loaded_union = ip.loadUnionType(@"const"); |
| 2574 | 3047 | const loaded_tag = ip.loadEnumType(loaded_union.enum_tag_type); |
| 2575 | 3048 | const zfi = loaded_union.zir_index.resolveFile(ip); |
| 2576 | 3049 | const zf = zcu.fileByIndex(zfi); |
| 3050 | const is_empty = loaded_union.captures.len == 0 and loaded_union.field_types.len == 0; |
| 2577 | 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 |
| 2579 | | loaded_union.field_types.len > 0) switch (loaded_union.layout) { |
| 2580 | | .auto, .@"extern" => .decl_instance_union, |
| 2581 | | .@"packed" => .decl_instance_packed_union, |
| 2582 | | } else switch (loaded_union.layout) { |
| 2583 | | .auto, .@"extern" => .decl_instance_empty_union, |
| 2584 | | .@"packed" => .decl_instance_empty_packed_union, |
| 3052 | try dwarf.abbrevCode(di_nw, switch (loaded_union.name_nav) { |
| 3053 | else => if (is_empty) switch (loaded_union.layout) { |
| 3054 | .auto, .@"extern" => .decl_instance_empty_union, |
| 3055 | .@"packed" => .decl_instance_empty_packed_union, |
| 3056 | } else switch (loaded_union.layout) { |
| 3057 | .auto, .@"extern" => .decl_instance_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 | 3074 | } else if (loaded_union.name_nav.unwrap()) |name_ni| { |
| 2588 | 3075 | const name_nav = ip.getNav(name_ni); |
| 2589 | 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 | 3078 | name_nav.analysis.?.namespace, |
| 2592 | 3079 | ).owner_type); |
| 2593 | | try dwarf.abbrevCode(di_nw, if (loaded_union.field_types.len > 0) |
| 2594 | | switch (loaded_union.layout) { |
| 2595 | | .auto, .@"extern" => .decl_union, |
| 2596 | | .@"packed" => .decl_packed_union, |
| 2597 | | } |
| 2598 | | else switch (loaded_union.layout) { |
| 3080 | try dwarf.abbrevCode(di_nw, if (is_empty) switch (loaded_union.layout) { |
| 2599 | 3081 | .auto, .@"extern" => .decl_empty_union, |
| 2600 | 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 | 3087 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2603 | 3088 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2604 | 3089 | try di_w.writeUleb128(decl.src_column + 1); |
| 2605 | 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 | 3092 | } else { |
| 2608 | 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 | 3095 | ip.namespacePtr(loaded_union.namespace).parent.unwrap().?, |
| 2611 | 3096 | ).owner_type); |
| 2612 | | try dwarf.abbrevCode(di_nw, if (loaded_union.field_types.len > 0) |
| 2613 | | switch (loaded_union.layout) { |
| 2614 | | .auto, .@"extern" => .type_decl_union, |
| 2615 | | .@"packed" => .type_decl_packed_union, |
| 2616 | | } |
| 2617 | | else switch (loaded_union.layout) { |
| 3097 | try dwarf.abbrevCode(di_nw, if (is_empty) switch (loaded_union.layout) { |
| 2618 | 3098 | .auto, .@"extern" => .type_decl_empty_union, |
| 2619 | 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 | 3104 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2622 | 3105 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2623 | 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 | 3109 | switch (loaded_union.layout) { |
| 2627 | 3110 | .auto, .@"extern" => { |
| ... | ... | @@ -2631,10 +3114,12 @@ fn updateConstInner( |
| 2631 | 3114 | try dwarf.genCaptures(pt, di_nw, loaded_union.captures); |
| 2632 | 3115 | if (loaded_union.has_runtime_tag) { |
| 2633 | 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 | 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 | 3123 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_union.enum_tag_type)); |
| 2639 | 3124 | try di_w.writeUleb128(union_layout.tagOffset()); |
| 2640 | 3125 | |
| ... | ... | @@ -2643,8 +3128,7 @@ fn updateConstInner( |
| 2643 | 3128 | try dwarf.enumConstValue(di_w, loaded_tag, field_index); |
| 2644 | 3129 | { |
| 2645 | 3130 | try dwarf.abbrevCode(di_nw, .field); |
| 2646 | | try dwarf.strp( |
| 2647 | | &dwarf.debug_str, |
| 3131 | try dwarf.strx( |
| 2648 | 3132 | di_nw, |
| 2649 | 3133 | loaded_tag.field_names.get(ip)[field_index].toSlice(ip), |
| 2650 | 3134 | ); |
| ... | ... | @@ -2666,8 +3150,7 @@ fn updateConstInner( |
| 2666 | 3150 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2667 | 3151 | } else for (0..loaded_union.field_types.len) |field_index| { |
| 2668 | 3152 | try dwarf.abbrevCode(di_nw, .field); |
| 2669 | | try dwarf.strp( |
| 2670 | | &dwarf.debug_str, |
| 3153 | try dwarf.strx( |
| 2671 | 3154 | di_nw, |
| 2672 | 3155 | loaded_tag.field_names.get(ip)[field_index].toSlice(ip), |
| 2673 | 3156 | ); |
| ... | ... | @@ -2688,8 +3171,7 @@ fn updateConstInner( |
| 2688 | 3171 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_union.packed_backing_int_type)); |
| 2689 | 3172 | for (0..loaded_union.field_types.len) |field_index| { |
| 2690 | 3173 | try dwarf.abbrevCode(di_nw, .packed_field); |
| 2691 | | try dwarf.strp( |
| 2692 | | &dwarf.debug_str, |
| 3174 | try dwarf.strx( |
| 2693 | 3175 | di_nw, |
| 2694 | 3176 | loaded_tag.field_names.get(ip)[field_index].toSlice(ip), |
| 2695 | 3177 | ); |
| ... | ... | @@ -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) |
| 2704 | | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 3185 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2705 | 3186 | }, |
| 2706 | 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 | 3190 | switch (loaded_enum.owner_union) { |
| 2709 | 3191 | .none => { |
| 2710 | 3192 | const zfi = loaded_enum.zir_index.unwrap().?.resolveFile(ip); |
| 2711 | 3193 | const zf = zcu.fileByIndex(zfi); |
| 3194 | const zir = &zf.zir.?; |
| 2712 | 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 |
| 2714 | | loaded_enum.field_names.len > 0) |
| 2715 | | .decl_instance_enum |
| 2716 | | else |
| 2717 | | .decl_instance_empty_enum); |
| 2718 | | try dwarf.secOffset(di_nw, try dwarf.getDecl(pt, val), 0); |
| 3196 | try dwarf.abbrevCode(di_nw, switch (loaded_enum.name_nav) { |
| 3197 | else => if (is_empty) .decl_instance_empty_enum else .decl_instance_enum, |
| 3198 | .none => if (is_empty) |
| 3199 | .type_decl_instance_empty_enum |
| 3200 | else |
| 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 | 3209 | } else if (loaded_enum.name_nav.unwrap()) |name_ni| { |
| 2720 | 3210 | const name_nav = ip.getNav(name_ni); |
| 2721 | | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 2722 | | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 3211 | const decl = zir.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 3212 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 2723 | 3213 | name_nav.analysis.?.namespace, |
| 2724 | 3214 | ).owner_type); |
| 2725 | 3215 | try dwarf.abbrevCode( |
| 2726 | 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 | 3219 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2730 | 3220 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2731 | 3221 | try di_w.writeUleb128(decl.src_column + 1); |
| 2732 | 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 | 3224 | } else { |
| 2735 | | const decl = |
| 2736 | | zf.zir.?.getEnumDecl(loaded_enum.zir_index.unwrap().?.resolve(ip).?); |
| 2737 | | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 3225 | const decl = zir.getEnumDecl(loaded_enum.zir_index.unwrap().?.resolve(ip).?); |
| 3226 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 2738 | 3227 | ip.namespacePtr(loaded_enum.namespace).parent.unwrap().?, |
| 2739 | 3228 | ).owner_type); |
| 2740 | | try dwarf.abbrevCode(di_nw, if (loaded_enum.field_names.len > 0) |
| 2741 | | .type_decl_enum |
| 2742 | | else |
| 2743 | | .type_decl_empty_enum); |
| 3229 | try dwarf.abbrevCode( |
| 3230 | di_nw, |
| 3231 | if (is_empty) .type_decl_empty_enum else .type_decl_enum, |
| 3232 | ); |
| 2744 | 3233 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 2745 | 3234 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2746 | 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 | 3239 | else => { |
| 2751 | | try dwarf.abbrevCode(di_nw, if (loaded_enum.field_names.len > 0) |
| 2752 | | .generated_enum_type |
| 2753 | | else |
| 2754 | | .generated_empty_enum_type); |
| 2755 | | try dwarf.strp(&dwarf.debug_str, di_nw, loaded_enum.fqn.toSlice(ip)); |
| 3240 | try dwarf.abbrevCode( |
| 3241 | di_nw, |
| 3242 | if (is_empty) .generated_empty_enum_type else .generated_enum_type, |
| 3243 | ); |
| 3244 | try dwarf.strx(di_nw, loaded_enum.fqn.toSlice(ip)); |
| 2756 | 3245 | }, |
| 2757 | 3246 | } |
| 2758 | 3247 | try dwarf.refType(pt, di_nw, .fromInterned(loaded_enum.int_tag_type)); |
| 3248 | try dwarf.genCaptures(pt, di_nw, loaded_enum.captures); |
| 2759 | 3249 | for (0..loaded_enum.field_names.len) |field_index| { |
| 2760 | 3250 | try dwarf.abbrevCode(di_nw, .enum_field); |
| 2761 | 3251 | try dwarf.enumConstValue(di_w, loaded_enum, field_index); |
| 2762 | | try dwarf.strp( |
| 2763 | | &dwarf.debug_str, |
| 2764 | | di_nw, |
| 2765 | | loaded_enum.field_names.get(ip)[field_index].toSlice(ip), |
| 2766 | | ); |
| 3252 | try dwarf.strx(di_nw, loaded_enum.field_names.get(ip)[field_index].toSlice(ip)); |
| 2767 | 3253 | } |
| 2768 | | if (loaded_enum.captures.len > 0 or loaded_enum.field_names.len > 0) |
| 2769 | | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 3254 | if (!is_empty) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2770 | 3255 | }, |
| 2771 | 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 | 3258 | .spirv_type => unreachable, |
| 2774 | 3259 | .func_type => |func_type| { |
| 2775 | | const is_nullary = 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)}); |
| 3260 | const is_empty = func_type.param_types.len == 0 and !func_type.is_var_args; |
| 3261 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(@"const").fmt(pt)}); |
| 2777 | 3262 | defer zcu.gpa.free(name); |
| 2778 | | try dwarf.abbrevCode(di_nw, if (is_nullary) .nullary_func_type else .func_type); |
| 2779 | | try dwarf.strp(&dwarf.debug_str, di_nw, name); |
| 3263 | try dwarf.abbrevCode(di_nw, if (is_empty) .empty_func_type else .func_type); |
| 3264 | try dwarf.strx(di_nw, name); |
| 2780 | 3265 | const cc: DW.CC = cc: { |
| 2781 | 3266 | if (zcu.getTarget().cCallingConvention()) |cc| { |
| 2782 | 3267 | if (@as(std.lang.CallingConvention.Tag, cc) == func_type.cc) { |
| ... | ... | @@ -2848,40 +3333,38 @@ fn updateConstInner( |
| 2848 | 3333 | }; |
| 2849 | 3334 | try di_w.writeByte(@backingInt(cc)); |
| 2850 | 3335 | try dwarf.refType(pt, di_nw, .fromInterned(func_type.return_type)); |
| 2851 | | if (!is_nullary) { |
| 2852 | | for (0..func_type.param_types.len) |param_index| { |
| 2853 | | try dwarf.abbrevCode(di_nw, .unnamed_param); |
| 2854 | | try dwarf.refType(pt, di_nw, .fromInterned( |
| 2855 | | func_type.param_types.get(ip)[param_index], |
| 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)); |
| 3336 | for (0..func_type.param_types.len) |param_index| { |
| 3337 | try dwarf.abbrevCode(di_nw, .unnamed_param); |
| 3338 | try dwarf.refType(pt, di_nw, .fromInterned( |
| 3339 | func_type.param_types.get(ip)[param_index], |
| 3340 | )); |
| 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 | 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 | 3347 | defer zcu.gpa.free(name); |
| 2865 | 3348 | try dwarf.abbrevCode( |
| 2866 | 3349 | di_nw, |
| 2867 | 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 | 3353 | try dwarf.refType(pt, di_nw, try pt.intType(.unsigned, zcu.errorSetBits())); |
| 2871 | 3354 | for (0..error_set_type.names.len) |field_index| { |
| 2872 | 3355 | const field_name = error_set_type.names.get(ip)[field_index]; |
| 2873 | 3356 | try dwarf.abbrevCode(di_nw, .enum_field); |
| 2874 | 3357 | try di_w.writeUleb128(DW.FORM.udata); |
| 2875 | 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 | 3361 | if (error_set_type.names.len > 0) try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2879 | 3362 | }, |
| 2880 | 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 | 3365 | defer zcu.gpa.free(name); |
| 2883 | 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 | 3368 | try dwarf.refType(pt, di_nw, switch (ies: { |
| 2886 | 3369 | const fi = dwarf.getFuncIfExists(ip.indexToKey(func).func.owner_nav) orelse |
| 2887 | 3370 | break :ies .none; |
| ... | ... | @@ -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 | 3396 | .func => |func| { |
| 2900 | | const fn_ty = ip.indexToKey(func.ty).func_type; |
| 3397 | const func_type = ip.indexToKey(func.ty).func_type; |
| 2901 | 3398 | const nav = ip.getNav(func.owner_nav); |
| 2902 | 3399 | const inst_info = nav.srcInst(ip).resolveFull(ip).?; |
| 2903 | | const zf = zcu.fileByIndex(inst_info.file); |
| 2904 | | const decl = zf.zir.?.getDeclaration(inst_info.inst); |
| 3400 | const zir = &zcu.fileByIndex(inst_info.file).zir.?; |
| 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 | 3403 | const parent_ty: Type = .fromInterned(ip.namespacePtr(nav.analysis.?.namespace).owner_type); |
| 2906 | | try dwarf.abbrevCode(di_nw, .decl_func_generic); |
| 2907 | | try dwarf.refType(pt, di_nw, parent_ty); |
| 2908 | | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 2909 | | try di_w.writeUleb128(decl.src_column + 1); |
| 2910 | | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 2911 | | try dwarf.strp(&dwarf.debug_str, di_nw, nav.name.toSlice(ip)); |
| 2912 | | try dwarf.refType(pt, di_nw, .fromInterned(fn_ty.return_type)); |
| 2913 | | var param_index: u32 = 0; |
| 2914 | | for (zf.zir.?.getParamBody(func.zir_body_inst.resolve(ip).?)) |param_inst| { |
| 2915 | | switch (zf.zir.?.getParamName(param_inst) orelse break) { |
| 3404 | if (func.generic_owner != .none or parent_ty.getCaptures(zcu).len > 0) { |
| 3405 | try dwarf.abbrevCode( |
| 3406 | di_nw, |
| 3407 | if (is_empty) .decl_instance_empty_func_generic else .decl_instance_func_generic, |
| 3408 | ); |
| 3409 | try dwarf.refType(pt, di_nw, parent_ty); |
| 3410 | try dwarf.secOffset(di_nw, try dwarf.getConstDecl(pt, @"const"), 0); |
| 3411 | } else { |
| 3412 | try dwarf.abbrevCode( |
| 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 | 3428 | .empty => try dwarf.abbrevCode(di_nw, .unnamed_param), |
| 2917 | 3429 | else => |param_name| { |
| 2918 | 3430 | try dwarf.abbrevCode(di_nw, .param); |
| 2919 | | try dwarf.strp(&dwarf.debug_str, di_nw, zf.zir.?.nullTerminatedString( |
| 2920 | | param_name, |
| 2921 | | )); |
| 3431 | try dwarf.strx(di_nw, zir.nullTerminatedString(param_name)); |
| 2922 | 3432 | }, |
| 2923 | 3433 | } |
| 2924 | | try dwarf.refType(pt, di_nw, .fromInterned( |
| 2925 | | fn_ty.param_types.get(&zcu.intern_pool)[param_index], |
| 2926 | | )); |
| 2927 | | param_index += 1; |
| 3434 | try dwarf.refType(pt, di_nw, .fromInterned(param_ty)); |
| 3435 | } |
| 3436 | if (func_type.is_var_args) try dwarf.abbrevCode(di_nw, .is_var_args); |
| 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 | 3843 | try di_w.writeUleb128(@backingInt(AbbrevCode.null)); |
| 2931 | 3844 | }, |
| 2932 | 3845 | |
| ... | ... | @@ -2935,11 +3848,11 @@ fn updateConstInner( |
| 2935 | 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 } { |
| 2939 | | if (opt_child_type.isNoReturn(zcu)) return .opv_null; |
| 2940 | | return switch (opt_child_type.toIntern()) { |
| 3851 | fn optRepr(opt_child_ty: Type, zcu: *const Zcu) enum { unpacked, opv_null, error_set, pointer } { |
| 3852 | if (opt_child_ty.isNoReturn(zcu)) return .opv_null; |
| 3853 | return switch (opt_child_ty.toIntern()) { |
| 2941 | 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 | 3856 | else => .unpacked, |
| 2944 | 3857 | .error_set_type, .inferred_error_set_type => .error_set, |
| 2945 | 3858 | .ptr_type => |ptr_type| if (ptr_type.flags.is_allowzero) .unpacked else .pointer, |
| ... | ... | @@ -2983,21 +3896,21 @@ fn updateConstIncompleteInner( |
| 2983 | 3896 | _, const fi = try ui.get(dwarf).getFile(zcu.gpa, ui, src_inst.file); |
| 2984 | 3897 | try dwarf.abbrevCode(di_nw, .empty_file); |
| 2985 | 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 | 3900 | try di_w.writeByte(@intFromBool(true)); |
| 2988 | 3901 | break :done; |
| 2989 | 3902 | }, |
| 2990 | 3903 | else => { |
| 2991 | | const data = |
| 2992 | | zf.zir.?.instructions.items(.data)[@backingInt(src_inst.inst)].extended; |
| 3904 | const zir = &zf.zir.?; |
| 3905 | const data = zir.instructions.items(.data)[@backingInt(src_inst.inst)].extended; |
| 2993 | 3906 | const src_line, const src_column = src_loc: switch (data.opcode) { |
| 2994 | 3907 | else => unreachable, |
| 2995 | 3908 | .struct_decl => { |
| 2996 | | const decl = zf.zir.?.getStructDecl(src_inst.inst); |
| 3909 | const decl = zir.getStructDecl(src_inst.inst); |
| 2997 | 3910 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 2998 | 3911 | }, |
| 2999 | 3912 | .reify_struct => { |
| 3000 | | const decl = zf.zir.?.extraData( |
| 3913 | const decl = zir.extraData( |
| 3001 | 3914 | std.zig.Zir.Inst.ReifyStruct, |
| 3002 | 3915 | data.operand, |
| 3003 | 3916 | ).data; |
| ... | ... | @@ -3025,15 +3938,16 @@ fn updateConstIncompleteInner( |
| 3025 | 3938 | break :done; |
| 3026 | 3939 | }; |
| 3027 | 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 | 3943 | const src_line, const src_column = src_loc: switch (data.opcode) { |
| 3030 | 3944 | else => unreachable, |
| 3031 | 3945 | .union_decl => { |
| 3032 | | const decl = zf.zir.?.getUnionDecl(src_inst.inst); |
| 3946 | const decl = zir.getUnionDecl(src_inst.inst); |
| 3033 | 3947 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 3034 | 3948 | }, |
| 3035 | 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 | 3951 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 3038 | 3952 | }, |
| 3039 | 3953 | }; |
| ... | ... | @@ -3053,7 +3967,7 @@ fn updateConstIncompleteInner( |
| 3053 | 3967 | const loaded_enum = ip.loadEnumType(val); |
| 3054 | 3968 | const zir_index = loaded_enum.zir_index.unwrap() orelse { |
| 3055 | 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 | 3971 | try di_w.writeByte(@intFromBool(true)); |
| 3058 | 3972 | break :done; |
| 3059 | 3973 | }; |
| ... | ... | @@ -3062,15 +3976,16 @@ fn updateConstIncompleteInner( |
| 3062 | 3976 | break :done; |
| 3063 | 3977 | }; |
| 3064 | 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 | 3981 | const src_line, const src_column = src_loc: switch (data.opcode) { |
| 3067 | 3982 | else => unreachable, |
| 3068 | 3983 | .enum_decl => { |
| 3069 | | const decl = zf.zir.?.getEnumDecl(src_inst.inst); |
| 3984 | const decl = zir.getEnumDecl(src_inst.inst); |
| 3070 | 3985 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 3071 | 3986 | }, |
| 3072 | 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 | 3989 | break :src_loc .{ decl.src_line, decl.src_column }; |
| 3075 | 3990 | }, |
| 3076 | 3991 | }; |
| ... | ... | @@ -3112,7 +4027,7 @@ fn updateConstIncompleteInner( |
| 3112 | 4027 | const name = try zcu.gpa.print("{f}", .{Type.fromInterned(val).fmt(pt)}); |
| 3113 | 4028 | defer zcu.gpa.free(name); |
| 3114 | 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 | 4031 | try di_w.writeByte(@intFromBool(true)); |
| 3117 | 4032 | }, |
| 3118 | 4033 | else => |ty| { |
| ... | ... | @@ -3131,13 +4046,15 @@ fn updateConstIncompleteInner( |
| 3131 | 4046 | .@"union" => .decl_instance_empty_incomplete_union, |
| 3132 | 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 | 4053 | } else if (maybe_name_nav.unwrap()) |name_ni| { |
| 3136 | 4054 | const name_nav = ip.getNav(name_ni); |
| 3137 | 4055 | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 3138 | | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 3139 | | name_nav.analysis.?.namespace, |
| 3140 | | ).owner_type); |
| 4056 | const parent_ni = |
| 4057 | try dwarf.getConstDecl(pt, ip.namespacePtr(name_nav.analysis.?.namespace).owner_type); |
| 3141 | 4058 | try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) { |
| 3142 | 4059 | .@"struct" => .decl_incomplete_struct, |
| 3143 | 4060 | .@"union" => .decl_incomplete_union, |
| ... | ... | @@ -3151,9 +4068,9 @@ fn updateConstIncompleteInner( |
| 3151 | 4068 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 3152 | 4069 | try di_w.writeUleb128(decl.src_column + 1); |
| 3153 | 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 | 4072 | } else { |
| 3156 | | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 4073 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 3157 | 4074 | ip.namespacePtr(namespace).parent.unwrap().?, |
| 3158 | 4075 | ).owner_type); |
| 3159 | 4076 | try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) { |
| ... | ... | @@ -3168,7 +4085,7 @@ fn updateConstIncompleteInner( |
| 3168 | 4085 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 3169 | 4086 | try di_w.writeInt(u32, src_line + 1, dwarf.endian); |
| 3170 | 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 | 4090 | try dwarf.genCaptures(pt, di_nw, captures); |
| 3174 | 4091 | if (captures.len > 0) try di_w.writeByte(@backingInt(AbbrevCode.null)); |
| ... | ... | @@ -3224,10 +4141,16 @@ pub fn genDecl( |
| 3224 | 4141 | dwarf: *Dwarf, |
| 3225 | 4142 | pt: Zcu.PerThread, |
| 3226 | 4143 | di_nw: *link.MappedFile.Node.Writer, |
| 3227 | | instance_val: InternPool.Index, |
| 4144 | instance: Decl.Instance, |
| 3228 | 4145 | ) link.Error!void { |
| 3229 | | log.debug("genDecl({f})", .{Value.fromInterned(instance_val).fmtValue(pt)}); |
| 3230 | | dwarf.genDeclInner(pt, di_nw, instance_val) catch |err| switch (err) { |
| 4146 | switch (instance) { |
| 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 | 4154 | else => |e| return e, |
| 3232 | 4155 | error.WriteFailed => return dwarf.reportWriteError(di_nw), |
| 3233 | 4156 | }; |
| ... | ... | @@ -3236,216 +4159,255 @@ fn genDeclInner( |
| 3236 | 4159 | dwarf: *Dwarf, |
| 3237 | 4160 | pt: Zcu.PerThread, |
| 3238 | 4161 | di_nw: *link.MappedFile.Node.Writer, |
| 3239 | | instance_val: InternPool.Index, |
| 4162 | instance: Decl.Instance, |
| 3240 | 4163 | ) link.EmitError!void { |
| 3241 | 4164 | const zcu = pt.zcu; |
| 3242 | 4165 | const ip = &zcu.intern_pool; |
| 3243 | 4166 | const di_w = &di_nw.interface; |
| 3244 | | done: { |
| 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)) { |
| 3246 | | else => unreachable, |
| 3247 | | .struct_type => { |
| 3248 | | const loaded_struct = ip.loadStructType(instance_val); |
| 3249 | | const src_inst = loaded_struct.zir_index.resolveFull(ip) orelse { |
| 3250 | | try dwarf.lostTracking(di_nw); |
| 3251 | | break :done; |
| 3252 | | }; |
| 3253 | | const zf = zcu.fileByIndex(src_inst.file); |
| 3254 | | const inst = zf.zir.?.instructions.get(@backingInt(src_inst.inst)); |
| 3255 | | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { |
| 3256 | | else => unreachable, |
| 3257 | | .struct_init, .struct_init_ref => { |
| 3258 | | const decl = zf.zir.?.extraData( |
| 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) { |
| 4167 | done: switch (instance) { |
| 4168 | .none => unreachable, |
| 4169 | .@"const" => |@"const"| { |
| 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")) { |
| 4171 | else => unreachable, |
| 4172 | .struct_type => { |
| 4173 | const loaded_struct = ip.loadStructType(@"const"); |
| 4174 | const src_inst = loaded_struct.zir_index.resolveFull(ip) orelse { |
| 4175 | try dwarf.lostTracking(di_nw); |
| 4176 | break :done; |
| 4177 | }; |
| 4178 | const zf = zcu.fileByIndex(src_inst.file); |
| 4179 | const zir = &zf.zir.?; |
| 4180 | const inst = zir.instructions.get(@backingInt(src_inst.inst)); |
| 4181 | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { |
| 3272 | 4182 | else => unreachable, |
| 3273 | | .struct_decl => { |
| 3274 | | const decl = zf.zir.?.getStructDecl(src_inst.inst); |
| 3275 | | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; |
| 3276 | | }, |
| 3277 | | .reify_struct => { |
| 3278 | | const decl = zf.zir.?.extraData( |
| 3279 | | std.zig.Zir.Inst.ReifyStruct, |
| 3280 | | inst.data.extended.operand, |
| 4183 | .struct_init, .struct_init_ref => { |
| 4184 | const decl = zir.extraData( |
| 4185 | std.zig.Zir.Inst.StructInit, |
| 4186 | inst.data.pl_node.payload_index, |
| 3281 | 4187 | ).data; |
| 3282 | 4188 | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| 3283 | 4189 | }, |
| 3284 | | }, |
| 3285 | | }; |
| 3286 | | break :container .{ |
| 3287 | | .@"struct", |
| 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, |
| 4190 | .struct_init_anon => { |
| 4191 | const decl = zir.extraData( |
| 4192 | std.zig.Zir.Inst.StructInitAnon, |
| 4193 | inst.data.pl_node.payload_index, |
| 3318 | 4194 | ).data; |
| 3319 | 4195 | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| 3320 | 4196 | }, |
| 3321 | | }, |
| 3322 | | }; |
| 3323 | | break :container .{ |
| 3324 | | .@"union", |
| 3325 | | zf, |
| 3326 | | src_line, |
| 3327 | | src_column, |
| 3328 | | capture_names, |
| 3329 | | loaded_union.captures, |
| 3330 | | loaded_union.name, |
| 3331 | | loaded_union.name_nav, |
| 3332 | | loaded_union.namespace, |
| 3333 | | }; |
| 3334 | | }, |
| 3335 | | .enum_type => { |
| 3336 | | const loaded_enum = ip.loadEnumType(instance_val); |
| 3337 | | const src_inst = loaded_enum.zir_index.unwrap().?.resolveFull(ip) orelse { |
| 3338 | | try dwarf.lostTracking(di_nw); |
| 3339 | | break :done; |
| 3340 | | }; |
| 3341 | | const zf = zcu.fileByIndex(src_inst.file); |
| 3342 | | const inst = zf.zir.?.instructions.get(@backingInt(src_inst.inst)); |
| 3343 | | const src_line, const src_column, const capture_names = decl: switch (inst.tag) { |
| 3344 | | else => unreachable, |
| 3345 | | .extended => switch (inst.data.extended.opcode) { |
| 4197 | .extended => switch (inst.data.extended.opcode) { |
| 4198 | else => unreachable, |
| 4199 | .struct_decl => { |
| 4200 | const decl = zir.getStructDecl(src_inst.inst); |
| 4201 | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; |
| 4202 | }, |
| 4203 | .reify_struct => { |
| 4204 | const decl = zir.extraData( |
| 4205 | std.zig.Zir.Inst.ReifyStruct, |
| 4206 | inst.data.extended.operand, |
| 4207 | ).data; |
| 4208 | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| 4209 | }, |
| 4210 | }, |
| 4211 | }; |
| 4212 | break :container .{ |
| 4213 | .@"struct", |
| 4214 | zf, |
| 4215 | src_line, |
| 4216 | src_column, |
| 4217 | capture_names, |
| 4218 | loaded_struct.captures, |
| 4219 | loaded_struct.name_nav, |
| 4220 | loaded_struct.namespace, |
| 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 | 4233 | else => unreachable, |
| 3347 | | .enum_decl => { |
| 3348 | | const decl = zf.zir.?.getEnumDecl(src_inst.inst); |
| 3349 | | break :decl .{ decl.src_line, decl.src_column, decl.capture_names }; |
| 4234 | .extended => switch (inst.data.extended.opcode) { |
| 4235 | else => unreachable, |
| 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 => { |
| 3352 | | const decl = zf.zir.?.extraData( |
| 3353 | | std.zig.Zir.Inst.ReifyEnum, |
| 3354 | | inst.data.extended.operand, |
| 3355 | | ).data; |
| 3356 | | break :decl .{ decl.src_line, decl.src_column, &.{} }; |
| 4248 | }; |
| 4249 | break :container .{ |
| 4250 | .@"union", |
| 4251 | zf, |
| 4252 | src_line, |
| 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 | | }, |
| 3359 | | }; |
| 3360 | | break :container .{ |
| 3361 | | .@"enum", |
| 3362 | | zf, |
| 3363 | | src_line, |
| 3364 | | src_column, |
| 3365 | | capture_names, |
| 3366 | | loaded_enum.captures, |
| 3367 | | loaded_enum.name, |
| 3368 | | loaded_enum.name_nav, |
| 3369 | | loaded_enum.namespace, |
| 3370 | | }; |
| 3371 | | }, |
| 3372 | | .opaque_type => { |
| 3373 | | const loaded_opaque = ip.loadOpaqueType(instance_val); |
| 3374 | | const src_inst = loaded_opaque.zir_index.resolveFull(ip) orelse { |
| 3375 | | try dwarf.lostTracking(di_nw); |
| 4285 | }; |
| 4286 | break :container .{ |
| 4287 | .@"enum", |
| 4288 | zf, |
| 4289 | src_line, |
| 4290 | src_column, |
| 4291 | capture_names, |
| 4292 | loaded_enum.captures, |
| 4293 | loaded_enum.name_nav, |
| 4294 | loaded_enum.namespace, |
| 4295 | }; |
| 4296 | }, |
| 4297 | .opaque_type => { |
| 4298 | const loaded_opaque = ip.loadOpaqueType(@"const"); |
| 4299 | const src_inst = loaded_opaque.zir_index.resolveFull(ip) orelse { |
| 4300 | try dwarf.lostTracking(di_nw); |
| 4301 | break :done; |
| 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 | 4332 | break :done; |
| 3377 | | }; |
| 3378 | | const zf = zcu.fileByIndex(src_inst.file); |
| 3379 | | const decl = zf.zir.?.getOpaqueDecl(src_inst.inst); |
| 3380 | | break :container .{ |
| 3381 | | .@"struct", |
| 3382 | | zf, |
| 3383 | | decl.src_line, |
| 3384 | | decl.src_column, |
| 3385 | | decl.capture_names, |
| 3386 | | loaded_opaque.captures, |
| 3387 | | loaded_opaque.name, |
| 3388 | | loaded_opaque.name_nav, |
| 3389 | | loaded_opaque.namespace, |
| 3390 | | }; |
| 3391 | | }, |
| 3392 | | }; |
| 3393 | | if (maybe_name_nav.unwrap()) |name_ni| { |
| 3394 | | const name_nav = ip.getNav(name_ni); |
| 3395 | | const decl = zf.zir.?.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 3396 | | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 3397 | | name_nav.analysis.?.namespace, |
| 3398 | | ).owner_type); |
| 3399 | | try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) { |
| 3400 | | .@"struct" => .decl_specification_struct, |
| 3401 | | .@"union" => .decl_specification_union, |
| 3402 | | .@"enum" => .decl_specification_enum, |
| 3403 | | } else switch (kind) { |
| 3404 | | .@"struct" => .decl_specification_empty_struct, |
| 3405 | | .@"union" => .decl_specification_empty_union, |
| 3406 | | .@"enum" => .decl_specification_empty_enum, |
| 3407 | | }); |
| 3408 | | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 3409 | | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 3410 | | try di_w.writeUleb128(decl.src_column + 1); |
| 3411 | | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 3412 | | try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip)); |
| 3413 | | } else { |
| 3414 | | const parent_ni = try dwarf.getDecl(pt, ip.namespacePtr( |
| 3415 | | ip.namespacePtr(namespace).parent.unwrap().?, |
| 4333 | }, |
| 4334 | }; |
| 4335 | const zir = &zf.zir.?; |
| 4336 | if (maybe_name_nav.unwrap()) |name_ni| { |
| 4337 | const name_nav = ip.getNav(name_ni); |
| 4338 | const decl = zir.getDeclaration(name_nav.srcInst(ip).resolve(ip).?); |
| 4339 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 4340 | name_nav.analysis.?.namespace, |
| 4341 | ).owner_type); |
| 4342 | try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) { |
| 4343 | .@"struct" => .decl_specification_struct, |
| 4344 | .@"union" => .decl_specification_union, |
| 4345 | .@"enum" => .decl_specification_enum, |
| 4346 | } else switch (kind) { |
| 4347 | .@"struct" => .decl_specification_empty_struct, |
| 4348 | .@"union" => .decl_specification_empty_union, |
| 4349 | .@"enum" => .decl_specification_empty_enum, |
| 4350 | }); |
| 4351 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 4352 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 4353 | try di_w.writeUleb128(decl.src_column + 1); |
| 4354 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 4355 | try dwarf.strx(di_nw, name_nav.name.toSlice(ip)); |
| 4356 | } else { |
| 4357 | const parent_ni = try dwarf.getConstDecl(pt, ip.namespacePtr( |
| 4358 | ip.namespacePtr(namespace).parent.unwrap().?, |
| 4359 | ).owner_type); |
| 4360 | try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) { |
| 4361 | .@"struct" => .type_decl_specification_struct, |
| 4362 | .@"union" => .type_decl_specification_union, |
| 4363 | .@"enum" => .type_decl_specification_enum, |
| 4364 | } else switch (kind) { |
| 4365 | .@"struct" => .type_decl_specification_empty_struct, |
| 4366 | .@"union" => .type_decl_specification_empty_union, |
| 4367 | .@"enum" => .type_decl_specification_empty_enum, |
| 4368 | }); |
| 4369 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 4370 | try di_w.writeInt(u32, src_line + 1, dwarf.endian); |
| 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 | 4400 | ).owner_type); |
| 3417 | | try dwarf.abbrevCode(di_nw, if (captures.len > 0) switch (kind) { |
| 3418 | | .@"struct" => .type_decl_specification_struct, |
| 3419 | | .@"union" => .type_decl_specification_union, |
| 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, |
| 4401 | try dwarf.abbrevCode(di_nw, switch (nav_ty) { |
| 4402 | .type_type => .decl_specification_type, |
| 4403 | else => if (nav_const) .decl_specification_const else .decl_specification_var, |
| 3425 | 4404 | }); |
| 3426 | 4405 | try dwarf.secOffset(di_nw, parent_ni, 0); |
| 3427 | | try di_w.writeInt(u32, src_line + 1, dwarf.endian); |
| 3428 | | try di_w.writeUleb128(src_column + 1); |
| 3429 | | try dwarf.strp(&dwarf.debug_str, di_nw, name.toSlice(ip)); |
| 3430 | | } |
| 3431 | | for (capture_names, captures.get(ip)) |capture_name, capture| { |
| 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)); |
| 4406 | try di_w.writeInt(u32, decl.src_line + 1, dwarf.endian); |
| 4407 | try di_w.writeUleb128(decl.src_column + 1); |
| 4408 | try di_w.writeByte(if (decl.is_pub) DW.ACCESS.public else DW.ACCESS.private); |
| 4409 | try dwarf.strx(di_nw, nav.name.toSlice(ip)); |
| 4410 | }, |
| 3449 | 4411 | } |
| 3450 | 4412 | try dwarf.genDebugInfoPadding(di_w, di_w.unusedCapacityLen()); |
| 3451 | 4413 | } |
| ... | ... | @@ -3458,9 +4420,12 @@ pub fn updateLineNumber( |
| 3458 | 4420 | ) void { |
| 3459 | 4421 | const di = dwarf.getDeclIfExists(inst) orelse return; |
| 3460 | 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 | 4426 | std.mem.writeInt( |
| 3462 | 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 | 4429 | line + 1, |
| 3465 | 4430 | dwarf.endian, |
| 3466 | 4431 | ); |
| ... | ... | @@ -3486,8 +4451,11 @@ fn refAbbrevCode( |
| 3486 | 4451 | @branchHint(.likely); |
| 3487 | 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 | 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 | 4459 | defer da_nw.deinit(); |
| 3492 | 4460 | dwarf.genDebugAbbrev(&da_nw, abbrev_code) catch |err| switch (err) { |
| 3493 | 4461 | else => |e| return e, |
| ... | ... | @@ -3526,15 +4494,12 @@ fn genDebugAbbrev( |
| 3526 | 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 | 4498 | return switch (dwarf.format) { |
| 3531 | 4499 | .@"32" => 4, |
| 3532 | 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 | 4503 | fn secOffset( |
| 3539 | 4504 | dwarf: *Dwarf, |
| 3540 | 4505 | nw: *link.MappedFile.Node.Writer, |
| ... | ... | @@ -3543,6 +4508,18 @@ fn secOffset( |
| 3543 | 4508 | ) link.EmitError!void { |
| 3544 | 4509 | const offset = nw.interface.end; |
| 3545 | 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 | 4523 | if (dwarf.lf.cast(.elf2)) |elf| try elf.addNodeReloc( |
| 3547 | 4524 | nw.ni, |
| 3548 | 4525 | offset, |
| ... | ... | @@ -3574,6 +4551,21 @@ fn addrSym( |
| 3574 | 4551 | .absAddr(elf), |
| 3575 | 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 | 4570 | fn blockConst( |
| 3579 | 4571 | dwarf: *Dwarf, |
| ... | ... | @@ -3585,13 +4577,9 @@ fn blockConst( |
| 3585 | 4577 | const size = ty.abiSize(pt.zcu); |
| 3586 | 4578 | try nw.interface.writeUleb128(size); |
| 3587 | 4579 | const start = nw.interface.end; |
| 3588 | | if (size > 0) try codegen.generateSymbol( |
| 3589 | | dwarf.lf, |
| 3590 | | pt, |
| 3591 | | val, |
| 3592 | | &nw.interface, |
| 3593 | | .{ .atom_index = @bitCast(nw.ni) }, |
| 3594 | | ); |
| 4580 | if (size > 0) try codegen.generateSymbol(dwarf.lf, pt, val, &nw.interface, .{ |
| 4581 | .atom_index = @bitCast(nw.ni), |
| 4582 | }); |
| 3595 | 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 | 4679 | fn strp(dwarf: *Dwarf, s: *Str, nw: *link.MappedFile.Node.Writer, str: []const u8) link.EmitError!void { |
| 3692 | 4680 | const comp = dwarf.lf.comp; |
| 3693 | 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 | 4683 | error.MappedFileIo => return comp.link_diags.fail("failed to write output file: {t}", .{ |
| 3695 | 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 | 4713 | fn reportWriteError(dwarf: *Dwarf, nw: *const link.MappedFile.Node.Writer) link.Error { |
| 3702 | 4714 | switch (nw.err.?) { |
| 3703 | 4715 | else => |e| return e, |
| ... | ... | @@ -3744,7 +4756,6 @@ pub const AbbrevCode = enum { |
| 3744 | 4756 | pad_n, |
| 3745 | 4757 | // decl, specification, and instance codes are assumed to all have the same uleb128 size |
| 3746 | 4758 | decl_lost, |
| 3747 | | decl_alias, |
| 3748 | 4759 | decl_empty_incomplete_enum, |
| 3749 | 4760 | decl_incomplete_enum, |
| 3750 | 4761 | decl_empty_enum, |
| ... | ... | @@ -3777,16 +4788,17 @@ pub const AbbrevCode = enum { |
| 3777 | 4788 | decl_packed_union, |
| 3778 | 4789 | type_decl_empty_packed_union, |
| 3779 | 4790 | type_decl_packed_union, |
| 3780 | | decl_var, |
| 4791 | decl_type, |
| 3781 | 4792 | decl_const, |
| 3782 | | decl_const_runtime_bits, |
| 3783 | | decl_const_comptime_state, |
| 3784 | | decl_const_runtime_bits_comptime_state, |
| 3785 | | decl_nullary_func, |
| 4793 | decl_const_fully_runtime, |
| 4794 | decl_const_partially_comptime, |
| 4795 | decl_const_fully_comptime, |
| 4796 | decl_var, |
| 4797 | decl_empty_func, |
| 3786 | 4798 | decl_func, |
| 3787 | | decl_nullary_func_generic, |
| 4799 | decl_empty_func_generic, |
| 3788 | 4800 | decl_func_generic, |
| 3789 | | decl_extern_nullary_func, |
| 4801 | decl_extern_empty_func, |
| 3790 | 4802 | decl_extern_func, |
| 3791 | 4803 | decl_specification_empty_struct, |
| 3792 | 4804 | decl_specification_struct, |
| ... | ... | @@ -3800,40 +4812,48 @@ pub const AbbrevCode = enum { |
| 3800 | 4812 | decl_specification_union, |
| 3801 | 4813 | type_decl_specification_empty_union, |
| 3802 | 4814 | type_decl_specification_union, |
| 4815 | decl_specification_type, |
| 4816 | decl_specification_const, |
| 4817 | decl_specification_var, |
| 3803 | 4818 | decl_specification_func, |
| 3804 | | decl_instance_alias, |
| 3805 | 4819 | decl_instance_empty_incomplete_enum, |
| 3806 | 4820 | decl_instance_incomplete_enum, |
| 3807 | 4821 | decl_instance_empty_enum, |
| 3808 | 4822 | decl_instance_enum, |
| 4823 | type_decl_instance_empty_enum, |
| 4824 | type_decl_instance_enum, |
| 3809 | 4825 | decl_instance_empty_incomplete_struct, |
| 3810 | 4826 | decl_instance_incomplete_struct, |
| 3811 | 4827 | decl_instance_empty_struct, |
| 3812 | 4828 | decl_instance_struct, |
| 4829 | type_decl_instance_empty_struct, |
| 4830 | type_decl_instance_struct, |
| 3813 | 4831 | decl_instance_empty_packed_struct, |
| 3814 | 4832 | decl_instance_packed_struct, |
| 4833 | type_decl_instance_empty_packed_struct, |
| 4834 | type_decl_instance_packed_struct, |
| 3815 | 4835 | decl_instance_empty_incomplete_union, |
| 3816 | 4836 | decl_instance_incomplete_union, |
| 3817 | 4837 | decl_instance_empty_union, |
| 3818 | 4838 | decl_instance_union, |
| 4839 | type_decl_instance_empty_union, |
| 4840 | type_decl_instance_union, |
| 3819 | 4841 | decl_instance_empty_packed_union, |
| 3820 | 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 | 4846 | decl_instance_const, |
| 3823 | | decl_instance_const_runtime_bits, |
| 3824 | | decl_instance_const_comptime_state, |
| 3825 | | decl_instance_const_runtime_bits_comptime_state, |
| 3826 | | decl_instance_nullary_func, |
| 4847 | decl_instance_const_fully_runtime, |
| 4848 | decl_instance_const_partially_comptime, |
| 4849 | decl_instance_const_fully_comptime, |
| 4850 | decl_instance_var, |
| 4851 | decl_instance_empty_func, |
| 3827 | 4852 | decl_instance_func, |
| 3828 | | decl_instance_nullary_func_generic, |
| 4853 | decl_instance_empty_func_generic, |
| 3829 | 4854 | decl_instance_func_generic, |
| 3830 | | decl_instance_extern_nullary_func, |
| 3831 | | decl_instance_extern_func, |
| 3832 | 4855 | // the rest are unrestricted other than empty variants must not be longer |
| 3833 | 4856 | // than the non-empty variant, and so should appear first |
| 3834 | | compile_unit, |
| 3835 | | module, |
| 3836 | | module_dependency, |
| 3837 | 4857 | empty_file, |
| 3838 | 4858 | file, |
| 3839 | 4859 | access, |
| ... | ... | @@ -3856,8 +4876,7 @@ pub const AbbrevCode = enum { |
| 3856 | 4876 | inferred_error_set_type, |
| 3857 | 4877 | ptr_type, |
| 3858 | 4878 | ptr_sentinel_type, |
| 3859 | | ptr_aligned_type, |
| 3860 | | ptr_aligned_sentinel_type, |
| 4879 | is_aligned, |
| 3861 | 4880 | is_const, |
| 3862 | 4881 | is_volatile, |
| 3863 | 4882 | array_type, |
| ... | ... | @@ -3865,7 +4884,7 @@ pub const AbbrevCode = enum { |
| 3865 | 4884 | vector_type, |
| 3866 | 4885 | array_index, |
| 3867 | 4886 | array_len, |
| 3868 | | nullary_func_type, |
| 4887 | empty_func_type, |
| 3869 | 4888 | func_type, |
| 3870 | 4889 | param, |
| 3871 | 4890 | unnamed_param, |
| ... | ... | @@ -3882,7 +4901,7 @@ pub const AbbrevCode = enum { |
| 3882 | 4901 | comptime_capture_fully_comptime, |
| 3883 | 4902 | runtime_capture, |
| 3884 | 4903 | nav_capture, |
| 3885 | | builtin_extern_nullary_func, |
| 4904 | builtin_extern_empty_func, |
| 3886 | 4905 | builtin_extern_func, |
| 3887 | 4906 | builtin_extern_var, |
| 3888 | 4907 | empty_block, |
| ... | ... | @@ -3911,44 +4930,51 @@ pub const AbbrevCode = enum { |
| 3911 | 4930 | aggregate_undefined_comptime_value, |
| 3912 | 4931 | aggregate_comptime_value, |
| 3913 | 4932 | aggregate_location_comptime_value, |
| 3914 | | comptime_value_field_runtime_bits, |
| 3915 | | comptime_value_field_comptime_state, |
| 3916 | | comptime_value_elem_runtime_bits, |
| 3917 | | comptime_value_elem_comptime_state, |
| 4933 | comptime_value_field_runtime, |
| 4934 | comptime_value_field_comptime, |
| 4935 | comptime_value_elem_runtime, |
| 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 | 4943 | comptime { |
| 3921 | 4944 | assert(uleb128Size(@backingInt(AbbrevCode.pad_1)) == 1); |
| 3922 | 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 | 4949 | const Attr = struct { |
| 3927 | 4950 | DeclValEnum(DW.AT), |
| 3928 | 4951 | DeclValEnum(DW.FORM), |
| 3929 | 4952 | }; |
| 3930 | | const decl_attrs = &[_]Attr{ |
| 4953 | const common_decl_attrs = &[_]Attr{ |
| 3931 | 4954 | .{ .ZIG_parent, .ref_addr }, |
| 3932 | 4955 | .{ .decl_line, .data4 }, |
| 3933 | 4956 | .{ .decl_column, .udata }, |
| 4957 | }; |
| 4958 | const decl_attrs = common_decl_attrs ++ .{ |
| 3934 | 4959 | .{ .accessibility, .data1 }, |
| 3935 | | .{ .name, .strp }, |
| 4960 | .{ .name, .strx }, |
| 3936 | 4961 | }; |
| 3937 | | const type_decl_attrs = &[_]Attr{ |
| 3938 | | .{ .ZIG_parent, .ref_addr }, |
| 3939 | | .{ .decl_line, .data4 }, |
| 3940 | | .{ .decl_column, .udata }, |
| 3941 | | .{ .name, .strp }, |
| 4962 | const type_decl_attrs = common_decl_attrs ++ .{ |
| 4963 | .{ .name, .strx }, |
| 3942 | 4964 | }; |
| 3943 | 4965 | const decl_specification_attrs = decl_attrs ++ &[_]Attr{ |
| 3944 | 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 | 4969 | .{ .declaration, .flag_present }, |
| 3948 | 4970 | }; |
| 3949 | 4971 | const decl_instance_attrs = &[_]Attr{ |
| 4972 | .{ .ZIG_parent, .ref_addr }, |
| 3950 | 4973 | .{ .specification, .ref_addr }, |
| 3951 | 4974 | }; |
| 4975 | const type_decl_instance_attrs = decl_instance_attrs ++ .{ |
| 4976 | .{ .name, .strx }, |
| 4977 | }; |
| 3952 | 4978 | |
| 3953 | 4979 | const abbrevs = std.EnumArray(AbbrevCode, struct { |
| 3954 | 4980 | tag: DeclValEnum(DW.TAG), |
| ... | ... | @@ -3968,12 +4994,6 @@ pub const AbbrevCode = enum { |
| 3968 | 4994 | .decl_lost = .{ |
| 3969 | 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 | 4997 | .decl_empty_incomplete_enum = .{ |
| 3978 | 4998 | .tag = .enumeration_type, |
| 3979 | 4999 | .attrs = decl_attrs, |
| ... | ... | @@ -4166,62 +5186,68 @@ pub const AbbrevCode = enum { |
| 4166 | 5186 | .{ .type, .ref_addr }, |
| 4167 | 5187 | }, |
| 4168 | 5188 | }, |
| 4169 | | .decl_var = .{ |
| 4170 | | .tag = .variable, |
| 5189 | .decl_type = .{ |
| 5190 | .tag = .imported_declaration, |
| 4171 | 5191 | .attrs = decl_attrs ++ .{ |
| 4172 | | .{ .linkage_name, .strp }, |
| 4173 | | .{ .type, .ref_addr }, |
| 4174 | | .{ .location, .exprloc }, |
| 4175 | | .{ .alignment, .udata }, |
| 4176 | | .{ .external, .flag }, |
| 5192 | .{ .import, .ref_addr }, |
| 4177 | 5193 | }, |
| 4178 | 5194 | }, |
| 4179 | 5195 | .decl_const = .{ |
| 4180 | 5196 | .tag = .constant, |
| 4181 | 5197 | .attrs = decl_attrs ++ .{ |
| 4182 | | .{ .linkage_name, .strp }, |
| 5198 | .{ .linkage_name, .strx }, |
| 4183 | 5199 | .{ .type, .ref_addr }, |
| 4184 | 5200 | .{ .alignment, .udata }, |
| 4185 | 5201 | .{ .external, .flag }, |
| 4186 | 5202 | }, |
| 4187 | 5203 | }, |
| 4188 | | .decl_const_runtime_bits = .{ |
| 5204 | .decl_const_fully_runtime = .{ |
| 4189 | 5205 | .tag = .constant, |
| 4190 | 5206 | .attrs = decl_attrs ++ .{ |
| 4191 | | .{ .linkage_name, .strp }, |
| 5207 | .{ .linkage_name, .strx }, |
| 4192 | 5208 | .{ .type, .ref_addr }, |
| 4193 | 5209 | .{ .alignment, .udata }, |
| 4194 | 5210 | .{ .external, .flag }, |
| 4195 | 5211 | .{ .const_value, .block }, |
| 4196 | 5212 | }, |
| 4197 | 5213 | }, |
| 4198 | | .decl_const_comptime_state = .{ |
| 5214 | .decl_const_partially_comptime = .{ |
| 4199 | 5215 | .tag = .constant, |
| 4200 | 5216 | .attrs = decl_attrs ++ .{ |
| 4201 | | .{ .linkage_name, .strp }, |
| 5217 | .{ .linkage_name, .strx }, |
| 4202 | 5218 | .{ .type, .ref_addr }, |
| 4203 | 5219 | .{ .alignment, .udata }, |
| 4204 | 5220 | .{ .external, .flag }, |
| 5221 | .{ .const_value, .block }, |
| 4205 | 5222 | .{ .ZIG_comptime_value, .ref_addr }, |
| 4206 | 5223 | }, |
| 4207 | 5224 | }, |
| 4208 | | .decl_const_runtime_bits_comptime_state = .{ |
| 5225 | .decl_const_fully_comptime = .{ |
| 4209 | 5226 | .tag = .constant, |
| 4210 | 5227 | .attrs = decl_attrs ++ .{ |
| 4211 | | .{ .linkage_name, .strp }, |
| 5228 | .{ .linkage_name, .strx }, |
| 4212 | 5229 | .{ .type, .ref_addr }, |
| 4213 | 5230 | .{ .alignment, .udata }, |
| 4214 | 5231 | .{ .external, .flag }, |
| 4215 | | .{ .const_value, .block }, |
| 4216 | 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 | 5246 | .tag = .subprogram, |
| 4221 | 5247 | .attrs = decl_attrs ++ .{ |
| 4222 | | .{ .linkage_name, .strp }, |
| 5248 | .{ .linkage_name, .strx }, |
| 4223 | 5249 | .{ .type, .ref_addr }, |
| 4224 | | .{ .low_pc, .addr }, |
| 5250 | .{ .low_pc, .addrx }, |
| 4225 | 5251 | .{ .high_pc, .data4 }, |
| 4226 | 5252 | .{ .alignment, .udata }, |
| 4227 | 5253 | .{ .external, .flag }, |
| ... | ... | @@ -4232,20 +5258,19 @@ pub const AbbrevCode = enum { |
| 4232 | 5258 | .tag = .subprogram, |
| 4233 | 5259 | .children = true, |
| 4234 | 5260 | .attrs = decl_attrs ++ .{ |
| 4235 | | .{ .linkage_name, .strp }, |
| 5261 | .{ .linkage_name, .strx }, |
| 4236 | 5262 | .{ .type, .ref_addr }, |
| 4237 | | .{ .low_pc, .addr }, |
| 5263 | .{ .low_pc, .addrx }, |
| 4238 | 5264 | .{ .high_pc, .data4 }, |
| 4239 | 5265 | .{ .alignment, .udata }, |
| 4240 | 5266 | .{ .external, .flag }, |
| 4241 | 5267 | .{ .noreturn, .flag }, |
| 4242 | 5268 | }, |
| 4243 | 5269 | }, |
| 4244 | | .decl_nullary_func_generic = .{ |
| 5270 | .decl_empty_func_generic = .{ |
| 4245 | 5271 | .tag = .subprogram, |
| 4246 | 5272 | .attrs = decl_attrs ++ .{ |
| 4247 | 5273 | .{ .type, .ref_addr }, |
| 4248 | | .{ .noreturn, .flag }, |
| 4249 | 5274 | }, |
| 4250 | 5275 | }, |
| 4251 | 5276 | .decl_func_generic = .{ |
| ... | ... | @@ -4255,10 +5280,10 @@ pub const AbbrevCode = enum { |
| 4255 | 5280 | .{ .type, .ref_addr }, |
| 4256 | 5281 | }, |
| 4257 | 5282 | }, |
| 4258 | | .decl_extern_nullary_func = .{ |
| 5283 | .decl_extern_empty_func = .{ |
| 4259 | 5284 | .tag = .subprogram, |
| 4260 | 5285 | .attrs = decl_attrs ++ .{ |
| 4261 | | .{ .linkage_name, .strp }, |
| 5286 | .{ .linkage_name, .strx }, |
| 4262 | 5287 | .{ .type, .ref_addr }, |
| 4263 | 5288 | .{ .low_pc, .addr }, |
| 4264 | 5289 | .{ .external, .flag_present }, |
| ... | ... | @@ -4269,7 +5294,7 @@ pub const AbbrevCode = enum { |
| 4269 | 5294 | .tag = .subprogram, |
| 4270 | 5295 | .children = true, |
| 4271 | 5296 | .attrs = decl_attrs ++ .{ |
| 4272 | | .{ .linkage_name, .strp }, |
| 5297 | .{ .linkage_name, .strx }, |
| 4273 | 5298 | .{ .type, .ref_addr }, |
| 4274 | 5299 | .{ .low_pc, .addr }, |
| 4275 | 5300 | .{ .external, .flag_present }, |
| ... | ... | @@ -4330,16 +5355,22 @@ pub const AbbrevCode = enum { |
| 4330 | 5355 | .children = true, |
| 4331 | 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 | 5370 | .decl_specification_func = .{ |
| 4334 | 5371 | .tag = .subprogram, |
| 4335 | 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 | 5374 | .decl_instance_empty_incomplete_enum = .{ |
| 4344 | 5375 | .tag = .enumeration_type, |
| 4345 | 5376 | .attrs = decl_instance_attrs, |
| ... | ... | @@ -4362,6 +5393,19 @@ pub const AbbrevCode = enum { |
| 4362 | 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 | 5409 | .decl_instance_empty_incomplete_struct = .{ |
| 4366 | 5410 | .tag = .structure_type, |
| 4367 | 5411 | .attrs = decl_instance_attrs, |
| ... | ... | @@ -4386,6 +5430,21 @@ pub const AbbrevCode = enum { |
| 4386 | 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 | 5448 | .decl_instance_empty_packed_struct = .{ |
| 4390 | 5449 | .tag = .structure_type, |
| 4391 | 5450 | .attrs = decl_instance_attrs ++ .{ |
| ... | ... | @@ -4399,6 +5458,19 @@ pub const AbbrevCode = enum { |
| 4399 | 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 | 5474 | .decl_instance_empty_incomplete_union = .{ |
| 4403 | 5475 | .tag = .union_type, |
| 4404 | 5476 | .attrs = decl_instance_attrs, |
| ... | ... | @@ -4423,6 +5495,21 @@ pub const AbbrevCode = enum { |
| 4423 | 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 | 5513 | .decl_instance_empty_packed_union = .{ |
| 4427 | 5514 | .tag = .union_type, |
| 4428 | 5515 | .attrs = decl_instance_attrs ++ .{ |
| ... | ... | @@ -4436,150 +5523,118 @@ pub const AbbrevCode = enum { |
| 4436 | 5523 | .{ .type, .ref_addr }, |
| 4437 | 5524 | }, |
| 4438 | 5525 | }, |
| 4439 | | .decl_instance_var = .{ |
| 4440 | | .tag = .variable, |
| 4441 | | .attrs = decl_instance_attrs ++ .{ |
| 4442 | | .{ .linkage_name, .strp }, |
| 5526 | .type_decl_instance_empty_packed_union = .{ |
| 5527 | .tag = .union_type, |
| 5528 | .attrs = type_decl_instance_attrs ++ .{ |
| 4443 | 5529 | .{ .type, .ref_addr }, |
| 4444 | | .{ .location, .exprloc }, |
| 4445 | | .{ .alignment, .udata }, |
| 4446 | | .{ .external, .flag }, |
| 5530 | }, |
| 5531 | }, |
| 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 | 5545 | .decl_instance_const = .{ |
| 4450 | 5546 | .tag = .constant, |
| 4451 | 5547 | .attrs = decl_instance_attrs ++ .{ |
| 4452 | | .{ .linkage_name, .strp }, |
| 5548 | .{ .linkage_name, .strx }, |
| 4453 | 5549 | .{ .type, .ref_addr }, |
| 4454 | 5550 | .{ .alignment, .udata }, |
| 4455 | 5551 | .{ .external, .flag }, |
| 4456 | 5552 | }, |
| 4457 | 5553 | }, |
| 4458 | | .decl_instance_const_runtime_bits = .{ |
| 5554 | .decl_instance_const_fully_runtime = .{ |
| 4459 | 5555 | .tag = .constant, |
| 4460 | 5556 | .attrs = decl_instance_attrs ++ .{ |
| 4461 | | .{ .linkage_name, .strp }, |
| 5557 | .{ .linkage_name, .strx }, |
| 4462 | 5558 | .{ .type, .ref_addr }, |
| 4463 | 5559 | .{ .alignment, .udata }, |
| 4464 | 5560 | .{ .external, .flag }, |
| 4465 | 5561 | .{ .const_value, .block }, |
| 4466 | 5562 | }, |
| 4467 | 5563 | }, |
| 4468 | | .decl_instance_const_comptime_state = .{ |
| 5564 | .decl_instance_const_partially_comptime = .{ |
| 4469 | 5565 | .tag = .constant, |
| 4470 | 5566 | .attrs = decl_instance_attrs ++ .{ |
| 4471 | | .{ .linkage_name, .strp }, |
| 5567 | .{ .linkage_name, .strx }, |
| 4472 | 5568 | .{ .type, .ref_addr }, |
| 4473 | 5569 | .{ .alignment, .udata }, |
| 4474 | 5570 | .{ .external, .flag }, |
| 5571 | .{ .const_value, .block }, |
| 4475 | 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 | 5576 | .tag = .constant, |
| 4480 | 5577 | .attrs = decl_instance_attrs ++ .{ |
| 4481 | | .{ .linkage_name, .strp }, |
| 5578 | .{ .linkage_name, .strx }, |
| 4482 | 5579 | .{ .type, .ref_addr }, |
| 4483 | 5580 | .{ .alignment, .udata }, |
| 4484 | 5581 | .{ .external, .flag }, |
| 4485 | | .{ .const_value, .block }, |
| 4486 | 5582 | .{ .ZIG_comptime_value, .ref_addr }, |
| 4487 | 5583 | }, |
| 4488 | 5584 | }, |
| 4489 | | .decl_instance_nullary_func = .{ |
| 4490 | | .tag = .subprogram, |
| 5585 | .decl_instance_var = .{ |
| 5586 | .tag = .variable, |
| 4491 | 5587 | .attrs = decl_instance_attrs ++ .{ |
| 4492 | | .{ .linkage_name, .strp }, |
| 5588 | .{ .linkage_name, .strx }, |
| 4493 | 5589 | .{ .type, .ref_addr }, |
| 4494 | | .{ .low_pc, .addr }, |
| 4495 | | .{ .high_pc, .data4 }, |
| 5590 | .{ .location, .exprloc }, |
| 4496 | 5591 | .{ .alignment, .udata }, |
| 4497 | 5592 | .{ .external, .flag }, |
| 4498 | | .{ .noreturn, .flag }, |
| 4499 | 5593 | }, |
| 4500 | 5594 | }, |
| 4501 | | .decl_instance_func = .{ |
| 5595 | .decl_instance_empty_func = .{ |
| 4502 | 5596 | .tag = .subprogram, |
| 4503 | | .children = true, |
| 4504 | 5597 | .attrs = decl_instance_attrs ++ .{ |
| 4505 | | .{ .linkage_name, .strp }, |
| 5598 | .{ .linkage_name, .strx }, |
| 4506 | 5599 | .{ .type, .ref_addr }, |
| 4507 | | .{ .low_pc, .addr }, |
| 5600 | .{ .low_pc, .addrx }, |
| 4508 | 5601 | .{ .high_pc, .data4 }, |
| 4509 | 5602 | .{ .alignment, .udata }, |
| 4510 | 5603 | .{ .external, .flag }, |
| 4511 | 5604 | .{ .noreturn, .flag }, |
| 4512 | 5605 | }, |
| 4513 | 5606 | }, |
| 4514 | | .decl_instance_nullary_func_generic = .{ |
| 4515 | | .tag = .subprogram, |
| 4516 | | .attrs = decl_instance_attrs ++ .{ |
| 4517 | | .{ .type, .ref_addr }, |
| 4518 | | }, |
| 4519 | | }, |
| 4520 | | .decl_instance_func_generic = .{ |
| 5607 | .decl_instance_func = .{ |
| 4521 | 5608 | .tag = .subprogram, |
| 4522 | 5609 | .children = true, |
| 4523 | 5610 | .attrs = decl_instance_attrs ++ .{ |
| 5611 | .{ .linkage_name, .strx }, |
| 4524 | 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 | 5621 | .tag = .subprogram, |
| 4529 | 5622 | .attrs = decl_instance_attrs ++ .{ |
| 4530 | | .{ .linkage_name, .strp }, |
| 4531 | 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 | 5627 | .tag = .subprogram, |
| 4539 | 5628 | .children = true, |
| 4540 | 5629 | .attrs = decl_instance_attrs ++ .{ |
| 4541 | | .{ .linkage_name, .strp }, |
| 4542 | 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 | 5633 | .empty_file = .{ |
| 4579 | 5634 | .tag = .structure_type, |
| 4580 | 5635 | .attrs = &.{ |
| 4581 | 5636 | .{ .decl_file, .udata }, |
| 4582 | | .{ .name, .strp }, |
| 5637 | .{ .name, .strx }, |
| 4583 | 5638 | .{ .declaration, .flag }, |
| 4584 | 5639 | }, |
| 4585 | 5640 | }, |
| ... | ... | @@ -4588,7 +5643,7 @@ pub const AbbrevCode = enum { |
| 4588 | 5643 | .children = true, |
| 4589 | 5644 | .attrs = &.{ |
| 4590 | 5645 | .{ .decl_file, .udata }, |
| 4591 | | .{ .name, .strp }, |
| 5646 | .{ .name, .strx }, |
| 4592 | 5647 | .{ .byte_size, .udata }, |
| 4593 | 5648 | .{ .alignment, .udata }, |
| 4594 | 5649 | }, |
| ... | ... | @@ -4596,20 +5651,20 @@ pub const AbbrevCode = enum { |
| 4596 | 5651 | .access = .{ |
| 4597 | 5652 | .tag = .member, |
| 4598 | 5653 | .attrs = &.{ |
| 4599 | | .{ .name, .strp }, |
| 5654 | .{ .name, .strx }, |
| 4600 | 5655 | }, |
| 4601 | 5656 | }, |
| 4602 | 5657 | .enum_field = .{ |
| 4603 | 5658 | .tag = .enumerator, |
| 4604 | 5659 | .attrs = &.{ |
| 4605 | 5660 | .{ .const_value, .indirect }, |
| 4606 | | .{ .name, .strp }, |
| 5661 | .{ .name, .strx }, |
| 4607 | 5662 | }, |
| 4608 | 5663 | }, |
| 4609 | 5664 | .generated_field = .{ |
| 4610 | 5665 | .tag = .member, |
| 4611 | 5666 | .attrs = &.{ |
| 4612 | | .{ .name, .strp }, |
| 5667 | .{ .name, .strx }, |
| 4613 | 5668 | .{ .type, .ref_addr }, |
| 4614 | 5669 | .{ .data_member_location, .udata }, |
| 4615 | 5670 | .{ .artificial, .flag_present }, |
| ... | ... | @@ -4618,7 +5673,7 @@ pub const AbbrevCode = enum { |
| 4618 | 5673 | .field = .{ |
| 4619 | 5674 | .tag = .member, |
| 4620 | 5675 | .attrs = &.{ |
| 4621 | | .{ .name, .strp }, |
| 5676 | .{ .name, .strx }, |
| 4622 | 5677 | .{ .type, .ref_addr }, |
| 4623 | 5678 | .{ .data_member_location, .udata }, |
| 4624 | 5679 | .{ .alignment, .udata }, |
| ... | ... | @@ -4627,7 +5682,7 @@ pub const AbbrevCode = enum { |
| 4627 | 5682 | .field_default_fully_runtime = .{ |
| 4628 | 5683 | .tag = .member, |
| 4629 | 5684 | .attrs = &.{ |
| 4630 | | .{ .name, .strp }, |
| 5685 | .{ .name, .strx }, |
| 4631 | 5686 | .{ .type, .ref_addr }, |
| 4632 | 5687 | .{ .data_member_location, .udata }, |
| 4633 | 5688 | .{ .alignment, .udata }, |
| ... | ... | @@ -4637,7 +5692,7 @@ pub const AbbrevCode = enum { |
| 4637 | 5692 | .field_default_partially_comptime = .{ |
| 4638 | 5693 | .tag = .member, |
| 4639 | 5694 | .attrs = &.{ |
| 4640 | | .{ .name, .strp }, |
| 5695 | .{ .name, .strx }, |
| 4641 | 5696 | .{ .type, .ref_addr }, |
| 4642 | 5697 | .{ .data_member_location, .udata }, |
| 4643 | 5698 | .{ .alignment, .udata }, |
| ... | ... | @@ -4648,7 +5703,7 @@ pub const AbbrevCode = enum { |
| 4648 | 5703 | .field_default_fully_comptime = .{ |
| 4649 | 5704 | .tag = .member, |
| 4650 | 5705 | .attrs = &.{ |
| 4651 | | .{ .name, .strp }, |
| 5706 | .{ .name, .strx }, |
| 4652 | 5707 | .{ .type, .ref_addr }, |
| 4653 | 5708 | .{ .data_member_location, .udata }, |
| 4654 | 5709 | .{ .alignment, .udata }, |
| ... | ... | @@ -4659,7 +5714,7 @@ pub const AbbrevCode = enum { |
| 4659 | 5714 | .tag = .member, |
| 4660 | 5715 | .attrs = &.{ |
| 4661 | 5716 | .{ .const_expr, .flag_present }, |
| 4662 | | .{ .name, .strp }, |
| 5717 | .{ .name, .strx }, |
| 4663 | 5718 | .{ .type, .ref_addr }, |
| 4664 | 5719 | }, |
| 4665 | 5720 | }, |
| ... | ... | @@ -4667,7 +5722,7 @@ pub const AbbrevCode = enum { |
| 4667 | 5722 | .tag = .member, |
| 4668 | 5723 | .attrs = &.{ |
| 4669 | 5724 | .{ .const_expr, .flag_present }, |
| 4670 | | .{ .name, .strp }, |
| 5725 | .{ .name, .strx }, |
| 4671 | 5726 | .{ .type, .ref_addr }, |
| 4672 | 5727 | .{ .const_value, .block }, |
| 4673 | 5728 | }, |
| ... | ... | @@ -4676,7 +5731,7 @@ pub const AbbrevCode = enum { |
| 4676 | 5731 | .tag = .member, |
| 4677 | 5732 | .attrs = &.{ |
| 4678 | 5733 | .{ .const_expr, .flag_present }, |
| 4679 | | .{ .name, .strp }, |
| 5734 | .{ .name, .strx }, |
| 4680 | 5735 | .{ .type, .ref_addr }, |
| 4681 | 5736 | .{ .const_value, .block }, |
| 4682 | 5737 | .{ .ZIG_comptime_value, .ref_addr }, |
| ... | ... | @@ -4686,7 +5741,7 @@ pub const AbbrevCode = enum { |
| 4686 | 5741 | .tag = .member, |
| 4687 | 5742 | .attrs = &.{ |
| 4688 | 5743 | .{ .const_expr, .flag_present }, |
| 4689 | | .{ .name, .strp }, |
| 5744 | .{ .name, .strx }, |
| 4690 | 5745 | .{ .type, .ref_addr }, |
| 4691 | 5746 | .{ .ZIG_comptime_value, .ref_addr }, |
| 4692 | 5747 | }, |
| ... | ... | @@ -4694,7 +5749,7 @@ pub const AbbrevCode = enum { |
| 4694 | 5749 | .packed_field = .{ |
| 4695 | 5750 | .tag = .member, |
| 4696 | 5751 | .attrs = &.{ |
| 4697 | | .{ .name, .strp }, |
| 5752 | .{ .name, .strx }, |
| 4698 | 5753 | .{ .type, .ref_addr }, |
| 4699 | 5754 | .{ .data_bit_offset, .udata }, |
| 4700 | 5755 | }, |
| ... | ... | @@ -4720,13 +5775,13 @@ pub const AbbrevCode = enum { |
| 4720 | 5775 | .void_type = .{ |
| 4721 | 5776 | .tag = .unspecified_type, |
| 4722 | 5777 | .attrs = &.{ |
| 4723 | | .{ .name, .strp }, |
| 5778 | .{ .name, .strx }, |
| 4724 | 5779 | }, |
| 4725 | 5780 | }, |
| 4726 | 5781 | .numeric_type = .{ |
| 4727 | 5782 | .tag = .base_type, |
| 4728 | 5783 | .attrs = &.{ |
| 4729 | | .{ .name, .strp }, |
| 5784 | .{ .name, .strx }, |
| 4730 | 5785 | .{ .encoding, .data1 }, |
| 4731 | 5786 | .{ .bit_size, .udata }, |
| 4732 | 5787 | .{ .byte_size, .udata }, |
| ... | ... | @@ -4736,14 +5791,14 @@ pub const AbbrevCode = enum { |
| 4736 | 5791 | .inferred_error_set_type = .{ |
| 4737 | 5792 | .tag = .typedef, |
| 4738 | 5793 | .attrs = &.{ |
| 4739 | | .{ .name, .strp }, |
| 5794 | .{ .name, .strx }, |
| 4740 | 5795 | .{ .type, .ref_addr }, |
| 4741 | 5796 | }, |
| 4742 | 5797 | }, |
| 4743 | 5798 | .ptr_type = .{ |
| 4744 | 5799 | .tag = .pointer_type, |
| 4745 | 5800 | .attrs = &.{ |
| 4746 | | .{ .name, .strp }, |
| 5801 | .{ .name, .strx }, |
| 4747 | 5802 | .{ .address_class, .data1 }, |
| 4748 | 5803 | .{ .type, .ref_addr }, |
| 4749 | 5804 | }, |
| ... | ... | @@ -4751,28 +5806,16 @@ pub const AbbrevCode = enum { |
| 4751 | 5806 | .ptr_sentinel_type = .{ |
| 4752 | 5807 | .tag = .pointer_type, |
| 4753 | 5808 | .attrs = &.{ |
| 4754 | | .{ .name, .strp }, |
| 5809 | .{ .name, .strx }, |
| 4755 | 5810 | .{ .ZIG_sentinel, .block }, |
| 4756 | 5811 | .{ .address_class, .data1 }, |
| 4757 | 5812 | .{ .type, .ref_addr }, |
| 4758 | 5813 | }, |
| 4759 | 5814 | }, |
| 4760 | | .ptr_aligned_type = .{ |
| 4761 | | .tag = .pointer_type, |
| 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, |
| 5815 | .is_aligned = .{ |
| 5816 | .tag = .typedef, |
| 4771 | 5817 | .attrs = &.{ |
| 4772 | | .{ .name, .strp }, |
| 4773 | | .{ .ZIG_sentinel, .block }, |
| 4774 | 5818 | .{ .alignment, .udata }, |
| 4775 | | .{ .address_class, .data1 }, |
| 4776 | 5819 | .{ .type, .ref_addr }, |
| 4777 | 5820 | }, |
| 4778 | 5821 | }, |
| ... | ... | @@ -4792,7 +5835,7 @@ pub const AbbrevCode = enum { |
| 4792 | 5835 | .tag = .array_type, |
| 4793 | 5836 | .children = true, |
| 4794 | 5837 | .attrs = &.{ |
| 4795 | | .{ .name, .strp }, |
| 5838 | .{ .name, .strx }, |
| 4796 | 5839 | .{ .type, .ref_addr }, |
| 4797 | 5840 | }, |
| 4798 | 5841 | }, |
| ... | ... | @@ -4800,7 +5843,7 @@ pub const AbbrevCode = enum { |
| 4800 | 5843 | .tag = .array_type, |
| 4801 | 5844 | .children = true, |
| 4802 | 5845 | .attrs = &.{ |
| 4803 | | .{ .name, .strp }, |
| 5846 | .{ .name, .strx }, |
| 4804 | 5847 | .{ .ZIG_sentinel, .block }, |
| 4805 | 5848 | .{ .type, .ref_addr }, |
| 4806 | 5849 | }, |
| ... | ... | @@ -4809,7 +5852,7 @@ pub const AbbrevCode = enum { |
| 4809 | 5852 | .tag = .array_type, |
| 4810 | 5853 | .children = true, |
| 4811 | 5854 | .attrs = &.{ |
| 4812 | | .{ .name, .strp }, |
| 5855 | .{ .name, .strx }, |
| 4813 | 5856 | .{ .type, .ref_addr }, |
| 4814 | 5857 | .{ .GNU_vector, .flag_present }, |
| 4815 | 5858 | }, |
| ... | ... | @@ -4827,10 +5870,10 @@ pub const AbbrevCode = enum { |
| 4827 | 5870 | .{ .count, .udata }, |
| 4828 | 5871 | }, |
| 4829 | 5872 | }, |
| 4830 | | .nullary_func_type = .{ |
| 5873 | .empty_func_type = .{ |
| 4831 | 5874 | .tag = .subroutine_type, |
| 4832 | 5875 | .attrs = &.{ |
| 4833 | | .{ .name, .strp }, |
| 5876 | .{ .name, .strx }, |
| 4834 | 5877 | .{ .calling_convention, .data1 }, |
| 4835 | 5878 | .{ .type, .ref_addr }, |
| 4836 | 5879 | }, |
| ... | ... | @@ -4839,7 +5882,7 @@ pub const AbbrevCode = enum { |
| 4839 | 5882 | .tag = .subroutine_type, |
| 4840 | 5883 | .children = true, |
| 4841 | 5884 | .attrs = &.{ |
| 4842 | | .{ .name, .strp }, |
| 5885 | .{ .name, .strx }, |
| 4843 | 5886 | .{ .calling_convention, .data1 }, |
| 4844 | 5887 | .{ .type, .ref_addr }, |
| 4845 | 5888 | }, |
| ... | ... | @@ -4847,7 +5890,7 @@ pub const AbbrevCode = enum { |
| 4847 | 5890 | .param = .{ |
| 4848 | 5891 | .tag = .formal_parameter, |
| 4849 | 5892 | .attrs = &.{ |
| 4850 | | .{ .name, .strp }, |
| 5893 | .{ .name, .strx }, |
| 4851 | 5894 | .{ .type, .ref_addr }, |
| 4852 | 5895 | }, |
| 4853 | 5896 | }, |
| ... | ... | @@ -4863,7 +5906,7 @@ pub const AbbrevCode = enum { |
| 4863 | 5906 | .generated_empty_enum_type = .{ |
| 4864 | 5907 | .tag = .enumeration_type, |
| 4865 | 5908 | .attrs = &.{ |
| 4866 | | .{ .name, .strp }, |
| 5909 | .{ .name, .strx }, |
| 4867 | 5910 | .{ .type, .ref_addr }, |
| 4868 | 5911 | }, |
| 4869 | 5912 | }, |
| ... | ... | @@ -4871,14 +5914,14 @@ pub const AbbrevCode = enum { |
| 4871 | 5914 | .tag = .enumeration_type, |
| 4872 | 5915 | .children = true, |
| 4873 | 5916 | .attrs = &.{ |
| 4874 | | .{ .name, .strp }, |
| 5917 | .{ .name, .strx }, |
| 4875 | 5918 | .{ .type, .ref_addr }, |
| 4876 | 5919 | }, |
| 4877 | 5920 | }, |
| 4878 | 5921 | .generated_empty_struct_type = .{ |
| 4879 | 5922 | .tag = .structure_type, |
| 4880 | 5923 | .attrs = &.{ |
| 4881 | | .{ .name, .strp }, |
| 5924 | .{ .name, .strx }, |
| 4882 | 5925 | .{ .declaration, .flag }, |
| 4883 | 5926 | }, |
| 4884 | 5927 | }, |
| ... | ... | @@ -4886,7 +5929,7 @@ pub const AbbrevCode = enum { |
| 4886 | 5929 | .tag = .structure_type, |
| 4887 | 5930 | .children = true, |
| 4888 | 5931 | .attrs = &.{ |
| 4889 | | .{ .name, .strp }, |
| 5932 | .{ .name, .strx }, |
| 4890 | 5933 | .{ .byte_size, .udata }, |
| 4891 | 5934 | .{ .alignment, .udata }, |
| 4892 | 5935 | }, |
| ... | ... | @@ -4895,7 +5938,7 @@ pub const AbbrevCode = enum { |
| 4895 | 5938 | .tag = .union_type, |
| 4896 | 5939 | .children = true, |
| 4897 | 5940 | .attrs = &.{ |
| 4898 | | .{ .name, .strp }, |
| 5941 | .{ .name, .strx }, |
| 4899 | 5942 | .{ .byte_size, .udata }, |
| 4900 | 5943 | .{ .alignment, .udata }, |
| 4901 | 5944 | }, |
| ... | ... | @@ -4903,7 +5946,7 @@ pub const AbbrevCode = enum { |
| 4903 | 5946 | .capture_specification = .{ |
| 4904 | 5947 | .tag = .template_value_parameter, |
| 4905 | 5948 | .attrs = &.{ |
| 4906 | | .{ .name, .strp }, |
| 5949 | .{ .name, .strx }, |
| 4907 | 5950 | }, |
| 4908 | 5951 | }, |
| 4909 | 5952 | .comptime_capture = .{ |
| ... | ... | @@ -4946,11 +5989,11 @@ pub const AbbrevCode = enum { |
| 4946 | 5989 | .{ .location, .exprloc }, |
| 4947 | 5990 | }, |
| 4948 | 5991 | }, |
| 4949 | | .builtin_extern_nullary_func = .{ |
| 5992 | .builtin_extern_empty_func = .{ |
| 4950 | 5993 | .tag = .subprogram, |
| 4951 | 5994 | .attrs = &.{ |
| 4952 | 5995 | .{ .ZIG_parent, .ref_addr }, |
| 4953 | | .{ .linkage_name, .strp }, |
| 5996 | .{ .linkage_name, .strx }, |
| 4954 | 5997 | .{ .type, .ref_addr }, |
| 4955 | 5998 | .{ .low_pc, .addr }, |
| 4956 | 5999 | .{ .external, .flag_present }, |
| ... | ... | @@ -4962,7 +6005,7 @@ pub const AbbrevCode = enum { |
| 4962 | 6005 | .children = true, |
| 4963 | 6006 | .attrs = &.{ |
| 4964 | 6007 | .{ .ZIG_parent, .ref_addr }, |
| 4965 | | .{ .linkage_name, .strp }, |
| 6008 | .{ .linkage_name, .strx }, |
| 4966 | 6009 | .{ .type, .ref_addr }, |
| 4967 | 6010 | .{ .low_pc, .addr }, |
| 4968 | 6011 | .{ .external, .flag_present }, |
| ... | ... | @@ -4973,9 +6016,10 @@ pub const AbbrevCode = enum { |
| 4973 | 6016 | .tag = .variable, |
| 4974 | 6017 | .attrs = &.{ |
| 4975 | 6018 | .{ .ZIG_parent, .ref_addr }, |
| 4976 | | .{ .linkage_name, .strp }, |
| 6019 | .{ .linkage_name, .strx }, |
| 4977 | 6020 | .{ .type, .ref_addr }, |
| 4978 | 6021 | .{ .location, .exprloc }, |
| 6022 | .{ .alignment, .udata }, |
| 4979 | 6023 | .{ .external, .flag_present }, |
| 4980 | 6024 | }, |
| 4981 | 6025 | }, |
| ... | ... | @@ -5018,7 +6062,7 @@ pub const AbbrevCode = enum { |
| 5018 | 6062 | .arg = .{ |
| 5019 | 6063 | .tag = .formal_parameter, |
| 5020 | 6064 | .attrs = &.{ |
| 5021 | | .{ .name, .strp }, |
| 6065 | .{ .name, .strx }, |
| 5022 | 6066 | .{ .type, .ref_addr }, |
| 5023 | 6067 | .{ .location, .exprloc }, |
| 5024 | 6068 | }, |
| ... | ... | @@ -5034,7 +6078,7 @@ pub const AbbrevCode = enum { |
| 5034 | 6078 | .tag = .formal_parameter, |
| 5035 | 6079 | .attrs = &.{ |
| 5036 | 6080 | .{ .const_expr, .flag_present }, |
| 5037 | | .{ .name, .strp }, |
| 6081 | .{ .name, .strx }, |
| 5038 | 6082 | .{ .type, .ref_addr }, |
| 5039 | 6083 | }, |
| 5040 | 6084 | }, |
| ... | ... | @@ -5042,7 +6086,7 @@ pub const AbbrevCode = enum { |
| 5042 | 6086 | .tag = .formal_parameter, |
| 5043 | 6087 | .attrs = &.{ |
| 5044 | 6088 | .{ .const_expr, .flag_present }, |
| 5045 | | .{ .name, .strp }, |
| 6089 | .{ .name, .strx }, |
| 5046 | 6090 | .{ .type, .ref_addr }, |
| 5047 | 6091 | .{ .const_value, .block }, |
| 5048 | 6092 | }, |
| ... | ... | @@ -5051,7 +6095,7 @@ pub const AbbrevCode = enum { |
| 5051 | 6095 | .tag = .formal_parameter, |
| 5052 | 6096 | .attrs = &.{ |
| 5053 | 6097 | .{ .const_expr, .flag_present }, |
| 5054 | | .{ .name, .strp }, |
| 6098 | .{ .name, .strx }, |
| 5055 | 6099 | .{ .type, .ref_addr }, |
| 5056 | 6100 | .{ .const_value, .block }, |
| 5057 | 6101 | .{ .ZIG_comptime_value, .ref_addr }, |
| ... | ... | @@ -5061,7 +6105,7 @@ pub const AbbrevCode = enum { |
| 5061 | 6105 | .tag = .formal_parameter, |
| 5062 | 6106 | .attrs = &.{ |
| 5063 | 6107 | .{ .const_expr, .flag_present }, |
| 5064 | | .{ .name, .strp }, |
| 6108 | .{ .name, .strx }, |
| 5065 | 6109 | .{ .type, .ref_addr }, |
| 5066 | 6110 | .{ .ZIG_comptime_value, .ref_addr }, |
| 5067 | 6111 | }, |
| ... | ... | @@ -5107,7 +6151,7 @@ pub const AbbrevCode = enum { |
| 5107 | 6151 | .local_var = .{ |
| 5108 | 6152 | .tag = .variable, |
| 5109 | 6153 | .attrs = &.{ |
| 5110 | | .{ .name, .strp }, |
| 6154 | .{ .name, .strx }, |
| 5111 | 6155 | .{ .type, .ref_addr }, |
| 5112 | 6156 | .{ .location, .exprloc }, |
| 5113 | 6157 | }, |
| ... | ... | @@ -5115,14 +6159,14 @@ pub const AbbrevCode = enum { |
| 5115 | 6159 | .local_const = .{ |
| 5116 | 6160 | .tag = .constant, |
| 5117 | 6161 | .attrs = &.{ |
| 5118 | | .{ .name, .strp }, |
| 6162 | .{ .name, .strx }, |
| 5119 | 6163 | .{ .type, .ref_addr }, |
| 5120 | 6164 | }, |
| 5121 | 6165 | }, |
| 5122 | 6166 | .local_const_fully_runtime = .{ |
| 5123 | 6167 | .tag = .constant, |
| 5124 | 6168 | .attrs = &.{ |
| 5125 | | .{ .name, .strp }, |
| 6169 | .{ .name, .strx }, |
| 5126 | 6170 | .{ .type, .ref_addr }, |
| 5127 | 6171 | .{ .const_value, .block }, |
| 5128 | 6172 | }, |
| ... | ... | @@ -5130,7 +6174,7 @@ pub const AbbrevCode = enum { |
| 5130 | 6174 | .local_const_partially_comptime = .{ |
| 5131 | 6175 | .tag = .constant, |
| 5132 | 6176 | .attrs = &.{ |
| 5133 | | .{ .name, .strp }, |
| 6177 | .{ .name, .strx }, |
| 5134 | 6178 | .{ .type, .ref_addr }, |
| 5135 | 6179 | .{ .const_value, .block }, |
| 5136 | 6180 | .{ .ZIG_comptime_value, .ref_addr }, |
| ... | ... | @@ -5139,7 +6183,7 @@ pub const AbbrevCode = enum { |
| 5139 | 6183 | .local_const_fully_comptime = .{ |
| 5140 | 6184 | .tag = .constant, |
| 5141 | 6185 | .attrs = &.{ |
| 5142 | | .{ .name, .strp }, |
| 6186 | .{ .name, .strx }, |
| 5143 | 6187 | .{ .type, .ref_addr }, |
| 5144 | 6188 | .{ .ZIG_comptime_value, .ref_addr }, |
| 5145 | 6189 | }, |
| ... | ... | @@ -5187,32 +6231,64 @@ pub const AbbrevCode = enum { |
| 5187 | 6231 | .{ .location, .exprloc }, |
| 5188 | 6232 | }, |
| 5189 | 6233 | }, |
| 5190 | | .comptime_value_field_runtime_bits = .{ |
| 6234 | .comptime_value_field_runtime = .{ |
| 5191 | 6235 | .tag = .member, |
| 5192 | 6236 | .attrs = &.{ |
| 5193 | | .{ .name, .strp }, |
| 6237 | .{ .name, .strx }, |
| 5194 | 6238 | .{ .const_value, .block }, |
| 5195 | 6239 | }, |
| 5196 | 6240 | }, |
| 5197 | | .comptime_value_field_comptime_state = .{ |
| 6241 | .comptime_value_field_comptime = .{ |
| 5198 | 6242 | .tag = .member, |
| 5199 | 6243 | .attrs = &.{ |
| 5200 | | .{ .name, .strp }, |
| 6244 | .{ .name, .strx }, |
| 5201 | 6245 | .{ .ZIG_comptime_value, .ref_addr }, |
| 5202 | 6246 | }, |
| 5203 | 6247 | }, |
| 5204 | | .comptime_value_elem_runtime_bits = .{ |
| 6248 | .comptime_value_elem_runtime = .{ |
| 5205 | 6249 | .tag = .member, |
| 5206 | 6250 | .attrs = &.{ |
| 5207 | 6251 | .{ .const_value, .block }, |
| 5208 | 6252 | }, |
| 5209 | 6253 | }, |
| 5210 | | .comptime_value_elem_comptime_state = .{ |
| 6254 | .comptime_value_elem_comptime = .{ |
| 5211 | 6255 | .tag = .member, |
| 5212 | 6256 | .attrs = &.{ |
| 5213 | 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 | |