From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12703 invoked by alias); 21 Sep 2007 15:54:03 -0000 Received: (qmail 12693 invoked by uid 22791); 21 Sep 2007 15:54:02 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 21 Sep 2007 15:53:56 +0000 Received: (qmail 16970 invoked from network); 21 Sep 2007 15:53:54 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 21 Sep 2007 15:53:54 -0000 To: =?utf-8?B?5rGf5rKz?= Cc: news.gnu.gdb Subject: Re: How can i show the macro infor References: <9875e6b70709210230m28c92c54s6b9348ac010c2452@mail.gmail.com> From: Jim Blandy Date: Fri, 21 Sep 2007 16:23:00 -0000 In-Reply-To: <9875e6b70709210230m28c92c54s6b9348ac010c2452@mail.gmail.com> (=?utf-8?B?5rGf5rKzJ3M=?= message of "Fri, 21 Sep 2007 17:30:00 +0800") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: 2007-09/txt/msg00173.txt.bz2 "=E6=B1=9F=E6=B2=B3" writes: > I can't show the macro info by these operation. > > gcc --version > gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2) > > gdb --version > GNU gdb Red Hat Linux (6.3.0.0-1.96rh) > >>cat x.c > #include > #define NEX 1 > int main() > { > printf( "%d\n", N ); > return 0; > } > >>gcc -gdwarf-2 -g3 x.c -o x > > (gdb) l > 1 #include > 2 #define NEX 1 > 3 int main() > 4 { > 5 printf( "%d\n", NEX ); > 6 return 0; > 7 } > (gdb) info macro NEX > The symbol `NEX' has no definition as a C/C++ preprocessor macro > at x.c:8 > included at /usr/include/stdio.h:749 > > --=20 > =E6=A1=82=E8=8F=AF=E7=A7=8B=E7=9A=8E=E6=BD=94 That response from GDB to your 'info macro NEX' command looks very strange. I'd wonder whether your GCC was producing bad macro information. I wasn't able to reproduce this problem with Fedora Core 6's GCC 4.1.2: $ cat x.c #include #define NEX 1 int main() { printf( "%d\n", NEX ); return 0; } $ gcc -gdwarf-2 -g3 x.c -o x $ ~/gdb/pub/nat/gdb/gdb x GNU gdb 6.6.50.20070911-cvs Copyright (C) 2007 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-pc-linux-gnu"... Using host libthread_db library "/lib/libthread_db.so.1". (gdb) b main Breakpoint 1 at 0x8048395: file x.c, line 5. (gdb) run Starting program: /home/jimb/play/x=20 Breakpoint 1, main () at x.c:5 5 printf( "%d\n", NEX ); (gdb) info macro NEX Defined at /home/jimb/play/x.c:2 #define NEX 1 (gdb) print NEX $1 =3D 1 (gdb) quit The program is running. Exit anyway? (y or n) y $ gcc --version gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-13) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $=20