From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 386 invoked by alias); 1 Jul 2010 16:36:32 -0000 Received: (qmail 373 invoked by uid 22791); 1 Jul 2010 16:36:29 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 01 Jul 2010 16:36:25 +0000 Received: (qmail 16586 invoked from network); 1 Jul 2010 16:36:23 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 1 Jul 2010 16:36:23 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: dynamic type column width in "info breakpoints" output (Re: Static tracepoints support) Date: Thu, 01 Jul 2010 16:36:00 -0000 User-Agent: KMail/1.13.2 (Linux/2.6.31-10-rt; KDE/4.4.2; x86_64; ; ) Cc: Eli Zaretskii References: <201006251931.57860.pedro@codesourcery.com> <83tyoqcc8i.fsf@gnu.org> <201006281326.39820.pedro@codesourcery.com> In-Reply-To: <201006281326.39820.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201007011736.21310.pedro@codesourcery.com> 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-07/txt/msg00016.txt.bz2 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 * 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 */