This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Debugging macros (Was: Why Does "java_global_trees" Exist?)
- From: Anthony Green <green at redhat dot com>
- To: Ranjit Mathew <rmathew at gmail dot com>
- Cc: java at gcc dot gnu dot org
- Date: Fri, 11 Jun 2004 13:06:55 -0700
- Subject: Debugging macros (Was: Why Does "java_global_trees" Exist?)
- Organization: Red Hat, Inc.
- References: <cac1qs$8s3$1@sea.gmane.org>
On Fri, 2004-06-11 at 03:32, Ranjit Mathew wrote:
> Many a time have I been smitten/flummoxed by GDB
> proclaiming a supposedly global variable to be non-existent
> only to discover it being a macro aliasing one of the
> elements of "java_global_trees".
I find that not too many people know about this relatively new feature,
so it's probably worth mentioning. If you compile with -g3, then you
will be able to debug macros within gdb. It should make dealing with
these macros much easier.
Here's the example I always share:
(gdb) list main
3
4 #define M 42
5 #define ADD(x) (M + x)
6
7 main ()
8 {
9 #define N 28
10 printf ("Hello, world!\n");
11 #undef N
12 printf ("We're so creative.\n");
(gdb) info macro ADD
Defined at /home/jimb/gdb/macros/play/sample.c:5
#define ADD(x) (M + x)
(gdb) info macro Q
Defined at /home/jimb/gdb/macros/play/sample.h:1
included at /home/jimb/gdb/macros/play/sample.c:2
#define Q <
(gdb) macro expand ADD(1)
expands to: (42 + 1)
(gdb) macro expand-once ADD(1)
expands to: once (M + 1)
(gdb)
--
Anthony Green <green@redhat.com>
Red Hat, Inc.