@@ -4370,6 +4370,7 @@ fn genVarDbgInfo(
4370
4370
.dwarf = > | dw | {
4371
4371
const dbg_info = & dw .dbg_info ;
4372
4372
try dbg_info .append (@enumToInt (link .File .Dwarf .AbbrevKind .variable ));
4373
+ const endian = self .target .cpu .arch .endian ();
4373
4374
4374
4375
switch (mcv ) {
4375
4376
.register = > | reg | {
@@ -4390,7 +4391,6 @@ fn genVarDbgInfo(
4390
4391
dbg_info .items [fixup ] += @intCast (u8 , dbg_info .items .len - fixup - 2 );
4391
4392
},
4392
4393
.memory , .got_load , .direct_load = > {
4393
- const endian = self .target .cpu .arch .endian ();
4394
4394
const ptr_width = @intCast (u8 , @divExact (self .target .cpu .arch .ptrBitWidth (), 8 ));
4395
4395
const is_ptr = switch (tag ) {
4396
4396
.dbg_var_ptr = > true ,
@@ -4425,7 +4425,53 @@ fn genVarDbgInfo(
4425
4425
else = > {},
4426
4426
}
4427
4427
},
4428
+ .immediate = > | x | {
4429
+ const signedness : std.builtin.Signedness = blk : {
4430
+ if (ty .zigTypeTag () != .Int ) break :blk .unsigned ;
4431
+ break :blk ty .intInfo (self .target .* ).signedness ;
4432
+ };
4433
+ try dbg_info .ensureUnusedCapacity (2 );
4434
+ const fixup = dbg_info .items .len ;
4435
+ dbg_info .appendSliceAssumeCapacity (&[2 ]u8 { // DW.AT.location, DW.FORM.exprloc
4436
+ 1 ,
4437
+ switch (signedness ) {
4438
+ .signed = > DW .OP .consts ,
4439
+ .unsigned = > DW .OP .constu ,
4440
+ },
4441
+ });
4442
+ switch (signedness ) {
4443
+ .signed = > try leb128 .writeILEB128 (dbg_info .writer (), @bitCast (i64 , x )),
4444
+ .unsigned = > try leb128 .writeULEB128 (dbg_info .writer (), x ),
4445
+ }
4446
+ try dbg_info .append (DW .OP .stack_value );
4447
+ dbg_info .items [fixup ] += @intCast (u8 , dbg_info .items .len - fixup - 2 );
4448
+ },
4449
+ .undef = > {
4450
+ // DW.AT.location, DW.FORM.exprloc
4451
+ // uleb128(exprloc_len)
4452
+ // DW.OP.implicit_value uleb128(len_of_bytes) bytes
4453
+ const abi_size = @intCast (u32 , ty .abiSize (self .target .* ));
4454
+ var implicit_value_len = std .ArrayList (u8 ).init (self .gpa );
4455
+ defer implicit_value_len .deinit ();
4456
+ try leb128 .writeULEB128 (implicit_value_len .writer (), abi_size );
4457
+ const total_exprloc_len = 1 + implicit_value_len .items .len + abi_size ;
4458
+ try leb128 .writeULEB128 (dbg_info .writer (), total_exprloc_len );
4459
+ try dbg_info .ensureUnusedCapacity (total_exprloc_len );
4460
+ dbg_info .appendAssumeCapacity (DW .OP .implicit_value );
4461
+ dbg_info .appendSliceAssumeCapacity (implicit_value_len .items );
4462
+ dbg_info .appendNTimesAssumeCapacity (0xaa , abi_size );
4463
+ },
4464
+ .none = > {
4465
+ try dbg_info .ensureUnusedCapacity (3 );
4466
+ dbg_info .appendSliceAssumeCapacity (&[3 ]u8 { // DW.AT.location, DW.FORM.exprloc
4467
+ 2 , DW .OP .lit0 , DW .OP .stack_value ,
4468
+ });
4469
+ },
4428
4470
else = > {
4471
+ try dbg_info .ensureUnusedCapacity (2 );
4472
+ dbg_info .appendSliceAssumeCapacity (&[2 ]u8 { // DW.AT.location, DW.FORM.exprloc
4473
+ 1 , DW .OP .nop ,
4474
+ });
4429
4475
log .debug ("TODO generate debug info for {}" , .{mcv });
4430
4476
},
4431
4477
}
0 commit comments