From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27525 invoked by alias); 12 Nov 2010 16:02:34 -0000 Received: (qmail 27509 invoked by uid 22791); 12 Nov 2010 16:02:29 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from imr4.ericy.com (HELO imr4.ericy.com) (198.24.6.8) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 12 Nov 2010 16:01:46 +0000 Received: from eusaamw0711.eamcs.ericsson.se ([147.117.20.178]) by imr4.ericy.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id oACGPIBs001616; Fri, 12 Nov 2010 10:25:19 -0600 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.1.63]) by eusaamw0711.eamcs.ericsson.se ([147.117.20.178]) with mapi; Fri, 12 Nov 2010 11:01:22 -0500 From: Marc Khouzam To: "'Pedro Alves'" , "'gdb-patches@sourceware.org'" , "'Tom Tromey'" Date: Fri, 12 Nov 2010 16:02:00 -0000 Subject: RE: [MI][patch] broken -target-detach Message-ID: References: <201010160047.03094.pedro@codesourcery.com> In-Reply-To: <201010160047.03094.pedro@codesourcery.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes 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: 2010-11/txt/msg00157.txt.bz2 > -----Original Message----- > From: Pedro Alves [mailto:pedro@codesourcery.com]=20 > Sent: Friday, October 15, 2010 7:47 PM > To: gdb-patches@sourceware.org > Cc: Marc Khouzam > Subject: Re: [MI][patch] broken -target-detach >=20 > On Monday 27 September 2010 21:25:27, Marc Khouzam wrote: > > Hi, > >=20 > > with GDB 7.2, the MI command -target-detach is not working=20 > very well. > > It still assumes that the thread-group id is a pid, instead of the > > new thread-group id format which starts with an 'i'. > > Also, the usage printout does not correspond to the documentation: > >=20 > > Usage: -target-detach [thread-group] > > vs > > -target-detach [ pid | gid ] >=20 > Yeah. I think it used to correspond implicitly, since the thread > group id in 7.0 and 7.1 was actually equal to the pid, IIRC. With > 7.2, the 1-1 correspondence disappeared, but this command appears > to have been forgotten. >=20 > One would hope that frontends would stop using the PID form, > cause you may want to detach from targets that don't have > a PID concept at all, and even though GDB fakes a PID for > you today in such cases, it's better to not assume that. >=20 > Unfortunately, 7.2 was released accepting the PID form only, > so we may be better off continue accepting it... If we put this fix in the 7.2 branch, could we get rid of the PID form or is it too late? > > I have a patch that fixes things to parse both a pid or a=20 > thread-group. > > I've added it at the bottom, but I'm not sure it is the=20 > right approach. > > With the new global MI flag --thread-group, I wonder if=20 > -target-detach > > should take a thread-group as a parameter anymore. > > Note that although "-target-detach i1" does not work, > > "-target-detach --thread-group i1" works. > > I'm not sure what would happen if I did: > > "-target-detach --thread-group i1 " > > I'm guessing the --thread-group flag would get ignored. > >=20 > > What should we do about this? >=20 > FWIW, codewise, your patch also looked good to me. > (though IMO it'd be clearer to check for *argv[0] =3D=3D 'i' even > before trying to parse a number with strtol.) I knew someone was going to call me on that :-). Here is the new patch which still accepts PID. I have to apologize, I just don't have the time to get a test case for it. I hope the patch is useful enough as it is. If you feel we can get rid of PID, just let me know. Good for the 7.2 branch too? Thanks Marc 2010-11-12 Marc Khouzam * mi/mi-main.c (mi_cmd_target_detach): Accept new thread-group id format. ### Eclipse Workspace Patch 1.0 #P src Index: gdb/mi/mi-main.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/mi/mi-main.c,v retrieving revision 1.181 diff -u -r1.181 mi-main.c --- gdb/mi/mi-main.c 1 Sep 2010 19:03:54 -0000 1.181 +++ gdb/mi/mi-main.c 12 Nov 2010 15:56:16 -0000 @@ -418,19 +418,40 @@ mi_cmd_target_detach (char *command, char **argv, int argc) { if (argc !=3D 0 && argc !=3D 1) - error ("Usage: -target-detach [thread-group]"); + error ("Usage: -target-detach [pid | thread-group]"); =20 if (argc =3D=3D 1) { struct thread_info *tp; char *end =3D argv[0]; - int pid =3D strtol (argv[0], &end, 10); + int pid; =20 - if (*end !=3D '\0') - error (_("Cannot parse thread group id '%s'"), argv[0]); + /* First see if we are dealing with a thread-group id */ + if (*(argv[0]) =3D=3D 'i') + { + struct inferior *inf; + int id =3D strtoul (argv[0] + 1, &end, 0); + + if (*end !=3D '\0') + error (_("Invalid syntax of thread-group id '%s'"), argv[0]); + + inf =3D find_inferior_id (id); + if (!inf) + error (_("Non-existent thread-group id '%d'"), id); + + pid =3D inf->pid; + } + else + { + /* We must be dealing with a pid */ + pid =3D strtol (argv[0], &end, 10); + + if (*end !=3D '\0') + error (_("Invalid identifier '%s'"), argv[0]); + } =20 /* Pick any thread in the desired process. Current - target_detach deteches from the parent of inferior_ptid. */ + target_detach detaches from the parent of inferior_ptid. */ tp =3D iterate_over_threads (find_thread_of_process, &pid); if (!tp) error (_("Thread group is empty"));