From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13789 invoked by alias); 19 Apr 2011 10:47:40 -0000 Received: (qmail 13781 invoked by uid 22791); 19 Apr 2011 10:47:39 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 19 Apr 2011 10:47:20 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3JAlKuQ009803 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 19 Apr 2011 06:47:20 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p3JAlI8L026635; Tue, 19 Apr 2011 06:47:19 -0400 From: Phil Muldoon To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [patch] [python] mi/12531 References: Reply-to: pmuldoon@redhat.com X-URL: http://www.redhat.com Date: Tue, 19 Apr 2011 10:47:00 -0000 In-Reply-To: (Tom Tromey's message of "Mon, 18 Apr 2011 14:58:13 -0600") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-04/txt/msg00304.txt.bz2 Tom Tromey writes: >>>>>> "Phil" == Phil Muldoon writes: > I have some comments, but they are all minor things. > > Phil> 2011-04-13 Phil Muldoon > Phil> * varobj.c (install_default_visualizer): Do not install a > Phil> visualizer if the varobj is CPLUS_FAKE_CHILD. > Phil> (construct_visualizer): Likewise. > > I thought there was a PR open for this. If so, it should be mentioned > in the ChangeLog. (If it is just in Red Hat bugzilla then it is > optional; but if you choose to use it, put the whole URL in.) Nope, it is a sourceware bug. I just forgot this time ;) > Phil> +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ additional_flags=-DMI}] != "" } { > > This should be split somewhere. Ok. And for other line wraps/indention fixes. For some reason emacs want to further indent the "executable ..." line in py-mi.exp by an extra tab. It looks wrong, but I'll defer to emacs. ;) > Phil> #ifdef __cplusplus > Phil> +#include > > It is best not to rely on libstdc++ in the test suite. Ack, good catch. I can just use an int here. I converted it to a struct (compiled under C++) and for some reason, asking for the children of private just tells me variable not found. It works with a class though. You did not give an explicit ok, so I am attaching the patch. I won't attach the ChangeLog again, but I will attach the relevant bz entries. Also, as this tends to block Dodji's use of pretty-printing in Nemiver, is it ok for the 7.3 branch too? Cheers Phil -- diff --git a/gdb/testsuite/gdb.python/py-mi.exp b/gdb/testsuite/gdb.python/py-mi.exp index 629417b..37359e9 100644 --- a/gdb/testsuite/gdb.python/py-mi.exp +++ b/gdb/testsuite/gdb.python/py-mi.exp @@ -283,4 +283,44 @@ mi_list_varobj_children nstype2 { { {nstype2.} {} 6 {char \[6\]} } } "list children after setting exception flag" +# C++ MI tests +gdb_exit +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ + executable {debug c++ additional_flags=-DMI}] != "" } { + untested "Couldn't compile ${srcfile} in c++ mode" + return -1 +} + +if [mi_gdb_start] { + continue +} +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +if {[lsearch -exact [mi_get_features] python] < 0} { + unsupported "python support is disabled" + return -1 +} + +mi_runto main +mi_continue_to_line \ + [gdb_get_line_number {break to inspect struct and union} ${testfile}.c] \ + "step to breakpoint" + +# Test python/12531. Install visualizer on a cplus_fake_child. +mi_create_varobj fake fake \ + "create fake varobj" + +mi_list_varobj_children fake { + { fake.private private 1 } +} "list children of fake" + +mi_list_varobj_children fake.private { + { fake.private.sname sname 0 int } +} "list children fake.private" + +mi_gdb_test "-var-set-visualizer fake.private gdb.default_visualizer" \ + "\\^done" "Install visualizer on a cplus_fake_child" + remote_file host delete ${remote_python_file} diff --git a/gdb/testsuite/gdb.python/py-prettyprint.c b/gdb/testsuite/gdb.python/py-prettyprint.c index 1d88b4e..b65a84fb 100644 --- a/gdb/testsuite/gdb.python/py-prettyprint.c +++ b/gdb/testsuite/gdb.python/py-prettyprint.c @@ -94,6 +94,16 @@ class Derived : public Vbase1, public Vbase2, public Vbase3 } }; +class Fake +{ + int sname; + + public: + Fake (const int name = 0): + sname (name) + { + } +}; #endif struct substruct { @@ -267,6 +277,7 @@ main () Derived derived; + Fake fake (42); #endif add_item (&c, 23); /* MI breakpoint here */ diff --git a/gdb/varobj.c b/gdb/varobj.c index bfb3851..e068823 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -1397,6 +1397,10 @@ install_visualizer (struct varobj *var, PyObject *constructor, static void install_default_visualizer (struct varobj *var) { + /* Do not install a visualizer on a CPLUS_FAKE_CHILD. */ + if (CPLUS_FAKE_CHILD (var)) + return; + if (pretty_printing) { PyObject *pretty_printer = NULL; @@ -1429,6 +1433,10 @@ construct_visualizer (struct varobj *var, PyObject *constructor) { PyObject *pretty_printer; + /* Do not install a visualizer on a CPLUS_FAKE_CHILD. */ + if (CPLUS_FAKE_CHILD (var)) + return; + Py_INCREF (constructor); if (constructor == Py_None) pretty_printer = NULL;