From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4987 invoked by alias); 21 Sep 2012 14:47:22 -0000 Received: (qmail 4973 invoked by uid 22791); 21 Sep 2012 14:47:20 -0000 X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from imr4.ericy.com (HELO imr4.ericy.com) (198.24.6.9) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 21 Sep 2012 14:47:06 +0000 Received: from eusaamw0706.eamcs.ericsson.se ([147.117.20.31]) by imr4.ericy.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id q8LEqY4T031269 for ; Fri, 21 Sep 2012 09:52:37 -0500 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.2.164]) by eusaamw0706.eamcs.ericsson.se ([147.117.20.31]) with mapi; Fri, 21 Sep 2012 10:47:01 -0400 From: Marc Khouzam To: "gdb-patches@sourceware.org" Date: Fri, 21 Sep 2012 14:47:00 -0000 Subject: [MI][patch v2] -break-list to specify "thread-group" Message-ID: References: In-Reply-To: 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: 2012-09/txt/msg00435.txt.bz2 Hi, Here's a second stab at it using the "i" prefix for MI. In Eclipse I'm trying to filter breakpoints per thread and/or per process. Currently -break-list does not tell me the inferior of a bp as 'info break' does. Currently: (gdb) inf b Num Type Disp Enb Address What 1 breakpoint keep y 1.1 y 0x08048533 in main() at loopfirst.cc:8 in= f 2 1.2 y 0x08048533 in main() at loopfirst.cc:8 in= f 1 Notice the "inf 1" tag at the end. (gdb) interpreter-exec mi -break-list ^done,BreakpointTable=3D{nr_rows=3D"1",nr_cols=3D"6",hdr=3D[{width=3D"7",al= ignment=3D"-1",col_name=3D"number",colhdr=3D"Num"},{width=3D"14",alignment= =3D"-1",col_name=3D"type",colhdr=3D"Type"},{width=3D"4",alignment=3D"-1",co= l_name=3D"disp",colhdr=3D"Disp"},{width=3D"3",alignment=3D"-1",col_name=3D"= enabled",colhdr=3D"Enb"},{width=3D"10",alignment=3D"-1",col_name=3D"addr",c= olhdr=3D"Address"},{width=3D"40",alignment=3D"2",col_name=3D"what",colhdr= =3D"What"}],body=3D[bkpt=3D{number=3D"1",type=3D"breakpoint",disp=3D"keep",= enabled=3D"y",addr=3D"",times=3D"0",original-location=3D"/home/lm= ckhou/testing/loopfirst.cc:8"},{number=3D"1.1",enabled=3D"y",addr=3D"0x0804= 8533",func=3D"main()",file=3D"loopfirst.cc",fullname=3D"/home/lmckhou/testi= ng/loopfirst.cc",line=3D"8"},{number=3D"1.2",enabled=3D"y",addr=3D"0x080485= 33",func=3D"main()",file=3D"loopfirst.cc",fullname=3D"/home/lmckhou/testing= /loopfirst.cc",line=3D"8"}]} but no such info from MI. The below patch adds the new field "thread-group". The output would then look like: (gdb) interpreter-exec mi -break-list ^done,BreakpointTable=3D{nr_rows=3D"1",nr_cols=3D"6",hdr=3D[{width=3D"7",al= ignment=3D"-1",col_name=3D"number",colhdr=3D"Num"},{width=3D"14",alignment= =3D"-1",col_name=3D"type",colhdr=3D"Type"},{width=3D"4",alignment=3D"-1",co= l_name=3D"disp",colhdr=3D"Disp"},{width=3D"3",alignment=3D"-1",col_name=3D"= enabled",colhdr=3D"Enb"},{width=3D"10",alignment=3D"-1",col_name=3D"addr",c= olhdr=3D"Address"},{width=3D"40",alignment=3D"2",col_name=3D"what",colhdr= =3D"What"}],body=3D[bkpt=3D{number=3D"1",type=3D"breakpoint",disp=3D"keep",= enabled=3D"y",addr=3D"",times=3D"0",original-location=3D"/home/lm= ckhou/testing/loopfirst.cc:8"},{number=3D"1.1",enabled=3D"y",addr=3D"0x0804= 8533",func=3D"main()",file=3D"loopfirst.cc",fullname=3D"/home/lmckhou/testi= ng/loopfirst.cc",line=3D"8",thread-group=3D["i2"]},{number=3D"1.2",enabled= =3D"y",addr=3D"0x08048533",func=3D"main()",file=3D"loopfirst.cc",fullname= =3D"/home/lmckhou/testing/loopfirst.cc",line=3D"8",thread-group=3D["i1"]}]} or (if the bp applies to multiple inferiors, which I didn't quite out how to officially trigger, so I hacked the code to make sure the output was done properly in that case): (gdb) interpreter-exec mi -break-list ^done,BreakpointTable=3D{nr_rows=3D"1",nr_cols=3D"6",hdr=3D[{width=3D"7",al= ignment=3D"-1",col_name=3D"number",colhdr=3D"Num"},{width=3D"14",alignment= =3D"-1",col_name=3D"type",colhdr=3D"Type"},{width=3D"4",alignment=3D"-1",co= l_name=3D"disp",colhdr=3D"Disp"},{width=3D"3",alignment=3D"-1",col_name=3D"= enabled",colhdr=3D"Enb"},{width=3D"10",alignment=3D"-1",col_name=3D"addr",c= olhdr=3D"Address"},{width=3D"40",alignment=3D"2",col_name=3D"what",colhdr= =3D"What"}],body=3D[bkpt=3D{number=3D"1",type=3D"breakpoint",disp=3D"keep",= enabled=3D"y",addr=3D"",times=3D"0",original-location=3D"/home/lm= ckhou/testing/loopfirst.cc:8"},{number=3D"1.1",enabled=3D"y",addr=3D"0x0804= 8533",func=3D"main()",file=3D"loopfirst.cc",fullname=3D"/home/lmckhou/testi= ng/loopfirst.cc",line=3D"8",thread-group=3D["i2","i1"]},{number=3D"1.2",ena= bled=3D"y",addr=3D"0x08048533",func=3D"main()",file=3D"loopfirst.cc",fullna= me=3D"/home/lmckhou/testing/loopfirst.cc",line=3D"8",thread-group=3D["i2","= i1"]}]} I was going to update the doc, but when I looked at it I realized it was completely out-of-date with respect to -break-list _and_ that the MI output itself does not to have the right content in the 'hdr' part. I wasn't sure if I can change such MI output or not due to backwards compatibility. Can this patch go in as is? Or can I get some guidance about how to handle this out-of-date MI output? Thanks Marc 2012-09-21 Marc Khouzam * breakpoint.c (print_one_breakpoint_location): Add MI field 'thread-group' to output of -break-list. (output_thread_groups): New function. ### Eclipse Workspace Patch 1.0 #P src Index: gdb/breakpoint.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/breakpoint.c,v retrieving revision 1.704 diff -u -r1.704 breakpoint.c --- gdb/breakpoint.c 17 Sep 2012 07:03:14 -0000 1.704 +++ gdb/breakpoint.c 21 Sep 2012 14:40:23 -0000 @@ -69,6 +69,7 @@ #include "gdb_regex.h" #include "ax-gdb.h" #include "dummy-frame.h" +#include "interps.h" =20 #include "format.h" =20 @@ -5779,6 +5780,46 @@ return bptypes[(int) type].description; } =20 +/* Output a field named 'thread-group' with a list as the value. The + elements of the list are obtained by splitting 'groups' on + comma. */ + +static void=20 +output_thread_groups (struct ui_out *uiout, const char *field_name, const = char *xgroups) +{ + struct cleanup *back_to =3D make_cleanup_ui_out_list_begin_end (uiout, + field_name); + char *groups =3D xstrdup (xgroups); + char *p =3D groups; + int first =3D 1; + int is_mi =3D ui_out_is_mi_like_p (uiout); + + make_cleanup (xfree, groups); + + for (p =3D strtok (p, ","); p; p =3D strtok (NULL, ",")) + { + if (is_mi) + { + char mi_group[10] =3D "i"; + ui_out_field_string (uiout, NULL, strcat (mi_group, p)); + } + else + { + if (first) + { + first =3D 0; + ui_out_text (uiout, " inf "); + } + else + ui_out_text (uiout, ", "); + + ui_out_text (uiout, p); + } + } + + do_cleanups (back_to); +} + /* Print B to gdb_stdout. */ =20 static void @@ -5944,21 +5985,27 @@ { struct inferior *inf; int first =3D 1; + char thread_groups[100];=20 + const char *inf_name; + int len; =20 + thread_groups[0] =3D 0; for (inf =3D inferior_list; inf !=3D NULL; inf =3D inf->next) { if (inf->pspace =3D=3D loc->pspace) { if (first) - { - first =3D 0; - ui_out_text (uiout, " inf "); - } + first =3D 0; else - ui_out_text (uiout, ", "); - ui_out_text (uiout, plongest (inf->num)); + strncat (thread_groups, ",", len); + + inf_name =3D plongest (inf->num); + len =3D strlen (inf_name); + strncat (thread_groups, inf_name, len); } } + output_thread_groups (uiout, "thread-group", thread_groups); + } =20 if (!part_of_multiple)