From: Jim Blandy <jimb@redhat.com>
To: gdb-patches@sources.redhat.com
Cc: gcc@gcc.gnu.org
Subject: Test file for GDB preprocessor macro support
Date: Sat, 16 Mar 2002 22:28:00 -0000 [thread overview]
Message-ID: <20020317062810.EF65C5E9DE@zwingli.cygnus.com> (raw)
Since GCC doesn't emit Dwarf 2 macro information, you have to edit it
into the assembly file by hand. Compile the following source file
with "gcc -gdwarf-2 -dA -S test.c":
----
#include <stdio.h>
#include <stdlib.h>
void
foo ()
{
printf ("Nice to meet you!\n");
}
int
main (int argc, char **argv)
{
printf ("Hello, world!\n");
foo ();
return 0;
}
---
Now, add the following to the end of test.s:
.section .debug_macinfo
.byte 3 # DW_MACINFO_start_file
.byte 0 # line number
.byte 1 # file 1: test.c
.byte 1 # DW_MACINFO_define
.byte 2 # line 2
.ascii "FOO 12<\0"
.byte 1 # DW_MACINFO_define
.byte 3 # line 3
.ascii "BAR(arg1,arg2) (arg1<arg2)\0"
.byte 3 # DW_MACINFO_start_file
.byte 4 # line 4
.byte 5 # file 5: /usr/include/stdio.h
.byte 2 # DW_MACINFO_undef
.byte 1 # line 1
.ascii "FOO\0"
.byte 1 # DW_MACINFO_define
.byte 2 # line 2
.ascii "FOO(a,b) (a-b)\0"
.byte 4 # DW_MACINFO_end_file
.byte 1 # DW_MACINFO_define
.byte 5 # line 5
.ascii "smootz() 42\0"
.byte 2 # DW_MACINFO_undef
.byte 10 # line 10
.ascii "smootz\0"
.byte 1 # DW_MACINFO_define
.byte 11 # line 11
.ascii "smootz(a) a+42\0"
.byte 1 # DW_MACINFO_define
.byte 12 # line 12
.ascii "main_only this macro is only defined for main\0"
.byte 4 # DW_MACINFO_end_file
.byte 0 # end of macro information
Assemble that into an executable, with the command "gcc test.s -o
test". Now, GDB should be able to find the macro info, once you're at
a source line where the macros are in scope:
Starting program: /rigel/jimb/cygnus/pentium3/sourceware/gdb/main/native/build/gdb/gdb -nw macros3
GNU gdb 2002-03-14-cvs
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) break main
Breakpoint 1 at 0x8048426: file test.c, line 15.
(gdb) break foo
Breakpoint 2 at 0x8048406: file test.c, line 8.
(gdb) run
Starting program: /home/jimb/gdb/macros/play/macros3
Breakpoint 1, main (argc=1, argv=0xbfffd014) at test.c:15
15 printf ("Hello, world!\n");
(gdb) show macro smootz
Defined at /home/jimb/gdb/macros/play/test.c:11
#define smootz(a) a+42
(gdb)
next reply other threads:[~2002-03-17 6:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-16 22:28 Jim Blandy [this message]
2002-03-17 9:07 ` Daniel Berlin
2002-03-17 21:45 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020317062810.EF65C5E9DE@zwingli.cygnus.com \
--to=jimb@redhat.com \
--cc=gcc@gcc.gnu.org \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox