From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1164 invoked by alias); 5 Dec 2001 11:40:20 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 1123 invoked from network); 5 Dec 2001 11:40:17 -0000 Received: from unknown (HELO tiburon.adc.co.kr) (210.102.3.3) by sources.redhat.com with SMTP; 5 Dec 2001 11:40:17 -0000 Received: from [210.102.3.56] ([210.102.3.56]) by tiburon.adc.co.kr (8.10.2+Sun/8.11.0) with ESMTP id fB5BVkH17848; Wed, 5 Dec 2001 20:31:47 +0900 (KST) Date: Wed, 05 Dec 2001 03:40:00 -0000 From: "Choi, Jang-Wook" X-X-Sender: To: "Howind Axel, Externer Dienstleister" cc: "'gdb@sources.redhat.com'" Subject: Re: expanding c-macros in gdb In-Reply-To: <6380966D8BCFD5119C9300306E1C8487057727@clg-server7.clg.fja.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2001-12/txt/msg00026.txt.bz2 Hi, let me tell you my method. I use gdb through emacs and use emacs shortcut key C-c C-e after set region for the macro, then emacs expand & show the macro to me. After that I print the value in gdb. cjw On Wed, 5 Dec 2001, Howind Axel, Externer Dienstleister wrote: > Hello, > > we are using gcc/gdb for development in C. The C code uses some > macros for accessing data, for example: > > #define REFP_XYZ(i) xyz_ptr->s_xyz.r_xyz[i].xyz > ... > if (REFP_XYZ(a).abc != 0) ... > ... > > Is there a way to make gdb understand that the command > print REFP_XYZ(a).abc is the same as print xyz_ptr->s_xyz.r_xyz[i].xyz.abc? > > I have read in the gcc manual that compiling with -g3 stores information > about > all defined macros, so that "Some debuggers support macro expansion when you > use `-g3'." > This does not seem to work with gdb (gcc 2.95.2, gdb 5.0, on HP-UX 10.20). > > Then I thought about defining a macro printmac in gdb, but I have not found > a way to > do the expansion. What I'm thinking about is to call a shell- or sed-skript > that does > the expansion and pass the result on to the print command, something like > this > (transform is the name of a sed-script, that does the actual expansion): > > define printmac(arg) > print `echo $arg | sed -f transform` > > Is something like this possible in gdb? Can I use a hook? > > Thanks in advance, > > Axel Howind > >