From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28907 invoked by alias); 12 Nov 2008 20:39:42 -0000 Received: (qmail 28818 invoked by uid 22791); 12 Nov 2008 20:39:41 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 12 Nov 2008 20:39:04 +0000 Received: (qmail 30706 invoked from network); 12 Nov 2008 20:34:49 -0000 Received: from unknown (HELO localhost) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 12 Nov 2008 20:34:49 -0000 From: Vladimir Prus To: gdb-patches@sources.redhat.com Subject: [RFA] Implement 'detach pid'. Date: Wed, 12 Nov 2008 21:17:00 -0000 User-Agent: KMail/1.9.10 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200811122339.02463.vladimir@codesourcery.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-11/txt/msg00249.txt.bz2 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 =46rom 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 i= t."), - &detachlist, "detach ", 0, &cmdlist); + &detachlist, "detach ", 1, &cmdlist); =20 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[] =3D { "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 tar= get_ops *target, int extended static void remote_detach_1 (char *args, int from_tty, int extended) { - int pid =3D ptid_get_pid (inferior_ptid); + int pid; struct remote_state *rs =3D get_remote_state (); =20 if (args) - error (_("Argument given to \"detach\" when remotely debugging.")); + {=20=20=20=20=20=20 + char *end =3D args; + pid =3D strtol (args, &end, 10); + if (*end !=3D '\0') + error (_("Cannot parse process id '%s'"), args); + if (!in_inferior_list (pid)) + error (_("Invalid process id %d"), pid); + } + else + pid =3D ptid_get_pid (inferior_ptid); =20 if (!target_has_execution) error (_("No process to detach from.")); --=20 1.5.3.5