This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] stdio gdbserver connection


On Tue, Jun 8, 2010 at 10:27 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Tue, May 25, 2010 at 10:27:15AM -0700, Doug Evans wrote:
>> Hi.
>>
>> This patch lets gdbserver communicate via stdio.
>>
>> E.g.
>>
>> (gdb) target remote | ssh -T myhost gdbserver stdio hello
>
> Silly thing to comment about but... "-" instead to mean stdio?

Sure.  I avoided it but I don't have a strong preference.

>> One outstanding issue is what to do with inferior stdio.
>> stderr is ok, it'll just get propagated back to gdb which will display it.
>> But we don't want inferior stdio to interfere with the gdb connection.
>
> Send it to a pipe, pass it to GDB over semihosting?

Does semihosting work with non-stop mode?

An alternative, I think, is to redirect the inferior's stdout,stderr
to gdbserver's stderr, and redirect stdin to /dev/null (say).
That feels like more of a hack than explicitly handling inferior stdio.
But it's simpler, or at least should be theoretically ... alas when
gdbserver is starting it calls start_inferior before remote_open, and
thus unless one makes the chosen kind of connection known before
remote_open is called (or passes "port" to start_inferior, blech),
it's a non-starter.  Sigh.

Even when not using stdio, it can be useful to have the inferior's
stdio fed back to gdb, so that's probably the way to go (as an option)
anyway.
Except that it depends on my above question: Does semihosting work
with non-stop mode?  AIUI, currently it doesn't, but presumably it
could be made to.
[This feature isn't something that should be all-stop mode only.]

>> + ? ? ?/* Use stdin as the handle of the connection.
>> + ? ? ?We only select on reads, for example. ?*/
>> + ? ? ?remote_desc = 0;
>
> 0 -> STDIN_FILENO? ?That's what you check for.

Right, missed that.
I think I'll go with fileno().

>> Index: gdbserver/server.c
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
>> retrieving revision 1.120
>> diff -u -p -r1.120 server.c
>> --- gdbserver/server.c ? ? ? ?3 May 2010 04:02:20 -0000 ? ? ? 1.120
>> +++ gdbserver/server.c ? ? ? ?25 May 2010 16:48:02 -0000
>> @@ -2502,11 +2502,17 @@ main (int argc, char *argv[])
>>
>> ? ? ? ?/* If an exit was requested (using the "monitor exit" command),
>> ? ? ? ?terminate now. ?The only other way to get here is for
>> - ? ? ?getpkt to fail; close the connection and reopen it at the
>> + ? ? ?getpkt to fail; if the connection is via stdio terminate now,
>> + ? ? ?otherwise close the connection and reopen it at the
>> ? ? ? ?top of the loop. ?*/
>>
>> - ? ? ?if (exit_requested)
>> + ? ? ?if (exit_requested
>> + ? ? ? || remote_connection_is_stdio ())
>> ? ? ? {
>> + ? ? ? if (debug_threads
>> + ? ? ? ? ? && remote_connection_is_stdio ())
>> + ? ? ? ? fprintf (stderr, "Remote side has terminated connection. ?"
>> + ? ? ? ? ? ? ? ? ?"Shutting down.\n");
>> ? ? ? ? detach_or_kill_for_exit ();
>> ? ? ? ? exit (0);
>> ? ? ? }
>
> This will print the message if exit_requested &&
> remote_connection_is_stdio (); was that intended?

Not so much intended as not caring as it was just a debugging message.

>> +@smallexample
>> +(gdb) target remote | ssh -T gdbserver stdio emacs foo.txt
>> +@end smallexample
>> +
>> +The @samp{-T} option to ssh is provided because we don't need a remote pty,
>> +and we don't want escape-character handling.
>
> Host name is missing. ?Doesn't ssh default to -T if there's a command?

Right.
Re: -T: I didn't know whether it did, but at least in openssh's
implementation it does.

> I've no complaints about the general feature.
>
> A caveat somewhere about running with a terminal might be in order.
> Apps that write directly to the tty are unfortunately not too
> uncommon.
>
> --
> Daniel Jacobowitz
> CodeSourcery
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]