| author | |
| committer | |
| log | bfd36cbf97bfa012e5c399c16578b8756782e1d8 |
| tree | d6655a05c089ab0c316d3e36049b67768f774be8 |
| parent | 05962a4aa28eca701bb22c4b17d2f9ea236583f5 |
7 files changed, 50 insertions(+), 86 deletions(-)
src/arch/aarch64/CodeGen.zig+15-16| ... | ... | @@ -182,8 +182,6 @@ const DbgInfoReloc = struct { |
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | fn genArgDbgInfo(reloc: DbgInfoReloc, function: Self) error{OutOfMemory}!void { |
| 185 | const atom = function.getDbgInfoAtomPtr(); | |
| 186 | ||
| 187 | 185 | switch (function.debug_output) { |
| 188 | 186 | .dwarf => |dw| { |
| 189 | 187 | const loc: link.File.Dwarf.DeclState.DbgInfoLoc = switch (reloc.mcv) { |
| ... | ... | @@ -204,7 +202,13 @@ const DbgInfoReloc = struct { |
| 204 | 202 | else => unreachable, // not a possible argument |
| 205 | 203 | |
| 206 | 204 | }; |
| 207 | try dw.genArgDbgInfo(reloc.name, reloc.ty, atom, loc); | |
| 205 | try dw.genArgDbgInfo( | |
| 206 | reloc.name, | |
| 207 | reloc.ty, | |
| 208 | function.bin_file.tag, | |
| 209 | function.mod_fn.owner_decl, | |
| 210 | loc, | |
| 211 | ); | |
| 208 | 212 | }, |
| 209 | 213 | .plan9 => {}, |
| 210 | 214 | .none => {}, |
| ... | ... | @@ -217,7 +221,6 @@ const DbgInfoReloc = struct { |
| 217 | 221 | .dbg_var_val => false, |
| 218 | 222 | else => unreachable, |
| 219 | 223 | }; |
| 220 | const atom = function.getDbgInfoAtomPtr(); | |
| 221 | 224 | |
| 222 | 225 | switch (function.debug_output) { |
| 223 | 226 | .dwarf => |dw| { |
| ... | ... | @@ -251,7 +254,14 @@ const DbgInfoReloc = struct { |
| 251 | 254 | break :blk .nop; |
| 252 | 255 | }, |
| 253 | 256 | }; |
| 254 | try dw.genVarDbgInfo(reloc.name, reloc.ty, atom, is_ptr, loc); | |
| 257 | try dw.genVarDbgInfo( | |
| 258 | reloc.name, | |
| 259 | reloc.ty, | |
| 260 | function.bin_file.tag, | |
| 261 | function.mod_fn.owner_decl, | |
| 262 | is_ptr, | |
| 263 | loc, | |
| 264 | ); | |
| 255 | 265 | }, |
| 256 | 266 | .plan9 => {}, |
| 257 | 267 | .none => {}, |
| ... | ... | @@ -259,17 +269,6 @@ const DbgInfoReloc = struct { |
| 259 | 269 | } |
| 260 | 270 | }; |
| 261 | 271 | |
| 262 | fn getDbgInfoAtomPtr(self: Self) *link.File.Dwarf.Atom { | |
| 263 | const mod = self.bin_file.options.module.?; | |
| 264 | const fn_owner_decl = mod.declPtr(self.mod_fn.owner_decl); | |
| 265 | const atom = switch (self.bin_file.tag) { | |
| 266 | .elf => &fn_owner_decl.link.elf.dbg_info_atom, | |
| 267 | .macho => &fn_owner_decl.link.macho.dbg_info_atom, | |
| 268 | else => unreachable, | |
| 269 | }; | |
| 270 | return atom; | |
| 271 | } | |
| 272 | ||
| 273 | 272 | const Branch = struct { |
| 274 | 273 | inst_table: std.AutoArrayHashMapUnmanaged(Air.Inst.Index, MCValue) = .{}, |
| 275 | 274 |
src/arch/arm/CodeGen.zig+1-13| ... | ... | @@ -4033,7 +4033,6 @@ fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, arg_index: u32) error{OutOfMe |
| 4033 | 4033 | const mcv = self.args[arg_index]; |
| 4034 | 4034 | const ty = self.air.instructions.items(.data)[inst].ty; |
| 4035 | 4035 | const name = self.mod_fn.getParamName(self.bin_file.options.module.?, arg_index); |
| 4036 | const atom = self.getDbgInfoAtom(); | |
| 4037 | 4036 | |
| 4038 | 4037 | switch (self.debug_output) { |
| 4039 | 4038 | .dwarf => |dw| { |
| ... | ... | @@ -4055,24 +4054,13 @@ fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, arg_index: u32) error{OutOfMe |
| 4055 | 4054 | else => unreachable, // not a possible argument |
| 4056 | 4055 | |
| 4057 | 4056 | }; |
| 4058 | try dw.genArgDbgInfo(name, ty, atom, loc); | |
| 4057 | try dw.genArgDbgInfo(name, ty, self.bin_file.tag, self.mod_fn.owner_decl, loc); | |
| 4059 | 4058 | }, |
| 4060 | 4059 | .plan9 => {}, |
| 4061 | 4060 | .none => {}, |
| 4062 | 4061 | } |
| 4063 | 4062 | } |
| 4064 | 4063 | |
| 4065 | fn getDbgInfoAtom(self: Self) *link.File.Dwarf.Atom { | |
| 4066 | const mod = self.bin_file.options.module.?; | |
| 4067 | const fn_owner_decl = mod.declPtr(self.mod_fn.owner_decl); | |
| 4068 | const atom = switch (self.bin_file.tag) { | |
| 4069 | .elf => &fn_owner_decl.link.elf.dbg_info_atom, | |
| 4070 | .macho => &fn_owner_decl.link.macho.dbg_info_atom, | |
| 4071 | else => unreachable, | |
| 4072 | }; | |
| 4073 | return atom; | |
| 4074 | } | |
| 4075 | ||
| 4076 | 4064 | fn airArg(self: *Self, inst: Air.Inst.Index) !void { |
| 4077 | 4065 | const arg_index = self.arg_index; |
| 4078 | 4066 | self.arg_index += 1; |
src/arch/riscv64/CodeGen.zig+7-15| ... | ... | @@ -1605,13 +1605,16 @@ fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void { |
| 1605 | 1605 | fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, mcv: MCValue, arg_index: u32) !void { |
| 1606 | 1606 | const ty = self.air.instructions.items(.data)[inst].ty; |
| 1607 | 1607 | const name = self.mod_fn.getParamName(self.bin_file.options.module.?, arg_index); |
| 1608 | const atom = self.getDbgIntoAtomPtr(); | |
| 1609 | 1608 | |
| 1610 | 1609 | switch (self.debug_output) { |
| 1611 | 1610 | .dwarf => |dw| switch (mcv) { |
| 1612 | .register => |reg| try dw.genArgDbgInfo(name, ty, atom, .{ | |
| 1613 | .register = reg.dwarfLocOp(), | |
| 1614 | }), | |
| 1611 | .register => |reg| try dw.genArgDbgInfo( | |
| 1612 | name, | |
| 1613 | ty, | |
| 1614 | self.bin_file.tag, | |
| 1615 | self.mod_fn.owner_decl, | |
| 1616 | .{ .register = reg.dwarfLocOp() }, | |
| 1617 | ), | |
| 1615 | 1618 | .stack_offset => {}, |
| 1616 | 1619 | else => {}, |
| 1617 | 1620 | }, |
| ... | ... | @@ -1620,17 +1623,6 @@ fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, mcv: MCValue, arg_index: u32) |
| 1620 | 1623 | } |
| 1621 | 1624 | } |
| 1622 | 1625 | |
| 1623 | fn getDbgIntoAtomPtr(self: Self) *link.File.Dwarf.Atom { | |
| 1624 | const mod = self.bin_file.options.module.?; | |
| 1625 | const fn_owner_decl = mod.declPtr(self.mod_fn.owner_decl); | |
| 1626 | const atom = switch (self.bin_file.tag) { | |
| 1627 | .elf => &fn_owner_decl.link.elf.dbg_info_atom, | |
| 1628 | .macho => &fn_owner_decl.link.macho.dbg_info_atom, | |
| 1629 | else => unreachable, | |
| 1630 | }; | |
| 1631 | return atom; | |
| 1632 | } | |
| 1633 | ||
| 1634 | 1626 | fn airArg(self: *Self, inst: Air.Inst.Index) !void { |
| 1635 | 1627 | const arg_index = self.arg_index; |
| 1636 | 1628 | self.arg_index += 1; |
src/arch/sparc64/CodeGen.zig+7-14| ... | ... | @@ -3255,29 +3255,22 @@ fn finishAir(self: *Self, inst: Air.Inst.Index, result: MCValue, operands: [Live |
| 3255 | 3255 | fn genArgDbgInfo(self: Self, inst: Air.Inst.Index, mcv: MCValue, arg_index: u32) !void { |
| 3256 | 3256 | const ty = self.air.instructions.items(.data)[inst].ty; |
| 3257 | 3257 | const name = self.mod_fn.getParamName(self.bin_file.options.module.?, arg_index); |
| 3258 | const atom = self.getDbgInfoAtomPtr(); | |
| 3259 | 3258 | |
| 3260 | 3259 | switch (self.debug_output) { |
| 3261 | 3260 | .dwarf => |dw| switch (mcv) { |
| 3262 | .register => |reg| try dw.genArgDbgInfo(name, ty, atom, .{ | |
| 3263 | .register = reg.dwarfLocOp(), | |
| 3264 | }), | |
| 3261 | .register => |reg| try dw.genArgDbgInfo( | |
| 3262 | name, | |
| 3263 | ty, | |
| 3264 | self.bin_file.tag, | |
| 3265 | self.mod_fn.owner_decl, | |
| 3266 | .{ .register = reg.dwarfLocOp() }, | |
| 3267 | ), | |
| 3265 | 3268 | else => {}, |
| 3266 | 3269 | }, |
| 3267 | 3270 | else => {}, |
| 3268 | 3271 | } |
| 3269 | 3272 | } |
| 3270 | 3273 | |
| 3271 | fn getDbgInfoAtomPtr(self: Self) *link.File.Dwarf.Atom { | |
| 3272 | const mod = self.bin_file.options.module.?; | |
| 3273 | const fn_owner_decl = mod.declPtr(self.mod_fn.owner_decl); | |
| 3274 | const atom = switch (self.bin_file.tag) { | |
| 3275 | .elf => &fn_owner_decl.link.elf.dbg_info_atom, | |
| 3276 | else => unreachable, | |
| 3277 | }; | |
| 3278 | return atom; | |
| 3279 | } | |
| 3280 | ||
| 3281 | 3274 | // TODO replace this to call to extern memcpy |
| 3282 | 3275 | fn genInlineMemcpy( |
| 3283 | 3276 | self: *Self, |
src/arch/wasm/CodeGen.zig+2-10| ... | ... | @@ -2341,8 +2341,7 @@ fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2341 | 2341 | .dwarf => |dwarf| { |
| 2342 | 2342 | // TODO: Get the original arg index rather than wasm arg index |
| 2343 | 2343 | const name = func.mod_fn.getParamName(func.bin_file.base.options.module.?, arg_index); |
| 2344 | const atom = func.getDbgInfoAtom(); | |
| 2345 | try dwarf.genArgDbgInfo(name, arg_ty, atom, .{ | |
| 2344 | try dwarf.genArgDbgInfo(name, arg_ty, .wasm, func.mod_fn.owner_decl, .{ | |
| 2346 | 2345 | .wasm_local = arg.local.value, |
| 2347 | 2346 | }); |
| 2348 | 2347 | }, |
| ... | ... | @@ -2352,12 +2351,6 @@ fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 2352 | 2351 | func.finishAir(inst, arg, &.{}); |
| 2353 | 2352 | } |
| 2354 | 2353 | |
| 2355 | fn getDbgInfoAtom(func: CodeGen) *link.File.Dwarf.Atom { | |
| 2356 | const mod = func.bin_file.base.options.module.?; | |
| 2357 | const fn_owner_decl = mod.declPtr(func.mod_fn.owner_decl); | |
| 2358 | return &fn_owner_decl.link.wasm.dbg_info_atom; | |
| 2359 | } | |
| 2360 | ||
| 2361 | 2354 | fn airBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void { |
| 2362 | 2355 | const bin_op = func.air.instructions.items(.data)[inst].bin_op; |
| 2363 | 2356 | if (func.liveness.isUnused(inst)) return func.finishAir(inst, .none, &.{ bin_op.lhs, bin_op.rhs }); |
| ... | ... | @@ -5326,7 +5319,6 @@ fn airDbgVar(func: *CodeGen, inst: Air.Inst.Index, is_ptr: bool) !void { |
| 5326 | 5319 | const name = func.air.nullTerminatedString(pl_op.payload); |
| 5327 | 5320 | log.debug(" var name = ({s})", .{name}); |
| 5328 | 5321 | |
| 5329 | const atom = func.getDbgInfoAtom(); | |
| 5330 | 5322 | const loc: link.File.Dwarf.DeclState.DbgInfoLoc = switch (operand) { |
| 5331 | 5323 | .local => |local| .{ .wasm_local = local.value }, |
| 5332 | 5324 | else => blk: { |
| ... | ... | @@ -5334,7 +5326,7 @@ fn airDbgVar(func: *CodeGen, inst: Air.Inst.Index, is_ptr: bool) !void { |
| 5334 | 5326 | break :blk .nop; |
| 5335 | 5327 | }, |
| 5336 | 5328 | }; |
| 5337 | try func.debug_output.dwarf.genVarDbgInfo(name, ty, atom, is_ptr, loc); | |
| 5329 | try func.debug_output.dwarf.genVarDbgInfo(name, ty, .wasm, func.mod_fn.owner_decl, is_ptr, loc); | |
| 5338 | 5330 | |
| 5339 | 5331 | func.finishAir(inst, .none, &.{}); |
| 5340 | 5332 | } |
src/arch/x86_64/CodeGen.zig+2-16| ... | ... | @@ -3815,8 +3815,6 @@ fn airArg(self: *Self, inst: Air.Inst.Index) !void { |
| 3815 | 3815 | } |
| 3816 | 3816 | |
| 3817 | 3817 | fn genArgDbgInfo(self: Self, ty: Type, name: [:0]const u8, mcv: MCValue) !void { |
| 3818 | const atom = self.getDbgInfoAtomPtr(); | |
| 3819 | ||
| 3820 | 3818 | switch (self.debug_output) { |
| 3821 | 3819 | .dwarf => |dw| { |
| 3822 | 3820 | const loc: link.File.Dwarf.DeclState.DbgInfoLoc = switch (mcv) { |
| ... | ... | @@ -3830,7 +3828,7 @@ fn genArgDbgInfo(self: Self, ty: Type, name: [:0]const u8, mcv: MCValue) !void { |
| 3830 | 3828 | }, |
| 3831 | 3829 | else => unreachable, // not a valid function parameter |
| 3832 | 3830 | }; |
| 3833 | try dw.genArgDbgInfo(name, ty, atom, loc); | |
| 3831 | try dw.genArgDbgInfo(name, ty, self.bin_file.tag, self.mod_fn.owner_decl, loc); | |
| 3834 | 3832 | }, |
| 3835 | 3833 | .plan9 => {}, |
| 3836 | 3834 | .none => {}, |
| ... | ... | @@ -3849,7 +3847,6 @@ fn genVarDbgInfo( |
| 3849 | 3847 | .dbg_var_val => false, |
| 3850 | 3848 | else => unreachable, |
| 3851 | 3849 | }; |
| 3852 | const atom = self.getDbgInfoAtomPtr(); | |
| 3853 | 3850 | |
| 3854 | 3851 | switch (self.debug_output) { |
| 3855 | 3852 | .dwarf => |dw| { |
| ... | ... | @@ -3871,24 +3868,13 @@ fn genVarDbgInfo( |
| 3871 | 3868 | break :blk .nop; |
| 3872 | 3869 | }, |
| 3873 | 3870 | }; |
| 3874 | try dw.genVarDbgInfo(name, ty, atom, is_ptr, loc); | |
| 3871 | try dw.genVarDbgInfo(name, ty, self.bin_file.tag, self.mod_fn.owner_decl, is_ptr, loc); | |
| 3875 | 3872 | }, |
| 3876 | 3873 | .plan9 => {}, |
| 3877 | 3874 | .none => {}, |
| 3878 | 3875 | } |
| 3879 | 3876 | } |
| 3880 | 3877 | |
| 3881 | fn getDbgInfoAtomPtr(self: Self) *link.File.Dwarf.Atom { | |
| 3882 | const mod = self.bin_file.options.module.?; | |
| 3883 | const fn_owner_decl = mod.declPtr(self.mod_fn.owner_decl); | |
| 3884 | const atom = switch (self.bin_file.tag) { | |
| 3885 | .elf => &fn_owner_decl.link.elf.dbg_info_atom, | |
| 3886 | .macho => &fn_owner_decl.link.macho.dbg_info_atom, | |
| 3887 | else => unreachable, | |
| 3888 | }; | |
| 3889 | return atom; | |
| 3890 | } | |
| 3891 | ||
| 3892 | 3878 | fn airBreakpoint(self: *Self) !void { |
| 3893 | 3879 | _ = try self.addInst(.{ |
| 3894 | 3880 | .tag = .interrupt, |
src/link/Dwarf.zig+16-2| ... | ... | @@ -581,10 +581,12 @@ pub const DeclState = struct { |
| 581 | 581 | self: *DeclState, |
| 582 | 582 | name: [:0]const u8, |
| 583 | 583 | ty: Type, |
| 584 | atom: *Atom, | |
| 584 | tag: File.Tag, | |
| 585 | owner_decl: Module.Decl.Index, | |
| 585 | 586 | loc: DbgInfoLoc, |
| 586 | 587 | ) error{OutOfMemory}!void { |
| 587 | 588 | const dbg_info = &self.dbg_info; |
| 589 | const atom = self.getDbgInfoAtom(tag, owner_decl); | |
| 588 | 590 | const name_with_null = name.ptr[0 .. name.len + 1]; |
| 589 | 591 | |
| 590 | 592 | switch (loc) { |
| ... | ... | @@ -637,11 +639,13 @@ pub const DeclState = struct { |
| 637 | 639 | self: *DeclState, |
| 638 | 640 | name: [:0]const u8, |
| 639 | 641 | ty: Type, |
| 640 | atom: *Atom, | |
| 642 | tag: File.Tag, | |
| 643 | owner_decl: Module.Decl.Index, | |
| 641 | 644 | is_ptr: bool, |
| 642 | 645 | loc: DbgInfoLoc, |
| 643 | 646 | ) error{OutOfMemory}!void { |
| 644 | 647 | const dbg_info = &self.dbg_info; |
| 648 | const atom = self.getDbgInfoAtom(tag, owner_decl); | |
| 645 | 649 | const name_with_null = name.ptr[0 .. name.len + 1]; |
| 646 | 650 | try dbg_info.append(@enumToInt(AbbrevKind.variable)); |
| 647 | 651 | const target = self.mod.getTarget(); |
| ... | ... | @@ -774,6 +778,16 @@ pub const DeclState = struct { |
| 774 | 778 | try self.addTypeRelocGlobal(atom, child_ty, @intCast(u32, index)); |
| 775 | 779 | dbg_info.appendSliceAssumeCapacity(name_with_null); // DW.AT.name, DW.FORM.string |
| 776 | 780 | } |
| 781 | ||
| 782 | fn getDbgInfoAtom(self: *DeclState, tag: File.Tag, decl_index: Module.Decl.Index) *Atom { | |
| 783 | const decl = self.mod.declPtr(decl_index); | |
| 784 | return switch (tag) { | |
| 785 | .elf => &decl.link.elf.dbg_info_atom, | |
| 786 | .macho => &decl.link.macho.dbg_info_atom, | |
| 787 | .wasm => &decl.link.wasm.dbg_info_atom, | |
| 788 | else => unreachable, | |
| 789 | }; | |
| 790 | } | |
| 777 | 791 | }; |
| 778 | 792 | |
| 779 | 793 | pub const AbbrevEntry = struct { |