From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5527 invoked by alias); 17 Mar 2002 17:07:50 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 5385 invoked from network); 17 Mar 2002 17:07:43 -0000 Received: from unknown (HELO dberlin.org) (64.246.6.106) by sources.redhat.com with SMTP; 17 Mar 2002 17:07:43 -0000 Received: from localhost (pool-151-204-232-2.bos.east.verizon.net [151.204.232.2]) (authenticated (0 bits)) by dberlin.org (8.11.6/8.11.6) with ESMTP id g2HH7gm18899; Sun, 17 Mar 2002 12:07:42 -0500 Date: Sun, 17 Mar 2002 09:07:00 -0000 Subject: Re: Test file for GDB preprocessor macro support Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v481) Cc: gdb-patches@sources.redhat.com, gcc@gcc.gnu.org To: Jim Blandy From: Daniel Berlin In-Reply-To: <20020317062810.EF65C5E9DE@zwingli.cygnus.com> Message-Id: <7E0B5FE5-39C9-11D6-A7C8-000393575BCC@dberlin.org> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.481) X-SW-Source: 2002-03/txt/msg00282.txt.bz2 On Sunday, March 17, 2002, at 01:28 AM, Jim Blandy wrote: > > 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": Once again, we *do* generate it. add -g3 after -gdwarf-2, and you'll get macro info. > > ---- > #include > #include > > > 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 .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)