From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Eli Zaretskii <eliz@gnu.org>
Subject: dynamic type column width in "info breakpoints" output (Re: Static tracepoints support)
Date: Thu, 01 Jul 2010 16:36:00 -0000 [thread overview]
Message-ID: <201007011736.21310.pedro@codesourcery.com> (raw)
In-Reply-To: <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 */
next prev parent reply other threads:[~2010-07-01 16:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-25 18:33 Static tracepoints support Pedro Alves
2010-06-26 10:34 ` Eli Zaretskii
2010-06-28 12:28 ` Pedro Alves
2010-06-28 20:03 ` Eli Zaretskii
2010-06-29 21:00 ` Pedro Alves
2010-06-30 18:14 ` Eli Zaretskii
2010-07-01 10:41 ` Pedro Alves
2010-07-01 14:22 ` clarify "help break" output a bit (Re: Static tracepoints support) Pedro Alves
2010-07-01 17:10 ` Eli Zaretskii
2010-06-28 20:04 ` Static tracepoints support Eli Zaretskii
2010-07-01 13:50 ` el vs ell (Re: Static tracepoints support) Pedro Alves
2010-07-01 16:26 ` Michael Snyder
2010-07-01 17:07 ` Eli Zaretskii
2010-07-01 17:28 ` Pedro Alves
2010-07-01 14:00 ` Static tracepoints support Pedro Alves
2010-07-01 17:08 ` Eli Zaretskii
2010-07-01 17:13 ` Pedro Alves
2010-07-01 14:15 ` add a few index entries (Re: Static tracepoints support) Pedro Alves
2010-07-01 17:09 ` Eli Zaretskii
2010-07-01 15:38 ` remove redundant blank from strings " Pedro Alves
2010-07-01 17:11 ` Eli Zaretskii
2010-07-01 16:36 ` Pedro Alves [this message]
2010-07-01 17:17 ` dynamic type column width in "info breakpoints" output " Eli Zaretskii
2010-07-02 21:35 ` Tom Tromey
2010-07-21 11:30 ` Pedro Alves
2010-06-27 22:47 ` Static tracepoints support Michael Snyder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201007011736.21310.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).