gdb-tools
gdb-tools copied to clipboard
Can't access struct pointers returned by functions
If a function returns a pointer to a struct, you can't access the members with ->. Basically I want that this test succeeds:
diff --git a/tests/test.cc b/tests/test.cc
index f3952f8..3c02623 100644
--- a/tests/test.cc
+++ b/tests/test.cc
@@ -19,7 +19,7 @@ struct t t0={ 0, 0, 0}, t1={ 1, 0, 0}, t2={ 2, 0, 0}, t3={ 3, 0, 0},
t4={ 4, 0, 0}, t5={ 5, 0, 0}, t6={ 6, 0, 0}, t7={ 7, 0, 0},
t8={ 8,&t0,&t1}, t9={ 9,&t2,&t3}, ta={10,&t4,&t5}, tb={11,&t6,&t7},
tc={12,&t8,&t9}, td={13,&ta,&tb}, te={14,&tc,&td}, *tree = &te;
-
+struct t *struct_pointer(void) { return &t8; }
int main()
{
diff --git a/tests/test.gdb b/tests/test.gdb
index 2bdaa0a..28be273 100644
--- a/tests/test.gdb
+++ b/tests/test.gdb
@@ -462,3 +462,5 @@ $a + $1 = 10
$_strlen(s) = 2
(gdb) dl $_regex(s, ".*[0-9]")
$_regex(s,".*[0-9]") = true
+(gdb) dl struct_pointer()->v
+struct_pointer()->v = 8
But currently I get this error:
@@ -298,4 +298,4 @@
*(char *)s = 115 's'
$_strlen(s) = 2
$_regex(s,".*[0-9]") = true
-struct_pointer()->v = 8
+Expected '&&/' or '||/' or '#/' or '+/' or '-' or '*' or '&' or '!' or '~' or '(cast)' or real or hexadecimal or decimal or octal or char or string or underscores or ident or gdbvar or '(' or '{' at position (1, 18) => 'pointer()-*>v'.