Bug 16084 - -var-info-path-expression fails for nested structs
Summary: -var-info-path-expression fails for nested structs
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: mi (show other bugs)
Version: 7.6
: P2 normal
Target Milestone: 7.9
Assignee: Andrew Burgess
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-25 11:47 UTC by markus maghörndl
Modified: 2014-10-31 19:13 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description markus maghörndl 2013-10-25 11:47:18 UTC
-var-info-path-expression does not take into account the type tag of a nested struct.

Environment:
GDB 7.6 "--host=i686-pc-mingw32 --target=i386-wrs-vxworks".
No Python

Code to reproduce:
struct
{
	int a;
	struct _B
	{
		 int b [4];
 	} B;
} A[] = {1, { 2,3,4,5 } };

MI log from a CDT Session:
105,320 44-var-create --thread 3 --frame 0 - * A
105,323 44^done,name="var1",numchild="1",value="[1]",type="struct {...} [1]",has_more="0"
105,323 (gdb) 
105,324 45-var-create --thread 3 --frame 0 - * &(A)
105,333 45^done,name="var2",numchild="1",value="0x35ff4ec <A>",type="struct {...} (*)[1]",has_more="\
0"
105,333 (gdb) 
109,995 46-var-create --thread 3 --frame 0 - * A[0]
110,003 46^done,name="var3",numchild="2",value="{...}",type="struct {...}",has_more="0"
110,003 (gdb) 
112,040 47-var-list-children var3
112,069 47^done,numchild="2",children=[child={name="var3.a",exp="a",numchild="0",type="int"},child={\
name="var3.B",exp="B",numchild="1",type="struct _B"}],has_more="0"
112,082 (gdb) 
112,083 48-var-info-path-expression var3.a
112,083 49-var-info-path-expression var3.B
112,084 48^done,path_expr="(A[0]).a"
112,084 (gdb) 
112,084 49^done,path_expr="(A[0]).B"
112,084 (gdb) 
112,087 50-var-evaluate-expression var3.a
112,094 50^done,value="1"
112,094 (gdb) 
113,344 51-var-list-children var3.B
113,354 51^done,numchild="1",children=[child={name="var3.B.b",exp="b",numchild="4",type="char [4]"}]\
,has_more="0"
113,354 (gdb) 
113,355 52-var-info-path-expression var3.B.b
113,364 52^done,path_expr="(A[0]).b"
113,364 (gdb) 
113,368 53-var-create --thread 3 --frame 0 - * &((A[0]).b)
113,374 53^error,msg="Type struct {...} has no component named b."
113,374 (gdb) 


Expected Behaviour:
-var-info-path-expression var3.B.b should return the following(full path):
52^done,path_expr="((A[0]).B).b"

The following Patch fixes that behaviour, but I don't know what it might cause for sideefects:

Index: varobj.c
===================================================================
--- varobj.c	(revision 43031)
+++ varobj.c	(working copy)
@@ -1385,7 +1385,7 @@
   /* Anonymous unions and structs are also not path_expr parents.  */
   return !((TYPE_CODE (type) == TYPE_CODE_STRUCT
 	    || TYPE_CODE (type) == TYPE_CODE_UNION)
-	   && TYPE_NAME (type) == NULL);
+	   && TYPE_NAME (type) == NULL && TYPE_TAG_NAME (type) == NULL);
 }
 
 /* Return the path expression parent for VAR.  */