This is the mail archive of the 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: MI & pretty-printing

On Friday 07 August 2009 Tom Tromey wrote:

> >>>>> "Volodya" == Vladimir Prus <> writes:
> Volodya> On IRC, Tom and I talked about best way to support Python
> Volodya> pretty-printing with MI. Here's my attempt at summarizing.
> I finally finished the first draft of this.  I pushed it to the
> archer-tromey-python branch today.  Please give it a try; if it is all
> looking ok I will extract it and push it into CVS.

I have tried this. Basic vector<int> display works fine. I have run
into a couple of issues. Please see the attached test program and a
session below:

	-break-insert test.cpp:9
	*stopped,reason="breakpoint-	hit",disp="keep",bkptno="1",frame={addr="0x08048877",
	-var-create v * v
	^done,name="v",numchild="-1",value="{...}",type="std::vector<int, std::allocator<int> >",thread-id="1"
	-var-list-children --all-values v
	-var-update --all-values *
	^done,changelist=[{name="v",value="std::vector of length 2, capacity 2",in_scope="true",type_changed="false",new_num_children="2",

Note that at this point, displayed value of the vector switches to "std::vector of length 2...".
I think we discussed that such value should not be used inside MI.

	-break-insert test.cpp:14
    -var-create v2 * v2
    ^done,name="v2",numchild="-1",value="{...}",type="std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,  
    std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >",thread-id="1"
    -var-list-children --all-values v2
    std::char_traits<char>, std::allocator<char> >",thread-id="1"}],has_more="0"
    -var-list-children --all-values v2.[0]
    Segmentation fault

There are two problems here. First, the elements of vector<string> should be subject to pretty-printing
too (and should have zero children). Second, this should not crash.

> Volodya> 	-enable-pretty-printing [0|1]
> I omitted the argument in my implementation.

This is fine.

> Volodya>     -var-list-children varobj [low] [hi]
> Volodya>     -var-set-update-range varobj low hi
> I implemented these verbatim.
> There is now an optional has_more attribute on varobj output; it is a
> boolean which is "1" if there seem to be children past the last
> requested child.
> The "numchild" attribute is now a bit funny.  It can't tell the actual
> number of children, only the number you've requested.  It may be smaller
> than the range you requested.  The user has to pay attention to this,
> because it is the only way to notice that children were deleted (for
> -var-update, this will show up in new_num_children).

Is it expected that if I have varobj with 1 child, then 

   -var-list-children var 10 20

still prints numchild=1 ?

> When doing a -var-update, a dynamic varobj may report "new_children".
> This is a list of any new children added during this update.  New
> children can only be added at the end of the update range (changes to
> existing elements are reported as changed varobjs).
> I haven't documented all these details yet.  I'll do that soon.
> (FWIW, -var-update seems under-documented in general.)

Yes, I am planning to document that a bit more.


> Tom
#include <vector>
#include <string>

int main()
    std::vector<int> v;
    std::vector<std::string> v2;
    return 0;    

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