From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3771 invoked by alias); 13 Aug 2009 15:59:27 -0000 Received: (qmail 3728 invoked by uid 22791); 13 Aug 2009 15:59:26 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 13 Aug 2009 15:59:19 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7DFxH5d032737; Thu, 13 Aug 2009 11:59:17 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n7DFxFfh021101; Thu, 13 Aug 2009 11:59:16 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n7DFxE7O007087; Thu, 13 Aug 2009 11:59:15 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 6D72A3782F7; Thu, 13 Aug 2009 09:59:14 -0600 (MDT) To: selcuk.kopru@tyazilimevi.com Cc: gdb@sourceware.org Subject: Re: recursive user-defined commands and References: <1250118614.3975.43.camel@selcuk-laptop> From: Tom Tromey Reply-To: tromey@redhat.com Date: Thu, 13 Aug 2009 15:59:00 -0000 In-Reply-To: <1250118614.3975.43.camel@selcuk-laptop> (Selcuk Kopru's message of "Thu\, 13 Aug 2009 02\:10\:14 +0300") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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/msg00092.txt.bz2 >>>>> ">" == 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