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, 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?

> 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?

> +      /* 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.

> 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?

> +@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?

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]