authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-10-09 14:09:18-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-10-09 14:09:18-07:00
log10cb578e4e16bac44055f277cd06baaf99b159b6
tree108509bfba5587a5e930f48d9f5d6fa5483dda44
parentce5a5c361b5b098c3b7d68f88136a9c91e7bec19
parentd748cfc2b778f87f97b86001634cff66120f21a5
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #21640 from jacobly0/dwarf-progress

Dwarf: progress

10 files changed, 508 insertions(+), 281 deletions(-)

ci/x86_64-linux-debug.sh+1-1
...@@ -64,7 +64,7 @@ stage3-debug/bin/zig build \...@@ -64,7 +64,7 @@ stage3-debug/bin/zig build \
6464
65stage3-debug/bin/zig build test docs \65stage3-debug/bin/zig build test docs \
66 --maxrss 21000000000 \66 --maxrss 21000000000 \
67 -Dlldb=$HOME/deps/lldb-zig/Debug-4a44163df/bin/lldb \67 -Dlldb=$HOME/deps/lldb-zig/Debug-6ece8bda1/bin/lldb \
68 -fqemu \68 -fqemu \
69 -fwasmtime \69 -fwasmtime \
70 -Dstatic-llvm \70 -Dstatic-llvm \
ci/x86_64-linux-release.sh+1-1
...@@ -64,7 +64,7 @@ stage3-release/bin/zig build \...@@ -64,7 +64,7 @@ stage3-release/bin/zig build \
6464
65stage3-release/bin/zig build test docs \65stage3-release/bin/zig build test docs \
66 --maxrss 21000000000 \66 --maxrss 21000000000 \
67 -Dlldb=$HOME/deps/lldb-zig/Release-4a44163df/bin/lldb \67 -Dlldb=$HOME/deps/lldb-zig/Release-6ece8bda1/bin/lldb \
68 -fqemu \68 -fqemu \
69 -fwasmtime \69 -fwasmtime \
70 -Dstatic-llvm \70 -Dstatic-llvm \
src/arch/x86_64/CodeGen.zig+83-7
...@@ -36,6 +36,7 @@ const abi = @import("abi.zig");...@@ -36,6 +36,7 @@ const abi = @import("abi.zig");
36const bits = @import("bits.zig");36const bits = @import("bits.zig");
37const errUnionErrorOffset = codegen.errUnionErrorOffset;37const errUnionErrorOffset = codegen.errUnionErrorOffset;
38const errUnionPayloadOffset = codegen.errUnionPayloadOffset;38const errUnionPayloadOffset = codegen.errUnionPayloadOffset;
39const encoder = @import("encoder.zig");
3940
40const Condition = bits.Condition;41const Condition = bits.Condition;
41const Immediate = bits.Immediate;42const Immediate = bits.Immediate;
...@@ -1188,6 +1189,74 @@ fn formatWipMir(...@@ -1188,6 +1189,74 @@ fn formatWipMir(
1188 try writer.print(" | {}", .{lowered_inst});1189 try writer.print(" | {}", .{lowered_inst});
1189 first = false;1190 first = false;
1190 }1191 }
1192 if (first) {
1193 const ip = &data.self.pt.zcu.intern_pool;
1194 const mir_inst = lower.mir.instructions.get(data.inst);
1195 try writer.print(" | .{s}", .{@tagName(mir_inst.ops)});
1196 switch (mir_inst.ops) {
1197 else => unreachable,
1198 .pseudo_dbg_prologue_end_none,
1199 .pseudo_dbg_line_line_column,
1200 .pseudo_dbg_epilogue_begin_none,
1201 .pseudo_dbg_enter_block_none,
1202 .pseudo_dbg_leave_block_none,
1203 .pseudo_dbg_var_args_none,
1204 .pseudo_dead_none,
1205 => {},
1206 .pseudo_dbg_enter_inline_func, .pseudo_dbg_leave_inline_func => try writer.print(" {}", .{
1207 ip.getNav(ip.indexToKey(mir_inst.data.func).func.owner_nav).name.fmt(ip),
1208 }),
1209 .pseudo_dbg_local_a => try writer.print(" {}", .{mir_inst.data.a.air_inst}),
1210 .pseudo_dbg_local_ai_s => try writer.print(" {}, {d}", .{
1211 mir_inst.data.ai.air_inst,
1212 @as(i32, @bitCast(mir_inst.data.ai.i)),
1213 }),
1214 .pseudo_dbg_local_ai_u => try writer.print(" {}, {d}", .{
1215 mir_inst.data.ai.air_inst,
1216 mir_inst.data.ai.i,
1217 }),
1218 .pseudo_dbg_local_ai_64 => try writer.print(" {}, {d}", .{
1219 mir_inst.data.ai.air_inst,
1220 lower.mir.extraData(Mir.Imm64, mir_inst.data.ai.i).data.decode(),
1221 }),
1222 .pseudo_dbg_local_as => {
1223 const mem_op: Instruction.Operand = .{ .mem = .initSib(.qword, .{
1224 .base = .{ .reloc = mir_inst.data.as.sym_index },
1225 }) };
1226 try writer.print(" {}, {}", .{ mir_inst.data.as.air_inst, mem_op.fmt(.m) });
1227 },
1228 .pseudo_dbg_local_aso => {
1229 const sym_off = lower.mir.extraData(bits.SymbolOffset, mir_inst.data.ax.payload).data;
1230 const mem_op: Instruction.Operand = .{ .mem = .initSib(.qword, .{
1231 .base = .{ .reloc = sym_off.sym_index },
1232 .disp = sym_off.off,
1233 }) };
1234 try writer.print(" {}, {}", .{ mir_inst.data.ax.air_inst, mem_op.fmt(.m) });
1235 },
1236 .pseudo_dbg_local_aro => {
1237 const air_off = lower.mir.extraData(Mir.AirOffset, mir_inst.data.rx.payload).data;
1238 const mem_op: Instruction.Operand = .{ .mem = .initSib(.qword, .{
1239 .base = .{ .reg = mir_inst.data.rx.r1 },
1240 .disp = air_off.off,
1241 }) };
1242 try writer.print(" {}, {}", .{ air_off.air_inst, mem_op.fmt(.m) });
1243 },
1244 .pseudo_dbg_local_af => {
1245 const frame_addr = lower.mir.extraData(bits.FrameAddr, mir_inst.data.ax.payload).data;
1246 const mem_op: Instruction.Operand = .{ .mem = .initSib(.qword, .{
1247 .base = .{ .frame = frame_addr.index },
1248 .disp = frame_addr.off,
1249 }) };
1250 try writer.print(" {}, {d}", .{ mir_inst.data.ax.air_inst, mem_op.fmt(.m) });
1251 },
1252 .pseudo_dbg_local_am => {
1253 const mem_op: Instruction.Operand = .{
1254 .mem = lower.mir.extraData(Mir.Memory, mir_inst.data.ax.payload).data.decode(),
1255 };
1256 try writer.print(" {}, {}", .{ mir_inst.data.ax.air_inst, mem_op.fmt(.m) });
1257 },
1258 }
1259 }
1191}1260}
1192fn fmtWipMir(self: *Self, inst: Mir.Inst.Index) std.fmt.Formatter(formatWipMir) {1261fn fmtWipMir(self: *Self, inst: Mir.Inst.Index) std.fmt.Formatter(formatWipMir) {
1193 return .{ .data = .{ .self = self, .inst = inst } };1262 return .{ .data = .{ .self = self, .inst = inst } };
...@@ -2180,6 +2249,12 @@ fn checkInvariantsAfterAirInst(self: *Self, inst: Air.Inst.Index, old_air_bookke...@@ -2180,6 +2249,12 @@ fn checkInvariantsAfterAirInst(self: *Self, inst: Air.Inst.Index, old_air_bookke
2180 }2249 }
2181}2250}
21822251
2252fn genBodyBlock(self: *Self, body: []const Air.Inst.Index) InnerError!void {
2253 try self.asmPseudo(.pseudo_dbg_enter_block_none);
2254 try self.genBody(body);
2255 try self.asmPseudo(.pseudo_dbg_leave_block_none);
2256}
2257
2183fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {2258fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void {
2184 const pt = self.pt;2259 const pt = self.pt;
2185 const zcu = pt.zcu;2260 const zcu = pt.zcu;
...@@ -13184,7 +13259,7 @@ fn genTry(...@@ -13184,7 +13259,7 @@ fn genTry(
13184 const state = try self.saveState();13259 const state = try self.saveState();
1318513260
13186 for (liveness_cond_br.else_deaths) |death| try self.processDeath(death);13261 for (liveness_cond_br.else_deaths) |death| try self.processDeath(death);
13187 try self.genBody(body);13262 try self.genBodyBlock(body);
13188 try self.restoreState(state, &.{}, .{13263 try self.restoreState(state, &.{}, .{
13189 .emit_instructions = false,13264 .emit_instructions = false,
13190 .update_tracking = true,13265 .update_tracking = true,
...@@ -13293,7 +13368,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {...@@ -13293,7 +13368,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
13293 const reloc = try self.genCondBrMir(cond_ty, cond);13368 const reloc = try self.genCondBrMir(cond_ty, cond);
1329413369
13295 for (liveness_cond_br.then_deaths) |death| try self.processDeath(death);13370 for (liveness_cond_br.then_deaths) |death| try self.processDeath(death);
13296 try self.genBody(then_body);13371 try self.genBodyBlock(then_body);
13297 try self.restoreState(state, &.{}, .{13372 try self.restoreState(state, &.{}, .{
13298 .emit_instructions = false,13373 .emit_instructions = false,
13299 .update_tracking = true,13374 .update_tracking = true,
...@@ -13304,7 +13379,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {...@@ -13304,7 +13379,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
13304 self.performReloc(reloc);13379 self.performReloc(reloc);
1330513380
13306 for (liveness_cond_br.else_deaths) |death| try self.processDeath(death);13381 for (liveness_cond_br.else_deaths) |death| try self.processDeath(death);
13307 try self.genBody(else_body);13382 try self.genBodyBlock(else_body);
13308 try self.restoreState(state, &.{}, .{13383 try self.restoreState(state, &.{}, .{
13309 .emit_instructions = false,13384 .emit_instructions = false,
13310 .update_tracking = true,13385 .update_tracking = true,
...@@ -13665,14 +13740,16 @@ fn airLoop(self: *Self, inst: Air.Inst.Index) !void {...@@ -13665,14 +13740,16 @@ fn airLoop(self: *Self, inst: Air.Inst.Index) !void {
13665 });13740 });
13666 defer assert(self.loops.remove(inst));13741 defer assert(self.loops.remove(inst));
1366713742
13668 try self.genBody(body);13743 try self.genBodyBlock(body);
13669 self.finishAirBookkeeping();13744 self.finishAirBookkeeping();
13670}13745}
1367113746
13672fn airBlock(self: *Self, inst: Air.Inst.Index) !void {13747fn airBlock(self: *Self, inst: Air.Inst.Index) !void {
13673 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;13748 const ty_pl = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl;
13674 const extra = self.air.extraData(Air.Block, ty_pl.payload);13749 const extra = self.air.extraData(Air.Block, ty_pl.payload);
13750 try self.asmPseudo(.pseudo_dbg_enter_block_none);
13675 try self.lowerBlock(inst, @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]));13751 try self.lowerBlock(inst, @ptrCast(self.air.extra[extra.end..][0..extra.data.body_len]));
13752 try self.asmPseudo(.pseudo_dbg_leave_block_none);
13676}13753}
1367713754
13678fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) !void {13755fn 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) !...@@ -13684,7 +13761,6 @@ fn lowerBlock(self: *Self, inst: Air.Inst.Index, body: []const Air.Inst.Index) !
13684 try self.blocks.putNoClobber(self.gpa, inst, .{ .state = self.initRetroactiveState() });13761 try self.blocks.putNoClobber(self.gpa, inst, .{ .state = self.initRetroactiveState() });
13685 const liveness = self.liveness.getBlock(inst);13762 const liveness = self.liveness.getBlock(inst);
1368613763
13687 // TODO emit debug info lexical block
13688 try self.genBody(body);13764 try self.genBody(body);
1368913765
13690 var block_data = self.blocks.fetchRemove(inst).?;13766 var block_data = self.blocks.fetchRemove(inst).?;
...@@ -13796,7 +13872,7 @@ fn lowerSwitchBr(self: *Self, inst: Air.Inst.Index, switch_br: Air.UnwrappedSwit...@@ -13796,7 +13872,7 @@ fn lowerSwitchBr(self: *Self, inst: Air.Inst.Index, switch_br: Air.UnwrappedSwit
1379613872
13797 // Relocate all success cases to the body we're about to generate.13873 // Relocate all success cases to the body we're about to generate.
13798 for (relocs) |reloc| self.performReloc(reloc);13874 for (relocs) |reloc| self.performReloc(reloc);
13799 try self.genBody(case.body);13875 try self.genBodyBlock(case.body);
13800 try self.restoreState(state, &.{}, .{13876 try self.restoreState(state, &.{}, .{
13801 .emit_instructions = false,13877 .emit_instructions = false,
13802 .update_tracking = true,13878 .update_tracking = true,
...@@ -13814,7 +13890,7 @@ fn lowerSwitchBr(self: *Self, inst: Air.Inst.Index, switch_br: Air.UnwrappedSwit...@@ -13814,7 +13890,7 @@ fn lowerSwitchBr(self: *Self, inst: Air.Inst.Index, switch_br: Air.UnwrappedSwit
13814 const else_deaths = liveness.deaths.len - 1;13890 const else_deaths = liveness.deaths.len - 1;
13815 for (liveness.deaths[else_deaths]) |operand| try self.processDeath(operand);13891 for (liveness.deaths[else_deaths]) |operand| try self.processDeath(operand);
1381613892
13817 try self.genBody(else_body);13893 try self.genBodyBlock(else_body);
13818 try self.restoreState(state, &.{}, .{13894 try self.restoreState(state, &.{}, .{
13819 .emit_instructions = false,13895 .emit_instructions = false,
13820 .update_tracking = true,13896 .update_tracking = true,
src/arch/x86_64/Emit.zig+24
...@@ -287,6 +287,30 @@ pub fn emitMir(emit: *Emit) Error!void {...@@ -287,6 +287,30 @@ pub fn emitMir(emit: *Emit) Error!void {
287 .none => {},287 .none => {},
288 }288 }
289 },289 },
290 .pseudo_dbg_enter_block_none => {
291 switch (emit.debug_output) {
292 .dwarf => |dw| {
293 log.debug("mirDbgEnterBlock (line={d}, col={d})", .{
294 emit.prev_di_line, emit.prev_di_column,
295 });
296 try dw.enterBlock(emit.code.items.len);
297 },
298 .plan9 => {},
299 .none => {},
300 }
301 },
302 .pseudo_dbg_leave_block_none => {
303 switch (emit.debug_output) {
304 .dwarf => |dw| {
305 log.debug("mirDbgLeaveBlock (line={d}, col={d})", .{
306 emit.prev_di_line, emit.prev_di_column,
307 });
308 try dw.leaveBlock(emit.code.items.len);
309 },
310 .plan9 => {},
311 .none => {},
312 }
313 },
290 .pseudo_dbg_enter_inline_func => {314 .pseudo_dbg_enter_inline_func => {
291 switch (emit.debug_output) {315 switch (emit.debug_output) {
292 .dwarf => |dw| {316 .dwarf => |dw| {
src/arch/x86_64/Lower.zig+2
...@@ -312,6 +312,8 @@ pub fn lowerMir(lower: *Lower, index: Mir.Inst.Index) Error!struct {...@@ -312,6 +312,8 @@ pub fn lowerMir(lower: *Lower, index: Mir.Inst.Index) Error!struct {
312 .pseudo_dbg_prologue_end_none,312 .pseudo_dbg_prologue_end_none,
313 .pseudo_dbg_line_line_column,313 .pseudo_dbg_line_line_column,
314 .pseudo_dbg_epilogue_begin_none,314 .pseudo_dbg_epilogue_begin_none,
315 .pseudo_dbg_enter_block_none,
316 .pseudo_dbg_leave_block_none,
315 .pseudo_dbg_enter_inline_func,317 .pseudo_dbg_enter_inline_func,
316 .pseudo_dbg_leave_inline_func,318 .pseudo_dbg_leave_inline_func,
317 .pseudo_dbg_local_a,319 .pseudo_dbg_local_a,
src/arch/x86_64/Mir.zig+4
...@@ -935,6 +935,10 @@ pub const Inst = struct {...@@ -935,6 +935,10 @@ pub const Inst = struct {
935 pseudo_dbg_line_line_column,935 pseudo_dbg_line_line_column,
936 /// Start of epilogue936 /// Start of epilogue
937 pseudo_dbg_epilogue_begin_none,937 pseudo_dbg_epilogue_begin_none,
938 /// Start of lexical block
939 pseudo_dbg_enter_block_none,
940 /// End of lexical block
941 pseudo_dbg_leave_block_none,
938 /// Start of inline function942 /// Start of inline function
939 pseudo_dbg_enter_inline_func,943 pseudo_dbg_enter_inline_func,
940 /// End of inline function944 /// End of inline function
src/arch/x86_64/encoder.zig+4-4
...@@ -233,7 +233,7 @@ pub const Instruction = struct {...@@ -233,7 +233,7 @@ pub const Instruction = struct {
233 _ = unused_format_string;233 _ = unused_format_string;
234 _ = options;234 _ = options;
235 _ = writer;235 _ = writer;
236 @compileError("do not format Operand directly; use fmtPrint() instead");236 @compileError("do not format Operand directly; use fmt() instead");
237 }237 }
238238
239 const FormatContext = struct {239 const FormatContext = struct {
...@@ -241,7 +241,7 @@ pub const Instruction = struct {...@@ -241,7 +241,7 @@ pub const Instruction = struct {
241 enc_op: Encoding.Op,241 enc_op: Encoding.Op,
242 };242 };
243243
244 fn fmt(244 fn fmtContext(
245 ctx: FormatContext,245 ctx: FormatContext,
246 comptime unused_format_string: []const u8,246 comptime unused_format_string: []const u8,
247 options: std.fmt.FormatOptions,247 options: std.fmt.FormatOptions,
...@@ -309,7 +309,7 @@ pub const Instruction = struct {...@@ -309,7 +309,7 @@ pub const Instruction = struct {
309 }309 }
310 }310 }
311311
312 pub fn fmtPrint(op: Operand, enc_op: Encoding.Op) std.fmt.Formatter(fmt) {312 pub fn fmt(op: Operand, enc_op: Encoding.Op) std.fmt.Formatter(fmtContext) {
313 return .{ .data = .{ .op = op, .enc_op = enc_op } };313 return .{ .data = .{ .op = op, .enc_op = enc_op } };
314 }314 }
315 };315 };
...@@ -373,7 +373,7 @@ pub const Instruction = struct {...@@ -373,7 +373,7 @@ pub const Instruction = struct {
373 if (op == .none) break;373 if (op == .none) break;
374 if (i > 0) try writer.writeByte(',');374 if (i > 0) try writer.writeByte(',');
375 try writer.writeByte(' ');375 try writer.writeByte(' ');
376 try writer.print("{}", .{op.fmtPrint(enc)});376 try writer.print("{}", .{op.fmt(enc)});
377 }377 }
378 }378 }
379379
src/link/Dwarf.zig+95-64
...@@ -1374,10 +1374,11 @@ pub const WipNav = struct {...@@ -1374,10 +1374,11 @@ pub const WipNav = struct {
1374 any_children: bool,1374 any_children: bool,
1375 func: InternPool.Index,1375 func: InternPool.Index,
1376 func_sym_index: u32,1376 func_sym_index: u32,
1377 func_high_reloc: u32,1377 func_high_pc: u32,
1378 inlined_funcs: std.ArrayListUnmanaged(struct {1378 blocks: std.ArrayListUnmanaged(struct {
1379 abbrev_code: u32,1379 abbrev_code: u32,
1380 high_reloc: u32,1380 low_pc_off: u64,
1381 high_pc: u32,
1381 }),1382 }),
1382 cfi: struct {1383 cfi: struct {
1383 loc: u32,1384 loc: u32,
...@@ -1391,7 +1392,7 @@ pub const WipNav = struct {...@@ -1391,7 +1392,7 @@ pub const WipNav = struct {
13911392
1392 pub fn deinit(wip_nav: *WipNav) void {1393 pub fn deinit(wip_nav: *WipNav) void {
1393 const gpa = wip_nav.dwarf.gpa;1394 const gpa = wip_nav.dwarf.gpa;
1394 if (wip_nav.func != .none) wip_nav.inlined_funcs.deinit(gpa);1395 if (wip_nav.func != .none) wip_nav.blocks.deinit(gpa);
1395 wip_nav.debug_frame.deinit(gpa);1396 wip_nav.debug_frame.deinit(gpa);
1396 wip_nav.debug_info.deinit(gpa);1397 wip_nav.debug_info.deinit(gpa);
1397 wip_nav.debug_line.deinit(gpa);1398 wip_nav.debug_line.deinit(gpa);
...@@ -1486,49 +1487,72 @@ pub const WipNav = struct {...@@ -1486,49 +1487,72 @@ pub const WipNav = struct {
1486 try dlw.writeByte(DW.LNS.set_epilogue_begin);1487 try dlw.writeByte(DW.LNS.set_epilogue_begin);
1487 }1488 }
14881489
1489 pub fn enterInlineFunc(wip_nav: *WipNav, func: InternPool.Index, code_off: u64, line: u32, column: u32) UpdateError!void {1490 pub fn enterBlock(wip_nav: *WipNav, code_off: u64) UpdateError!void {
1491 const dwarf = wip_nav.dwarf;
1492 const diw = wip_nav.debug_info.writer(dwarf.gpa);
1493 const block = try wip_nav.blocks.addOne(dwarf.gpa);
1494
1495 block.abbrev_code = @intCast(wip_nav.debug_info.items.len);
1496 try wip_nav.abbrevCode(.block);
1497 block.low_pc_off = code_off;
1498 try wip_nav.infoAddrSym(wip_nav.func_sym_index, code_off);
1499 block.high_pc = @intCast(wip_nav.debug_info.items.len);
1500 try diw.writeInt(u32, 0, dwarf.endian);
1501 wip_nav.any_children = false;
1502 }
1503
1504 pub fn leaveBlock(wip_nav: *WipNav, code_off: u64) UpdateError!void {
1505 const block_bytes = comptime uleb128Bytes(@intFromEnum(AbbrevCode.block));
1506 const block = wip_nav.blocks.pop();
1507 if (wip_nav.any_children)
1508 try uleb128(wip_nav.debug_info.writer(wip_nav.dwarf.gpa), @intFromEnum(AbbrevCode.null))
1509 else
1510 std.leb.writeUnsignedFixed(
1511 block_bytes,
1512 wip_nav.debug_info.items[block.abbrev_code..][0..block_bytes],
1513 try wip_nav.dwarf.refAbbrevCode(.empty_block),
1514 );
1515 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);
1516 wip_nav.any_children = true;
1517 }
1518
1519 pub fn enterInlineFunc(
1520 wip_nav: *WipNav,
1521 func: InternPool.Index,
1522 code_off: u64,
1523 line: u32,
1524 column: u32,
1525 ) UpdateError!void {
1490 const dwarf = wip_nav.dwarf;1526 const dwarf = wip_nav.dwarf;
1491 const zcu = wip_nav.pt.zcu;1527 const zcu = wip_nav.pt.zcu;
1492 const diw = wip_nav.debug_info.writer(dwarf.gpa);1528 const diw = wip_nav.debug_info.writer(dwarf.gpa);
1493 const inlined_func = try wip_nav.inlined_funcs.addOne(dwarf.gpa);1529 const block = try wip_nav.blocks.addOne(dwarf.gpa);
14941530
1495 inlined_func.abbrev_code = @intCast(wip_nav.debug_info.items.len);1531 block.abbrev_code = @intCast(wip_nav.debug_info.items.len);
1496 try wip_nav.abbrevCode(.inlined_func);1532 try wip_nav.abbrevCode(.inlined_func);
1497 try wip_nav.refNav(zcu.funcInfo(func).owner_nav);1533 try wip_nav.refNav(zcu.funcInfo(func).owner_nav);
1498 try uleb128(diw, zcu.navSrcLine(zcu.funcInfo(wip_nav.func).owner_nav) + line + 1);1534 try uleb128(diw, zcu.navSrcLine(zcu.funcInfo(wip_nav.func).owner_nav) + line + 1);
1499 try uleb128(diw, column + 1);1535 try uleb128(diw, column + 1);
1500 const external_relocs = &dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs;1536 block.low_pc_off = code_off;
1501 try external_relocs.ensureUnusedCapacity(dwarf.gpa, 2);1537 try wip_nav.infoAddrSym(wip_nav.func_sym_index, code_off);
1502 external_relocs.appendAssumeCapacity(.{1538 block.high_pc = @intCast(wip_nav.debug_info.items.len);
1503 .source_off = @intCast(wip_nav.debug_info.items.len),1539 try diw.writeInt(u32, 0, dwarf.endian);
1504 .target_sym = wip_nav.func_sym_index,
1505 .target_off = code_off,
1506 });
1507 try diw.writeByteNTimes(0, @intFromEnum(dwarf.address_size));
1508 inlined_func.high_reloc = @intCast(external_relocs.items.len);
1509 external_relocs.appendAssumeCapacity(.{
1510 .source_off = @intCast(wip_nav.debug_info.items.len),
1511 .target_sym = wip_nav.func_sym_index,
1512 .target_off = undefined,
1513 });
1514 try diw.writeByteNTimes(0, @intFromEnum(dwarf.address_size));
1515 try wip_nav.setInlineFunc(func);1540 try wip_nav.setInlineFunc(func);
1516 wip_nav.any_children = false;1541 wip_nav.any_children = false;
1517 }1542 }
15181543
1519 pub fn leaveInlineFunc(wip_nav: *WipNav, func: InternPool.Index, code_off: u64) UpdateError!void {1544 pub fn leaveInlineFunc(wip_nav: *WipNav, func: InternPool.Index, code_off: u64) UpdateError!void {
1520 const inlined_func_bytes = comptime uleb128Bytes(@intFromEnum(AbbrevCode.inlined_func));1545 const inlined_func_bytes = comptime uleb128Bytes(@intFromEnum(AbbrevCode.inlined_func));
1521 const inlined_func = wip_nav.inlined_funcs.pop();1546 const block = wip_nav.blocks.pop();
1522 const external_relocs = &wip_nav.dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs;
1523 external_relocs.items[inlined_func.high_reloc].target_off = code_off;
1524 if (wip_nav.any_children)1547 if (wip_nav.any_children)
1525 try uleb128(wip_nav.debug_info.writer(wip_nav.dwarf.gpa), @intFromEnum(AbbrevCode.null))1548 try uleb128(wip_nav.debug_info.writer(wip_nav.dwarf.gpa), @intFromEnum(AbbrevCode.null))
1526 else1549 else
1527 std.leb.writeUnsignedFixed(1550 std.leb.writeUnsignedFixed(
1528 inlined_func_bytes,1551 inlined_func_bytes,
1529 wip_nav.debug_info.items[inlined_func.abbrev_code..][0..inlined_func_bytes],1552 wip_nav.debug_info.items[block.abbrev_code..][0..inlined_func_bytes],
1530 try wip_nav.dwarf.refAbbrevCode(.empty_inlined_func),1553 try wip_nav.dwarf.refAbbrevCode(.empty_inlined_func),
1531 );1554 );
1555 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);
1532 try wip_nav.setInlineFunc(func);1556 try wip_nav.setInlineFunc(func);
1533 wip_nav.any_children = true;1557 wip_nav.any_children = true;
1534 }1558 }
...@@ -1664,17 +1688,18 @@ pub const WipNav = struct {...@@ -1664,17 +1688,18 @@ pub const WipNav = struct {
1664 return ctx.wip_nav.dwarf.endian;1688 return ctx.wip_nav.dwarf.endian;
1665 }1689 }
1666 fn addrSym(ctx: @This(), sym_index: u32) UpdateError!void {1690 fn addrSym(ctx: @This(), sym_index: u32) UpdateError!void {
1667 try ctx.wip_nav.infoAddrSym(sym_index);1691 try ctx.wip_nav.infoAddrSym(sym_index, 0);
1668 }1692 }
1669 } = .{ .wip_nav = wip_nav };1693 } = .{ .wip_nav = wip_nav };
1670 try uleb128(adapter.writer(), counter.stream.bytes_written);1694 try uleb128(adapter.writer(), counter.stream.bytes_written);
1671 try loc.write(adapter);1695 try loc.write(adapter);
1672 }1696 }
16731697
1674 fn infoAddrSym(wip_nav: *WipNav, sym_index: u32) UpdateError!void {1698 fn infoAddrSym(wip_nav: *WipNav, sym_index: u32, sym_off: u64) UpdateError!void {
1675 try wip_nav.infoExternalReloc(.{1699 try wip_nav.infoExternalReloc(.{
1676 .source_off = @intCast(wip_nav.debug_info.items.len),1700 .source_off = @intCast(wip_nav.debug_info.items.len),
1677 .target_sym = sym_index,1701 .target_sym = sym_index,
1702 .target_off = sym_off,
1678 });1703 });
1679 try wip_nav.debug_info.appendNTimes(wip_nav.dwarf.gpa, 0, @intFromEnum(wip_nav.dwarf.address_size));1704 try wip_nav.debug_info.appendNTimes(wip_nav.dwarf.gpa, 0, @intFromEnum(wip_nav.dwarf.address_size));
1680 }1705 }
...@@ -1695,17 +1720,18 @@ pub const WipNav = struct {...@@ -1695,17 +1720,18 @@ pub const WipNav = struct {
1695 return ctx.wip_nav.dwarf.endian;1720 return ctx.wip_nav.dwarf.endian;
1696 }1721 }
1697 fn addrSym(ctx: @This(), sym_index: u32) UpdateError!void {1722 fn addrSym(ctx: @This(), sym_index: u32) UpdateError!void {
1698 try ctx.wip_nav.frameAddrSym(sym_index);1723 try ctx.wip_nav.frameAddrSym(sym_index, 0);
1699 }1724 }
1700 } = .{ .wip_nav = wip_nav };1725 } = .{ .wip_nav = wip_nav };
1701 try uleb128(adapter.writer(), counter.stream.bytes_written);1726 try uleb128(adapter.writer(), counter.stream.bytes_written);
1702 try loc.write(adapter);1727 try loc.write(adapter);
1703 }1728 }
17041729
1705 fn frameAddrSym(wip_nav: *WipNav, sym_index: u32) UpdateError!void {1730 fn frameAddrSym(wip_nav: *WipNav, sym_index: u32, sym_off: u64) UpdateError!void {
1706 try wip_nav.frameExternalReloc(.{1731 try wip_nav.frameExternalReloc(.{
1707 .source_off = @intCast(wip_nav.debug_frame.items.len),1732 .source_off = @intCast(wip_nav.debug_frame.items.len),
1708 .target_sym = sym_index,1733 .target_sym = sym_index,
1734 .target_off = sym_off,
1709 });1735 });
1710 try wip_nav.debug_frame.appendNTimes(wip_nav.dwarf.gpa, 0, @intFromEnum(wip_nav.dwarf.address_size));1736 try wip_nav.debug_frame.appendNTimes(wip_nav.dwarf.gpa, 0, @intFromEnum(wip_nav.dwarf.address_size));
1711 }1737 }
...@@ -2150,8 +2176,8 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In...@@ -2150,8 +2176,8 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
2150 .any_children = false,2176 .any_children = false,
2151 .func = .none,2177 .func = .none,
2152 .func_sym_index = undefined,2178 .func_sym_index = undefined,
2153 .func_high_reloc = undefined,2179 .func_high_pc = undefined,
2154 .inlined_funcs = undefined,2180 .blocks = undefined,
2155 .cfi = undefined,2181 .cfi = undefined,
2156 .debug_frame = .{},2182 .debug_frame = .{},
2157 .debug_info = .{},2183 .debug_info = .{},
...@@ -2294,7 +2320,7 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In...@@ -2294,7 +2320,7 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
2294 const func_type = ip.indexToKey(func.ty).func_type;2320 const func_type = ip.indexToKey(func.ty).func_type;
2295 wip_nav.func = nav_val.toIntern();2321 wip_nav.func = nav_val.toIntern();
2296 wip_nav.func_sym_index = sym_index;2322 wip_nav.func_sym_index = sym_index;
2297 wip_nav.inlined_funcs = .{};2323 wip_nav.blocks = .{};
2298 if (dwarf.debug_frame.header.format != .none) wip_nav.cfi = .{2324 if (dwarf.debug_frame.header.format != .none) wip_nav.cfi = .{
2299 .loc = 0,2325 .loc = 0,
2300 .cfa = dwarf.debug_frame.header.initial_instructions[0].def_cfa,2326 .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...@@ -2319,7 +2345,7 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
2319 .source_off = @intCast(wip_nav.debug_frame.items.len),2345 .source_off = @intCast(wip_nav.debug_frame.items.len),
2320 });2346 });
2321 try dfw.writeByteNTimes(0, dwarf.sectionOffsetBytes());2347 try dfw.writeByteNTimes(0, dwarf.sectionOffsetBytes());
2322 try wip_nav.frameAddrSym(sym_index);2348 try wip_nav.frameAddrSym(sym_index, 0);
2323 try dfw.writeByteNTimes(undefined, @intFromEnum(dwarf.address_size));2349 try dfw.writeByteNTimes(undefined, @intFromEnum(dwarf.address_size));
2324 },2350 },
2325 .eh_frame => {2351 .eh_frame => {
...@@ -2346,20 +2372,9 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In...@@ -2346,20 +2372,9 @@ pub fn initWipNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.In
2346 try wip_nav.strp(nav.name.toSlice(ip));2372 try wip_nav.strp(nav.name.toSlice(ip));
2347 try wip_nav.strp(nav.fqn.toSlice(ip));2373 try wip_nav.strp(nav.fqn.toSlice(ip));
2348 try wip_nav.refType(Type.fromInterned(func_type.return_type));2374 try wip_nav.refType(Type.fromInterned(func_type.return_type));
2349 const external_relocs = &dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs;2375 try wip_nav.infoAddrSym(sym_index, 0);
2350 try external_relocs.ensureUnusedCapacity(dwarf.gpa, 2);2376 wip_nav.func_high_pc = @intCast(wip_nav.debug_info.items.len);
2351 external_relocs.appendAssumeCapacity(.{2377 try diw.writeInt(u32, 0, dwarf.endian);
2352 .source_off = @intCast(wip_nav.debug_info.items.len),
2353 .target_sym = sym_index,
2354 });
2355 try diw.writeByteNTimes(0, @intFromEnum(dwarf.address_size));
2356 wip_nav.func_high_reloc = @intCast(external_relocs.items.len);
2357 external_relocs.appendAssumeCapacity(.{
2358 .source_off = @intCast(wip_nav.debug_info.items.len),
2359 .target_sym = sym_index,
2360 .target_off = undefined,
2361 });
2362 try diw.writeByteNTimes(0, @intFromEnum(dwarf.address_size));
2363 try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse2378 try uleb128(diw, nav.status.resolved.alignment.toByteUnits() orelse
2364 target_info.defaultFunctionAlignment(file.mod.resolved_target.result).toByteUnits().?);2379 target_info.defaultFunctionAlignment(file.mod.resolved_target.result).toByteUnits().?);
2365 try diw.writeByte(@intFromBool(false));2380 try diw.writeByte(@intFromBool(false));
...@@ -2466,8 +2481,7 @@ pub fn finishWipNav(...@@ -2466,8 +2481,7 @@ pub fn finishWipNav(
2466 },2481 },
2467 }2482 }
2468 {2483 {
2469 const external_relocs = &dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs;2484 std.mem.writeInt(u32, wip_nav.debug_info.items[wip_nav.func_high_pc..][0..4], @intCast(sym.size), dwarf.endian);
2470 external_relocs.items[wip_nav.func_high_reloc].target_off = sym.size;
2471 if (wip_nav.any_children) {2485 if (wip_nav.any_children) {
2472 const diw = wip_nav.debug_info.writer(dwarf.gpa);2486 const diw = wip_nav.debug_info.writer(dwarf.gpa);
2473 try uleb128(diw, @intFromEnum(AbbrevCode.null));2487 try uleb128(diw, @intFromEnum(AbbrevCode.null));
...@@ -2562,8 +2576,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2562,8 +2576,8 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2562 .any_children = false,2576 .any_children = false,
2563 .func = .none,2577 .func = .none,
2564 .func_sym_index = undefined,2578 .func_sym_index = undefined,
2565 .func_high_reloc = undefined,2579 .func_high_pc = undefined,
2566 .inlined_funcs = undefined,2580 .blocks = undefined,
2567 .cfi = undefined,2581 .cfi = undefined,
2568 .debug_frame = .{},2582 .debug_frame = .{},
2569 .debug_info = .{},2583 .debug_info = .{},
...@@ -3036,8 +3050,8 @@ fn updateType(...@@ -3036,8 +3050,8 @@ fn updateType(
3036 .any_children = false,3050 .any_children = false,
3037 .func = .none,3051 .func = .none,
3038 .func_sym_index = undefined,3052 .func_sym_index = undefined,
3039 .func_high_reloc = undefined,3053 .func_high_pc = undefined,
3040 .inlined_funcs = undefined,3054 .blocks = undefined,
3041 .cfi = undefined,3055 .cfi = undefined,
3042 .debug_frame = .{},3056 .debug_frame = .{},
3043 .debug_info = .{},3057 .debug_info = .{},
...@@ -3480,8 +3494,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3480,8 +3494,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3480 .any_children = false,3494 .any_children = false,
3481 .func = .none,3495 .func = .none,
3482 .func_sym_index = undefined,3496 .func_sym_index = undefined,
3483 .func_high_reloc = undefined,3497 .func_high_pc = undefined,
3484 .inlined_funcs = undefined,3498 .blocks = undefined,
3485 .cfi = undefined,3499 .cfi = undefined,
3486 .debug_frame = .{},3500 .debug_frame = .{},
3487 .debug_info = .{},3501 .debug_info = .{},
...@@ -3553,8 +3567,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP...@@ -3553,8 +3567,8 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP
3553 .any_children = false,3567 .any_children = false,
3554 .func = .none,3568 .func = .none,
3555 .func_sym_index = undefined,3569 .func_sym_index = undefined,
3556 .func_high_reloc = undefined,3570 .func_high_pc = undefined,
3557 .inlined_funcs = undefined,3571 .blocks = undefined,
3558 .cfi = undefined,3572 .cfi = undefined,
3559 .debug_frame = .{},3573 .debug_frame = .{},
3560 .debug_info = .{},3574 .debug_info = .{},
...@@ -3756,8 +3770,8 @@ pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void {...@@ -3756,8 +3770,8 @@ pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void {
3756 .any_children = false,3770 .any_children = false,
3757 .func = .none,3771 .func = .none,
3758 .func_sym_index = undefined,3772 .func_sym_index = undefined,
3759 .func_high_reloc = undefined,3773 .func_high_pc = undefined,
3760 .inlined_funcs = undefined,3774 .blocks = undefined,
3761 .cfi = undefined,3775 .cfi = undefined,
3762 .debug_frame = .{},3776 .debug_frame = .{},
3763 .debug_info = .{},3777 .debug_info = .{},
...@@ -4212,6 +4226,8 @@ const AbbrevCode = enum {...@@ -4212,6 +4226,8 @@ const AbbrevCode = enum {
4212 empty_packed_struct_type,4226 empty_packed_struct_type,
4213 union_type,4227 union_type,
4214 empty_union_type,4228 empty_union_type,
4229 empty_block,
4230 block,
4215 empty_inlined_func,4231 empty_inlined_func,
4216 inlined_func,4232 inlined_func,
4217 local_arg,4233 local_arg,
...@@ -4319,7 +4335,7 @@ const AbbrevCode = enum {...@@ -4319,7 +4335,7 @@ const AbbrevCode = enum {
4319 .{ .linkage_name, .strp },4335 .{ .linkage_name, .strp },
4320 .{ .type, .ref_addr },4336 .{ .type, .ref_addr },
4321 .{ .low_pc, .addr },4337 .{ .low_pc, .addr },
4322 .{ .high_pc, .addr },4338 .{ .high_pc, .data4 },
4323 .{ .alignment, .udata },4339 .{ .alignment, .udata },
4324 .{ .external, .flag },4340 .{ .external, .flag },
4325 .{ .noreturn, .flag },4341 .{ .noreturn, .flag },
...@@ -4331,7 +4347,7 @@ const AbbrevCode = enum {...@@ -4331,7 +4347,7 @@ const AbbrevCode = enum {
4331 .{ .linkage_name, .strp },4347 .{ .linkage_name, .strp },
4332 .{ .type, .ref_addr },4348 .{ .type, .ref_addr },
4333 .{ .low_pc, .addr },4349 .{ .low_pc, .addr },
4334 .{ .high_pc, .addr },4350 .{ .high_pc, .data4 },
4335 .{ .alignment, .udata },4351 .{ .alignment, .udata },
4336 .{ .external, .flag },4352 .{ .external, .flag },
4337 .{ .noreturn, .flag },4353 .{ .noreturn, .flag },
...@@ -4672,6 +4688,21 @@ const AbbrevCode = enum {...@@ -4672,6 +4688,21 @@ const AbbrevCode = enum {
4672 .{ .alignment, .udata },4688 .{ .alignment, .udata },
4673 },4689 },
4674 },4690 },
4691 .empty_block = .{
4692 .tag = .lexical_block,
4693 .attrs = &.{
4694 .{ .low_pc, .addr },
4695 .{ .high_pc, .data4 },
4696 },
4697 },
4698 .block = .{
4699 .tag = .lexical_block,
4700 .children = true,
4701 .attrs = &.{
4702 .{ .low_pc, .addr },
4703 .{ .high_pc, .data4 },
4704 },
4705 },
4675 .empty_inlined_func = .{4706 .empty_inlined_func = .{
4676 .tag = .inlined_subroutine,4707 .tag = .inlined_subroutine,
4677 .attrs = &.{4708 .attrs = &.{
...@@ -4679,7 +4710,7 @@ const AbbrevCode = enum {...@@ -4679,7 +4710,7 @@ const AbbrevCode = enum {
4679 .{ .call_line, .udata },4710 .{ .call_line, .udata },
4680 .{ .call_column, .udata },4711 .{ .call_column, .udata },
4681 .{ .low_pc, .addr },4712 .{ .low_pc, .addr },
4682 .{ .high_pc, .addr },4713 .{ .high_pc, .data4 },
4683 },4714 },
4684 },4715 },
4685 .inlined_func = .{4716 .inlined_func = .{
...@@ -4690,7 +4721,7 @@ const AbbrevCode = enum {...@@ -4690,7 +4721,7 @@ const AbbrevCode = enum {
4690 .{ .call_line, .udata },4721 .{ .call_line, .udata },
4691 .{ .call_column, .udata },4722 .{ .call_column, .udata },
4692 .{ .low_pc, .addr },4723 .{ .low_pc, .addr },
4693 .{ .high_pc, .addr },4724 .{ .high_pc, .data4 },
4694 },4725 },
4695 },4726 },
4696 .local_arg = .{4727 .local_arg = .{
test/src/Debugger.zig+286-199
...@@ -113,70 +113,70 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -113,70 +113,70 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
113 &.{113 &.{
114 \\(lldb) frame variable --show-types -- basic114 \\(lldb) frame variable --show-types -- basic
115 \\(root.basic.Basic) basic = {115 \\(root.basic.Basic) basic = {
116 \\ (void) void = {}116 \\ (void) .void = {}
117 \\ (bool) bool_false = false117 \\ (bool) .bool_false = false
118 \\ (bool) bool_true = true118 \\ (bool) .bool_true = true
119 \\ (u0) u0_0 = 0119 \\ (u0) .u0_0 = 0
120 \\ (u1) u1_0 = 0120 \\ (u1) .u1_0 = 0
121 \\ (u1) u1_1 = 1121 \\ (u1) .u1_1 = 1
122 \\ (u2) u2_0 = 0122 \\ (u2) .u2_0 = 0
123 \\ (u2) u2_3 = 3123 \\ (u2) .u2_3 = 3
124 \\ (u3) u3_0 = 0124 \\ (u3) .u3_0 = 0
125 \\ (u3) u3_7 = 7125 \\ (u3) .u3_7 = 7
126 \\ (u4) u4_0 = 0126 \\ (u4) .u4_0 = 0
127 \\ (u4) u4_15 = 15127 \\ (u4) .u4_15 = 15
128 \\ (u5) u5_0 = 0128 \\ (u5) .u5_0 = 0
129 \\ (u5) u5_31 = 31129 \\ (u5) .u5_31 = 31
130 \\ (u6) u6_0 = 0130 \\ (u6) .u6_0 = 0
131 \\ (u6) u6_63 = 63131 \\ (u6) .u6_63 = 63
132 \\ (u7) u7_0 = 0132 \\ (u7) .u7_0 = 0
133 \\ (u7) u7_127 = 127133 \\ (u7) .u7_127 = 127
134 \\ (u8) u8_0 = 0134 \\ (u8) .u8_0 = 0
135 \\ (u8) u8_255 = 255135 \\ (u8) .u8_255 = 255
136 \\ (u16) u16_0 = 0136 \\ (u16) .u16_0 = 0
137 \\ (u16) u16_65535 = 65535137 \\ (u16) .u16_65535 = 65535
138 \\ (u24) u24_0 = 0138 \\ (u24) .u24_0 = 0
139 \\ (u24) u24_16777215 = 16777215139 \\ (u24) .u24_16777215 = 16777215
140 \\ (u32) u32_0 = 0140 \\ (u32) .u32_0 = 0
141 \\ (u32) u32_4294967295 = 4294967295141 \\ (u32) .u32_4294967295 = 4294967295
142 \\ (i0) i0_0 = 0142 \\ (i0) .i0_0 = 0
143 \\ (i1) i1_-1 = -1143 \\ (i1) .@"i1_-1" = -1
144 \\ (i1) i1_0 = 0144 \\ (i1) .i1_0 = 0
145 \\ (i2) i2_-2 = -2145 \\ (i2) .@"i2_-2" = -2
146 \\ (i2) i2_0 = 0146 \\ (i2) .i2_0 = 0
147 \\ (i2) i2_1 = 1147 \\ (i2) .i2_1 = 1
148 \\ (i3) i3_-4 = -4148 \\ (i3) .@"i3_-4" = -4
149 \\ (i3) i3_0 = 0149 \\ (i3) .i3_0 = 0
150 \\ (i3) i3_3 = 3150 \\ (i3) .i3_3 = 3
151 \\ (i4) i4_-8 = -8151 \\ (i4) .@"i4_-8" = -8
152 \\ (i4) i4_0 = 0152 \\ (i4) .i4_0 = 0
153 \\ (i4) i4_7 = 7153 \\ (i4) .i4_7 = 7
154 \\ (i5) i5_-16 = -16154 \\ (i5) .@"i5_-16" = -16
155 \\ (i5) i5_0 = 0155 \\ (i5) .i5_0 = 0
156 \\ (i5) i5_15 = 15156 \\ (i5) .i5_15 = 15
157 \\ (i6) i6_-32 = -32157 \\ (i6) .@"i6_-32" = -32
158 \\ (i6) i6_0 = 0158 \\ (i6) .i6_0 = 0
159 \\ (i6) i6_31 = 31159 \\ (i6) .i6_31 = 31
160 \\ (i7) i7_-64 = -64160 \\ (i7) .@"i7_-64" = -64
161 \\ (i7) i7_0 = 0161 \\ (i7) .i7_0 = 0
162 \\ (i7) i7_63 = 63162 \\ (i7) .i7_63 = 63
163 \\ (i8) i8_-128 = -128163 \\ (i8) .@"i8_-128" = -128
164 \\ (i8) i8_0 = 0164 \\ (i8) .i8_0 = 0
165 \\ (i8) i8_127 = 127165 \\ (i8) .i8_127 = 127
166 \\ (i16) i16_-32768 = -32768166 \\ (i16) .@"i16_-32768" = -32768
167 \\ (i16) i16_0 = 0167 \\ (i16) .i16_0 = 0
168 \\ (i16) i16_32767 = 32767168 \\ (i16) .i16_32767 = 32767
169 \\ (i24) i24_-8388608 = -8388608169 \\ (i24) .@"i24_-8388608" = -8388608
170 \\ (i24) i24_0 = 0170 \\ (i24) .i24_0 = 0
171 \\ (i24) i24_8388607 = 8388607171 \\ (i24) .i24_8388607 = 8388607
172 \\ (i32) i32_-2147483648 = -2147483648172 \\ (i32) .@"i32_-2147483648" = -2147483648
173 \\ (i32) i32_0 = 0173 \\ (i32) .i32_0 = 0
174 \\ (i32) i32_2147483647 = 2147483647174 \\ (i32) .i32_2147483647 = 2147483647
175 \\ (f16) f16_42.625 = 42.625175 \\ (f16) .@"f16_42.625" = 42.625
176 \\ (f32) f32_-2730.65625 = -2730.65625176 \\ (f32) .@"f32_-2730.65625" = -2730.65625
177 \\ (f64) f64_357913941.33203125 = 357913941.33203125177 \\ (f64) .@"f64_357913941.33203125" = 357913941.33203125
178 \\ (f80) f80_-91625968981.3330078125 = -91625968981.3330078125178 \\ (f80) .@"f80_-91625968981.3330078125" = -91625968981.3330078125
179 \\ (f128) f128_384307168202282325.333332061767578125 = 384307168202282325.333332061767578125179 \\ (f128) .@"f128_384307168202282325.333332061767578125" = 384307168202282325.333332061767578125
180 \\}180 \\}
181 \\(lldb) breakpoint delete --force 1181 \\(lldb) breakpoint delete --force 1
182 \\1 breakpoints deleted; 0 breakpoint locations disabled.182 \\1 breakpoints deleted; 0 breakpoint locations disabled.
...@@ -249,57 +249,57 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -249,57 +249,57 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
249 &.{249 &.{
250 \\(lldb) frame variable --show-types -- pointers250 \\(lldb) frame variable --show-types -- pointers
251 \\(root.pointers.Pointers) pointers = {251 \\(root.pointers.Pointers) pointers = {
252 \\ (*u32) single = 0x0000000000001010252 \\ (*u32) .single = 0x0000000000001010
253 \\ (*const u32) single_const = 0x0000000000001014253 \\ (*const u32) .single_const = 0x0000000000001014
254 \\ (*volatile u32) single_volatile = 0x0000000000001018254 \\ (*volatile u32) .single_volatile = 0x0000000000001018
255 \\ (*const volatile u32) single_const_volatile = 0x000000000000101c255 \\ (*const volatile u32) .single_const_volatile = 0x000000000000101c
256 \\ (*allowzero u32) single_allowzero = 0x0000000000001020256 \\ (*allowzero u32) .single_allowzero = 0x0000000000001020
257 \\ (*allowzero const u32) single_allowzero_const = 0x0000000000001024257 \\ (*allowzero const u32) .single_allowzero_const = 0x0000000000001024
258 \\ (*allowzero volatile u32) single_allowzero_volatile = 0x0000000000001028258 \\ (*allowzero volatile u32) .single_allowzero_volatile = 0x0000000000001028
259 \\ (*allowzero const volatile u32) single_allowzero_const_volatile = 0x000000000000102c259 \\ (*allowzero const volatile u32) .single_allowzero_const_volatile = 0x000000000000102c
260 \\ ([*]u32) many = 0x0000000000002010260 \\ ([*]u32) .many = 0x0000000000002010
261 \\ ([*]const u32) many_const = 0x0000000000002014261 \\ ([*]const u32) .many_const = 0x0000000000002014
262 \\ ([*]volatile u32) many_volatile = 0x0000000000002018262 \\ ([*]volatile u32) .many_volatile = 0x0000000000002018
263 \\ ([*]const volatile u32) many_const_volatile = 0x000000000000201c263 \\ ([*]const volatile u32) .many_const_volatile = 0x000000000000201c
264 \\ ([*]allowzero u32) many_allowzero = 0x0000000000002020264 \\ ([*]allowzero u32) .many_allowzero = 0x0000000000002020
265 \\ ([*]allowzero const u32) many_allowzero_const = 0x0000000000002024265 \\ ([*]allowzero const u32) .many_allowzero_const = 0x0000000000002024
266 \\ ([*]allowzero volatile u32) many_allowzero_volatile = 0x0000000000002028266 \\ ([*]allowzero volatile u32) .many_allowzero_volatile = 0x0000000000002028
267 \\ ([*]allowzero const volatile u32) many_allowzero_const_volatile = 0x000000000000202c267 \\ ([*]allowzero const volatile u32) .many_allowzero_const_volatile = 0x000000000000202c
268 \\ ([]u32) slice = len=1 {268 \\ ([]u32) .slice = len=1 {
269 \\ (u32) [0] = 3010269 \\ (u32) [0] = 3010
270 \\ }270 \\ }
271 \\ ([]const u32) slice_const = len=2 {271 \\ ([]const u32) .slice_const = len=2 {
272 \\ (u32) [0] = 3010272 \\ (u32) [0] = 3010
273 \\ (u32) [1] = 3014273 \\ (u32) [1] = 3014
274 \\ }274 \\ }
275 \\ ([]volatile u32) slice_volatile = len=3 {275 \\ ([]volatile u32) .slice_volatile = len=3 {
276 \\ (u32) [0] = 3010276 \\ (u32) [0] = 3010
277 \\ (u32) [1] = 3014277 \\ (u32) [1] = 3014
278 \\ (u32) [2] = 3018278 \\ (u32) [2] = 3018
279 \\ }279 \\ }
280 \\ ([]const volatile u32) slice_const_volatile = len=4 {280 \\ ([]const volatile u32) .slice_const_volatile = len=4 {
281 \\ (u32) [0] = 3010281 \\ (u32) [0] = 3010
282 \\ (u32) [1] = 3014282 \\ (u32) [1] = 3014
283 \\ (u32) [2] = 3018283 \\ (u32) [2] = 3018
284 \\ (u32) [3] = 3022284 \\ (u32) [3] = 3022
285 \\ }285 \\ }
286 \\ ([]allowzero u32) slice_allowzero = len=0 {}286 \\ ([]allowzero u32) .slice_allowzero = len=0 {}
287 \\ ([]allowzero const u32) slice_allowzero_const = len=1 {287 \\ ([]allowzero const u32) .slice_allowzero_const = len=1 {
288 \\ (u32) [0] = 3026288 \\ (u32) [0] = 3026
289 \\ }289 \\ }
290 \\ ([]allowzero volatile u32) slice_allowzero_volatile = len=2 {290 \\ ([]allowzero volatile u32) .slice_allowzero_volatile = len=2 {
291 \\ (u32) [0] = 3026291 \\ (u32) [0] = 3026
292 \\ (u32) [1] = 3030292 \\ (u32) [1] = 3030
293 \\ }293 \\ }
294 \\ ([]allowzero const volatile u32) slice_allowzero_const_volatile = len=3 {294 \\ ([]allowzero const volatile u32) .slice_allowzero_const_volatile = len=3 {
295 \\ (u32) [0] = 3026295 \\ (u32) [0] = 3026
296 \\ (u32) [1] = 3030296 \\ (u32) [1] = 3030
297 \\ (u32) [2] = 3034297 \\ (u32) [2] = 3034
298 \\ }298 \\ }
299 \\ ([*c]u32) c = 0x0000000000004010299 \\ ([*c]u32) .c = 0x0000000000004010
300 \\ ([*c]const u32) c_const = 0x0000000000004014300 \\ ([*c]const u32) .c_const = 0x0000000000004014
301 \\ ([*c]volatile u32) c_volatile = 0x0000000000004018301 \\ ([*c]volatile u32) .c_volatile = 0x0000000000004018
302 \\ ([*c]const volatile u32) c_const_volatile = 0x000000000000401c302 \\ ([*c]const volatile u32) .c_const_volatile = 0x000000000000401c
303 \\}303 \\}
304 \\(lldb) breakpoint delete --force 1304 \\(lldb) breakpoint delete --force 1
305 \\1 breakpoints deleted; 0 breakpoint locations disabled.305 \\1 breakpoints deleted; 0 breakpoint locations disabled.
...@@ -362,10 +362,10 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -362,10 +362,10 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
362 \\}362 \\}
363 \\(lldb) frame variable --show-types --format c-string -- strings363 \\(lldb) frame variable --show-types --format c-string -- strings
364 \\(root.strings.Strings) strings = {364 \\(root.strings.Strings) strings = {
365 \\ ([*c]const u8) c_ptr = "c_ptr\x07\x08\t"365 \\ ([*c]const u8) .c_ptr = "c_ptr\x07\x08\t"
366 \\ ([*:0]const u8) many_ptr = "many_ptr\n\x0b\x0c"366 \\ ([*:0]const u8) .many_ptr = "many_ptr\n\x0b\x0c"
367 \\ (*const [12:0]u8) ptr_array = "ptr_array\x00\r\x1b"367 \\ (*const [12:0]u8) .ptr_array = "ptr_array\x00\r\x1b"
368 \\ ([:0]const u8) slice = "slice\"\'\\\x00" len=9 {368 \\ ([:0]const u8) .slice = "slice\"\'\\\x00" len=9 {
369 \\ (u8) [0] = "s"369 \\ (u8) [0] = "s"
370 \\ (u8) [1] = "l"370 \\ (u8) [1] = "l"
371 \\ (u8) [2] = "i"371 \\ (u8) [2] = "i"
...@@ -434,10 +434,10 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -434,10 +434,10 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
434 \\}434 \\}
435 \\(lldb) frame variable --show-types -- enums435 \\(lldb) frame variable --show-types -- enums
436 \\(root.enums.Enums) enums = {436 \\(root.enums.Enums) enums = {
437 \\ (root.enums.Enums.Zero) zero = @enumFromInt(13)437 \\ (root.enums.Enums.Zero) .zero = @enumFromInt(13)
438 \\ (root.enums.Enums.One) one = .first438 \\ (root.enums.Enums.One) .one = .first
439 \\ (root.enums.Enums.Two) two = @enumFromInt(-1234)439 \\ (root.enums.Enums.Two) .two = @enumFromInt(-1234)
440 \\ (root.enums.Enums.Three) three = .second440 \\ (root.enums.Enums.Three) .three = .second
441 \\}441 \\}
442 \\(lldb) breakpoint delete --force 1442 \\(lldb) breakpoint delete --force 1
443 \\1 breakpoints deleted; 0 breakpoint locations disabled.443 \\1 breakpoints deleted; 0 breakpoint locations disabled.
...@@ -498,15 +498,15 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -498,15 +498,15 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
498 \\}498 \\}
499 \\(lldb) frame variable --show-types -- errors499 \\(lldb) frame variable --show-types -- errors
500 \\(root.errors.Errors) errors = {500 \\(root.errors.Errors) errors = {
501 \\ (error{One}) one = error.One501 \\ (error{One}) .one = error.One
502 \\ (error{One,Two}) two = error.Two502 \\ (error{One,Two}) .two = error.Two
503 \\ (error{One,Two,Three}) three = error.Three503 \\ (error{One,Two,Three}) .three = error.Three
504 \\ (anyerror) any = error.Any504 \\ (anyerror) .any = error.Any
505 \\ (anyerror!void) any_void = {505 \\ (anyerror!void) .any_void = {
506 \\ (anyerror) error = error.NotVoid506 \\ (anyerror) .error = error.NotVoid
507 \\ }507 \\ }
508 \\ (error{One}!u32) any_u32 = {508 \\ (error{One}!u32) .any_u32 = {
509 \\ (u32) value = 42509 \\ (u32) .value = 42
510 \\ }510 \\ }
511 \\}511 \\}
512 \\(lldb) breakpoint delete --force 1512 \\(lldb) breakpoint delete --force 1
...@@ -630,17 +630,17 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -630,17 +630,17 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
630 \\}630 \\}
631 \\(lldb) frame variable --show-types -- unions631 \\(lldb) frame variable --show-types -- unions
632 \\(root.unions.Unions) unions = {632 \\(root.unions.Unions) unions = {
633 \\ (root.unions.Unions.Untagged) untagged = {633 \\ (root.unions.Unions.Untagged) .untagged = {
634 \\ (u32) u32 = 3217031168634 \\ (u32) .u32 = 3217031168
635 \\ (i32) i32 = -1077936128635 \\ (i32) .i32 = -1077936128
636 \\ (f32) f32 = -1.5636 \\ (f32) .f32 = -1.5
637 \\ }637 \\ }
638 \\ (root.unions.Unions.SafetyTagged) safety_tagged = {638 \\ (root.unions.Unions.SafetyTagged) .safety_tagged = {
639 \\ (root.unions.Unions.Enum) en = .second639 \\ (root.unions.Unions.Enum) .en = .second
640 \\ }640 \\ }
641 \\ (root.unions.Unions.Tagged) tagged = {641 \\ (root.unions.Unions.Tagged) .tagged = {
642 \\ (error{Error}!root.unions.Unions.Enum) eu = {642 \\ (error{Error}!root.unions.Unions.Enum) .eu = {
643 \\ (error{Error}) error = error.Error643 \\ (error{Error}) .error = error.Error
644 \\ }644 \\ }
645 \\ }645 \\ }
646 \\}646 \\}
...@@ -721,6 +721,93 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -721,6 +721,93 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
721 \\1 breakpoints deleted; 0 breakpoint locations disabled.721 \\1 breakpoints deleted; 0 breakpoint locations disabled.
722 },722 },
723 );723 );
724 db.addLldbTest(
725 "if_blocks",
726 target,
727 &.{
728 .{
729 .path = "if_blocks.zig",
730 .source =
731 \\pub fn main() void {
732 \\ for (0..2) |i| {
733 \\ if (i == 0) {
734 \\ var x: u32 = 123;
735 \\ _ = &x;
736 \\ } else {
737 \\ var x: f32 = 4.5;
738 \\ _ = &x;
739 \\ }
740 \\ }
741 \\}
742 \\
743 ,
744 },
745 },
746 \\breakpoint set --file if_blocks.zig --source-pattern-regexp '_ = &x;'
747 \\process launch
748 \\frame variable
749 \\process continue
750 \\frame variable
751 \\breakpoint delete --force 1
752 ,
753 &.{
754 \\(lldb) frame variable
755 \\(usize) i = 0
756 \\(u32) x = 123
757 \\(lldb) process continue
758 ,
759 \\(lldb) frame variable
760 \\(usize) i = 1
761 \\(f32) x = 4.5
762 \\(lldb) breakpoint delete --force 1
763 \\1 breakpoints deleted; 0 breakpoint locations disabled.
764 },
765 );
766 db.addLldbTest(
767 "switch_blocks",
768 target,
769 &.{
770 .{
771 .path = "switch_blocks.zig",
772 .source =
773 \\pub fn main() void {
774 \\ for (0..2) |i| {
775 \\ switch (i) {
776 \\ 0 => {
777 \\ var x: u32 = 123;
778 \\ _ = &x;
779 \\ },
780 \\ else => {
781 \\ var x: f32 = 4.5;
782 \\ _ = &x;
783 \\ },
784 \\ }
785 \\ }
786 \\}
787 \\
788 ,
789 },
790 },
791 \\breakpoint set --file switch_blocks.zig --source-pattern-regexp '_ = &x;'
792 \\process launch
793 \\frame variable
794 \\process continue
795 \\frame variable
796 \\breakpoint delete --force 1
797 ,
798 &.{
799 \\(lldb) frame variable
800 \\(usize) i = 0
801 \\(u32) x = 123
802 \\(lldb) process continue
803 ,
804 \\(lldb) frame variable
805 \\(usize) i = 1
806 \\(f32) x = 4.5
807 \\(lldb) breakpoint delete --force 1
808 \\1 breakpoints deleted; 0 breakpoint locations disabled.
809 },
810 );
724 db.addLldbTest(811 db.addLldbTest(
725 "inline_call",812 "inline_call",
726 target,813 target,
...@@ -1370,24 +1457,24 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -1370,24 +1457,24 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
1370 \\(lldb) frame variable --show-types -- map.unmanaged1457 \\(lldb) frame variable --show-types -- map.unmanaged
1371 \\(std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63)) map.unmanaged = len=5 capacity=16 {1458 \\(std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63)) map.unmanaged = len=5 capacity=16 {
1372 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [0] = {1459 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [0] = {
1373 \\ (u32) key = 01460 \\ (u32) .key = 0
1374 \\ (u32) value = 11461 \\ (u32) .value = 1
1375 \\ }1462 \\ }
1376 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [1] = {1463 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [1] = {
1377 \\ (u32) key = 21464 \\ (u32) .key = 2
1378 \\ (u32) value = 31465 \\ (u32) .value = 3
1379 \\ }1466 \\ }
1380 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [2] = {1467 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [2] = {
1381 \\ (u32) key = 41468 \\ (u32) .key = 4
1382 \\ (u32) value = 51469 \\ (u32) .value = 5
1383 \\ }1470 \\ }
1384 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [3] = {1471 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [3] = {
1385 \\ (u32) key = 61472 \\ (u32) .key = 6
1386 \\ (u32) value = 71473 \\ (u32) .value = 7
1387 \\ }1474 \\ }
1388 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [4] = {1475 \\ (std.hash_map.HashMapUnmanaged(u32,u32,main.Context,63).KV) [4] = {
1389 \\ (u32) key = 81476 \\ (u32) .key = 8
1390 \\ (u32) value = 91477 \\ (u32) .value = 9
1391 \\ }1478 \\ }
1392 \\}1479 \\}
1393 \\(lldb) breakpoint delete --force 11480 \\(lldb) breakpoint delete --force 1
...@@ -1447,37 +1534,37 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -1447,37 +1534,37 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
1447 \\(lldb) frame variable --show-types -- list0 list0.len list0.capacity list0[0] list0[1] list0[2] list0.0 list0.1 list0.21534 \\(lldb) frame variable --show-types -- list0 list0.len list0.capacity list0[0] list0[1] list0[2] list0.0 list0.1 list0.2
1448 \\(std.multi_array_list.MultiArrayList(main.Elem0)) list0 = len=3 capacity=8 {1535 \\(std.multi_array_list.MultiArrayList(main.Elem0)) list0 = len=3 capacity=8 {
1449 \\ (root.main.Elem0) [0] = {1536 \\ (root.main.Elem0) [0] = {
1450 \\ (u32) 0 = 11537 \\ (u32) .@"0" = 1
1451 \\ (u8) 1 = 21538 \\ (u8) .@"1" = 2
1452 \\ (u16) 2 = 31539 \\ (u16) .@"2" = 3
1453 \\ }1540 \\ }
1454 \\ (root.main.Elem0) [1] = {1541 \\ (root.main.Elem0) [1] = {
1455 \\ (u32) 0 = 41542 \\ (u32) .@"0" = 4
1456 \\ (u8) 1 = 51543 \\ (u8) .@"1" = 5
1457 \\ (u16) 2 = 61544 \\ (u16) .@"2" = 6
1458 \\ }1545 \\ }
1459 \\ (root.main.Elem0) [2] = {1546 \\ (root.main.Elem0) [2] = {
1460 \\ (u32) 0 = 71547 \\ (u32) .@"0" = 7
1461 \\ (u8) 1 = 81548 \\ (u8) .@"1" = 8
1462 \\ (u16) 2 = 91549 \\ (u16) .@"2" = 9
1463 \\ }1550 \\ }
1464 \\}1551 \\}
1465 \\(usize) list0.len = 31552 \\(usize) list0.len = 3
1466 \\(usize) list0.capacity = 81553 \\(usize) list0.capacity = 8
1467 \\(root.main.Elem0) list0[0] = {1554 \\(root.main.Elem0) list0[0] = {
1468 \\ (u32) 0 = 11555 \\ (u32) .@"0" = 1
1469 \\ (u8) 1 = 21556 \\ (u8) .@"1" = 2
1470 \\ (u16) 2 = 31557 \\ (u16) .@"2" = 3
1471 \\}1558 \\}
1472 \\(root.main.Elem0) list0[1] = {1559 \\(root.main.Elem0) list0[1] = {
1473 \\ (u32) 0 = 41560 \\ (u32) .@"0" = 4
1474 \\ (u8) 1 = 51561 \\ (u8) .@"1" = 5
1475 \\ (u16) 2 = 61562 \\ (u16) .@"2" = 6
1476 \\}1563 \\}
1477 \\(root.main.Elem0) list0[2] = {1564 \\(root.main.Elem0) list0[2] = {
1478 \\ (u32) 0 = 71565 \\ (u32) .@"0" = 7
1479 \\ (u8) 1 = 81566 \\ (u8) .@"1" = 8
1480 \\ (u16) 2 = 91567 \\ (u16) .@"2" = 9
1481 \\}1568 \\}
1482 \\([3]u32) list0.0 = {1569 \\([3]u32) list0.0 = {
1483 \\ (u32) [0] = 11570 \\ (u32) [0] = 1
...@@ -1497,37 +1584,37 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -1497,37 +1584,37 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
1497 \\(lldb) frame variable --show-types -- slice0 slice0.len slice0.capacity slice0[0] slice0[1] slice0[2] slice0.0 slice0.1 slice0.21584 \\(lldb) frame variable --show-types -- slice0 slice0.len slice0.capacity slice0[0] slice0[1] slice0[2] slice0.0 slice0.1 slice0.2
1498 \\(std.multi_array_list.MultiArrayList(main.Elem0).Slice) slice0 = len=3 capacity=8 {1585 \\(std.multi_array_list.MultiArrayList(main.Elem0).Slice) slice0 = len=3 capacity=8 {
1499 \\ (root.main.Elem0) [0] = {1586 \\ (root.main.Elem0) [0] = {
1500 \\ (u32) 0 = 11587 \\ (u32) .@"0" = 1
1501 \\ (u8) 1 = 21588 \\ (u8) .@"1" = 2
1502 \\ (u16) 2 = 31589 \\ (u16) .@"2" = 3
1503 \\ }1590 \\ }
1504 \\ (root.main.Elem0) [1] = {1591 \\ (root.main.Elem0) [1] = {
1505 \\ (u32) 0 = 41592 \\ (u32) .@"0" = 4
1506 \\ (u8) 1 = 51593 \\ (u8) .@"1" = 5
1507 \\ (u16) 2 = 61594 \\ (u16) .@"2" = 6
1508 \\ }1595 \\ }
1509 \\ (root.main.Elem0) [2] = {1596 \\ (root.main.Elem0) [2] = {
1510 \\ (u32) 0 = 71597 \\ (u32) .@"0" = 7
1511 \\ (u8) 1 = 81598 \\ (u8) .@"1" = 8
1512 \\ (u16) 2 = 91599 \\ (u16) .@"2" = 9
1513 \\ }1600 \\ }
1514 \\}1601 \\}
1515 \\(usize) slice0.len = 31602 \\(usize) slice0.len = 3
1516 \\(usize) slice0.capacity = 81603 \\(usize) slice0.capacity = 8
1517 \\(root.main.Elem0) slice0[0] = {1604 \\(root.main.Elem0) slice0[0] = {
1518 \\ (u32) 0 = 11605 \\ (u32) .@"0" = 1
1519 \\ (u8) 1 = 21606 \\ (u8) .@"1" = 2
1520 \\ (u16) 2 = 31607 \\ (u16) .@"2" = 3
1521 \\}1608 \\}
1522 \\(root.main.Elem0) slice0[1] = {1609 \\(root.main.Elem0) slice0[1] = {
1523 \\ (u32) 0 = 41610 \\ (u32) .@"0" = 4
1524 \\ (u8) 1 = 51611 \\ (u8) .@"1" = 5
1525 \\ (u16) 2 = 61612 \\ (u16) .@"2" = 6
1526 \\}1613 \\}
1527 \\(root.main.Elem0) slice0[2] = {1614 \\(root.main.Elem0) slice0[2] = {
1528 \\ (u32) 0 = 71615 \\ (u32) .@"0" = 7
1529 \\ (u8) 1 = 81616 \\ (u8) .@"1" = 8
1530 \\ (u16) 2 = 91617 \\ (u16) .@"2" = 9
1531 \\}1618 \\}
1532 \\([3]u32) slice0.0 = {1619 \\([3]u32) slice0.0 = {
1533 \\ (u32) [0] = 11620 \\ (u32) [0] = 1
...@@ -1547,37 +1634,37 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -1547,37 +1634,37 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
1547 \\(lldb) frame variable --show-types -- list1 list1.len list1.capacity list1[0] list1[1] list1[2] list1.a list1.b list1.c1634 \\(lldb) frame variable --show-types -- list1 list1.len list1.capacity list1[0] list1[1] list1[2] list1.a list1.b list1.c
1548 \\(std.multi_array_list.MultiArrayList(main.Elem1)) list1 = len=3 capacity=12 {1635 \\(std.multi_array_list.MultiArrayList(main.Elem1)) list1 = len=3 capacity=12 {
1549 \\ (root.main.Elem1) [0] = {1636 \\ (root.main.Elem1) [0] = {
1550 \\ (u32) a = 11637 \\ (u32) .a = 1
1551 \\ (u8) b = 21638 \\ (u8) .b = 2
1552 \\ (u16) c = 31639 \\ (u16) .c = 3
1553 \\ }1640 \\ }
1554 \\ (root.main.Elem1) [1] = {1641 \\ (root.main.Elem1) [1] = {
1555 \\ (u32) a = 41642 \\ (u32) .a = 4
1556 \\ (u8) b = 51643 \\ (u8) .b = 5
1557 \\ (u16) c = 61644 \\ (u16) .c = 6
1558 \\ }1645 \\ }
1559 \\ (root.main.Elem1) [2] = {1646 \\ (root.main.Elem1) [2] = {
1560 \\ (u32) a = 71647 \\ (u32) .a = 7
1561 \\ (u8) b = 81648 \\ (u8) .b = 8
1562 \\ (u16) c = 91649 \\ (u16) .c = 9
1563 \\ }1650 \\ }
1564 \\}1651 \\}
1565 \\(usize) list1.len = 31652 \\(usize) list1.len = 3
1566 \\(usize) list1.capacity = 121653 \\(usize) list1.capacity = 12
1567 \\(root.main.Elem1) list1[0] = {1654 \\(root.main.Elem1) list1[0] = {
1568 \\ (u32) a = 11655 \\ (u32) .a = 1
1569 \\ (u8) b = 21656 \\ (u8) .b = 2
1570 \\ (u16) c = 31657 \\ (u16) .c = 3
1571 \\}1658 \\}
1572 \\(root.main.Elem1) list1[1] = {1659 \\(root.main.Elem1) list1[1] = {
1573 \\ (u32) a = 41660 \\ (u32) .a = 4
1574 \\ (u8) b = 51661 \\ (u8) .b = 5
1575 \\ (u16) c = 61662 \\ (u16) .c = 6
1576 \\}1663 \\}
1577 \\(root.main.Elem1) list1[2] = {1664 \\(root.main.Elem1) list1[2] = {
1578 \\ (u32) a = 71665 \\ (u32) .a = 7
1579 \\ (u8) b = 81666 \\ (u8) .b = 8
1580 \\ (u16) c = 91667 \\ (u16) .c = 9
1581 \\}1668 \\}
1582 \\([3]u32) list1.a = {1669 \\([3]u32) list1.a = {
1583 \\ (u32) [0] = 11670 \\ (u32) [0] = 1
...@@ -1597,37 +1684,37 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {...@@ -1597,37 +1684,37 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
1597 \\(lldb) frame variable --show-types -- slice1 slice1.len slice1.capacity slice1[0] slice1[1] slice1[2] slice1.a slice1.b slice1.c1684 \\(lldb) frame variable --show-types -- slice1 slice1.len slice1.capacity slice1[0] slice1[1] slice1[2] slice1.a slice1.b slice1.c
1598 \\(std.multi_array_list.MultiArrayList(main.Elem1).Slice) slice1 = len=3 capacity=12 {1685 \\(std.multi_array_list.MultiArrayList(main.Elem1).Slice) slice1 = len=3 capacity=12 {
1599 \\ (root.main.Elem1) [0] = {1686 \\ (root.main.Elem1) [0] = {
1600 \\ (u32) a = 11687 \\ (u32) .a = 1
1601 \\ (u8) b = 21688 \\ (u8) .b = 2
1602 \\ (u16) c = 31689 \\ (u16) .c = 3
1603 \\ }1690 \\ }
1604 \\ (root.main.Elem1) [1] = {1691 \\ (root.main.Elem1) [1] = {
1605 \\ (u32) a = 41692 \\ (u32) .a = 4
1606 \\ (u8) b = 51693 \\ (u8) .b = 5
1607 \\ (u16) c = 61694 \\ (u16) .c = 6
1608 \\ }1695 \\ }
1609 \\ (root.main.Elem1) [2] = {1696 \\ (root.main.Elem1) [2] = {
1610 \\ (u32) a = 71697 \\ (u32) .a = 7
1611 \\ (u8) b = 81698 \\ (u8) .b = 8
1612 \\ (u16) c = 91699 \\ (u16) .c = 9
1613 \\ }1700 \\ }
1614 \\}1701 \\}
1615 \\(usize) slice1.len = 31702 \\(usize) slice1.len = 3
1616 \\(usize) slice1.capacity = 121703 \\(usize) slice1.capacity = 12
1617 \\(root.main.Elem1) slice1[0] = {1704 \\(root.main.Elem1) slice1[0] = {
1618 \\ (u32) a = 11705 \\ (u32) .a = 1
1619 \\ (u8) b = 21706 \\ (u8) .b = 2
1620 \\ (u16) c = 31707 \\ (u16) .c = 3
1621 \\}1708 \\}
1622 \\(root.main.Elem1) slice1[1] = {1709 \\(root.main.Elem1) slice1[1] = {
1623 \\ (u32) a = 41710 \\ (u32) .a = 4
1624 \\ (u8) b = 51711 \\ (u8) .b = 5
1625 \\ (u16) c = 61712 \\ (u16) .c = 6
1626 \\}1713 \\}
1627 \\(root.main.Elem1) slice1[2] = {1714 \\(root.main.Elem1) slice1[2] = {
1628 \\ (u32) a = 71715 \\ (u32) .a = 7
1629 \\ (u8) b = 81716 \\ (u8) .b = 8
1630 \\ (u16) c = 91717 \\ (u16) .c = 9
1631 \\}1718 \\}
1632 \\([3]u32) slice1.a = {1719 \\([3]u32) slice1.a = {
1633 \\ (u32) [0] = 11720 \\ (u32) [0] = 1
tools/lldb_pretty_printers.py+8-5
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1# pretty printing for the zig language, zig standard library, and zig stage 2 compiler.1# pretty printing for the zig language, zig standard library, and zig stage 2 compiler.
2# put commands in ~/.lldbinit to run them automatically when starting lldb2# put commands in ~/.lldbinit to run them automatically when starting lldb
3# `command script import /path/to/zig/tools/lldb_pretty_printers.py` to import this file3# `command script import /path/to/zig/tools/lldb_pretty_printers.py` to import this file
4# `type category enable zig` to enable pretty printing for the zig language4# `type category enable zig.lang` to enable pretty printing for the zig language
5# `type category enable zig.std` to enable pretty printing for the zig standard library5# `type category enable zig.std` to enable pretty printing for the zig standard library
6# `type category enable zig.stage2` to enable pretty printing for the zig stage 2 compiler6# `type category enable zig.stage2` to enable pretty printing for the zig stage 2 compiler
7import lldb7import lldb
...@@ -688,11 +688,14 @@ def add(debugger, *, category, regex=False, type, identifier=None, synth=False,...@@ -688,11 +688,14 @@ def add(debugger, *, category, regex=False, type, identifier=None, synth=False,
688def MultiArrayList_Entry(type): return '^multi_array_list\\.MultiArrayList\\(%s\\)\\.Entry__struct_[1-9][0-9]*$' % type688def MultiArrayList_Entry(type): return '^multi_array_list\\.MultiArrayList\\(%s\\)\\.Entry__struct_[1-9][0-9]*$' % type
689689
690def __lldb_init_module(debugger, _=None):690def __lldb_init_module(debugger, _=None):
691 # Initialize Zig Categories
692 debugger.HandleCommand('type category define --language c99 zig.lang zig.std')
693
691 # Initialize Zig Language694 # Initialize Zig Language
692 add(debugger, category='zig', regex=True, type='^\\[\\]', identifier='zig_Slice', synth=True, expand=True, summary='len=${svar%#}')695 add(debugger, category='zig.lang', regex=True, type='^\\[\\]', identifier='zig_Slice', synth=True, expand=True, summary='len=${svar%#}')
693 add(debugger, category='zig', type='[]u8', identifier='zig_String', summary=True)696 add(debugger, category='zig.lang', type='[]u8', identifier='zig_String', summary=True)
694 add(debugger, category='zig', regex=True, type='^\\?', identifier='zig_Optional', synth=True, summary=True)697 add(debugger, category='zig.lang', regex=True, type='^\\?', identifier='zig_Optional', synth=True, summary=True)
695 add(debugger, category='zig', regex=True, type='^(error{.*}|anyerror)!', identifier='zig_ErrorUnion', synth=True, inline_children=True, summary=True)698 add(debugger, category='zig.lang', regex=True, type='^(error{.*}|anyerror)!', identifier='zig_ErrorUnion', synth=True, inline_children=True, summary=True)
696699
697 # Initialize Zig Standard Library700 # Initialize Zig Standard Library
698 add(debugger, category='zig.std', type='mem.Allocator', summary='${var.ptr}')701 add(debugger, category='zig.std', type='mem.Allocator', summary='${var.ptr}')