Re: [RFC] Limit attempts to place breakpoints on _start, __start, and main in solib-svr4.c

Jan Kratochvil
2010-12-01T23:03:55Z

On Wed, 01 Dec 2010 02:06:18 +0100, Kevin Buettner wrote:
> My testing shows that use of `! current_inferior ()->attach_flag' as
> the test in enable_break() works when attaching to a process started
> natively. I also see the correct behavior (in which a breakpoint is
> placed on _start, et al) when the process is started via GDB's
> "run" command.
>
> The case that doesn't work - and, unfortunately, it's the case that
> really matters to me - is connecting to a remote target via "target
> remote".

GNU gdb (GDB) 7.2.50.20101201-cvs

killall -9 gdbserver;sleep 1h&p=$!;sleep 0.1;./gdbserver/gdbserver :1234 ./pause& ./gdb -nx -ex 'file ./pause' -ex 'target remote localhost:1234'
attach_flag=0
- correct

killall -9 gdbserver;./pause&p=$!;sleep 0.1;./gdbserver/gdbserver --attach :1234 $p& ./gdb -nx -ex 'file ./pause' -ex 'target remote localhost:1234'
attach_flag=1
- correct

killall -9 gdbserver;./pause&p=$!;sleep 0.1;./gdbserver/gdbserver --multi :1234& ./gdb -nx -ex 'file ./pause' -ex 'target extended-remote localhost:1234' -ex "attach $p"
attach_flag=1
- correct

Probably in the first case you do not want to place those breakpoints?

But I think at least the "main" breakpoint is the one requested by Mark
Kettenis to stay there even in the case solib_break_names[] bpts fail:
http://sourceware.org/ml/gdb-patches/2010-09/msg00313.html

Maybe the single-hit variant would be enough?

> The patch that I've posted does correctly handle the "target remote"
> case. (It correctly handles the native cases too.)

(The problem is it introduces two variants of "attach_flag".)

Thanks,
Jan