2002-08-06 Daniel Jacobowitz * remote.c (remote_detach): Support `detach remote'. (remote_async_detach): Likewise. 2002-08-06 Daniel Jacobowitz * gdb.texinfo: Document `detach remote'. (Remote Protocol): Document `K' packet. Index: remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.89 diff -u -p -r1.89 remote.c --- remote.c 23 Jul 2002 18:55:06 -0000 1.89 +++ remote.c 6 Aug 2002 20:49:59 -0000 @@ -2496,17 +2496,28 @@ remote_detach (char *args, int from_tty) struct remote_state *rs = get_remote_state (); char *buf = alloca (rs->remote_packet_size); - if (args) - error ("Argument given to \"detach\" when remotely debugging."); - - /* Tell the remote target to detach. */ - strcpy (buf, "D"); - remote_send (buf, (rs->remote_packet_size)); + if (args && strcmp (args, "remote") == 0) + { + /* Tell the target to detach and resume the inferior. */ + putpkt ("K"); + getpkt (buf, rs->remote_packet_size, 0); + if (strcmp (buf, "ERR") == 0) + error ("Remote target refused to detach."); + else if (strcmp (buf, "OK") != 0) + error ("Remote target does not support detaching."); + } + else if (args) + error ("Unknown argument given to \"detach\"."); + else + { + /* Tell the remote target to detach. */ + strcpy (buf, "D"); + remote_send (buf, (rs->remote_packet_size)); + } target_mourn_inferior (); if (from_tty) puts_filtered ("Ending remote debugging.\n"); - } /* Same as remote_detach, but with async support. */ @@ -2516,12 +2527,24 @@ remote_async_detach (char *args, int fro struct remote_state *rs = get_remote_state (); char *buf = alloca (rs->remote_packet_size); - if (args) - error ("Argument given to \"detach\" when remotely debugging."); - - /* Tell the remote target to detach. */ - strcpy (buf, "D"); - remote_send (buf, (rs->remote_packet_size)); + if (args && strcmp (args, "remote") == 0) + { + /* Tell the target to detach and resume the inferior. */ + putpkt ("K"); + getpkt (buf, rs->remote_packet_size, 0); + if (strcmp (buf, "ERR") == 0) + error ("Remote target refused to detach."); + else if (strcmp (buf, "OK") != 0) + error ("Remote target does not support detaching."); + } + else if (args) + error ("Unknown argument given to \"detach\"."); + else + { + /* Tell the remote target to detach. */ + strcpy (buf, "D"); + remote_send (buf, (rs->remote_packet_size)); + } /* Unregister the file descriptor from the event loop. */ if (target_is_async_p ()) Index: doc/gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.107 diff -u -p -r1.107 gdb.texinfo --- doc/gdb.texinfo 3 Aug 2002 23:37:07 -0000 1.107 +++ doc/gdb.texinfo 6 Aug 2002 20:50:03 -0000 @@ -10784,8 +10784,11 @@ session. Now you can use all the usual commands to examine and change data and to step and continue the remote program. -To resume the remote program and stop debugging it, use the @code{detach} -command. +To end remote debugging, use the @code{detach} command. Most remote stubs +will wait for @value{GDBN} to reconnect; for some stubs, you can use +@code{detach remote} to cause the stub to resume the remote program. +Depending on the remote stub, this may cause the stub to exit or become +unavailable. @cindex interrupting remote programs @cindex remote programs, interrupting @@ -14502,6 +14505,20 @@ See @samp{i} and @samp{S} for likely syn @tab FIXME: @emph{There is no description of how to operate when a specific thread context has been selected (i.e.@: does 'k' kill only that thread?)}. + +@item Detach request +@tab @code{K} +@tab +Detach @value{GDBN} from the remote system. Sent to the remote target before +@value{GDBN} disconnects. This packet indicates that the inferior should +be resumed instead of kept stopped, waiting for @value{GDBN} to reconnect. +The stub may exit after replying to this packet, or may wait for @value{GDBN}. +@item +@tab reply @code{ERR} +@tab The stub should return failure if it can not detach or refuses to detach. +@item +@tab reply @code{OK} +@tab Success @item reserved @tab @code{l}