This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Debugging macros (Was: Why Does "java_global_trees" Exist?)


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]