From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23780 invoked by alias); 15 Aug 2009 20:43:37 -0000 Received: (qmail 23686 invoked by uid 22791); 15 Aug 2009 20:43:36 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 15 Aug 2009 20:43:26 +0000 Received: (qmail 13738 invoked from network); 15 Aug 2009 20:43:25 -0000 Received: from unknown (HELO wind.localnet) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 15 Aug 2009 20:43:25 -0000 From: Vladimir Prus To: tromey@redhat.com Subject: Re: MI & pretty-printing Date: Sat, 15 Aug 2009 20:43:00 -0000 User-Agent: KMail/1.11.90 (Linux/2.6.24-24-generic; KDE/4.2.90; i686; svn-979530; 2009-06-10) Cc: gdb@sources.redhat.com References: <200907132142.18043.vladimir@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_q3xhK3f1bAypq1O" Message-Id: <200908160043.22383.vladimir@codesourcery.com> Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-08/txt/msg00118.txt.bz2 --Boundary-00=_q3xhK3f1bAypq1O Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-length: 5623 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. Tom, I have tried this. Basic vector display works fine. I have run into a couple of issues. Please see the attached test program and a session below: (gdb) -enable-pretty-printing ^done (gdb) -break-insert test.cpp:9 ^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x08048877", func="main",file="test.cpp",fullname="/home/ghost/Build/test/test.cpp",line="9",times="0",original-location="test.cpp:9"} (gdb) -exec-run =thread-group-created,id="26265" =thread-created,id="1",group-id="26265" ^running *running,thread-id="all" (gdb) =library-loaded,id="/lib/ld-linux.so.2",target-name="/lib/ld-linux.so.2",host-name="/lib/ld-linux.so.2",symbols-loaded="0" =library-loaded,id="/usr/lib/libstdc++.so.6",target-name="/usr/lib/libstdc++.so.6",host-name="/usr/lib/libstdc++.so.6",symbols-loaded="0" =library-loaded,id="/lib/tls/i686/cmov/libm.so.6",target-name="/lib/tls/i686/cmov/libm.so.6",host-name="/lib/tls/i686/cmov/libm.so.6",symbols-loaded="0" =library-loaded,id="/lib/libgcc_s.so.1",target-name="/lib/libgcc_s.so.1",host-name="/lib/libgcc_s.so.1",symbols-loaded="0" =library-loaded,id="/lib/tls/i686/cmov/libc.so.6",target-name="/lib/tls/i686/cmov/libc.so.6",host-name="/lib/tls/i686/cmov/libc.so.6",symbols-loaded="0" *stopped,reason="breakpoint- hit",disp="keep",bkptno="1",frame={addr="0x08048877", func="main",args=[],file="test.cpp",fullname="/home/ghost/Build/test/test.cpp",line="9"},thread-id="1",stopped-threads="all" (gdb) -var-create v * v ^done,name="v",numchild="-1",value="{...}",type="std::vector >",thread-id="1" (gdb) -var-list-children --all-values v ^done,numchild="1",displayhint="array",children=[child={name="v.[0]",exp="[0]",numchild="0",value="10",type="int",thread-id="1"}],has_more="0" (gdb) -exec-next ^running *running,thread-id="1" (gdb) *stopped,reason="end-stepping-range",frame={addr="0x08048890",func="main",args=[],file="test.cpp",fullname="/home/ghost/Build/test/test.cpp",line="11"} (gdb) -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", displayhint="array",has_more="0",new_children=[{name="v.[1]",exp="[1]",numchild="0",value="11",type="int",thread-id="1"}]}] (gdb) 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 ^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0804891d",func="main", file="test.cpp",fullname="/home/ghost/Build/test/test.cpp",line="14",times="0",original-location="test.cpp:14"} (gdb) -exec-continue ^running *running,thread-id="all" (gdb) *stopped,reason="breakpoint- hit",disp="keep",bkptno="2",frame={addr="0x0804891d",func="main",args=[],file="test.cpp",fullname="/home/ghost/Build/test/test.cpp",line="14"},thread- id="1",stopped-threads="all" (gdb) -var-create v2 * v2 ^done,name="v2",numchild="-1",value="{...}",type="std::vector, std::allocator >, std::allocator, std::allocator > > >",thread-id="1" (gdb) -var-list-children --all-values v2 ^done,numchild="1",displayhint="array",children=[child={name="v2.[0]",exp="[0]",numchild="-1",value="{...}",type="std::basic_string, std::allocator >",thread-id="1"}],has_more="0" (gdb) -var-list-children --all-values v2.[0] Segmentation fault There are two problems here. First, the elements of vector 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. Thanks, Volodya > > Tom > --Boundary-00=_q3xhK3f1bAypq1O Content-Type: text/x-c++src; charset="UTF-8"; name="test.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="test.cpp" Content-length: 203 #include #include int main() { std::vector v; v.push_back(10); v.push_back(11); std::vector v2; v2.push_back("hi"); return 0; } --Boundary-00=_q3xhK3f1bAypq1O--