This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Problem with MI -var-evaluate-expression command
- From: Mo DeJong <supermo at bayarea dot net>
- To: gdb <gdb at sources dot redhat dot com>
- Date: Wed, 10 Jul 2002 17:19:57 -0700
- Subject: Problem with MI -var-evaluate-expression command
- Organization: House of Mirth
Hello gdbers.
I have been looking at the GDB/MI recently and have run into a problem
with the -var-evaluate-expression method that really seems like a bug.
It seems one is unable to access children of a variable object unless
the -var-list-children command has been run for that object. Here
is a quick example to demonstrate what I mean.
% cat S.c
struct S {
int v1;
int v2;
};
int main() {
struct S* s = (struct S*) malloc(sizeof(struct S));
s->v1 = 0;
s->v2 = 1;
return 0;
}
(compile, then invoke with mi1)
-file-exec-and-symbols S
^done
(gdb)
-break-insert S.c:9
^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x080483ee",func="main",file="S.c",line="9",times="0"}
(gdb)
-var-create svar * "(struct S *) 0x8049560"
^done,name="svar",numchild="2",type="struct S *"
(gdb)
# I can access the variable
-var-evaluate-expression svar
^done,value="0x8049560"
(gdb)
# But not the a child variable
-var-evaluate-expression svar.v1
&"Variable object not found\n"
^error,msg="Variable object not found"
(gdb)
# I need to call -var-list-children first
-var-list-children svar
^done,numchild="2",children={child={name="svar.v1",exp="v1",numchild="0",type="int"},child={name="svar.v2",exp="v2",numchild="0",type="int"}}
(gdb)
# Now it works
-var-evaluate-expression svar.v1
^done,value="0"
(gdb)
Is this a bug in the MI? It sure seems like one to me, but I thought
I would ask to make sure. The docs don't mention anything about
having to invoke the -var-evaluate-expression method before accessing
children of a variable.
cheers
Mo DeJong