commit 10cb578e4e16bac44055f277cd06baaf99b159b6 (tree)
parent ce5a5c361b5b098c3b7d68f88136a9c91e7bec19
Author: Andrew Kelley <andrew@ziglang.org>
Date: Wed, 9 Oct 2024 14:09:18 -0700
Merge pull request #21640 from jacobly0/dwarf-progress
Dwarf: progress
Diffstat:
10 files changed, 508 insertions(+), 281 deletions(-)
diff --git a/ci/x86_64-linux-debug.sh b/ci/x86_64-linux-debug.sh
@@ -64,7 +64,7 @@ stage3-debug/bin/zig build \
stage3-debug/bin/zig build test docs \
--maxrss 21000000000 \
- -Dlldb=$HOME/deps/lldb-zig/Debug-4a44163df/bin/lldb \
+ -Dlldb=$HOME/deps/lldb-zig/Debug-6ece8bda1/bin/lldb \
-fqemu \
-fwasmtime \
-Dstatic-llvm \
diff --git a/ci/x86_64-linux-release.sh b/ci/x86_64-linux-release.sh
@@ -64,7 +64,7 @@ stage3-release/bin/zig build \
stage3-release/bin/zig build test docs \
--maxrss 21000000000 \
- -Dlldb=$HOME/deps/lldb-zig/Release-4a44163df/bin/lldb \
+ -Dlldb=$HOME/deps/lldb-zig/Release-6ece8bda1/bin/lldb \
-fqemu \
-fwasmtime \
-Dstatic-llvm \
diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig
@@ -36,6 +36,7 @@ const abi = @import("abi.zig");
const bits = @import("bits.zig");
const errUnionErrorOffset = codegen.errUnionErrorOffset;
const errUnionPayloadOffset = codegen.errUnionPayloadOffset;
+const encoder = @import("encoder.zig");
const Condition = bits.Condition;
const Immediate = bits.Immediate;
@@ -1188,6 +1189,74 @@ fn formatWipMir(
try writer.print(" | {}", .{lowered_inst});
first = false;
}
+ if (first) {
+ const ip = &data.self.pt.zcu.intern_pool;
+ const mir_inst = lower.mir.instructions.get(data.inst);
+ try writer.print(" | .{s}", .{@tagName(mir_inst.ops)});
+ switch (mir_inst.ops) {
+ else => unreachable,
+ .pseudo_dbg_prologue_end_none,
+ .pseudo_dbg_line_line_column,
+ .pseudo_dbg_epilogue_begin_none,
+ .pseudo_dbg_enter_block_none,
+ .pseudo_dbg_leave_block_none,
+ .pseudo_dbg_var_args_none,
+ .pseudo_dead_none,
+ => {},
+ .pseudo_dbg_enter_inline_func, .pseudo_dbg_leave_inline_func => try writer.print(" {}", .{
+ ip.getNav(ip.indexToKey(mir_inst.data.func).func.owner_nav).name.fmt(ip),
+ }),
+ .pseudo_dbg_local_a => try writer.print(" {}", .{mir_inst.data.a.air_inst}),
+ .pseudo_dbg_local_ai_s => try writer.print(" {}, {d}", .{
+ mir_inst.data.ai.air_inst,
+ @as(i32, @bitCast(mir_inst.data.ai.i)),
+ }),
+ .pseudo_dbg_local_ai_u => try writer.print(" {}, {d}", .{
+ mir_inst.data.ai.air_inst,
+ mir_inst.data.ai.i,
+ }),
+ .pseudo_dbg_local_ai_64 => try writer.print(" {}, {d}", .{
+ mir_inst.data.ai.air_inst,
+ lower.mir.extraData(Mir.Imm64, mir_inst.data.ai.i).data.decode(),
+ }),
+ .pseudo_dbg_local_as => {
+ const mem_op: Instruction.Operand = .{ .mem = .initSib(.qword, .{
+ .base = .{ .reloc = mir_inst.data.as.sym_index },
+ }) };
+ try writer.print(" {}, {}", .{ mir_inst.data.as.air_inst, mem_op.fmt(.m) });
+ },
+ .pseudo_dbg_local_aso => {
+ const sym_off = lower.mir.extraData(bits.SymbolOffset, mir_inst.data.ax.payload).data;
+ const mem_op: Instruction.Operand = .{ .mem = .initSib(.qword, .{
+ .base = .{ .reloc = sym_off.sym_index },
+ .disp = sym_off.off,
+ }) };
+ try writer.print(" {}, {}", .{ mir_inst.data.ax.air_inst, mem_op.fmt(.m) });
+ },
+ .pseudo_dbg_local_aro => {
+ const air_off = lower.mir.extraData(Mir.AirOffset, mir_inst.data.rx.payload).data;
+ const mem_op: Instruction.Operand = .{ .mem = .initSib(.qword, .{
+ .base = .{ .reg = mir_inst.data.rx.r1 },
+ .disp = air_off.off,
+ }) };
+ try writer.print(" {}, {}", .{ air_off.air_inst, mem_op.fmt(.m) });
+ },
+ .pseudo_dbg_local_af => {
+ const frame_addr = lower.mir.extraData(bits.FrameAddr, mir_inst.data.ax.payload).data;
+ const mem_op: Instruction.Operand = .{ .mem = .initSib(.qword, .{
+ .base = .{ .frame = frame_addr.index },
+ .disp = frame_addr.off,
+ }) };
+ try writer.print(" {}, {d}", .{ mir_inst.data.ax.air_inst, mem_op.fmt(.m) });
+ },
+ .pseudo_dbg_local_am => {
+ const mem_op: Instruction.Operand = .{
+ .mem = lower.mir.extraData(Mir.Memory, mir_inst.data.ax.payload).data.decode(),
+ };
+ try writer.print(" {}, {}", .{ mir_inst.data.ax.air_inst, mem_op.fmt(.m) });
+ },
+ }
+ }
}
fn fmtWipMir(self: *Self, inst: Mir.Inst.Index) std.fmt.Formatter(formatWipMir) {
return .{ .data = .{ .self = self, .inst = inst } };
@@ -2180,6 +2249,12 @@ fn checkInvariantsAfterAirInst(self: *Self, inst: Air.Inst.Index, old_air_bookke
}
}
+fn genBodyBlock(self: *Self, body: []const Air.Inst.Index) InnerError!void {
+ try self.asmPseudo(.pseudo_dbg_enter_block_none);
+ try self.genBody(body);
+ try self.asmPseudo(.pseudo_dbg_leave_block_none);
+}
+
fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
const pt = self.pt;
const zcu = pt.zcu;
@@ -13184,7 +13259,7 @@ fn genTry(
const state = try self.saveState();
for (liveness_cond_br.else_deaths) |death| try self.processDeath(death);
- try self.genBody(body);
+ try self.genBodyBlock(body);
try self.restoreState(state, &.{}, .{
.emit_instructions = false,
.update_tracking = true,
@@ -13293,7 +13368,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
const reloc = try self.genCondBrMir(cond_ty, cond);
for (liveness_cond_br.then_deaths) |death| try self.processDeath(death);
- try self.genBody(then_body);
+ try self.genBodyBlock(then_body);
try self.restoreState(state, &.{}, .{
.emit_instructions = false,
.update_tracking = true,
@@ -13304,7 +13379,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
self.performReloc(reloc);
for (liveness_cond_br.else_deaths) |death| try self.processDeath(death);
- try self.genBody(else_body);
+ try self.genBodyBlock(else_body);
try self.restoreState(state, &.{}, .{
.emit_instructions = false,
.update_tracking = true,
@@ -13665,14 +13740,16 @@ fn airLoop(self: *Self, inst: Air.Inst.Index) !void {
});
defer assert(self.loops.remove(inst));
- try self.genBody(body);
+ try self.genBodyBlock(body);
self.finishAirBookkeeping();
}
fn airBlock(self: *Self, inst: Air.Inst.Index) !void {
const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
const extra = self.air.extraData(Air.Block, ty_pl.payload);
+ try self.asmPseudo(.pseudo_dbg_enter_block_none);
try self.lowerBlock(inst, @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]));
+ try self.asmPseudo(.pseudo_dbg_leave_block_none);
}
fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) !void {
@@ -13684,7 +13761,6 @@ fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) !
try self.blocks.putNoClobber(self.gpa, inst, .{ .state = self.initRetroactiveState() });
const liveness = self.liveness.getBlock(inst);
- // TODO emit debug info lexical block
try self.genBody(body);
var block_data = self.blocks.fetchRemove(inst).?;
@@ -13796,7 +13872,7 @@ fn lowerSwitchBr(self: *Self, inst: Air.Inst.Index, switch_br: Air.UnwrappedSwit
// Relocate all success cases to the body we're about to generate.
for (relocs) |reloc| self.performReloc(reloc);
- try self.genBody(case.body);
+ try self.genBodyBlock(case.body);
try self.restoreState(state, &.{}, .{
.emit_instructions = false,
.update_tracking = true,
@@ -13814,7 +13890,7 @@ fn lowerSwitchBr(self: *Self, inst: Air.Inst.Index, switch_br: Air.UnwrappedSwit
const else_deaths = liveness.deaths.len - 1;
for (liveness.deaths[else_deaths]) |operand| try self.processDeath(operand);
- try self.genBody(else_body);
+ try self.genBodyBlock(else_body);
try self.restoreState(state, &.{}, .{
.emit_instructions = false,
.update_tracking = true,
diff --git a/src/arch/x86_64/Emit.zig b/src/arch/x86_64/Emit.zig
@@ -287,6 +287,30 @@ pub fn emitMir(emit: *Emit) Error!void {
.none => {},
}
},
+ .pseudo_dbg_enter_block_none => {
+ switch (emit.debug_output) {
+ .dwarf => |dw| {
+ log.debug("mirDbgEnterBlock (line={d}, col={d})", .{
+ emit.prev_di_line, emit.prev_di_column,
+ });
+ try dw.enterBlock(emit.code.items.len);
+ },
+ .plan9 => {},
+ .none => {},
+ }
+ },
+ .pseudo_dbg_leave_block_none => {
+ switch (emit.debug_output) {
+ .dwarf => |dw| {
+ log.debug("mirDbgLeaveBlock (line={d}, col={d})", .{
+ emit.prev_di_line, emit.prev_di_column,
+ });
+ try dw.leaveBlock(emit.code.items.len);
+ },
+ .plan9 => {},
+ .none => {},
+ }
+ },
.pseudo_dbg_enter_inline_func => {
switch (emit.debug_output) {
.dwarf => |dw| {
diff --git a/src/arch/x86_64/Lower.zig b/src/arch/x86_64/Lower.zig
@@ -312,6 +312,8 @@ pub fn lowerMir(lower: *Lower, index: Mir.Inst.Index) Error!struct {
.pseudo_dbg_prologue_end_none,
.pseudo_dbg_line_line_column,
.pseudo_dbg_epilogue_begin_none,
+ .pseudo_dbg_enter_block_none,
+ .pseudo_dbg_leave_block_none,
.pseudo_dbg_enter_inline_func,
.pseudo_dbg_leave_inline_func,
.pseudo_dbg_local_a,
diff --git a/src/arch/x86_64/Mir.zig b/src/arch/x86_64/Mir.zig
@@ -935,6 +935,10 @@ pub const Inst = struct {
pseudo_dbg_line_line_column,
/// Start of epilogue
pseudo_dbg_epilogue_begin_none,
+ /// Start of lexical block
+ pseudo_dbg_enter_block_none,
+ /// End of lexical block
+ pseudo_dbg_leave_block_none,
/// Start of inline function
pseudo_dbg_enter_inline_func,
/// End of inline function
diff --git a/src/arch/x86_64/encoder.zig b/src/arch/x86_64/encoder.zig
@@ -233,7 +233,7 @@ pub const Instruction = struct {
_ = unused_format_string;
_ = options;
_ = writer;
- @compileError("do not format Operand directly; use fmtPrint() instead");
+ @compileError("do not format Operand directly; use fmt() instead");
}
const FormatContext = struct {
@@ -241,7 +241,7 @@ pub const Instruction = struct {
enc_op: Encoding.Op,
};
- fn fmt(
+ fn fmtContext(
ctx: FormatContext,
comptime unused_format_string: []const u8,
options: std.fmt.FormatOptions,
@@ -309,7 +309,7 @@ pub const Instruction = struct {
}
}
- pub fn fmtPrint(op: Operand, enc_op: Encoding.Op) std.fmt.Formatter(fmt) {
+ pub fn fmt(op: Operand, enc_op: Encoding.Op) std.fmt.Formatter(fmtContext) {
return .{ .data = .{ .op = op, .enc_op = enc_op } };
}
};
@@ -373,7 +373,7 @@ pub const Instruction = struct {
if (op == .none) break;
if (i > 0) try writer.writeByte(',');
try writer.writeByte(' ');
- try writer.print("{}", .{op.fmtPrint(enc)});
+ try writer.print("{}", .{op.fmt(enc)});
}
}
diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig
@@ -1374,10 +1374,11 @@ pub const WipNav = struct {
any_children: bool,
func: InternPool.Index,
func_sym_index: u32,
- func_high_reloc: u32,
- inlined_funcs: std.ArrayListUnmanaged(struct {
+ func_high_pc: u32,
+ blocks: std.ArrayListUnmanaged(struct {
abbrev_code: u32,
- high_reloc: u32,
+ low_pc_off: u64,
+ high_pc: u32,
}),
cfi: struct {
loc: u32,
@@ -1391,7 +1392,7 @@ pub const WipNav = struct {
pub fn deinit(wip_nav: *WipNav) void {
const gpa = wip_nav.dwarf.gpa;
- if (wip_nav.func != .none) wip_nav.inlined_funcs.deinit(gpa);
+ if (wip_nav.func != .none) wip_nav.blocks.deinit(gpa);
wip_nav.debug_frame.deinit(gpa);
wip_nav.debug_info.deinit(gpa);
wip_nav.debug_line.deinit(gpa);
@@ -1486,49 +1487,72 @@ pub const WipNav = struct {
try dlw.writeByte(DW.LNS.set_epilogue_begin);
}
- pub fn enterInlineFunc(wip_nav: *WipNav, func: InternPool.Index, code_off: u64, line: u32, column: u32) UpdateError!void {
+ pub fn enterBlock(wip_nav: *WipNav, code_off: u64) UpdateError!void {
+ const dwarf = wip_nav.dwarf;
+ const diw = wip_nav.debug_info.writer(dwarf.gpa);
+ const block = try wip_nav.blocks.addOne(dwarf.gpa);
+
+ block.abbrev_code = @intCast(wip_nav.debug_info.items.len);
+ try wip_nav.abbrevCode(.block);
+ block.low_pc_off = code_off;
+ try wip_nav.infoAddrSym(wip_nav.func_sym_index, code_off);
+ block.high_pc = @intCast(wip_nav.debug_info.items.len);
+ try diw.writeInt(u32, 0, dwarf.endian);
+ wip_nav.any_children = false;
+ }
+
+ pub fn leaveBlock(wip_nav: *WipNav, code_off: u64) UpdateError!void {
+ const block_bytes = comptime uleb128Bytes(@intFromEnum(AbbrevCode.block));
+ const block = wip_nav.blocks.pop();
+ if (wip_nav.any_children)
+ try uleb128(wip_nav.debug_info.writer(wip_nav.dwarf.gpa), @intFromEnum(AbbrevCode.null))
+ else
+ std.leb.writeUnsignedFixed(
+ block_bytes,
+ wip_nav.debug_info.items[block.abbrev_code..][0..block_bytes],
+ try wip_nav.dwarf.refAbbrevCode(.empty_block),
+ );
+ std.mem.writeInt(u32, wip_nav.debug_info.items[block.high_pc..][0..4], @intCast(code_off - block.low_pc_off), wip_nav.dwarf.endian);
+ wip_nav.any_children = true;
+ }
+
+ pub fn enterInlineFunc(
+ wip_nav: *WipNav,
+ func: InternPool.Index,
+ code_off: u64,
+ line: u32,
+ column: u32,
+ ) UpdateError!void {
const dwarf = wip_nav.dwarf;
const zcu = wip_nav.pt.zcu;
const diw = wip_nav.debug_info.writer(dwarf.gpa);
- const inlined_func = try wip_nav.inlined_funcs.addOne(dwarf.gpa);
+ const block = try wip_nav.blocks.addOne(dwarf.gpa);
- inlined_func.abbrev_code = @intCast(wip_nav.debug_info.items.len);
+ block.abbrev_code = @intCast(wip_nav.debug_info.items.len);
try wip_nav.abbrevCode(.inlined_func);
try wip_nav.refNav(zcu.funcInfo(func).owner_nav);
try uleb128(diw, zcu.navSrcLine(zcu.funcInfo(wip_nav.func).owner_nav) + line + 1);
try uleb128(diw, column + 1);
- const external_relocs = &dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs;
- try external_relocs.ensureUnusedCapacity(dwarf.gpa, 2);
- external_relocs.appendAssumeCapacity(.{
- .source_off = @intCast(wip_nav.debug_info.items.len),
- .target_sym = wip_nav.func_sym_index,
- .target_off = code_off,
- });
- try diw.writeByteNTimes(0, @intFromEnum(dwarf.address_size));
- inlined_func.high_reloc = @intCast(external_relocs.items.len);
- external_relocs.appendAssumeCapacity(.{
- .source_off = @intCast(wip_nav.debug_info.items.len),
- .target_sym = wip_nav.func_sym_index,
- .target_off = undefined,
- });
- try diw.writeByteNTimes(0, @intFromEnum(dwarf.address_size));
+ block.low_pc_off = code_off;
+ try wip_nav.infoAddrSym(wip_nav.func_sym_index, code_off);
+ block.high_pc = @intCast(wip_nav.debug_info.items.len);
+ try diw.writeInt(u32, 0, dwarf.endian);
try wip_nav.setInlineFunc(func);
wip_nav.any_children = false;
}
pub fn leaveInlineFunc(wip_nav: *WipNav, func: InternPool.Index, code_off: u64) UpdateError!void {
const inlined_func_bytes = comptime uleb128Bytes(@intFromEnum(AbbrevCode.inlined_func));
- const inlined_func = wip_nav.inlined_funcs.pop();
- const external_relocs = &wip_nav.dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs;
- external_relocs.items[inlined_func.high_reloc].target_off = code_off;
+ const block = wip_nav.blocks.pop();
if (wip_nav.any_children)
try uleb128(wip_nav.debug_info.writer(wip_nav.dwarf.gpa), @intFromEnum(AbbrevCode.null))
else
std.leb.writeUnsignedFixed(
inlined_func_bytes,
- wip_nav.debug_info.items[inlined_func.abbrev_code..][0..inlined_func_bytes],
+ wip_nav.debug_info.items[block.abbrev_code..][0..inlined_func_bytes],
try wip_nav.dwarf.refAbbrevCode(.empty_inlined_func),
);
+ std.mem.writeInt(u32, wip_nav.debug_info.items[block.high_pc..][0..4], @intCast(code_off - block.low_pc_off), wip_nav.dwarf.endian);
try wip_nav.setInlineFunc(func);
wip_nav.any_children = true;
}
@@ -1664,17 +1688,18 @@ pub const WipNav = struct {
return ctx.wip_nav.dwarf.endian;
}
fn addrSym(ctx: @This(), sym_index: u32) UpdateError!void {
- try ctx.wip_nav.infoAddrSym(sym_index);
+ try ctx.wip_nav.infoAddrSym(sym_index, 0);
}
} = .{ .wip_nav = wip_nav };
try uleb128(adapter.writer(), counter.stream.bytes_written);
try loc.write(adapter);
}
- fn infoAddrSym(wip_nav: *WipNav, sym_index: u32) UpdateError!void {
+ fn infoAddrSym(wip_nav: *WipNav, sym_index: u32, sym_off: u64) UpdateError!void {
try wip_nav.infoExternalReloc(.{
.source_off = @intCast(wip_nav.debug_info.items.len),
.target_sym = sym_index,
+ .target_off = sym_off,
});
try wip_nav.debug_info.appendNTimes(wip_nav.dwarf.gpa, 0, @intFromEnum(wip_nav.dwarf.address_size));
}
@@ -1695,17 +1720,18 @@ pub const WipNav = struct {
return ctx.wip_nav.dwarf.endian;
}
fn addrSym(ctx: @This(), sym_index: u32) UpdateError!void {
- try ctx.wip_nav.frameAddrSym(sym_index);
+ try ctx.wip_nav.frameAddrSym(sym_index, 0);
}
} = .{ .wip_nav = wip_nav };
try uleb128(adapter.writer(), counter.stream.bytes_written);
try loc.write(adapter);
}
- fn frameAddrSym(wip_nav: *WipNav, sym_index: u32) UpdateError!void {
+ fn frameAddrSym(wip_nav: *WipNav, sym_index: u32, sym_off: u64) UpdateError!void {
try wip_nav.frameExternalReloc(.{
.source_off = @intCast(wip_nav.debug_frame.items.len),
.target_sym = sym_index,
+ .target_off = sym_off,
});
try wip_nav.debug_frame.appendNTimes(wip_nav.dwarf.gpa, 0, @intFromEnum(wip_nav.dwarf.address_size));
}
@@ -2150,8 +2176,8 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
.any_children = false,
.func = .none,
.func_sym_index = undefined,
- .func_high_reloc = undefined,
- .inlined_funcs = undefined,
+ .func_high_pc = undefined,
+ .blocks = undefined,
.cfi = undefined,
.debug_frame = .{},
.debug_info = .{},
@@ -2294,7 +2320,7 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
const func_type = ip.indexToKey(func.ty).func_type;
wip_nav.func = nav_val.toIntern();
wip_nav.func_sym_index = sym_index;
- wip_nav.inlined_funcs = .{};
+ wip_nav.blocks = .{};
if (dwarf.debug_frame.header.format != .none) wip_nav.cfi = .{
.loc = 0,
.cfa = dwarf.debug_frame.header.initial_instructions[0].def_cfa,
@@ -2319,7 +2345,7 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
.source_off = @intCast(wip_nav.debug_frame.items.len),
});
try dfw.writeByteNTimes(0, dwarf.sectionOffsetBytes());
- try wip_nav.frameAddrSym(sym_index);
+ try wip_nav.frameAddrSym(sym_index, 0);
try dfw.writeByteNTimes(undefined, @intFromEnum(dwarf.address_size));
},
.eh_frame => {
@@ -2346,20 +2372,9 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
try wip_nav.strp(nav.name.toSlice(ip));
try wip_nav.strp(nav.fqn.toSlice(ip));
try wip_nav.refType(Type.fromInterned(func_type.return_type));
- const external_relocs = &dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs;
- try external_relocs.ensureUnusedCapacity(dwarf.gpa, 2);
- external_relocs.appendAssumeCapacity(.{
- .source_off = @intCast(wip_nav.debug_info.items.len),
- .target_sym = sym_index,
- });
- try diw.writeByteNTimes(0, @intFromEnum(dwarf.address_size));
- wip_nav.func_high_reloc = @intCast(external_relocs.items.len);
- external_relocs.appendAssumeCapacity(.{
- .source_off = @intCast(wip_nav.debug_info.items.len),
- .target_sym = sym_index,
- .target_off = undefined,
- });
- try diw.writeByteNTimes(0, @intFromEnum(dwarf.address_size));
+ try wip_nav.infoAddrSym(sym_index, 0);
+ wip_nav.func_high_pc = @intCast(wip_nav.debug_info.items.len);
+ try diw.writeInt(u32, 0, dwarf.endian);
try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse
target_info.defaultFunctionAlignment(file.mod.resolved_target.result).toByteUnits().?);
try diw.writeByte(@intFromBool(false));
@@ -2466,8 +2481,7 @@ pub fn finishWipNav(
},
}
{
- const external_relocs = &dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs;
- external_relocs.items[wip_nav.func_high_reloc].target_off = sym.size;
+ std.mem.writeInt(u32, wip_nav.debug_info.items[wip_nav.func_high_pc..][0..4], @intCast(sym.size), dwarf.endian);
if (wip_nav.any_children) {
const diw = wip_nav.debug_info.writer(dwarf.gpa);
try uleb128(diw, @intFromEnum(AbbrevCode.null));
@@ -2562,8 +2576,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
.any_children = false,
.func = .none,
.func_sym_index = undefined,
- .func_high_reloc = undefined,
- .inlined_funcs = undefined,
+ .func_high_pc = undefined,
+ .blocks = undefined,
.cfi = undefined,
.debug_frame = .{},
.debug_info = .{},
@@ -3036,8 +3050,8 @@ fn updateType(
.any_children = false,
.func = .none,
.func_sym_index = undefined,
- .func_high_reloc = undefined,
- .inlined_funcs = undefined,
+ .func_high_pc = undefined,
+ .blocks = undefined,
.cfi = undefined,
.debug_frame = .{},
.debug_info = .{},
@@ -3480,8 +3494,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
.any_children = false,
.func = .none,
.func_sym_index = undefined,
- .func_high_reloc = undefined,
- .inlined_funcs = undefined,
+ .func_high_pc = undefined,
+ .blocks = undefined,
.cfi = undefined,
.debug_frame = .{},
.debug_info = .{},
@@ -3553,8 +3567,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
.any_children = false,
.func = .none,
.func_sym_index = undefined,
- .func_high_reloc = undefined,
- .inlined_funcs = undefined,
+ .func_high_pc = undefined,
+ .blocks = undefined,
.cfi = undefined,
.debug_frame = .{},
.debug_info = .{},
@@ -3756,8 +3770,8 @@ pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void {
.any_children = false,
.func = .none,
.func_sym_index = undefined,
- .func_high_reloc = undefined,
- .inlined_funcs = undefined,
+ .func_high_pc = undefined,
+ .blocks = undefined,
.cfi = undefined,
.debug_frame = .{},
.debug_info = .{},
@@ -4212,6 +4226,8 @@ const AbbrevCode = enum {
empty_packed_struct_type,
union_type,
empty_union_type,
+ empty_block,
+ block,
empty_inlined_func,
inlined_func,
local_arg,
@@ -4319,7 +4335,7 @@ const AbbrevCode = enum {
.{ .linkage_name, .strp },
.{ .type, .ref_addr },
.{ .low_pc, .addr },
- .{ .high_pc, .addr },
+ .{ .high_pc, .data4 },
.{ .alignment, .udata },
.{ .external, .flag },
.{ .noreturn, .flag },
@@ -4331,7 +4347,7 @@ const AbbrevCode = enum {
.{ .linkage_name, .strp },
.{ .type, .ref_addr },
.{ .low_pc, .addr },
- .{ .high_pc, .addr },
+ .{ .high_pc, .data4 },
.{ .alignment, .udata },
.{ .external, .flag },
.{ .noreturn, .flag },
@@ -4672,6 +4688,21 @@ const AbbrevCode = enum {
.{ .alignment, .udata },
},
},
+ .empty_block = .{
+ .tag = .lexical_block,
+ .attrs = &.{
+ .{ .low_pc, .addr },
+ .{ .high_pc, .data4 },
+ },
+ },
+ .block = .{
+ .tag = .lexical_block,
+ .children = true,
+ .attrs = &.{
+ .{ .low_pc, .addr },
+ .{ .high_pc, .data4 },
+ },
+ },
.empty_inlined_func = .{
.tag = .inlined_subroutine,
.attrs = &.{
@@ -4679,7 +4710,7 @@ const AbbrevCode = enum {
.{ .call_line, .udata },
.{ .call_column, .udata },
.{ .low_pc, .addr },
- .{ .high_pc, .addr },
+ .{ .high_pc, .data4 },
},
},
.inlined_func = .{
@@ -4690,7 +4721,7 @@ const AbbrevCode = enum {
.{ .call_line, .udata },
.{ .call_column, .udata },
.{ .low_pc, .addr },
- .{ .high_pc, .addr },
+ .{ .high_pc, .data4 },
},
},
.local_arg = .{
diff --git a/test/src/Debugger.zig b/test/src/Debugger.zig
@@ -113,70 +113,70 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
&.{
\\(lldb) frame variable --show-types -- basic
\\(root.basic.Basic) basic = {
- \\ (void) void = {}
- \\ (bool) bool_false = false
- \\ (bool) bool_true = true
- \\ (u0) u0_0 = 0
- \\ (u1) u1_0 = 0
- \\ (u1) u1_1 = 1
- \\ (u2) u2_0 = 0
- \\ (u2) u2_3 = 3
- \\ (u3) u3_0 = 0
- \\ (u3) u3_7 = 7
- \\ (u4) u4_0 = 0
- \\ (u4) u4_15 = 15
- \\ (u5) u5_0 = 0
- \\ (u5) u5_31 = 31
- \\ (u6) u6_0 = 0
- \\ (u6) u6_63 = 63
- \\ (u7) u7_0 = 0
- \\ (u7) u7_127 = 127
- \\ (u8) u8_0 = 0
- \\ (u8) u8_255 = 255
- \\ (u16) u16_0 = 0
- \\ (u16) u16_65535 = 65535
- \\ (u24) u24_0 = 0
- \\ (u24) u24_16777215 = 16777215
- \\ (u32) u32_0 = 0
- \\ (u32) u32_4294967295 = 4294967295
- \\ (i0) i0_0 = 0
- \\ (i1) i1_-1 = -1
- \\ (i1) i1_0 = 0
- \\ (i2) i2_-2 = -2
- \\ (i2) i2_0 = 0
- \\ (i2) i2_1 = 1
- \\ (i3) i3_-4 = -4
- \\ (i3) i3_0 = 0
- \\ (i3) i3_3 = 3
- \\ (i4) i4_-8 = -8
- \\ (i4) i4_0 = 0
- \\ (i4) i4_7 = 7
- \\ (i5) i5_-16 = -16
- \\ (i5) i5_0 = 0
- \\ (i5) i5_15 = 15
- \\ (i6) i6_-32 = -32
- \\ (i6) i6_0 = 0
- \\ (i6) i6_31 = 31
- \\ (i7) i7_-64 = -64
- \\ (i7) i7_0 = 0
- \\ (i7) i7_63 = 63
- \\ (i8) i8_-128 = -128
- \\ (i8) i8_0 = 0
- \\ (i8) i8_127 = 127
- \\ (i16) i16_-32768 = -32768
- \\ (i16) i16_0 = 0
- \\ (i16) i16_32767 = 32767
- \\ (i24) i24_-8388608 = -8388608
- \\ (i24) i24_0 = 0
- \\ (i24) i24_8388607 = 8388607
- \\ (i32) i32_-2147483648 = -2147483648
- \\ (i32) i32_0 = 0
- \\ (i32) i32_2147483647 = 2147483647
- \\ (f16) f16_42.625 = 42.625
- \\ (f32) f32_-2730.65625 = -2730.65625
- \\ (f64) f64_357913941.33203125 = 357913941.33203125
- \\ (f80) f80_-91625968981.3330078125 = -91625968981.3330078125
- \\ (f128) f128_384307168202282325.333332061767578125 = 384307168202282325.333332061767578125
+ \\ (void) .void = {}
+ \\ (bool) .bool_false = false
+ \\ (bool) .bool_true = true
+ \\ (u0) .u0_0 = 0
+ \\ (u1) .u1_0 = 0
+ \\ (u1) .u1_1 = 1
+ \\ (u2) .u2_0 = 0
+ \\ (u2) .u2_3 = 3
+ \\ (u3) .u3_0 = 0
+ \\ (u3) .u3_7 = 7
+ \\ (u4) .u4_0 = 0
+ \\ (u4) .u4_15 = 15
+ \\ (u5) .u5_0 = 0
+ \\ (u5) .u5_31 = 31
+ \\ (u6) .u6_0 = 0
+ \\ (u6) .u6_63 = 63
+ \\ (u7) .u7_0 = 0
+ \\ (u7) .u7_127 = 127
+ \\ (u8) .u8_0 = 0
+ \\ (u8) .u8_255 = 255
+ \\ (u16) .u16_0 = 0
+ \\ (u16) .u16_65535 = 65535
+ \\ (u24) .u24_0 = 0
+ \\ (u24) .u24_16777215 = 16777215
+ \\ (u32) .u32_0 = 0
+ \\ (u32) .u32_4294967295 = 4294967295
+ \\ (i0) .i0_0 = 0
+ \\ (i1) .@"i1_-1" = -1
+ \\ (i1) .i1_0 = 0
+ \\ (i2) .@"i2_-2" = -2
+ \\ (i2) .i2_0 = 0
+ \\ (i2) .i2_1 = 1
+ \\ (i3) .@"i3_-4" = -4
+ \\ (i3) .i3_0 = 0
+ \\ (i3) .i3_3 = 3
+ \\ (i4) .@"i4_-8" = -8
+ \\ (i4) .i4_0 = 0
+ \\ (i4) .i4_7 = 7
+ \\ (i5) .@"i5_-16" = -16
+ \\ (i5) .i5_0 = 0
+ \\ (i5) .i5_15 = 15
+ \\ (i6) .@"i6_-32" = -32
+ \\ (i6) .i6_0 = 0
+ \\ (i6) .i6_31 = 31
+ \\ (i7) .@"i7_-64" = -64
+ \\ (i7) .i7_0 = 0
+ \\ (i7) .i7_63 = 63
+ \\ (i8) .@"i8_-128" = -128
+ \\ (i8) .i8_0 = 0
+ \\ (i8) .i8_127 = 127
+ \\ (i16) .@"i16_-32768" = -32768
+ \\ (i16) .i16_0 = 0
+ \\ (i16) .i16_32767 = 32767
+ \\ (i24) .@"i24_-8388608" = -8388608
+ \\ (i24) .i24_0 = 0
+ \\ (i24) .i24_8388607 = 8388607
+ \\ (i32) .@"i32_-2147483648" = -2147483648
+ \\ (i32) .i32_0 = 0
+ \\ (i32) .i32_2147483647 = 2147483647
+ \\ (f16) .@"f16_42.625" = 42.625
+ \\ (f32) .@"f32_-2730.65625" = -2730.65625
+ \\ (f64) .@"f64_357913941.33203125" = 357913941.33203125
+ \\ (f80) .@"f80_-91625968981.3330078125" = -91625968981.3330078125
+ \\ (f128) .@"f128_384307168202282325.333332061767578125" = 384307168202282325.333332061767578125
\\}
\\(lldb) breakpoint delete --force 1
\\1 breakpoints deleted; 0 breakpoint locations disabled.
@@ -249,57 +249,57 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
&.{
\\(lldb) frame variable --show-types -- pointers
\\(root.pointers.Pointers) pointers = {
- \\ (*u32) single = 0x0000000000001010
- \\ (*const u32) single_const = 0x0000000000001014
- \\ (*volatile u32) single_volatile = 0x0000000000001018
- \\ (*const volatile u32) single_const_volatile = 0x000000000000101c
- \\ (*allowzero u32) single_allowzero = 0x0000000000001020
- \\ (*allowzero const u32) single_allowzero_const = 0x0000000000001024
- \\ (*allowzero volatile u32) single_allowzero_volatile = 0x0000000000001028
- \\ (*allowzero const volatile u32) single_allowzero_const_volatile = 0x000000000000102c
- \\ ([*]u32) many = 0x0000000000002010
- \\ ([*]const u32) many_const = 0x0000000000002014
- \\ ([*]volatile u32) many_volatile = 0x0000000000002018
- \\ ([*]const volatile u32) many_const_volatile = 0x000000000000201c
- \\ ([*]allowzero u32) many_allowzero = 0x0000000000002020
- \\ ([*]allowzero const u32) many_allowzero_const = 0x0000000000002024
- \\ ([*]allowzero volatile u32) many_allowzero_volatile = 0x0000000000002028
- \\ ([*]allowzero const volatile u32) many_allowzero_const_volatile = 0x000000000000202c
- \\ ([]u32) slice = len=1 {
+ \\ (*u32) .single = 0x0000000000001010
+ \\ (*const u32) .single_const = 0x0000000000001014
+ \\ (*volatile u32) .single_volatile = 0x0000000000001018
+ \\ (*const volatile u32) .single_const_volatile = 0x000000000000101c
+ \\ (*allowzero u32) .single_allowzero = 0x0000000000001020
+ \\ (*allowzero const u32) .single_allowzero_const = 0x0000000000001024
+ \\ (*allowzero volatile u32) .single_allowzero_volatile = 0x0000000000001028
+ \\ (*allowzero const volatile u32) .single_allowzero_const_volatile = 0x000000000000102c
+ \\ ([*]u32) .many = 0x0000000000002010
+ \\ ([*]const u32) .many_const = 0x0000000000002014
+ \\ ([*]volatile u32) .many_volatile = 0x0000000000002018
+ \\ ([*]const volatile u32) .many_const_volatile = 0x000000000000201c
+ \\ ([*]allowzero u32) .many_allowzero = 0x0000000000002020
+ \\ ([*]allowzero const u32) .many_allowzero_const = 0x0000000000002024
+ \\ ([*]allowzero volatile u32) .many_allowzero_volatile = 0x0000000000002028
+ \\ ([*]allowzero const volatile u32) .many_allowzero_const_volatile = 0x000000000000202c
+ \\ ([]u32) .slice = len=1 {
\\ (u32) [0] = 3010
\\ }
- \\ ([]const u32) slice_const = len=2 {
+ \\ ([]const u32) .slice_const = len=2 {
\\ (u32) [0] = 3010
\\ (u32) [1] = 3014
\\ }
- \\ ([]volatile u32) slice_volatile = len=3 {
+ \\ ([]volatile u32) .slice_volatile = len=3 {
\\ (u32) [0] = 3010
\\ (u32) [1] = 3014
\\ (u32) [2] = 3018
\\ }
- \\ ([]const volatile u32) slice_const_volatile = len=4 {
+ \\ ([]const volatile u32) .slice_const_volatile = len=4 {
\\ (u32) [0] = 3010
\\ (u32) [1] = 3014
\\ (u32) [2] = 3018
\\ (u32) [3] = 3022
\\ }
- \\ ([]allowzero u32) slice_allowzero = len=0 {}
- \\ ([]allowzero const u32) slice_allowzero_const = len=1 {
+ \\ ([]allowzero u32) .slice_allowzero = len=0 {}
+ \\ ([]allowzero const u32) .slice_allowzero_const = len=1 {
\\ (u32) [0] = 3026
\\ }
- \\ ([]allowzero volatile u32) slice_allowzero_volatile = len=2 {
+ \\ ([]allowzero volatile u32) .slice_allowzero_volatile = len=2 {
\\ (u32) [0] = 3026
\\ (u32) [1] = 3030
\\ }
- \\ ([]allowzero const volatile u32) slice_allowzero_const_volatile = len=3 {
+ \\ ([]allowzero const volatile u32) .slice_allowzero_const_volatile = len=3 {
\\ (u32) [0] = 3026
\\ (u32) [1] = 3030
\\ (u32) [2] = 3034
\\ }
- \\ ([*c]u32) c = 0x0000000000004010
- \\ ([*c]const u32) c_const = 0x0000000000004014
- \\ ([*c]volatile u32) c_volatile = 0x0000000000004018
- \\ ([*c]const volatile u32) c_const_volatile = 0x000000000000401c
+ \\ ([*c]u32) .c = 0x0000000000004010
+ \\ ([*c]const u32) .c_const = 0x0000000000004014
+ \\ ([*c]volatile u32) .c_volatile = 0x0000000000004018
+ \\ ([*c]const volatile u32) .c_const_volatile = 0x000000000000401c
\\}
\\(lldb) breakpoint delete --force 1
\\1 breakpoints deleted; 0 breakpoint locations disabled.
@@ -362,10 +362,10 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
\\}
\\(lldb) frame variable --show-types --format c-string -- strings
\\(root.strings.Strings) strings = {
- \\ ([*c]const u8) c_ptr = "c_ptr\x07\x08\t"
- \\ ([*:0]const u8) many_ptr = "many_ptr\n\x0b\x0c"
- \\ (*const [12:0]u8) ptr_array = "ptr_array\x00\r\x1b"
- \\ ([:0]const u8) slice = "slice\"\'\\\x00" len=9 {
+ \\ ([*c]const u8) .c_ptr = "c_ptr\x07\x08\t"
+ \\ ([*:0]const u8) .many_ptr = "many_ptr\n\x0b\x0c"
+ \\ (*const [12:0]u8) .ptr_array = "ptr_array\x00\r\x1b"
+ \\ ([:0]const u8) .slice = "slice\"\'\\\x00" len=9 {
\\ (u8) [0] = "s"
\\ (u8) [1] = "l"
\\ (u8) [2] = "i"
@@ -434,10 +434,10 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
\\}
\\(lldb) frame variable --show-types -- enums
\\(root.enums.Enums) enums = {
- \\ (root.enums.Enums.Zero) zero = @enumFromInt(13)
- \\ (root.enums.Enums.One) one = .first
- \\ (root.enums.Enums.Two) two = @enumFromInt(-1234)
- \\ (root.enums.Enums.Three) three = .second
+ \\ (root.enums.Enums.Zero) .zero = @enumFromInt(13)
+ \\ (root.enums.Enums.One) .one = .first
+ \\ (root.enums.Enums.Two) .two = @enumFromInt(-1234)
+ \\ (root.enums.Enums.Three) .three = .second
\\}
\\(lldb) breakpoint delete --force 1
\\1 breakpoints deleted; 0 breakpoint locations disabled.
@@ -498,15 +498,15 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
\\}
\\(lldb) frame variable --show-types -- errors
\\(root.errors.Errors) errors = {
- \\ (error{One}) one = error.One
- \\ (error{One,Two}) two = error.Two
- \\ (error{One,Two,Three}) three = error.Three
- \\ (anyerror) any = error.Any
- \\ (anyerror!void) any_void = {
- \\ (anyerror) error = error.NotVoid
+ \\ (error{One}) .one = error.One
+ \\ (error{One,Two}) .two = error.Two
+ \\ (error{One,Two,Three}) .three = error.Three
+ \\ (anyerror) .any = error.Any
+ \\ (anyerror!void) .any_void = {
+ \\ (anyerror) .error = error.NotVoid
\\ }
- \\ (error{One}!u32) any_u32 = {
- \\ (u32) value = 42
+ \\ (error{One}!u32) .any_u32 = {
+ \\ (u32) .value = 42
\\ }
\\}
\\(lldb) breakpoint delete --force 1
@@ -630,17 +630,17 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
\\}
\\(lldb) frame variable --show-types -- unions
\\(root.unions.Unions) unions = {
- \\ (root.unions.Unions.Untagged) untagged = {
- \\ (u32) u32 = 3217031168
- \\ (i32) i32 = -1077936128
- \\ (f32) f32 = -1.5
+ \\ (root.unions.Unions.Untagged) .untagged = {
+ \\ (u32) .u32 = 3217031168
+ \\ (i32) .i32 = -1077936128
+ \\ (f32) .f32 = -1.5
\\ }
- \\ (root.unions.Unions.SafetyTagged) safety_tagged = {
- \\ (root.unions.Unions.Enum) en = .second
+ \\ (root.unions.Unions.SafetyTagged) .safety_tagged = {
+ \\ (root.unions.Unions.Enum) .en = .second
\\ }
- \\ (root.unions.Unions.Tagged) tagged = {
- \\ (error{Error}!root.unions.Unions.Enum) eu = {
- \\ (error{Error}) error = error.Error
+ \\ (root.unions.Unions.Tagged) .tagged = {
+ \\ (error{Error}!root.unions.Unions.Enum) .eu = {
+ \\ (error{Error}) .error = error.Error
\\ }
\\ }
\\}
@@ -722,6 +722,93 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
},
);
db.addLldbTest(
+ "if_blocks",
+ target,
+ &.{
+ .{
+ .path = "if_blocks.zig",
+ .source =
+ \\pub fn main() void {
+ \\ for (0..2) |i| {
+ \\ if (i == 0) {
+ \\ var x: u32 = 123;
+ \\ _ = &x;
+ \\ } else {
+ \\ var x: f32 = 4.5;
+ \\ _ = &x;
+ \\ }
+ \\ }
+ \\}
+ \\
+ ,
+ },
+ },
+ \\breakpoint set --file if_blocks.zig --source-pattern-regexp '_ = &x;'
+ \\process launch
+ \\frame variable
+ \\process continue
+ \\frame variable
+ \\breakpoint delete --force 1
+ ,
+ &.{
+ \\(lldb) frame variable
+ \\(usize) i = 0
+ \\(u32) x = 123
+ \\(lldb) process continue
+ ,
+ \\(lldb) frame variable
+ \\(usize) i = 1
+ \\(f32) x = 4.5
+ \\(lldb) breakpoint delete --force 1
+ \\1 breakpoints deleted; 0 breakpoint locations disabled.
+ },
+ );
+ db.addLldbTest(
+ "switch_blocks",
+ target,
+ &.{
+ .{
+ .path = "switch_blocks.zig",
+ .source =
+ \\pub fn main() void {
+ \\ for (0..2) |i| {
+ \\ switch (i) {
+ \\ 0 => {
+ \\ var x: u32 = 123;
+ \\ _ = &x;
+ \\ },
+ \\ else => {
+ \\ var x: f32 = 4.5;
+ \\ _ = &x;
+ \\ },
+ \\ }
+ \\ }
+ \\}
+ \\
+ ,
+ },
+ },
+ \\breakpoint set --file switch_blocks.zig --source-pattern-regexp '_ = &x;'
+ \\process launch
+ \\frame variable
+ \\process continue
+ \\frame variable
+ \\breakpoint delete --force 1
+ ,
+ &.{
+ \\(lldb) frame variable
+ \\(usize) i = 0
+ \\(u32) x = 123
+ \\(lldb) process continue
+ ,
+ \\(lldb) frame variable
+ \\(usize) i = 1
+ \\(f32) x = 4.5
+ \\(lldb) breakpoint delete --force 1
+ \\1 breakpoints deleted; 0 breakpoint locations disabled.
+ },
+ );
+ db.addLldbTest(
"inline_call",
target,
&.{
@@ -1370,24 +1457,24 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
\\(lldb) frame variable --show-types -- map.unmanaged
\\(std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63)) map.unmanaged = len=5 capacity=16 {
\\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [0] = {
- \\ (u32) key = 0
- \\ (u32) value = 1
+ \\ (u32) .key = 0
+ \\ (u32) .value = 1
\\ }
\\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [1] = {
- \\ (u32) key = 2
- \\ (u32) value = 3
+ \\ (u32) .key = 2
+ \\ (u32) .value = 3
\\ }
\\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [2] = {
- \\ (u32) key = 4
- \\ (u32) value = 5
+ \\ (u32) .key = 4
+ \\ (u32) .value = 5
\\ }
\\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [3] = {
- \\ (u32) key = 6
- \\ (u32) value = 7
+ \\ (u32) .key = 6
+ \\ (u32) .value = 7
\\ }
\\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [4] = {
- \\ (u32) key = 8
- \\ (u32) value = 9
+ \\ (u32) .key = 8
+ \\ (u32) .value = 9
\\ }
\\}
\\(lldb) breakpoint delete --force 1
@@ -1447,37 +1534,37 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
\\(lldb) frame variable --show-types -- list0 list0.len list0.capacity list0[0] list0[1] list0[2] list0.0 list0.1 list0.2
\\(std.multi_array_list.MultiArrayList(main.Elem0)) list0 = len=3 capacity=8 {
\\ (root.main.Elem0) [0] = {
- \\ (u32) 0 = 1
- \\ (u8) 1 = 2
- \\ (u16) 2 = 3
+ \\ (u32) .@"0" = 1
+ \\ (u8) .@"1" = 2
+ \\ (u16) .@"2" = 3
\\ }
\\ (root.main.Elem0) [1] = {
- \\ (u32) 0 = 4
- \\ (u8) 1 = 5
- \\ (u16) 2 = 6
+ \\ (u32) .@"0" = 4
+ \\ (u8) .@"1" = 5
+ \\ (u16) .@"2" = 6
\\ }
\\ (root.main.Elem0) [2] = {
- \\ (u32) 0 = 7
- \\ (u8) 1 = 8
- \\ (u16) 2 = 9
+ \\ (u32) .@"0" = 7
+ \\ (u8) .@"1" = 8
+ \\ (u16) .@"2" = 9
\\ }
\\}
\\(usize) list0.len = 3
\\(usize) list0.capacity = 8
\\(root.main.Elem0) list0[0] = {
- \\ (u32) 0 = 1
- \\ (u8) 1 = 2
- \\ (u16) 2 = 3
+ \\ (u32) .@"0" = 1
+ \\ (u8) .@"1" = 2
+ \\ (u16) .@"2" = 3
\\}
\\(root.main.Elem0) list0[1] = {
- \\ (u32) 0 = 4
- \\ (u8) 1 = 5
- \\ (u16) 2 = 6
+ \\ (u32) .@"0" = 4
+ \\ (u8) .@"1" = 5
+ \\ (u16) .@"2" = 6
\\}
\\(root.main.Elem0) list0[2] = {
- \\ (u32) 0 = 7
- \\ (u8) 1 = 8
- \\ (u16) 2 = 9
+ \\ (u32) .@"0" = 7
+ \\ (u8) .@"1" = 8
+ \\ (u16) .@"2" = 9
\\}
\\([3]u32) list0.0 = {
\\ (u32) [0] = 1
@@ -1497,37 +1584,37 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
\\(lldb) frame variable --show-types -- slice0 slice0.len slice0.capacity slice0[0] slice0[1] slice0[2] slice0.0 slice0.1 slice0.2
\\(std.multi_array_list.MultiArrayList(main.Elem0).Slice) slice0 = len=3 capacity=8 {
\\ (root.main.Elem0) [0] = {
- \\ (u32) 0 = 1
- \\ (u8) 1 = 2
- \\ (u16) 2 = 3
+ \\ (u32) .@"0" = 1
+ \\ (u8) .@"1" = 2
+ \\ (u16) .@"2" = 3
\\ }
\\ (root.main.Elem0) [1] = {
- \\ (u32) 0 = 4
- \\ (u8) 1 = 5
- \\ (u16) 2 = 6
+ \\ (u32) .@"0" = 4
+ \\ (u8) .@"1" = 5
+ \\ (u16) .@"2" = 6
\\ }
\\ (root.main.Elem0) [2] = {
- \\ (u32) 0 = 7
- \\ (u8) 1 = 8
- \\ (u16) 2 = 9
+ \\ (u32) .@"0" = 7
+ \\ (u8) .@"1" = 8
+ \\ (u16) .@"2" = 9
\\ }
\\}
\\(usize) slice0.len = 3
\\(usize) slice0.capacity = 8
\\(root.main.Elem0) slice0[0] = {
- \\ (u32) 0 = 1
- \\ (u8) 1 = 2
- \\ (u16) 2 = 3
+ \\ (u32) .@"0" = 1
+ \\ (u8) .@"1" = 2
+ \\ (u16) .@"2" = 3
\\}
\\(root.main.Elem0) slice0[1] = {
- \\ (u32) 0 = 4
- \\ (u8) 1 = 5
- \\ (u16) 2 = 6
+ \\ (u32) .@"0" = 4
+ \\ (u8) .@"1" = 5
+ \\ (u16) .@"2" = 6
\\}
\\(root.main.Elem0) slice0[2] = {
- \\ (u32) 0 = 7
- \\ (u8) 1 = 8
- \\ (u16) 2 = 9
+ \\ (u32) .@"0" = 7
+ \\ (u8) .@"1" = 8
+ \\ (u16) .@"2" = 9
\\}
\\([3]u32) slice0.0 = {
\\ (u32) [0] = 1
@@ -1547,37 +1634,37 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
\\(lldb) frame variable --show-types -- list1 list1.len list1.capacity list1[0] list1[1] list1[2] list1.a list1.b list1.c
\\(std.multi_array_list.MultiArrayList(main.Elem1)) list1 = len=3 capacity=12 {
\\ (root.main.Elem1) [0] = {
- \\ (u32) a = 1
- \\ (u8) b = 2
- \\ (u16) c = 3
+ \\ (u32) .a = 1
+ \\ (u8) .b = 2
+ \\ (u16) .c = 3
\\ }
\\ (root.main.Elem1) [1] = {
- \\ (u32) a = 4
- \\ (u8) b = 5
- \\ (u16) c = 6
+ \\ (u32) .a = 4
+ \\ (u8) .b = 5
+ \\ (u16) .c = 6
\\ }
\\ (root.main.Elem1) [2] = {
- \\ (u32) a = 7
- \\ (u8) b = 8
- \\ (u16) c = 9
+ \\ (u32) .a = 7
+ \\ (u8) .b = 8
+ \\ (u16) .c = 9
\\ }
\\}
\\(usize) list1.len = 3
\\(usize) list1.capacity = 12
\\(root.main.Elem1) list1[0] = {
- \\ (u32) a = 1
- \\ (u8) b = 2
- \\ (u16) c = 3
+ \\ (u32) .a = 1
+ \\ (u8) .b = 2
+ \\ (u16) .c = 3
\\}
\\(root.main.Elem1) list1[1] = {
- \\ (u32) a = 4
- \\ (u8) b = 5
- \\ (u16) c = 6
+ \\ (u32) .a = 4
+ \\ (u8) .b = 5
+ \\ (u16) .c = 6
\\}
\\(root.main.Elem1) list1[2] = {
- \\ (u32) a = 7
- \\ (u8) b = 8
- \\ (u16) c = 9
+ \\ (u32) .a = 7
+ \\ (u8) .b = 8
+ \\ (u16) .c = 9
\\}
\\([3]u32) list1.a = {
\\ (u32) [0] = 1
@@ -1597,37 +1684,37 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
\\(lldb) frame variable --show-types -- slice1 slice1.len slice1.capacity slice1[0] slice1[1] slice1[2] slice1.a slice1.b slice1.c
\\(std.multi_array_list.MultiArrayList(main.Elem1).Slice) slice1 = len=3 capacity=12 {
\\ (root.main.Elem1) [0] = {
- \\ (u32) a = 1
- \\ (u8) b = 2
- \\ (u16) c = 3
+ \\ (u32) .a = 1
+ \\ (u8) .b = 2
+ \\ (u16) .c = 3
\\ }
\\ (root.main.Elem1) [1] = {
- \\ (u32) a = 4
- \\ (u8) b = 5
- \\ (u16) c = 6
+ \\ (u32) .a = 4
+ \\ (u8) .b = 5
+ \\ (u16) .c = 6
\\ }
\\ (root.main.Elem1) [2] = {
- \\ (u32) a = 7
- \\ (u8) b = 8
- \\ (u16) c = 9
+ \\ (u32) .a = 7
+ \\ (u8) .b = 8
+ \\ (u16) .c = 9
\\ }
\\}
\\(usize) slice1.len = 3
\\(usize) slice1.capacity = 12
\\(root.main.Elem1) slice1[0] = {
- \\ (u32) a = 1
- \\ (u8) b = 2
- \\ (u16) c = 3
+ \\ (u32) .a = 1
+ \\ (u8) .b = 2
+ \\ (u16) .c = 3
\\}
\\(root.main.Elem1) slice1[1] = {
- \\ (u32) a = 4
- \\ (u8) b = 5
- \\ (u16) c = 6
+ \\ (u32) .a = 4
+ \\ (u8) .b = 5
+ \\ (u16) .c = 6
\\}
\\(root.main.Elem1) slice1[2] = {
- \\ (u32) a = 7
- \\ (u8) b = 8
- \\ (u16) c = 9
+ \\ (u32) .a = 7
+ \\ (u8) .b = 8
+ \\ (u16) .c = 9
\\}
\\([3]u32) slice1.a = {
\\ (u32) [0] = 1
diff --git a/tools/lldb_pretty_printers.py b/tools/lldb_pretty_printers.py
@@ -1,7 +1,7 @@
# pretty printing for the zig language, zig standard library, and zig stage 2 compiler.
# put commands in ~/.lldbinit to run them automatically when starting lldb
# `command script import /path/to/zig/tools/lldb_pretty_printers.py` to import this file
-# `type category enable zig` to enable pretty printing for the zig language
+# `type category enable zig.lang` to enable pretty printing for the zig language
# `type category enable zig.std` to enable pretty printing for the zig standard library
# `type category enable zig.stage2` to enable pretty printing for the zig stage 2 compiler
import lldb
@@ -688,11 +688,14 @@ def add(debugger, *, category, regex=False, type, identifier=None, synth=False,
def MultiArrayList_Entry(type): return '^multi_array_list\\.MultiArrayList\\(%s\\)\\.Entry__struct_[1-9][0-9]*$' % type
def __lldb_init_module(debugger, _=None):
+ # Initialize Zig Categories
+ debugger.HandleCommand('type category define --language c99 zig.lang zig.std')
+
# Initialize Zig Language
- add(debugger, category='zig', regex=True, type='^\\[\\]', identifier='zig_Slice', synth=True, expand=True, summary='len=${svar%#}')
- add(debugger, category='zig', type='[]u8', identifier='zig_String', summary=True)
- add(debugger, category='zig', regex=True, type='^\\?', identifier='zig_Optional', synth=True, summary=True)
- add(debugger, category='zig', regex=True, type='^(error{.*}|anyerror)!', identifier='zig_ErrorUnion', synth=True, inline_children=True, summary=True)
+ add(debugger, category='zig.lang', regex=True, type='^\\[\\]', identifier='zig_Slice', synth=True, expand=True, summary='len=${svar%#}')
+ add(debugger, category='zig.lang', type='[]u8', identifier='zig_String', summary=True)
+ add(debugger, category='zig.lang', regex=True, type='^\\?', identifier='zig_Optional', synth=True, summary=True)
+ add(debugger, category='zig.lang', regex=True, type='^(error{.*}|anyerror)!', identifier='zig_ErrorUnion', synth=True, inline_children=True, summary=True)
# Initialize Zig Standard Library
add(debugger, category='zig.std', type='mem.Allocator', summary='${var.ptr}')