| ... | @@ -3911,8 +3911,8 @@ fn airDbgVar(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -3911,8 +3911,8 @@ fn airDbgVar(self: *Self, inst: Air.Inst.Index) !void { |
| 3911 | | 3911 | |
| 3912 | const tag = self.air.instructions.items(.tag)[inst]; | 3912 | const tag = self.air.instructions.items(.tag)[inst]; |
| 3913 | switch (tag) { | 3913 | switch (tag) { |
| 3914 | .dbg_var_ptr => try self.genVarDbgInfo(ty.childType(), mcv, name), | 3914 | .dbg_var_ptr => try self.genVarDbgInfo(tag, ty.childType(), mcv, name), |
| 3915 | .dbg_var_val => try self.genVarDbgInfo(ty, mcv, name), | 3915 | .dbg_var_val => try self.genVarDbgInfo(tag, ty, mcv, name), |
| 3916 | else => unreachable, | 3916 | else => unreachable, |
| 3917 | } | 3917 | } |
| 3918 | | 3918 | |
| ... | @@ -3921,6 +3921,7 @@ fn airDbgVar(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -3921,6 +3921,7 @@ fn airDbgVar(self: *Self, inst: Air.Inst.Index) !void { |
| 3921 | | 3921 | |
| 3922 | fn genVarDbgInfo( | 3922 | fn genVarDbgInfo( |
| 3923 | self: *Self, | 3923 | self: *Self, |
| | 3924 | tag: Air.Inst.Tag, |
| 3924 | ty: Type, | 3925 | ty: Type, |
| 3925 | mcv: MCValue, | 3926 | mcv: MCValue, |
| 3926 | name: [:0]const u8, | 3927 | name: [:0]const u8, |
| ... | @@ -3952,9 +3953,14 @@ fn genVarDbgInfo( | ... | @@ -3952,9 +3953,14 @@ fn genVarDbgInfo( |
| 3952 | .memory => |addr| { | 3953 | .memory => |addr| { |
| 3953 | const endian = self.target.cpu.arch.endian(); | 3954 | const endian = self.target.cpu.arch.endian(); |
| 3954 | const ptr_width = @intCast(u8, @divExact(self.target.cpu.arch.ptrBitWidth(), 8)); | 3955 | const ptr_width = @intCast(u8, @divExact(self.target.cpu.arch.ptrBitWidth(), 8)); |
| | 3956 | const is_ptr = switch (tag) { |
| | 3957 | .dbg_var_ptr => true, |
| | 3958 | .dbg_var_val => false, |
| | 3959 | else => unreachable, |
| | 3960 | }; |
| 3955 | try dbg_info.ensureUnusedCapacity(2 + ptr_width); | 3961 | try dbg_info.ensureUnusedCapacity(2 + ptr_width); |
| 3956 | dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc | 3962 | dbg_info.appendSliceAssumeCapacity(&[2]u8{ // DW.AT.location, DW.FORM.exprloc |
| 3957 | 1 + ptr_width, | 3963 | 1 + ptr_width + @boolToInt(is_ptr), |
| 3958 | DW.OP.addr, // literal address | 3964 | DW.OP.addr, // literal address |
| 3959 | }); | 3965 | }); |
| 3960 | switch (ptr_width) { | 3966 | switch (ptr_width) { |
| ... | @@ -3966,6 +3972,10 @@ fn genVarDbgInfo( | ... | @@ -3966,6 +3972,10 @@ fn genVarDbgInfo( |
| 3966 | }, | 3972 | }, |
| 3967 | else => unreachable, | 3973 | else => unreachable, |
| 3968 | } | 3974 | } |
| | 3975 | if (is_ptr) { |
| | 3976 | // We need deref the address as we point to the value via GOT entry. |
| | 3977 | try dbg_info.append(DW.OP.deref); |
| | 3978 | } |
| 3969 | }, | 3979 | }, |
| 3970 | else => { | 3980 | else => { |
| 3971 | log.debug("TODO generate debug info for {}", .{mcv}); | 3981 | log.debug("TODO generate debug info for {}", .{mcv}); |