Re: [RFC/RFA?] Should break FILE:LINENO skip prologue?

Jim Blandy
2008-01-16T21:36:45Z

Eli Zaretskii <eliz at gnu.org> writes:
>> Date: Wed, 16 Jan 2008 11:34:41 +0100 (CET)
>> From: Mark Kettenis <mark.kettenis@xs4all.nl>
>> CC: uweigand@de.ibm.com, brobecker@adacore.com, msnyder@specifix.com,
>> gdb-patches@sourceware.org
>>
>> > Btw, the manual does not say *EXPRESSION, it says *ADDRESS.
>>
>> That's fine as long as the manual says that ADDRESS is parsed as an
>> expression in the current language.
>
> It doesn't. It says it "may be any expression", which is vague, even
> inaccurate.
>
>> > Anyway, if "break *FILENAME:FUNCTION" does not need to work, then how
>> > does one set a breakpoint on the entry point of FILENAME:FUNCTION,
>> > after the suggested change that makes "break FUNCTION" behave
>> > differently than "break *FUNCTION"?
>>
>> Joel's change does not change how "break FUNCTION" works at all. It
>> changes what "break LINE" does in the case where LINE doesn't
>> correspond to an actual line of source code, and makes it more similar
>> to what "break FUNCTION" does, which is putting the breakpoint on the
>> first line of actual code in a function.
>
> My question was about putting the breakpoint on the beginning of the
> prolog of a function in another file, not about "break FUNCTION" or
> "break LINE". You didn't answer my question: how does one put a
> breakpoint on that address. For a function in the current file, or
> one whose name identifies it unambiguously, "break *FUNCTION" is the
> solution. But what about the case where FUNCTION alone is not enough
> to unambiguously specify a function?

GDB allows 'FILENAME'::FUNCTION in C expressions:

$ cat u.mk
CC = gcc
CFLAGS = -g3
u: u1.o u2.o
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
clean:
rm -f u u1.o u2.o
$ cat u1.c
#include <stdio.h>

void e (void);

static void
s (void)
{
puts ("u1.c: s");
}

int
main (int argc, char **argv)
{
s ();
e ();

return 0;
}
$ cat u2.c
#include <stdio.h>

static void
s (void)
{
puts ("u2.c: s");
}

void
e (void)
{
puts ("u2.c: e");
s ();
}
$ make -f u.mk
gcc -g3 -c -o u1.o u1.c
gcc -g3 -c -o u2.o u2.c
gcc u1.o u2.o -o u
$ ~/gdb/pub/nat/gdb/gdb u
GNU gdb 6.7.50.20080111-cvs
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) print 'u1.c'::s
$1 = {void (void)} 0x8048384
(gdb) print 'u2.c'::s
$2 = {void (void)} 0x80483c4
(gdb) break *'u1.c'::s
Breakpoint 1 at 0x8048384: file u1.c, line 7.
(gdb) break *'u2.c'::s
Breakpoint 2 at 0x80483c4: file u2.c, line 5.
(gdb)