Skip to content

Commit 76ae040

Browse files
authored
v.debug: fix $dbg with @[heap] structs (fix #23979) (#23989)
1 parent a9a96b8 commit 76ae040

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

vlib/v/debug/tests/struct_heap.expect

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env expect
2+
source "common.tcl"
3+
4+
expect "Break on * main in ${test_file}:8"
5+
expect "${test_file}:8 vdbg> "
6+
send "p st\n"
7+
expect "st = AStruct{\r\n a: 1\r\n} (main.AStruct)"
8+
expect "${test_file}:8 vdbg> "
9+
send "q\n"
10+
expect eof

vlib/v/debug/tests/struct_heap.vv

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@[heap]
2+
struct AStruct {
3+
a int
4+
}
5+
6+
fn main() {
7+
st := AStruct{1}
8+
$dbg;
9+
dump(st)
10+
}

vlib/v/gen/c/cgen.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4527,6 +4527,8 @@ fn (mut g Gen) debugger_stmt(node ast.DebuggerStmt) {
45274527
'&'
45284528
} else if !str_method_expects_ptr && obj.typ.is_ptr() {
45294529
'*'.repeat(obj.typ.nr_muls())
4530+
} else if !str_method_expects_ptr && obj_sym.is_heap() {
4531+
'*'
45304532
} else if obj.is_auto_heap && var_typ.is_ptr() && str_method_expects_ptr {
45314533
'*'
45324534
} else if !obj.is_auto_heap && var_typ.is_ptr() && str_method_expects_ptr {

0 commit comments

Comments
 (0)