| author | |
| committer | |
| log | 7d0af639d82bc22b204e20b11f5f6aee1ed1766e |
| tree | 5abde4a591290b14f8b184602262a2f26168d45c |
| parent | 5ee99f862a1b3a4d1f5ca304623e7394603136a6 |
4 files changed, 79 insertions(+), 162 deletions(-)
src/arch/aarch64/CodeGen.zig+21-25| ... | ... | @@ -195,32 +195,28 @@ const DbgInfoReloc = struct { |
| 195 | 195 | }; |
| 196 | 196 | |
| 197 | 197 | switch (function.debug_output) { |
| 198 | .dwarf => |dw| { | |
| 199 | switch (reloc.mcv) { | |
| 200 | .register => |reg| { | |
| 201 | try dw.genArgDbgInfo(reloc.name, reloc.ty, atom, .{ | |
| 202 | .register = reg.dwarfLocOp(), | |
| 203 | }); | |
| 204 | }, | |
| 205 | ||
| 206 | .stack_offset, | |
| 207 | .stack_argument_offset, | |
| 208 | => |offset| { | |
| 209 | const adjusted_offset = switch (reloc.mcv) { | |
| 210 | .stack_offset => -@intCast(i32, offset), | |
| 211 | .stack_argument_offset => @intCast(i32, function.saved_regs_stack_space + offset), | |
| 212 | else => unreachable, | |
| 213 | }; | |
| 214 | try dw.genArgDbgInfo(reloc.name, reloc.ty, atom, .{ | |
| 215 | .stack = .{ | |
| 216 | .fp_register = Register.x29.dwarfLocOpDeref(), | |
| 217 | .offset = adjusted_offset, | |
| 218 | }, | |
| 219 | }); | |
| 220 | }, | |
| 198 | .dwarf => |dw| switch (reloc.mcv) { | |
| 199 | .register => |reg| try dw.genArgDbgInfo(reloc.name, reloc.ty, atom, .{ | |
| 200 | .register = reg.dwarfLocOp(), | |
| 201 | }), | |
| 202 | ||
| 203 | .stack_offset, | |
| 204 | .stack_argument_offset, | |
| 205 | => |offset| { | |
| 206 | const adjusted_offset = switch (reloc.mcv) { | |
| 207 | .stack_offset => -@intCast(i32, offset), | |
| 208 | .stack_argument_offset => @intCast(i32, function.saved_regs_stack_space + offset), | |
| 209 | else => unreachable, | |
| 210 | }; | |
| 211 | try dw.genArgDbgInfo(reloc.name, reloc.ty, atom, .{ | |
| 212 | .stack = .{ | |
| 213 | .fp_register = Register.x29.dwarfLocOpDeref(), | |
| 214 | .offset = adjusted_offset, | |
| 215 | }, | |
| 216 | }); | |
| 217 | }, | |
| 221 | 218 | |
| 222 | else => unreachable, // not a possible argument | |
| 223 | } | |
| 219 | else => unreachable, // not a possible argument | |
| 224 | 220 | }, |
| 225 | 221 | .plan9 => {}, |
| 226 | 222 | .none => {}, |
src/arch/arm/CodeGen.zig+30-73| ... | ... | @@ -4029,86 +4029,43 @@ fn genInlineMemsetCode( |
| 4029 | 4029 | // end: |
| 4030 | 4030 | } |
| 4031 | 4031 | |
| 4032 | /// Adds a Type to the .debug_info at the current position. The bytes will be populated later, | |
| 4033 | /// after codegen for this symbol is done. | |
| 4034 | fn addDbgInfoTypeReloc(self: *Self, ty: Type) error{OutOfMemory}!void { | |
| 4035 | switch (self.debug_output) { | |
| 4036 | .dwarf => |dw| { | |
| 4037 | assert(ty.hasRuntimeBits()); | |
| 4038 | const dbg_info = &dw.dbg_info; | |
| 4039 | const index = dbg_info.items.len; | |
| 4040 | try dbg_info.resize(index + 4); // DW.AT.type, DW.FORM.ref4 | |
| 4041 | const mod = self.bin_file.options.module.?; | |
| 4042 | const atom = switch (self.bin_file.tag) { | |
| 4043 | .elf => &mod.declPtr(self.mod_fn.owner_decl).link.elf.dbg_info_atom, | |
| 4044 | .macho => unreachable, | |
| 4045 | else => unreachable, | |
| 4046 | }; | |
| 4047 | try dw.addTypeRelocGlobal(atom, ty, @intCast(u32, index)); | |
| 4048 | }, | |
| 4049 | .plan9 => {}, | |
| 4050 | .none => {}, | |
| 4051 | } | |
| 4052 | } | |
| 4053 | ||
| 4054 | 4032 | fn genArgDbgInfo(self: *Self, inst: Air.Inst.Index, arg_index: u32) error{OutOfMemory}!void { |
| 4055 | 4033 | const mcv = self.args[arg_index]; |
| 4056 | 4034 | const ty = self.air.instructions.items(.data)[inst].ty; |
| 4057 | 4035 | const name = self.mod_fn.getParamName(self.bin_file.options.module.?, arg_index); |
| 4058 | const name_with_null = name.ptr[0 .. name.len + 1]; | |
| 4059 | 4036 | |
| 4060 | switch (mcv) { | |
| 4061 | .register => |reg| { | |
| 4062 | switch (self.debug_output) { | |
| 4063 | .dwarf => |dw| { | |
| 4064 | const dbg_info = &dw.dbg_info; | |
| 4065 | try dbg_info.ensureUnusedCapacity(3); | |
| 4066 | dbg_info.appendAssumeCapacity(@enumToInt(link.File.Dwarf.AbbrevKind.parameter)); | |
| 4067 | dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc | |
| 4068 | 1, // ULEB128 dwarf expression length | |
| 4069 | reg.dwarfLocOp(), | |
| 4070 | }); | |
| 4071 | try dbg_info.ensureUnusedCapacity(5 + name_with_null.len); | |
| 4072 | try self.addDbgInfoTypeReloc(ty); // DW.AT.type, DW.FORM.ref4 | |
| 4073 | dbg_info.appendSliceAssumeCapacity(name_with_null); // DW.AT.name, DW.FORM.string | |
| 4074 | }, | |
| 4075 | .plan9 => {}, | |
| 4076 | .none => {}, | |
| 4077 | } | |
| 4078 | }, | |
| 4079 | .stack_offset, | |
| 4080 | .stack_argument_offset, | |
| 4081 | => { | |
| 4082 | switch (self.debug_output) { | |
| 4083 | .dwarf => |dw| { | |
| 4084 | const adjusted_stack_offset = switch (mcv) { | |
| 4085 | .stack_offset => |offset| -@intCast(i32, offset), | |
| 4086 | .stack_argument_offset => |offset| @intCast(i32, self.saved_regs_stack_space + offset), | |
| 4087 | else => unreachable, | |
| 4088 | }; | |
| 4089 | ||
| 4090 | const dbg_info = &dw.dbg_info; | |
| 4091 | try dbg_info.append(@enumToInt(link.File.Dwarf.AbbrevKind.parameter)); | |
| 4092 | ||
| 4093 | // Get length of the LEB128 stack offset | |
| 4094 | var counting_writer = std.io.countingWriter(std.io.null_writer); | |
| 4095 | leb128.writeILEB128(counting_writer.writer(), adjusted_stack_offset) catch unreachable; | |
| 4096 | ||
| 4097 | // DW.AT.location, DW.FORM.exprloc | |
| 4098 | // ULEB128 dwarf expression length | |
| 4099 | try leb128.writeULEB128(dbg_info.writer(), counting_writer.bytes_written + 1); | |
| 4100 | try dbg_info.append(DW.OP.breg11); | |
| 4101 | try leb128.writeILEB128(dbg_info.writer(), adjusted_stack_offset); | |
| 4037 | const mod = self.bin_file.options.module.?; | |
| 4038 | const fn_owner_decl = mod.declPtr(self.mod_fn.owner_decl); | |
| 4039 | const atom = switch (self.bin_file.tag) { | |
| 4040 | .elf => &fn_owner_decl.link.elf.dbg_info_atom, | |
| 4041 | .macho => &fn_owner_decl.link.macho.dbg_info_atom, | |
| 4042 | else => unreachable, | |
| 4043 | }; | |
| 4102 | 4044 | |
| 4103 | try dbg_info.ensureUnusedCapacity(5 + name_with_null.len); | |
| 4104 | try self.addDbgInfoTypeReloc(ty); // DW.AT.type, DW.FORM.ref4 | |
| 4105 | dbg_info.appendSliceAssumeCapacity(name_with_null); // DW.AT.name, DW.FORM.string | |
| 4106 | }, | |
| 4107 | .plan9 => {}, | |
| 4108 | .none => {}, | |
| 4109 | } | |
| 4045 | switch (self.debug_output) { | |
| 4046 | .dwarf => |dw| switch (mcv) { | |
| 4047 | .register => |reg| try dw.genArgDbgInfo(name, ty, atom, .{ | |
| 4048 | .register = reg.dwarfLocOp(), | |
| 4049 | }), | |
| 4050 | .stack_offset, | |
| 4051 | .stack_argument_offset, | |
| 4052 | => { | |
| 4053 | const adjusted_stack_offset = switch (mcv) { | |
| 4054 | .stack_offset => |offset| -@intCast(i32, offset), | |
| 4055 | .stack_argument_offset => |offset| @intCast(i32, self.saved_regs_stack_space + offset), | |
| 4056 | else => unreachable, | |
| 4057 | }; | |
| 4058 | try dw.genArgDbgInfo(name, ty, atom, .{ | |
| 4059 | .stack = .{ | |
| 4060 | .fp_register = DW.OP.breg11, | |
| 4061 | .offset = adjusted_stack_offset, | |
| 4062 | }, | |
| 4063 | }); | |
| 4064 | }, | |
| 4065 | else => unreachable, // not a possible argument | |
| 4110 | 4066 | }, |
| 4111 | else => unreachable, // not a possible argument | |
| 4067 | .plan9 => {}, | |
| 4068 | .none => {}, | |
| 4112 | 4069 | } |
| 4113 | 4070 | } |
| 4114 | 4071 |
src/arch/riscv64/CodeGen.zig+17-50| ... | ... | @@ -772,28 +772,6 @@ fn ensureProcessDeathCapacity(self: *Self, additional_count: usize) !void { |
| 772 | 772 | try table.ensureUnusedCapacity(self.gpa, additional_count); |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | /// Adds a Type to the .debug_info at the current position. The bytes will be populated later, | |
| 776 | /// after codegen for this symbol is done. | |
| 777 | fn addDbgInfoTypeReloc(self: *Self, ty: Type) !void { | |
| 778 | switch (self.debug_output) { | |
| 779 | .dwarf => |dw| { | |
| 780 | assert(ty.hasRuntimeBits()); | |
| 781 | const dbg_info = &dw.dbg_info; | |
| 782 | const index = dbg_info.items.len; | |
| 783 | try dbg_info.resize(index + 4); // DW.AT.type, DW.FORM.ref4 | |
| 784 | const mod = self.bin_file.options.module.?; | |
| 785 | const atom = switch (self.bin_file.tag) { | |
| 786 | .elf => &mod.declPtr(self.mod_fn.owner_decl).link.elf.dbg_info_atom, | |
| 787 | .macho => unreachable, | |
| 788 | else => unreachable, | |
| 789 | }; | |
| 790 | try dw.addTypeRelocGlobal(atom, ty, @intCast(u32, index)); | |
| 791 | }, | |
| 792 | .plan9 => {}, | |
| 793 | .none => {}, | |
| 794 | } | |
| 795 | } | |
| 796 | ||
| 797 | 775 | fn allocMem(self: *Self, inst: Air.Inst.Index, abi_size: u32, abi_align: u32) !u32 { |
| 798 | 776 | if (abi_align > self.stack_align) |
| 799 | 777 | self.stack_align = abi_align; |
| ... | ... | @@ -1627,36 +1605,25 @@ fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void { |
| 1627 | 1605 | fn genArgDbgInfo(self: *Self, inst: Air.Inst.Index, mcv: MCValue, arg_index: u32) !void { |
| 1628 | 1606 | const ty = self.air.instructions.items(.data)[inst].ty; |
| 1629 | 1607 | const name = self.mod_fn.getParamName(self.bin_file.options.module.?, arg_index); |
| 1630 | const name_with_null = name.ptr[0 .. name.len + 1]; | |
| 1631 | 1608 | |
| 1632 | switch (mcv) { | |
| 1633 | .register => |reg| { | |
| 1634 | switch (self.debug_output) { | |
| 1635 | .dwarf => |dw| { | |
| 1636 | const dbg_info = &dw.dbg_info; | |
| 1637 | try dbg_info.ensureUnusedCapacity(3); | |
| 1638 | dbg_info.appendAssumeCapacity(@enumToInt(link.File.Dwarf.AbbrevKind.parameter)); | |
| 1639 | dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc | |
| 1640 | 1, // ULEB128 dwarf expression length | |
| 1641 | reg.dwarfLocOp(), | |
| 1642 | }); | |
| 1643 | try dbg_info.ensureUnusedCapacity(5 + name_with_null.len); | |
| 1644 | try self.addDbgInfoTypeReloc(ty); // DW.AT.type, DW.FORM.ref4 | |
| 1645 | dbg_info.appendSliceAssumeCapacity(name_with_null); // DW.AT.name, DW.FORM.string | |
| 1646 | }, | |
| 1647 | .plan9 => {}, | |
| 1648 | .none => {}, | |
| 1649 | } | |
| 1650 | }, | |
| 1651 | .stack_offset => |offset| { | |
| 1652 | _ = offset; | |
| 1653 | switch (self.debug_output) { | |
| 1654 | .dwarf => {}, | |
| 1655 | .plan9 => {}, | |
| 1656 | .none => {}, | |
| 1657 | } | |
| 1609 | const mod = self.bin_file.options.module.?; | |
| 1610 | const fn_owner_decl = mod.declPtr(self.mod_fn.owner_decl); | |
| 1611 | const atom = switch (self.bin_file.tag) { | |
| 1612 | .elf => &fn_owner_decl.link.elf.dbg_info_atom, | |
| 1613 | .macho => &fn_owner_decl.link.macho.dbg_info_atom, | |
| 1614 | else => unreachable, | |
| 1615 | }; | |
| 1616 | ||
| 1617 | switch (self.debug_output) { | |
| 1618 | .dwarf => |dw| switch (mcv) { | |
| 1619 | .register => |reg| try dw.genArgDbgInfo(name, ty, atom, .{ | |
| 1620 | .register = reg.dwarfLocOp(), | |
| 1621 | }), | |
| 1622 | .stack_offset => {}, | |
| 1623 | else => {}, | |
| 1658 | 1624 | }, |
| 1659 | else => {}, | |
| 1625 | .plan9 => {}, | |
| 1626 | .none => {}, | |
| 1660 | 1627 | } |
| 1661 | 1628 | } |
| 1662 | 1629 |
src/arch/x86_64/CodeGen.zig+11-14| ... | ... | @@ -3827,21 +3827,18 @@ fn genArgDbgInfo(self: Self, ty: Type, name: [:0]const u8, mcv: MCValue) !void { |
| 3827 | 3827 | }; |
| 3828 | 3828 | |
| 3829 | 3829 | switch (self.debug_output) { |
| 3830 | .dwarf => |dw| { | |
| 3831 | switch (mcv) { | |
| 3832 | .register => |reg| try dw.genArgDbgInfo(name, ty, atom, .{ | |
| 3833 | .register = reg.dwarfLocOp(), | |
| 3834 | }), | |
| 3835 | ||
| 3836 | .stack_offset => |off| try dw.genArgDbgInfo(name, ty, atom, .{ | |
| 3837 | .stack = .{ | |
| 3838 | .fp_register = Register.rbp.dwarfLocOpDeref(), // TODO handle -fomit-frame-pointer | |
| 3839 | .offset = -off, | |
| 3840 | }, | |
| 3841 | }), | |
| 3830 | .dwarf => |dw| switch (mcv) { | |
| 3831 | .register => |reg| try dw.genArgDbgInfo(name, ty, atom, .{ | |
| 3832 | .register = reg.dwarfLocOp(), | |
| 3833 | }), | |
| 3834 | .stack_offset => |off| try dw.genArgDbgInfo(name, ty, atom, .{ | |
| 3835 | .stack = .{ | |
| 3836 | .fp_register = Register.rbp.dwarfLocOpDeref(), // TODO handle -fomit-frame-pointer | |
| 3837 | .offset = -off, | |
| 3838 | }, | |
| 3839 | }), | |
| 3842 | 3840 | |
| 3843 | else => unreachable, // not a valid function parameter | |
| 3844 | } | |
| 3841 | else => unreachable, // not a valid function parameter | |
| 3845 | 3842 | }, |
| 3846 | 3843 | .plan9 => {}, |
| 3847 | 3844 | .none => {}, |