This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] Limit attempts to place breakpoints on _start, __start, and main in solib-svr4.c
> Date: Fri, 3 Dec 2010 14:04:33 -0700
> From: Kevin Buettner <kevinb@redhat.com>
>
> On Thu, 2 Dec 2010 00:03:39 +0100
> Jan Kratochvil <jan.kratochvil@redhat.com> wrote:
>
> Hi Jan,
>
> That's a nice demonstration of GDB's behavior when using gdbserver.
> My earlier testing and analysis was flawed. (FWIW, I was testing
> only case 1.)
>
> We do want to (potentially) attempt to place the breakpoints on
> _start, __start, and main in case 1, but not for case 2 and 3. You
> have demonstrated that the patch appended below will work correctly
> for gdbserver. I have used variants of your examples to verify that
> this is the case. (I have a hacked static executable in which I
> see a breakpoint placed on _start in case 1, but not for case 2 and 3 -
> which is as it should be.)
>
> The patch below won't necessarily work correctly with stubs which do
> not implement the qAttached packet. (gdbserver does implement
> qAttached.) My reading of remote.c indicates that stubs which do
> not implement "qAttached" will end up causing attach_flag to be 0.
> This may or may not be what we want depending upon the situation. It
> is certainly not what we want when connecting to a kernel stub (intended
> to debug a running kernel). On the other hand, there may be other
> stubs where this is in fact the correct answer. I'm going to
> recommend that my colleague (who pointed me at this problem a while
> ago) implement qAttached in his kernel stubs.
>
> I hereby withdraw my earlier patch in favor of the one below.
>
> Further comments?
Makes sense to me.
> * solib-svr4.c (enable_break): Don't attempt to place breakpoints,
> when attaching, on the names in bkpt_names: _start, __start, and
> main.