From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11312 invoked by alias); 21 Sep 2012 10:01:43 -0000 Received: (qmail 11303 invoked by uid 22791); 21 Sep 2012 10:01:42 -0000 X-SWARE-Spam-Status: No, hits=-3.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,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 10:01:28 +0000 Received: from eusaamw0712.eamcs.ericsson.se ([147.117.20.181]) by imr4.ericy.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id q8LA6uZs026570 for ; Fri, 21 Sep 2012 05:06:57 -0500 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.2.164]) by eusaamw0712.eamcs.ericsson.se ([147.117.20.181]) with mapi; Fri, 21 Sep 2012 06:01:21 -0400 From: Marc Khouzam To: "gdb-patches@sourceware.org" Date: Fri, 21 Sep 2012 10:01:00 -0000 Subject: [MI][patch] -break-list to specify "thread-group" 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: 2012-09/txt/msg00429.txt.bz2 Hi, 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 =20 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 this new field. 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["2"]},{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["1"]}]} 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"loopfirs= t.cc:8"},{number=3D"1.1",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["2","1"]},{number=3D"1.2",enabled=3D"y",addr=3D"0x08= 048533",func=3D"main()",file=3D"loopfirst.cc",fullname=3D"/home/lmckhou/tes= ting/loopfirst.cc",line=3D"8",thread-group=3D["2","1"]}]} I was going to update the doc, but when I looked at it=20 I realized it was completely out-of-date with respect to=20 -break-list _and_ that the MI output itself does not to have=20 the right content in the 'hdr' part. I wasn't sure if I can=20 change such MI output or not due to backwards compatibility. Can this patch go in as is? Or can I get some guidance=20 about how to handle this out-of-date MI output? Thanks Marc 2012-09-20 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 09:50:03 -0000 @@ -5779,6 +5779,36 @@ 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; + + make_cleanup (xfree, groups); + + for (p =3D strtok (p, ","); p; p =3D strtok (NULL, ",")) + { + if (first) + { + first =3D 0; + ui_out_text (uiout, " inf "); + } + else + ui_out_text (uiout, ", "); + ui_out_field_string (uiout, NULL, p); + } + + do_cleanups (back_to); +} + /* Print B to gdb_stdout. */ =20 static void @@ -5944,21 +5974,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)