Re: [patch 1/8] Generalize interaction with agent in gdb/gdbserver

Yao Qi
2012-02-14T02:41:25Z

On 02/10/2012 03:20 AM, Pedro Alves wrote:
>> > +#ifdef GDBSERVER
>> > + /* Need to read response with the inferior stopped. */
>> > + if (!ptid_equal (ptid, null_ptid))
>> > + {
>> > + int was_non_stop = non_stop;
>> > + struct target_waitstatus status;
>> > + struct thread_resume resume_info;
>> > +
>> > + /* Stop thread PTID. */
>> > + resume_info.thread = ptid;
>> > + resume_info.kind = resume_stop;
>> > + resume_info.sig = TARGET_SIGNAL_0;
>> > + (*the_target->resume) (&resume_info, 1);
>> > +
>> > + non_stop = 1;
>> > + mywait (ptid, &status, 0, 0);
>> > + non_stop = was_non_stop;
>> > + }
>> > +#endif
> Since there's no #else, I take it you haven't really tried using this
> on GDB, without gdbserver?
>

I thought this part can be removed. The intention of this part is to
really stop "debugging thread", so it is safe to read from command
buffer later. We don't have "debugging thread" stopped, because the
synchronization of read and write is controlled by socket. When we get
here, after reading one byte from socket, "debugging thread" has
finished executing command, and write return result in command buffer.
It is being blocked by reading from socket, even it is not stopped.
GDB/GDBserver can safely read contents out of command buffer without
having to stop "debugging thread". Am I missing something here?

I get rid of this part from its original place (gdbserver/tracepoint.c),
and run gdb.trace/strace.exp. Results look unchanged.

--
Yao (é½å°§)