From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10407 invoked by alias); 27 Sep 2010 20:28:56 -0000 Received: (qmail 10397 invoked by uid 22791); 27 Sep 2010 20:28:55 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from imr3.ericy.com (HELO imr3.ericy.com) (198.24.6.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 27 Sep 2010 20:28:48 +0000 Received: from eusaamw0712.eamcs.ericsson.se ([147.117.20.181]) by imr3.ericy.com (8.13.8/8.13.8) with ESMTP id o8RKSBox002865 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL) for ; Mon, 27 Sep 2010 15:28:46 -0500 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.1.219]) by eusaamw0712.eamcs.ericsson.se ([147.117.20.181]) with mapi; Mon, 27 Sep 2010 16:25:30 -0400 From: Marc Khouzam To: "'gdb-patches@sourceware.org'" Date: Tue, 28 Sep 2010 09:21:00 -0000 Subject: [MI][patch] broken -target-detach Message-ID: 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-09/txt/msg00464.txt.bz2 Hi, with GDB 7.2, the MI command -target-detach is not working 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: Usage: -target-detach [thread-group] vs -target-detach [ pid | gid ] I have a patch that fixes things to parse both a pid or a thread-group. I've added it at the bottom, but I'm not sure it is the right approach. With the new global MI flag --thread-group, I wonder if -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. What should we do about this? Thanks Marc You can see the error in the session below: GNU gdb (GDB) 7.2.50.20100927-cvs (gdb) interpreter-exec mi "-target-attach --thread-group i1 12283" ^done,frame=3D{addr=3D"0x00f2b422",func=3D"__kernel_vsyscall",args=3D[]} (gdb)=20 (gdb) interpreter-exec mi "-list-thread-groups" ^done,groups=3D[{id=3D"i1",type=3D"process",pid=3D"12283",executable=3D"/ho= me/lmckhou/testing/a1",cores=3D["0"]}] (gdb)=20 (gdb) interpreter-exec mi "-target-detach a a" ^error,msg=3D"Usage: -target-detach [thread-group]" (gdb)=20 (gdb) interpreter-exec mi "-target-detach i1" ^error,msg=3D"Cannot parse thread group id 'i1'" (gdb) interpreter-exec mi "-target-detach --thread-group i1" ^done Patch: ### 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 27 Sep 2010 17:18:21 -0000 @@ -418,19 +418,36 @@ 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]; + /* First see if we are dealing with a pid */ int pid =3D strtol (argv[0], &end, 10); =20 if (*end !=3D '\0') - error (_("Cannot parse thread group id '%s'"), argv[0]); + { + int id; + struct inferior *inf; + /* We are not dealing with a pid. Check for group id */ + if (*(argv[0]) !=3D 'i') + error (_("Invalid pid or thread-group id '%s'"), argv[0]); + + id =3D strtoul (argv[0] + 1, &end, 0); + if (*end !=3D '\0') + error (_("Invalid syntax of 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; + } =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"));