From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11600 invoked by alias); 10 Sep 2010 15:59:46 -0000 Received: (qmail 11590 invoked by uid 22791); 10 Sep 2010 15:59:45 -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; Fri, 10 Sep 2010 15:59:41 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8AFxcwT027866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 10 Sep 2010 11:59:39 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8AFxchV027476; Fri, 10 Sep 2010 11:59:38 -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 o8AFxbYe018517; Fri, 10 Sep 2010 11:59:37 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 26AB63792BD; Fri, 10 Sep 2010 09:59:37 -0600 (MDT) From: Tom Tromey To: Pawel K Cc: gdb@sourceware.org Subject: Re: user defined function and passing types References: Date: Fri, 10 Sep 2010 15:59:00 -0000 In-Reply-To: (Pawel K.'s message of "Fri, 10 Sep 2010 16:41:34 +0200") 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 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: 2010-09/txt/msg00066.txt.bz2 >>>>> "Pawel" == Pawel K writes: Pawel> I have following user defined function: Pawel> define my_stl_list [...] Pawel> As You can see, it displays contents of slist. Pawel> It's drawback is that it has hard coded type of list (const Pawel> __gnu_cxx::_Slist_node *). Pawel> Is there a way to pass it as parameter to this macro? What you really want is to use the new Python pretty-printing support. We have a full suite of printers for libstdc++, checked into the libstdc++ repository. On a recent Linux distro, it will all "just work" without manual intervention. If you do need to set it up manually, there is some info here: http://sourceware.org/gdb/wiki/STLSupport To answer your original question, there are two ways to do complicated scripting things in gdb. One is use the Python scripting support. This is usually simplest, if you can use it, because it is easy to do all kinds of string manipulations and whatnot in Python. The other is to use a gross GDB scripting trick: use "set logging" to redirect output to a file; print things to that file; use "shell" plus a shell script (or external perl or python or sed or whatever) to convert that to a gdb script; then finally "source" the result. Tom