From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9023 invoked by alias); 4 Sep 2009 19:29:36 -0000 Received: (qmail 9014 invoked by uid 22791); 4 Sep 2009 19:29:36 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: sourceware.org Received: from mail35d.att-webhosting.com (HELO mail35d.att-webhosting.com) (161.58.104.164) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Fri, 04 Sep 2009 19:29:29 +0000 Received: from mx42.stngva01.us.mxservers.net (204.202.242.44) by mail35d.att-webhosting.com (RS ver 1.0.95vs) with SMTP id 1-040522566 for ; Fri, 4 Sep 2009 15:29:27 -0400 (EDT) Received: from unknown [198.66.164.83] (EHLO mxw3501.att-webhosting.com) by va1-mx42.stngva01.us.mxservers.net (mxl_mta-3.1.0-05) with ESMTP id 79a61aa4.2805877664.575546.00-001.va1-mx42.stngva01.us.mxservers.net (envelope-from ); Fri, 04 Sep 2009 15:29:27 -0400 (EDT) Received: (qmail 33702 invoked from network); 4 Sep 2009 19:29:26 -0000 Received: from unknown (HELO ?10.10.10.116?) (selcuk@12.154.95.130) by with ESMTPA; 4 Sep 2009 19:29:26 -0000 Subject: Re: recursive user-defined commands and From: Selcuk Kopru Reply-To: selcuk.kopru@tyazilimevi.com To: gdb@sourceware.org In-Reply-To: References: <1250118614.3975.43.camel@selcuk-laptop> Content-Type: text/plain Date: Fri, 04 Sep 2009 19:29:00 -0000 Message-Id: <1252092562.3662.8.camel@selcuk-laptop> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-MAIL-FROM: X-SF-Loop: 1 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-09/txt/msg00083.txt.bz2 Hi, A late follow-up question: How can we allocate an array type convenience variable? Using $dlist[$depth] without any prior declaration results in the following error: "cannot subscript something of type `void'" Regards, selcuk On Thu, 2009-08-13 at 09:59 -0600, Tom Tromey wrote: > >>>>> ">" == Selcuk Kopru writes: > > >> I'm trying to write user-defined commands to view some > >> nested/embedded classes which form a huge data hierarchy. > > My advice is to switch to CVS GDB and use the new Python-based > pretty-printing feature. > > With this feature you can write Python code to customize the display of > various objects in your program. This is mostly transparent to the user > -- "print" will print them prettily, so will stack traces, so will MI > (soon), etc. > > >> define show_string > >> wchar_print ((CMyString*)$arg0).m_Value > >> end > > CVS GDB also has direct support for wide characters. > > >> If the "show_dag" command is being hit for the second time in the same > >> call sequence then the "$dlist" variable becomes invalid at the time the > >> control returns back to the first instance of the "show_dag" command and > >> resulting in a "Cannot access memory at address 0x.." error message. How > >> can I prevent this error? > > I suppose you could allocate an array and then manage the recursion > manually by using $dlist[$depth]. > > Otherwise, yeah, this seems like a limitation of gdb's scripting > language. It seems like it would nice to let user-defined commands > define local variables. > > Tom