This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [MI][patch] -break-list to specify "thread-group"
- From: Marc Khouzam <marc dot khouzam at ericsson dot com>
- To: Marc Khouzam <marc dot khouzam at ericsson dot com>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Fri, 21 Sep 2012 06:41:57 -0400
- Subject: RE: [MI][patch] -break-list to specify "thread-group"
- References: <F7CE05678329534C957159168FA70DEC5E11404FDC@EUSAACMS0703.eamcs.ericsson.se>
> 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 <MULTIPLE>
> 1.1 y 0x08048533 in main() at loopfirst.cc:8 inf 2
> 1.2 y 0x08048533 in main() at loopfirst.cc:8 inf 1
>
> Notice the "inf 1" tag at the end.
>
> (gdb) interpreter-exec mi -break-list
> ^done,BreakpointTable={nr_rows="1",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="<MULTIPLE>",times="0",original-location="/home/lmckhou/testing/loopfirst.cc:8"},{number="1.1",enabled="y",addr="0x08048533",func="main()",file="loopfirst.cc",fullname="/home/lmckhou/testing/loopfirst.cc",line="8"},{number="1.2",enabled="y",addr="0x08048533",func="main()",file="loopfirst.cc",fullname="/home/lmckhou/testing/loopfirst.cc",line="8"}]}
>
> but no such info from MI.
>
> The below patch adds this new field.
I just realized I should use "i<num>" for an MI thread-group id e.g., "i1", "i2"
I'll come back with a new version of the patch.
Sorry about that.
> The output would then look like:
>
> (gdb) interpreter-exec mi -break-list
> ^done,BreakpointTable={nr_rows="1",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="<MULTIPLE>",times="0",original-location="/home/lmckhou/testing/loopfirst.cc:8"},{number="1.1",enabled="y",addr="0x08048533",func="main()",file="loopfirst.cc",fullname="/home/lmckhou/testing/loopfirst.cc",line="8",thread-group=["2"]},{number="1.2",enabled="y",addr="0x08048533",func="main()",file="loopfirst.cc",fullname="/home/lmckhou/testing/loopfirst.cc",line="8",thread-group=["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={nr_rows="1",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="<MULTIPLE>",times="0",original-location="loopfirst.cc:8"},{number="1.1",enabled="y",addr="0x08048533",func="main()",file="loopfirst.cc",fullname="/home/lmckhou/testing/loopfirst.cc",line="8",thread-group=["2","1"]},{number="1.2",enabled="y",addr="0x08048533",func="main()",file="loopfirst.cc",fullname="/home/lmckhou/testing/loopfirst.cc",line="8",thread-group=["2","1"]}]}
>
>
> 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-20 Marc Khouzam <marc.khouzam@ericsson.com>
>
> * 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
> ===================================================================
> 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;
> }
>
> +/* 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
> +output_thread_groups (struct ui_out *uiout, const char *field_name, const char *xgroups)
> +{
> + struct cleanup *back_to = make_cleanup_ui_out_list_begin_end (uiout,
> + field_name);
> + char *groups = xstrdup (xgroups);
> + char *p = groups;
> + int first = 1;
> +
> + make_cleanup (xfree, groups);
> +
> + for (p = strtok (p, ","); p; p = strtok (NULL, ","))
> + {
> + if (first)
> + {
> + first = 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. */
>
> static void
> @@ -5944,21 +5974,27 @@
> {
> struct inferior *inf;
> int first = 1;
> + char thread_groups[100];
> + const char *inf_name;
> + int len;
>
> + thread_groups[0] = 0;
> for (inf = inferior_list; inf != NULL; inf = inf->next)
> {
> if (inf->pspace == loc->pspace)
> {
> if (first)
> - {
> - first = 0;
> - ui_out_text (uiout, " inf ");
> - }
> + first = 0;
> else
> - ui_out_text (uiout, ", ");
> - ui_out_text (uiout, plongest (inf->num));
> + strncat (thread_groups, ",", len);
> +
> + inf_name = plongest (inf->num);
> + len = strlen (inf_name);
> + strncat (thread_groups, inf_name, len);
> }
> }
> + output_thread_groups (uiout, "thread-group", thread_groups);
> +
> }
>
> if (!part_of_multiple)