authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-08-26 23:37:03-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-08-27 02:09:59-04:00
log8c3f6c72c07e853e28cf7226a3f76da2fd5a9c6e
treeed2f9f0159760dac8deb2dee7f546cc9929f448c
parent93cb44c80582dd02b63b02e7bb7e54d7ad8a4ebc

Dwarf: fix and test string format


8 files changed, 193 insertions(+), 64 deletions(-)

ci/x86_64-linux-debug.sh+1-1
......@@ -64,7 +64,7 @@ stage3-debug/bin/zig build \
6464
6565stage3-debug/bin/zig build test docs \
6666 --maxrss 21000000000 \
67 -Dlldb=$HOME/deps/lldb-zig/Debug-62538077d/bin/lldb \
67 -Dlldb=$HOME/deps/lldb-zig/Debug-70b8227f1/bin/lldb \
6868 -fqemu \
6969 -fwasmtime \
7070 -Dstatic-llvm \
ci/x86_64-linux-release.sh+1-1
......@@ -64,7 +64,7 @@ stage3-release/bin/zig build \
6464
6565stage3-release/bin/zig build test docs \
6666 --maxrss 21000000000 \
67 -Dlldb=$HOME/deps/lldb-zig/Release-62538077d/bin/lldb \
67 -Dlldb=$HOME/deps/lldb-zig/Release-70b8227f1/bin/lldb \
6868 -fqemu \
6969 -fwasmtime \
7070 -Dstatic-llvm \
src/Value.zig+23-41
......@@ -192,11 +192,12 @@ pub fn toBigIntAdvanced(
192192 zcu: *Zcu,
193193 tid: strat.Tid(),
194194) Zcu.CompileError!BigIntConst {
195 const ip = &zcu.intern_pool;
195196 return switch (val.toIntern()) {
196197 .bool_false => BigIntMutable.init(&space.limbs, 0).toConst(),
197198 .bool_true => BigIntMutable.init(&space.limbs, 1).toConst(),
198199 .null_value => BigIntMutable.init(&space.limbs, 0).toConst(),
199 else => switch (zcu.intern_pool.indexToKey(val.toIntern())) {
200 else => switch (ip.indexToKey(val.toIntern())) {
200201 .int => |int| switch (int.storage) {
201202 .u64, .i64, .big_int => int.storage.toBigInt(space),
202203 .lazy_align, .lazy_size => |ty| {
......@@ -214,6 +215,7 @@ pub fn toBigIntAdvanced(
214215 &space.limbs,
215216 (try val.getUnsignedIntInner(strat, zcu, tid)).?,
216217 ).toConst(),
218 .err => |err| BigIntMutable.init(&space.limbs, ip.getErrorValueIfExists(err.name).?).toConst(),
217219 else => unreachable,
218220 },
219221 };
......@@ -326,15 +328,11 @@ pub fn toBool(val: Value) bool {
326328 };
327329}
328330
329fn ptrHasIntAddr(val: Value, zcu: *Zcu) bool {
330 return zcu.intern_pool.getBackingAddrTag(val.toIntern()).? == .int;
331}
332
333331/// Write a Value's contents to `buffer`.
334332///
335333/// Asserts that buffer.len >= ty.abiSize(). The buffer is allowed to extend past
336334/// the end of the value in memory.
337pub fn writeToMemory(val: Value, ty: Type, pt: Zcu.PerThread, buffer: []u8) error{
335pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{
338336 ReinterpretDeclRef,
339337 IllDefinedMemoryLayout,
340338 Unimplemented,
......@@ -343,19 +341,25 @@ pub fn writeToMemory(val: Value, ty: Type, pt: Zcu.PerThread, buffer: []u8) erro
343341 const zcu = pt.zcu;
344342 const target = zcu.getTarget();
345343 const endian = target.cpu.arch.endian();
344 const ip = &zcu.intern_pool;
345 const ty = val.typeOf(zcu);
346346 if (val.isUndef(zcu)) {
347347 const size: usize = @intCast(ty.abiSize(zcu));
348348 @memset(buffer[0..size], 0xaa);
349349 return;
350350 }
351 const ip = &zcu.intern_pool;
352351 switch (ty.zigTypeTag(zcu)) {
353352 .Void => {},
354353 .Bool => {
355354 buffer[0] = @intFromBool(val.toBool());
356355 },
357 .Int, .Enum => {
358 const int_info = ty.intInfo(zcu);
356 .Int, .Enum, .ErrorSet, .Pointer => |tag| {
357 const int_ty = if (tag == .Pointer) int_ty: {
358 if (ty.isSlice(zcu)) return error.IllDefinedMemoryLayout;
359 if (ip.getBackingAddrTag(val.toIntern()).? != .int) return error.ReinterpretDeclRef;
360 break :int_ty Type.usize;
361 } else ty;
362 const int_info = int_ty.intInfo(zcu);
359363 const bits = int_info.bits;
360364 const byte_count: u16 = @intCast((@as(u17, bits) + 7) / 8);
361365
......@@ -379,7 +383,7 @@ pub fn writeToMemory(val: Value, ty: Type, pt: Zcu.PerThread, buffer: []u8) erro
379383 var buf_off: usize = 0;
380384 while (elem_i < len) : (elem_i += 1) {
381385 const elem_val = try val.elemValue(pt, elem_i);
382 try elem_val.writeToMemory(elem_ty, pt, buffer[buf_off..]);
386 try elem_val.writeToMemory(pt, buffer[buf_off..]);
383387 buf_off += elem_size;
384388 }
385389 },
......@@ -403,8 +407,7 @@ pub fn writeToMemory(val: Value, ty: Type, pt: Zcu.PerThread, buffer: []u8) erro
403407 .elems => |elems| elems[field_index],
404408 .repeated_elem => |elem| elem,
405409 });
406 const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[field_index]);
407 try writeToMemory(field_val, field_ty, pt, buffer[off..]);
410 try writeToMemory(field_val, pt, buffer[off..]);
408411 },
409412 .@"packed" => {
410413 const byte_count = (@as(usize, @intCast(ty.bitSize(zcu))) + 7) / 8;
......@@ -412,22 +415,6 @@ pub fn writeToMemory(val: Value, ty: Type, pt: Zcu.PerThread, buffer: []u8) erro
412415 },
413416 }
414417 },
415 .ErrorSet => {
416 const bits = zcu.errorSetBits();
417 const byte_count: u16 = @intCast((@as(u17, bits) + 7) / 8);
418
419 const name = switch (ip.indexToKey(val.toIntern())) {
420 .err => |err| err.name,
421 .error_union => |error_union| error_union.val.err_name,
422 else => unreachable,
423 };
424 var bigint_buffer: BigIntSpace = undefined;
425 const bigint = BigIntMutable.init(
426 &bigint_buffer.limbs,
427 ip.getErrorValueIfExists(name).?,
428 ).toConst();
429 bigint.writeTwosComplement(buffer[0..byte_count], endian);
430 },
431418 .Union => switch (ty.containerLayout(zcu)) {
432419 .auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already
433420 .@"extern" => {
......@@ -437,11 +424,11 @@ pub fn writeToMemory(val: Value, ty: Type, pt: Zcu.PerThread, buffer: []u8) erro
437424 const field_type = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);
438425 const field_val = try val.fieldValue(pt, field_index);
439426 const byte_count: usize = @intCast(field_type.abiSize(zcu));
440 return writeToMemory(field_val, field_type, pt, buffer[0..byte_count]);
427 return writeToMemory(field_val, pt, buffer[0..byte_count]);
441428 } else {
442429 const backing_ty = try ty.unionBackingType(pt);
443430 const byte_count: usize = @intCast(backing_ty.abiSize(zcu));
444 return writeToMemory(val.unionValue(zcu), backing_ty, pt, buffer[0..byte_count]);
431 return writeToMemory(val.unionValue(zcu), pt, buffer[0..byte_count]);
445432 }
446433 },
447434 .@"packed" => {
......@@ -450,19 +437,13 @@ pub fn writeToMemory(val: Value, ty: Type, pt: Zcu.PerThread, buffer: []u8) erro
450437 return writeToPackedMemory(val, ty, pt, buffer[0..byte_count], 0);
451438 },
452439 },
453 .Pointer => {
454 if (ty.isSlice(zcu)) return error.IllDefinedMemoryLayout;
455 if (!val.ptrHasIntAddr(zcu)) return error.ReinterpretDeclRef;
456 return val.writeToMemory(Type.usize, pt, buffer);
457 },
458440 .Optional => {
459441 if (!ty.isPtrLikeOptional(zcu)) return error.IllDefinedMemoryLayout;
460 const child = ty.optionalChild(zcu);
461442 const opt_val = val.optionalValue(zcu);
462443 if (opt_val) |some| {
463 return some.writeToMemory(child, pt, buffer);
444 return some.writeToMemory(pt, buffer);
464445 } else {
465 return writeToMemory(try pt.intValue(Type.usize, 0), Type.usize, pt, buffer);
446 return writeToMemory(try pt.intValue(Type.usize, 0), pt, buffer);
466447 }
467448 },
468449 else => return error.Unimplemented,
......@@ -582,7 +563,7 @@ pub fn writeToPackedMemory(
582563 },
583564 .Pointer => {
584565 assert(!ty.isSlice(zcu)); // No well defined layout.
585 if (!val.ptrHasIntAddr(zcu)) return error.ReinterpretDeclRef;
566 if (ip.getBackingAddrTag(val.toIntern()).? != .int) return error.ReinterpretDeclRef;
586567 return val.writeToPackedMemory(Type.usize, pt, buffer, bit_offset);
587568 },
588569 .Optional => {
......@@ -3658,14 +3639,15 @@ pub fn mulAddScalar(
36583639
36593640/// If the value is represented in-memory as a series of bytes that all
36603641/// have the same value, return that byte value, otherwise null.
3661pub fn hasRepeatedByteRepr(val: Value, ty: Type, pt: Zcu.PerThread) !?u8 {
3642pub fn hasRepeatedByteRepr(val: Value, pt: Zcu.PerThread) !?u8 {
36623643 const zcu = pt.zcu;
3644 const ty = val.typeOf(zcu);
36633645 const abi_size = std.math.cast(usize, ty.abiSize(zcu)) orelse return null;
36643646 assert(abi_size >= 1);
36653647 const byte_buffer = try zcu.gpa.alloc(u8, abi_size);
36663648 defer zcu.gpa.free(byte_buffer);
36673649
3668 writeToMemory(val, ty, pt, byte_buffer) catch |err| switch (err) {
3650 writeToMemory(val, pt, byte_buffer) catch |err| switch (err) {
36693651 error.OutOfMemory => return error.OutOfMemory,
36703652 error.ReinterpretDeclRef => return null,
36713653 // TODO: The writeToMemory function was originally created for the purpose
src/arch/wasm/CodeGen.zig+1-1
......@@ -3357,7 +3357,7 @@ fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue {
33573357 .vector_type => {
33583358 assert(determineSimdStoreStrategy(ty, zcu, func.target.*) == .direct);
33593359 var buf: [16]u8 = undefined;
3360 val.writeToMemory(ty, pt, &buf) catch unreachable;
3360 val.writeToMemory(pt, &buf) catch unreachable;
33613361 return func.storeSimdImmd(buf);
33623362 },
33633363 .struct_type => {
src/codegen/llvm.zig+1-1
......@@ -9412,7 +9412,7 @@ pub const FuncGen = struct {
94129412 // repeating byte pattern, for example, `@as(u64, 0)` has a
94139413 // repeating byte pattern of 0 bytes. In such case, the memset
94149414 // intrinsic can be used.
9415 if (try elem_val.hasRepeatedByteRepr(elem_ty, pt)) |byte_val| {
9415 if (try elem_val.hasRepeatedByteRepr(pt)) |byte_val| {
94169416 const fill_byte = try o.builder.intValue(.i8, byte_val);
94179417 const len = try self.sliceOrArrayLenInBytes(dest_slice, ptr_ty);
94189418 if (intrinsic_len0_traps) {
src/link.zig+2-1
......@@ -589,7 +589,8 @@ pub const File = struct {
589589 fs.File.WriteFileError ||
590590 fs.File.OpenError ||
591591 std.process.Child.SpawnError ||
592 fs.Dir.CopyFileError;
592 fs.Dir.CopyFileError ||
593 FlushDebugInfoError;
593594
594595 /// Commit pending changes and write headers. Takes into account final output mode
595596 /// and `use_lld`, not only `effectiveOutputMode`.
src/link/Dwarf.zig+88-18
......@@ -17,13 +17,21 @@ debug_loclists: DebugLocLists,
1717debug_rnglists: DebugRngLists,
1818debug_str: StringSection,
1919
20pub const UpdateError =
20pub const UpdateError = error{
21 ReinterpretDeclRef,
22 IllDefinedMemoryLayout,
23 Unimplemented,
24 OutOfMemory,
25 EndOfStream,
26 Overflow,
27 Underflow,
28 UnexpectedEndOfFile,
29} ||
2130 std.fs.File.OpenError ||
2231 std.fs.File.SetEndPosError ||
2332 std.fs.File.CopyRangeError ||
2433 std.fs.File.PReadError ||
25 std.fs.File.PWriteError ||
26 error{ EndOfStream, Overflow, Underflow, UnexpectedEndOfFile };
34 std.fs.File.PWriteError;
2735
2836pub const FlushError =
2937 UpdateError ||
......@@ -1401,7 +1409,7 @@ pub const WipNav = struct {
14011409 else => Type.fromInterned(loaded_enum.tag_ty).intInfo(zcu).signedness,
14021410 };
14031411 if (loaded_enum.values.len > 0) {
1404 var big_int_space: InternPool.Key.Int.Storage.BigIntSpace = undefined;
1412 var big_int_space: Value.BigIntSpace = undefined;
14051413 const big_int = ip.indexToKey(loaded_enum.values.get(ip)[field_index]).int.storage.toBigInt(&big_int_space);
14061414 const bits = @max(1, big_int.bitCountTwosCompForSignedness(signedness));
14071415 if (bits <= 64) {
......@@ -1429,9 +1437,12 @@ pub const WipNav = struct {
14291437 }
14301438 } else {
14311439 try wip_nav.abbrevCode(abbrev_code.block);
1432 const bytes = Type.fromInterned(loaded_enum.tag_ty).abiSize(wip_nav.pt.zcu);
1440 const bytes = Type.fromInterned(loaded_enum.tag_ty).abiSize(zcu);
14331441 try uleb128(diw, bytes);
1434 big_int.writeTwosComplement(try wip_nav.debug_info.addManyAsSlice(wip_nav.dwarf.gpa, @intCast(bytes)), wip_nav.dwarf.endian);
1442 big_int.writeTwosComplement(
1443 try wip_nav.debug_info.addManyAsSlice(wip_nav.dwarf.gpa, @intCast(bytes)),
1444 wip_nav.dwarf.endian,
1445 );
14351446 }
14361447 } else switch (signedness) {
14371448 .signed => {
......@@ -2566,8 +2577,17 @@ fn updateType(
25662577 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
25672578 .One, .Many, .C => {
25682579 const ptr_child_type = Type.fromInterned(ptr_type.child);
2569 try wip_nav.abbrevCode(.ptr_type);
2580 try wip_nav.abbrevCode(if (ptr_type.sentinel == .none) .ptr_type else .ptr_sentinel_type);
25702581 try wip_nav.strp(name);
2582 if (ptr_type.sentinel != .none) {
2583 const bytes = ptr_child_type.abiSize(zcu);
2584 try uleb128(diw, bytes);
2585 const mem = try wip_nav.debug_info.addManyAsSlice(dwarf.gpa, @intCast(bytes));
2586 Value.fromInterned(ptr_type.sentinel).writeToMemory(pt, mem) catch |err| switch (err) {
2587 error.IllDefinedMemoryLayout => @memset(mem, 0),
2588 else => |e| return e,
2589 };
2590 }
25712591 try uleb128(diw, ptr_type.flags.alignment.toByteUnits() orelse
25722592 ptr_child_type.abiAlignment(zcu).toByteUnits().?);
25732593 try diw.writeByte(@intFromEnum(ptr_type.flags.address_space));
......@@ -2609,16 +2629,34 @@ fn updateType(
26092629 try uleb128(diw, @intFromEnum(AbbrevCode.null));
26102630 },
26112631 },
2612 inline .array_type, .vector_type => |array_type, ty_tag| {
2613 try wip_nav.abbrevCode(.array_type);
2632 .array_type => |array_type| {
2633 const array_child_type = Type.fromInterned(array_type.child);
2634 try wip_nav.abbrevCode(if (array_type.sentinel == .none) .array_type else .array_sentinel_type);
26142635 try wip_nav.strp(name);
2615 try wip_nav.refType(Type.fromInterned(array_type.child));
2616 try diw.writeByte(@intFromBool(ty_tag == .vector_type));
2636 if (array_type.sentinel != .none) {
2637 const bytes = array_child_type.abiSize(zcu);
2638 try uleb128(diw, bytes);
2639 const mem = try wip_nav.debug_info.addManyAsSlice(dwarf.gpa, @intCast(bytes));
2640 Value.fromInterned(array_type.sentinel).writeToMemory(pt, mem) catch |err| switch (err) {
2641 error.IllDefinedMemoryLayout => @memset(mem, 0),
2642 else => |e| return e,
2643 };
2644 }
2645 try wip_nav.refType(array_child_type);
26172646 try wip_nav.abbrevCode(.array_index);
26182647 try wip_nav.refType(Type.usize);
26192648 try uleb128(diw, array_type.len);
26202649 try uleb128(diw, @intFromEnum(AbbrevCode.null));
26212650 },
2651 .vector_type => |vector_type| {
2652 try wip_nav.abbrevCode(.vector_type);
2653 try wip_nav.strp(name);
2654 try wip_nav.refType(Type.fromInterned(vector_type.child));
2655 try wip_nav.abbrevCode(.array_index);
2656 try wip_nav.refType(Type.usize);
2657 try uleb128(diw, vector_type.len);
2658 try uleb128(diw, @intFromEnum(AbbrevCode.null));
2659 },
26222660 .opt_type => |opt_child_type_index| {
26232661 const opt_child_type = Type.fromInterned(opt_child_type_index);
26242662 try wip_nav.abbrevCode(.union_type);
......@@ -2660,7 +2698,7 @@ fn updateType(
26602698 .error_set => {
26612699 try wip_nav.refType(Type.fromInterned(try pt.intern(.{ .int_type = .{
26622700 .signedness = .unsigned,
2663 .bits = pt.zcu.errorSetBits(),
2701 .bits = zcu.errorSetBits(),
26642702 } })));
26652703 try uleb128(diw, 0);
26662704 },
......@@ -2729,7 +2767,7 @@ fn updateType(
27292767 try wip_nav.strp("is_error");
27302768 try wip_nav.refType(Type.fromInterned(try pt.intern(.{ .int_type = .{
27312769 .signedness = .unsigned,
2732 .bits = pt.zcu.errorSetBits(),
2770 .bits = zcu.errorSetBits(),
27332771 } })));
27342772 try uleb128(diw, error_union_error_set_offset);
27352773
......@@ -2892,7 +2930,7 @@ fn updateType(
28922930 try wip_nav.strp(name);
28932931 try wip_nav.refType(Type.fromInterned(try pt.intern(.{ .int_type = .{
28942932 .signedness = .unsigned,
2895 .bits = pt.zcu.errorSetBits(),
2933 .bits = zcu.errorSetBits(),
28962934 } })));
28972935 for (0..error_set_type.names.len) |field_index| {
28982936 const field_name = error_set_type.names.get(ip)[field_index];
......@@ -3204,7 +3242,8 @@ fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(A
32043242}
32053243
32063244pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void {
3207 const ip = &pt.zcu.intern_pool;
3245 const zcu = pt.zcu;
3246 const ip = &zcu.intern_pool;
32083247 if (dwarf.types.get(.anyerror_type)) |entry| {
32093248 var wip_nav: WipNav = .{
32103249 .dwarf = dwarf,
......@@ -3228,7 +3267,7 @@ pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void {
32283267 try wip_nav.strp("anyerror");
32293268 try wip_nav.refType(Type.fromInterned(try pt.intern(.{ .int_type = .{
32303269 .signedness = .unsigned,
3231 .bits = pt.zcu.errorSetBits(),
3270 .bits = zcu.errorSetBits(),
32323271 } })));
32333272 for (global_error_set_names, 1..) |name, value| {
32343273 try wip_nav.abbrevCode(.unsigned_enum_field);
......@@ -3455,7 +3494,7 @@ pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void {
34553494 uleb128(header.fixedWriter(), DW.FORM.line_strp) catch unreachable;
34563495 uleb128(header.fixedWriter(), mod_info.files.count()) catch unreachable;
34573496 for (mod_info.files.keys()) |file_index| {
3458 const file = pt.zcu.fileByIndex(file_index);
3497 const file = zcu.fileByIndex(file_index);
34593498 unit.cross_section_relocs.appendAssumeCapacity(.{
34603499 .source_off = @intCast(header.items.len),
34613500 .target_sec = .debug_line_str,
......@@ -3602,9 +3641,12 @@ const AbbrevCode = enum {
36023641 numeric_type,
36033642 inferred_error_set_type,
36043643 ptr_type,
3644 ptr_sentinel_type,
36053645 is_const,
36063646 is_volatile,
36073647 array_type,
3648 array_sentinel_type,
3649 vector_type,
36083650 array_index,
36093651 nullary_func_type,
36103652 func_type,
......@@ -3913,6 +3955,16 @@ const AbbrevCode = enum {
39133955 .{ .type, .ref_addr },
39143956 },
39153957 },
3958 .ptr_sentinel_type = .{
3959 .tag = .pointer_type,
3960 .attrs = &.{
3961 .{ .name, .strp },
3962 .{ .ZIG_sentinel, .block },
3963 .{ .alignment, .udata },
3964 .{ .address_class, .data1 },
3965 .{ .type, .ref_addr },
3966 },
3967 },
39163968 .is_const = .{
39173969 .tag = .const_type,
39183970 .attrs = &.{
......@@ -3931,7 +3983,24 @@ const AbbrevCode = enum {
39313983 .attrs = &.{
39323984 .{ .name, .strp },
39333985 .{ .type, .ref_addr },
3934 .{ .GNU_vector, .flag },
3986 },
3987 },
3988 .array_sentinel_type = .{
3989 .tag = .array_type,
3990 .children = true,
3991 .attrs = &.{
3992 .{ .name, .strp },
3993 .{ .ZIG_sentinel, .block },
3994 .{ .type, .ref_addr },
3995 },
3996 },
3997 .vector_type = .{
3998 .tag = .array_type,
3999 .children = true,
4000 .attrs = &.{
4001 .{ .name, .strp },
4002 .{ .type, .ref_addr },
4003 .{ .GNU_vector, .flag_present },
39354004 },
39364005 },
39374006 .array_index = .{
......@@ -4132,6 +4201,7 @@ const Dwarf = @This();
41324201const InternPool = @import("../InternPool.zig");
41334202const Module = @import("../Package.zig").Module;
41344203const Type = @import("../Type.zig");
4204const Value = @import("../Value.zig");
41354205const Zcu = @import("../Zcu.zig");
41364206const Zir = std.zig.Zir;
41374207const assert = std.debug.assert;
test/src/Debugger.zig+76
......@@ -305,6 +305,82 @@ pub fn addTestsForTarget(db: *Debugger, target: Target) void {
305305 \\1 breakpoints deleted; 0 breakpoint locations disabled.
306306 },
307307 );
308 db.addLldbTest(
309 "strings",
310 target,
311 &.{
312 .{
313 .path = "strings.zig",
314 .source =
315 \\const Strings = struct {
316 \\ c_ptr: [*c]const u8 = "c_ptr\x07\x08\t",
317 \\ many_ptr: [*:0]const u8 = "many_ptr\n\x0b\x0c",
318 \\ ptr_array: *const [12:0]u8 = "ptr_array\x00\r\x1b",
319 \\ slice: [:0]const u8 = "slice\"\'\\\x00",
320 \\};
321 \\fn testStrings(strings: Strings) void {
322 \\ _ = strings;
323 \\}
324 \\pub fn main() void {
325 \\ testStrings(.{});
326 \\}
327 \\
328 ,
329 },
330 },
331 \\breakpoint set --file strings.zig --source-pattern-regexp '_ = strings;'
332 \\process launch
333 \\frame variable --show-types strings.slice
334 \\frame variable --show-types --format character strings.slice
335 \\frame variable --show-types --format c-string strings
336 \\breakpoint delete --force 1
337 ,
338 &.{
339 \\(lldb) frame variable --show-types strings.slice
340 \\([:0]const u8) strings.slice = len=9 {
341 \\ (u8) [0] = 115
342 \\ (u8) [1] = 108
343 \\ (u8) [2] = 105
344 \\ (u8) [3] = 99
345 \\ (u8) [4] = 101
346 \\ (u8) [5] = 34
347 \\ (u8) [6] = 39
348 \\ (u8) [7] = 92
349 \\ (u8) [8] = 0
350 \\}
351 \\(lldb) frame variable --show-types --format character strings.slice
352 \\([:0]const u8) strings.slice = len=9 {
353 \\ (u8) [0] = 's'
354 \\ (u8) [1] = 'l'
355 \\ (u8) [2] = 'i'
356 \\ (u8) [3] = 'c'
357 \\ (u8) [4] = 'e'
358 \\ (u8) [5] = '\"'
359 \\ (u8) [6] = '\''
360 \\ (u8) [7] = '\\'
361 \\ (u8) [8] = '\x00'
362 \\}
363 \\(lldb) frame variable --show-types --format c-string strings
364 \\(root.strings.Strings) strings = {
365 \\ ([*c]const u8) c_ptr = "c_ptr\x07\x08\t"
366 \\ ([*:0]const u8) many_ptr = "many_ptr\n\x0b\x0c"
367 \\ (*const [12:0]u8) ptr_array = "ptr_array\x00\r\x1b"
368 \\ ([:0]const u8) slice = "slice\"\'\\\x00" len=9 {
369 \\ (u8) [0] = "s"
370 \\ (u8) [1] = "l"
371 \\ (u8) [2] = "i"
372 \\ (u8) [3] = "c"
373 \\ (u8) [4] = "e"
374 \\ (u8) [5] = "\""
375 \\ (u8) [6] = "\'"
376 \\ (u8) [7] = "\\"
377 \\ (u8) [8] = "\x00"
378 \\ }
379 \\}
380 \\(lldb) breakpoint delete --force 1
381 \\1 breakpoints deleted; 0 breakpoint locations disabled.
382 },
383 );
308384 db.addLldbTest(
309385 "enums",
310386 target,