Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Vladimir Prus <vladimir@codesourcery.com>
To: gdb-patches@sources.redhat.com
Subject: [RFA] Implement 'detach pid'.
Date: Wed, 12 Nov 2008 21:17:00 -0000	[thread overview]
Message-ID: <200811122339.02463.vladimir@codesourcery.com> (raw)


This patch makes CLI 'detach' and MI '-target-detach' accept the PID
of the process to detach from.

Is the infcmd.c change OK?

- Volodya

From 8c0569ee17d85cf591426a0b9900d8cad0e02389 Mon Sep 17 00:00:00 2001

	* infcmd.c (_initialize_infcmd): Make 'detach' accept
	parameter.
	* mi/mi-cmds.c (mi_cmds): Make '-target-detach' pass parameter
	to 'detach'.
	* remote.c (remote_detach_1): Interpret the passed
	parameter as a pid to detach from.
---
 gdb/infcmd.c     |    2 +-
 gdb/mi/mi-cmds.c |    2 +-
 gdb/remote.c     |   13 +++++++++++--
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index b3af31f..76b48ae 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2556,7 +2556,7 @@ to specify the program, and to load its symbol table."));
 Detach a process or file previously attached.\n\
 If a process, it is no longer traced, and it continues its execution.  If\n\
 you were debugging a file, the file is closed and gdb no longer accesses it."),
-		  &detachlist, "detach ", 0, &cmdlist);
+		  &detachlist, "detach ", 1, &cmdlist);
 
   add_com ("disconnect", class_run, disconnect_command, _("\
 Disconnect from a target.\n\
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index d38de35..708dcf8 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -121,7 +121,7 @@ struct mi_cmd mi_cmds[] =
   { "symbol-type", { NULL, 0 }, NULL },
   { "target-attach", { "attach", 1 }, NULL },
   { "target-compare-sections", { NULL, 0 }, NULL },
-  { "target-detach", { "detach", 0 }, 0 },
+  { "target-detach", { "detach", 1 }, 0 },
   { "target-disconnect", { "disconnect", 0 }, 0 },
   { "target-download", { "load", 1 }, NULL},
   { "target-exec-status", { NULL, 0 }, NULL },
diff --git a/gdb/remote.c b/gdb/remote.c
index 5cb36b8..b1adfdb 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -3261,11 +3261,20 @@ remote_open_1 (char *name, int from_tty, struct target_ops *target, int extended
 static void
 remote_detach_1 (char *args, int from_tty, int extended)
 {
-  int pid = ptid_get_pid (inferior_ptid);
+  int pid;
   struct remote_state *rs = get_remote_state ();
 
   if (args)
-    error (_("Argument given to \"detach\" when remotely debugging."));
+    {      
+      char *end = args;
+      pid = strtol (args, &end, 10);
+      if (*end != '\0')
+	error (_("Cannot parse process id '%s'"), args);
+      if (!in_inferior_list (pid))
+	error (_("Invalid process id %d"), pid);
+    }
+  else
+    pid = ptid_get_pid (inferior_ptid);
 
   if (!target_has_execution)
     error (_("No process to detach from."));
-- 
1.5.3.5


             reply	other threads:[~2008-11-12 20:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-12 21:17 Vladimir Prus [this message]
2008-11-13 12:52 ` Pedro Alves
2008-11-14  1:55   ` Vladimir Prus
2008-11-14  5:12     ` Pedro Alves
2008-11-14 12:57       ` Vladimir Prus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200811122339.02463.vladimir@codesourcery.com \
    --to=vladimir@codesourcery.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox