This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with MI -var-evaluate-expression command


On Wed, 10 Jul 2002, Mo DeJong wrote:

> % cat S.c
> struct S {
>     int v1;
>     int v2;
> };
>
> -var-create svar * "(struct S *) 0x8049560"
> ^done,name="svar",numchild="2",type="struct S *"
> (gdb)
> -var-evaluate-expression svar
> ^done,value="0x8049560"
> (gdb)
> -var-evaluate-expression svar.v1
> &"Variable object not found\n"
> ^error,msg="Variable object not found"

How is a UI to know what the children of svar are? You do, because you're
a human, but a UI reacting programmatically could not automatically know
that svar has a child named "v1" _until_ it asks svar for its children
(thus creating the varobjs).

Remember, we're dealing with VARiable OBJects here. You cannot do anything
without a varobj.

Insight is the major client for this code right now. (In fact varobj was
originally written for Insight, but it appeared to be useful to someone
else, and it was added to MI.) Here's what Insight does:

Given the expression "svar" which is perhaps supplied by "info
locals", "-stack-list-locals", or from the user inputting it as a watch, a
UI would:

1) Create varobj for (the expression) "svar"
2) Ask the varobj for a display name and stuff this into a column of the
   display
3) Ask the varobj for its type and stuff that into a column
4) Ask the varobj for its value and stuff that into a column
5) Ask the varobj if it has any children. If it does, it puts a little "+"
   next to the name, so that the user can expand it.

Now, when the user hits the "+", Insight will ask the varobj for its
children. It gets back a list of varobjs. It then repeats steps 2-5 for
each of these new varobjs.

In practice, I think it works quite well, but I may be a little biased,
since I originally wrote varobj for Insight. ;-)

Keith



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]