This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] solib-svr4.c: Never attempt to place breakpoints on _start, __start, or main
On Fri, 17 Sep 2010 10:10:18 +0200 (CEST)
Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> > Comments? (I.e. does anyone know of a platform or a situation where
> > the code that I'm deleting is still needed?)
>
> Sorry, but I think that code is still useful. Over the years I've
> seen various cases where setting the breakpoint in the proper place
> failed: the magic ld.so breakpoint function was renamed, somebody
> stripped ld.so, GDB misinterpreted the debug information in ld.so.
> The code you're removing makes sure (or at least attempts too make
> sure) that you have a valid list of shared libraries as soon as you
> hit main().
Okay.
> Obviously it is pointless to keep removing and reinserting these
> breakpoints. Perhaps they should be disabled as soon as one of them
> has been hit?
That sounds like a good idea. It's not sufficient though for
debugging scenarios in which one attaches to a program that's
already gone past start or main. Perhaps we should skip the
attempt to place a breakpoint on _start, __start, and main
when attaching?
> Also, I think it is pointless to insert these if the program you're
> debugging isn't using the dynamic linker. I'm a little bit suprised
> that the solib-svr4.c code is used at all when debugging the Linux
> kernel. Does the same thing happen for static binaries?
Yes, the same thing happens for static binaries. Here's
"maint info breakpoints" when run on a static hello world program:
(gdb) maint info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000000004003f8 in main at hello.c:6 inf 1
breakpoint already hit 1 time
-2 shlib events keep y 0x000000000043a200 <_dl_debug_state> inf 1
-4 exception master keep n 0x0000000000469960 <_Unwind_DebugHook> inf 1
We don't have a breakpoint on _start, __start, or main, but that's
because _dl_debug_state was found first. (The code searches for that
symbol and others like it first...)
If I edit the binary and change _dl_debug_state to _dl_rebug_state, I
can get a breakpoint set on _start:
(gdb) maint info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000000004003f8 in main at hello.c:6 inf 1
breakpoint already hit 1 time
-2 shlib events keep y 0x00000000004002e0 <_start> inf 1
breakpoint already hit 1 time
-4 exception master keep n 0x0000000000469960 <_Unwind_DebugHook> inf 1
Kevin