This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Breaks in include files (was :RE: breakpoint setting weirdness in C++)
- To: Fabrice Gautier <Fabrice_Gautier at sdesigns dot com>
- Subject: Re: Breaks in include files (was :RE: breakpoint setting weirdness in C++)
- From: Jim Blandy <jimb at zwingli dot cygnus dot com>
- Date: 03 Nov 2000 17:17:08 -0500
- Cc: "'Daniel Berlin'" <dberlin at redhat dot com>, gdb at sources dot redhat dot com
- References: <5AF611D83988D4118ACF00E0B1040054055801@mr-intranet.sdesigns.net>
> Yes, but now consider the following "C" case:
>
> fun.h:
> static void fun(void)
> {
> int i=1;
> }
>
> fun1.c:
> #include "fun.h"
> void fun1(void)
> {
> fun();
> }
>
> void main(void)
> {
> fun1();
> fun2();
> }
>
> fun2.c:
> #include "fun.h"
> void fun2(void)
> {
> fun();
> }
>
> In this case I think the static function are really duplicated.
That's true --- the compilation units fun1.o and fun2.o each have
their own static function named `fun'. You can set breakpoints on
them like this:
(gdb) zwingli:play$ gdb fun
GNU gdb 4.17-gnupro-98r1
Copyright 1998 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. This version of GDB is supported
for customers of Cygnus Solutions. Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.5"...
(gdb) break fun1.c:fun
Breakpoint 1 at 0x10764: file fun.h, line 3.
(gdb) break fun2.c:fun
Breakpoint 2 at 0x107a8
(gdb) run
Starting program: /mill/home/jimb/play/fun
Breakpoint 1, fun () at fun.h:3
3 int i=1;
(gdb) where
#0 fun () at fun.h:3
#1 0x10780 in fun1 () at fun1.c:4
#2 0x10794 in main () at fun1.c:9
(gdb) c
Continuing.
Breakpoint 2, 0x107a8 in fun () at fun2.c:2
2 void fun2(void)
(gdb) where
#0 0x107a8 in fun () at fun2.c:2
#1 0x107c4 in fun2 () at fun2.c:4
#2 0x1079c in main () at fun1.c:10
(gdb)