From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3304 invoked by alias); 14 May 2009 23:17:21 -0000 Received: (qmail 3287 invoked by uid 22791); 14 May 2009 23:17:20 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 May 2009 23:17:11 +0000 Received: from wpaz9.hot.corp.google.com (wpaz9.hot.corp.google.com [172.24.198.73]) by smtp-out.google.com with ESMTP id n4ENH91F002194 for ; Thu, 14 May 2009 16:17:09 -0700 Received: from qyk10 (qyk10.prod.google.com [10.241.83.138]) by wpaz9.hot.corp.google.com with ESMTP id n4ENGlsZ014441 for ; Thu, 14 May 2009 16:17:07 -0700 Received: by qyk10 with SMTP id 10so2725531qyk.25 for ; Thu, 14 May 2009 16:17:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.99.69 with SMTP id t5mr1949644qcn.30.1242343027598; Thu, 14 May 2009 16:17:07 -0700 (PDT) In-Reply-To: References: Date: Thu, 14 May 2009 23:17:00 -0000 Message-ID: <8ac60eac0905141617g1db278e5l906eef8f5b899ed4@mail.gmail.com> Subject: Re: overloading 'print' command. From: Paul Pluzhnikov To: =?ISO-8859-2?Q?Pawe=B3_Sikora?= Cc: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true 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: 2009-05/txt/msg00080.txt.bz2 2009/5/14 Pawe=B3 Sikora : > I'd like to ask about overloading gdb's 'print' command. > e.g. I've defined a macro 'ps' for printing std::string: > > define ps > p $arg0.c_str() > end > > Now, I'd like to avoid calling 'ps' and just use the 'p' command > in top-macros for printing more complex data structures. > Is it possible in gdb to register some hooks for type-based > printing? Support for doing *exactly* this is coming to mainline GDB, but you can get it now from the archer-tromey-python branch: http://sourceware.org/gdb/wiki/PythonGdb It is significantly more powerful than what you can do with simple 'define'. Cheers, --=20 Paul Pluzhnikov