From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25278 invoked by alias); 10 Feb 2008 21:02:56 -0000 Received: (qmail 25265 invoked by uid 22791); 10 Feb 2008 21:02:56 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 10 Feb 2008 21:02:30 +0000 Received: from kahikatea.snap.net.nz (97.30.255.123.static.snap.net.nz [123.255.30.97]) by viper.snap.net.nz (Postfix) with ESMTP id 91C9C3DA3E1; Mon, 11 Feb 2008 10:02:26 +1300 (NZDT) Received: by kahikatea.snap.net.nz (Postfix, from userid 1000) id 914428FC6D; Mon, 11 Feb 2008 10:02:24 +1300 (NZDT) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18351.26207.310382.539746@kahikatea.snap.net.nz> Date: Sun, 10 Feb 2008 21:02:00 -0000 To: Vladimir Prus Cc: gdb@sources.redhat.com Subject: Re: Variable objects and STL containers In-Reply-To: <200802101010.49506.ghost@cs.msu.su> References: <18343.64413.689019.489727@kahikatea.snap.net.nz> <200802080946.28915.ghost@cs.msu.su> <18350.32064.844389.155290@kahikatea.snap.net.nz> <200802101010.49506.ghost@cs.msu.su> X-Mailer: VM 7.19 under Emacs 23.0.60.9 X-IsSubscribed: yes 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: 2008-02/txt/msg00054.txt.bz2 > > > I anticipate that -var-update will: > > > > > > 1. Create new children, and report them. > > > 2. Report children that are now gone, possibly deleting them. > > > > That sounds sensible. Discussion on the gcc mailing list suggested that > > this should all be done in GDB, i.e., in C. I will explore that > > possibility. > > Please note that I already have proof-of-concept Python integration, > together with code to use Python for -var-evaluate-expression, together > with not-yet-working patch to dynamically compute the list of varobj children. > It might be better to wait till I got the last bit done. Will the Python integration be self contained or does it require separate libraries? Will it restrict the number of platforms that GDB builds on? In any case, there seem to be two projects here: Python integration and the display of STL containers using variable objects. It's not clear to me that the former is necessary for the latter. Below is just a quick sketch of the thoughts I have, which may or may not be sensible. In the case of vectors, var->num_children would be computed from n = v._M_impl._M_finish - v._M_impl._M_start and the children would be created from *(v._M_impl._M_start+1), *(v._M_impl._M_start+2), ...*(v._M_impl._M_start+n). I guess a special variable object would need to be created for n and when it was reported as changed bt -var-update, new/old variable objects could accordingly be created/deleted. -- Nick http://www.inet.net.nz/~nickrob *** mi-cmd-var.c.~1.45.~ 2008-01-30 21:35:45.000000000 +1300 --- mi-cmd-var.c 2008-02-11 09:42:05.000000000 +1300 *************** mi_cmd_var_list_children (char *command, *** 361,366 **** --- 361,369 ---- int numchild; enum print_values print_values; int ix; + struct expression *expr; + struct value *value; + char* stl_member; if (argc != 1 && argc != 2) error (_("mi_cmd_var_list_children: Usage: [PRINT_VALUES] NAME")); *************** mi_cmd_var_list_children (char *command, *** 373,379 **** if (var == NULL) error (_("Variable object not found")); ! children = varobj_list_children (var); ui_out_field_int (uiout, "numchild", VEC_length (varobj_p, children)); if (argc == 2) print_values = mi_parse_values_option (argv[0]); --- 376,390 ---- if (var == NULL) error (_("Variable object not found")); ! stl_member = xstrprintf ("%s._M_impl", varobj_get_expression (var)); ! expr = parse_expression (stl_member); ! if (gdb_evaluate_expression (expr, &value)) ! // TODO: List children according to STL container. ! children = varobj_list_stl_children (var); ! else ! children = varobj_list_children (var); ! xfree (stl_member); ! ui_out_field_int (uiout, "numchild", VEC_length (varobj_p, children)); if (argc == 2) print_values = mi_parse_values_option (argv[0]);