This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
dynamic type column width in "info breakpoints" output (Re: Static tracepoints support)
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Cc: Eli Zaretskii <eliz at gnu dot org>
- Date: Thu, 1 Jul 2010 17:36:21 +0100
- Subject: dynamic type column width in "info breakpoints" output (Re: Static tracepoints support)
- References: <201006251931.57860.pedro@codesourcery.com> <83tyoqcc8i.fsf@gnu.org> <201006281326.39820.pedro@codesourcery.com>
On Monday 28 June 2010 13:26:38, Pedro Alves wrote:
> > > (gdb) info breakpoints
> > > Num Type Disp Enb Address What
> > > 1 breakpoint keep y 0x0000000000400c30 in main at stexample.c:13
> > > 2 static tracepoint keep y 0x0000000000400ddc in main at stexample.c:20
> > > static tracepoint id is ust/bar33
> > > collect $registers
> > > collect $_sdata
> >
> > Suggest to use "stracepoint" instead of "static tracepoint", because
> > the latter makes the table appear misaligned.
>
> We have other cases like that:
>
> (gdb) info breakpoints
> Num Type Disp Enb Address What
> 1 breakpoint keep y 0x0000000000400c30 in main at stexample.c:15
> breakpoint already hit 1 time
> 2 hw watchpoint keep y glob
> 3 read watchpoint keep y glob
> 4 fast tracepoint keep y 0x0000000000400ddc in main at stexample.c:18
> 5 static tracepoint keep y 0x0000000000400ddc in main at stexample.c:22
> static tracepoint id is ust/bar33
>
> I like seeing the static spelled out, like read and fast. Maybe we could
> instead dynamically adjust the column width to the largest type string, similarly
> to how we do for the "Address" column. I'll leave that for a follow up.
Okay, here's a last (I think) tweak I had signed up to do. The result is this:
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x0000000000400c30 in main at stexample.c:16
breakpoint already hit 1 time
2 read watchpoint keep y glob
3 static tracepoint keep y 0x0000000000400c7b in main at stexample.c:22
marker id is ust/bar33
Opinions on whether we want this?
--
Pedro Alves
20100-07-01 Pedro Alves <pedro@codesourcery.com>
* breakpoint.c (bptype_string): New, abstracted out from
print_one_breakpoint_location.
(print_one_breakpoint_location): Adjust.
(breakpoint_1): Adjust the type column width dynamically.
---
gdb/breakpoint.c | 66 +++++++++++++++++++++++++++++++++----------------------
1 file changed, 40 insertions(+), 26 deletions(-)
Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c 2010-07-01 17:25:17.000000000 +0100
+++ src/gdb/breakpoint.c 2010-07-01 17:34:21.000000000 +0100
@@ -4507,21 +4507,14 @@ static void print_breakpoint_location (s
do_cleanups (old_chain);
}
-/* Print B to gdb_stdout. */
-static void
-print_one_breakpoint_location (struct breakpoint *b,
- struct bp_location *loc,
- int loc_number,
- struct bp_location **last_loc,
- int print_address_bits,
- int allflag)
+static const char *
+bptype_string (enum bptype type)
{
- struct command_line *l;
struct ep_type_description
- {
- enum bptype type;
- char *description;
- };
+ {
+ enum bptype type;
+ char *description;
+ };
static struct ep_type_description bptypes[] =
{
{bp_none, "?deleted?"},
@@ -4550,7 +4543,27 @@ print_one_breakpoint_location (struct br
{bp_static_tracepoint, "static tracepoint"},
{bp_jit_event, "jit events"},
};
-
+
+ if (((int) type >= (sizeof (bptypes) / sizeof (bptypes[0])))
+ || ((int) type != bptypes[(int) type].type))
+ internal_error (__FILE__, __LINE__,
+ _("bptypes table does not describe type #%d."),
+ (int) type);
+
+ return bptypes[(int) type].description;
+}
+
+/* Print B to gdb_stdout. */
+
+static void
+print_one_breakpoint_location (struct breakpoint *b,
+ struct bp_location *loc,
+ int loc_number,
+ struct bp_location **last_loc,
+ int print_address_bits,
+ int allflag)
+{
+ struct command_line *l;
static char bpenables[] = "nynny";
char wrap_indent[80];
struct ui_stream *stb = ui_out_stream_new (uiout);
@@ -4595,15 +4608,8 @@ print_one_breakpoint_location (struct br
annotate_field (1);
if (part_of_multiple)
ui_out_field_skip (uiout, "type");
- else
- {
- if (((int) b->type >= (sizeof (bptypes) / sizeof (bptypes[0])))
- || ((int) b->type != bptypes[(int) b->type].type))
- internal_error (__FILE__, __LINE__,
- _("bptypes table does not describe type #%d."),
- (int) b->type);
- ui_out_field_string (uiout, "type", bptypes[(int) b->type].description);
- }
+ else
+ ui_out_field_string (uiout, "type", bptype_string (b->type));
/* 3 */
annotate_field (2);
@@ -4981,7 +4987,8 @@ breakpoint_1 (int bnum, int allflag, int
struct cleanup *bkpttbl_chain;
struct value_print_options opts;
int print_address_bits = 0;
-
+ int print_type_col_width = 14;
+
get_user_print_options (&opts);
/* Compute the number of rows in the table, as well as the
@@ -4997,10 +5004,16 @@ breakpoint_1 (int bnum, int allflag, int
if (allflag || user_settable_breakpoint (b))
{
- int addr_bit = breakpoint_address_bits (b);
+ int addr_bit, type_len;
+
+ addr_bit = breakpoint_address_bits (b);
if (addr_bit > print_address_bits)
print_address_bits = addr_bit;
+ type_len = strlen (bptype_string (b->type));
+ if (type_len > print_type_col_width)
+ print_type_col_width = type_len;
+
nr_printable_breakpoints++;
}
}
@@ -5021,7 +5034,8 @@ breakpoint_1 (int bnum, int allflag, int
ui_out_table_header (uiout, 7, ui_left, "number", "Num"); /* 1 */
if (nr_printable_breakpoints > 0)
annotate_field (1);
- ui_out_table_header (uiout, 14, ui_left, "type", "Type"); /* 2 */
+ ui_out_table_header (uiout, print_type_col_width, ui_left,
+ "type", "Type"); /* 2 */
if (nr_printable_breakpoints > 0)
annotate_field (2);
ui_out_table_header (uiout, 4, ui_left, "disp", "Disp"); /* 3 */