From 170b53b2b6ca83fe08123b53fad469ba8e92aed4 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Mon, 28 Feb 2011 15:21:21 +0000 Subject: [PATCH] * breakpoint.c (wrap_indent_at_field): New function. (print_breakpoint_location): Use it instead of WRAP_INDENT argument. Allocate ui_stream locally instead of using STB argument. (print_one_breakpoint_location): Update call. * ui-out.c (ui_out_query_field): New function. * ui-out.h (ui_out_query_field): Add prototype. --- gdb/ChangeLog | 9 +++++++++ gdb/breakpoint.c | 61 +++++++++++++++++++++++++++++++++++++------------------- gdb/ui-out.c | 22 ++++++++++++++++++++ gdb/ui-out.h | 3 +++ 4 files changed, 75 insertions(+), 20 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 682c9f1..a821470 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2011-02-28 Ulrich Weigand + + * breakpoint.c (wrap_indent_at_field): New function. + (print_breakpoint_location): Use it instead of WRAP_INDENT argument. + Allocate ui_stream locally instead of using STB argument. + (print_one_breakpoint_location): Update call. + * ui-out.c (ui_out_query_field): New function. + * ui-out.h (ui_out_query_field): Add prototype. + 2011-02-28 Joel Brobecker From Michael Snyder diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 490084e..a38fed9 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4565,12 +4565,40 @@ bpstat_causes_stop (bpstat bs) +/* Compute a string of spaces suitable to indent the next line + so it starts at the position corresponding to the table column + named COL_NAME in the currently active table of UIOUT. */ + +static char * +wrap_indent_at_field (struct ui_out *uiout, const char *col_name) +{ + static char wrap_indent[80]; + int i, total_width, width, align; + char *text; + + total_width = 0; + for (i = 1; ui_out_query_field (uiout, i, &width, &align, &text); i++) + { + if (strcmp (text, col_name) == 0) + { + gdb_assert (total_width < sizeof wrap_indent); + memset (wrap_indent, ' ', total_width); + wrap_indent[total_width] = 0; + + return wrap_indent; + } + + total_width += width + 1; + } + + return NULL; +} + /* Print the LOC location out of the list of B->LOC locations. */ -static void print_breakpoint_location (struct breakpoint *b, - struct bp_location *loc, - char *wrap_indent, - struct ui_stream *stb) +static void +print_breakpoint_location (struct breakpoint *b, + struct bp_location *loc) { struct cleanup *old_chain = save_current_program_space (); @@ -4589,8 +4617,9 @@ static void print_breakpoint_location (struct breakpoint *b, ui_out_text (uiout, "in "); ui_out_field_string (uiout, "func", SYMBOL_PRINT_NAME (sym)); - ui_out_wrap_hint (uiout, wrap_indent); - ui_out_text (uiout, " at "); + ui_out_text (uiout, " "); + ui_out_wrap_hint (uiout, wrap_indent_at_field (uiout, "what")); + ui_out_text (uiout, "at "); } ui_out_field_string (uiout, "file", b->source_file); ui_out_text (uiout, ":"); @@ -4608,9 +4637,14 @@ static void print_breakpoint_location (struct breakpoint *b, } else if (loc) { + struct ui_stream *stb = ui_out_stream_new (uiout); + struct cleanup *stb_chain = make_cleanup_ui_out_stream_delete (stb); + print_address_symbolic (loc->gdbarch, loc->address, stb->stream, demangle, ""); ui_out_field_stream (uiout, "at", stb); + + do_cleanups (stb_chain); } else ui_out_field_string (uiout, "pending", b->addr_string); @@ -4679,9 +4713,6 @@ print_one_breakpoint_location (struct breakpoint *b, { struct command_line *l; static char bpenables[] = "nynny"; - char wrap_indent[80]; - struct ui_stream *stb = ui_out_stream_new (uiout); - struct cleanup *old_chain = make_cleanup_ui_out_stream_delete (stb); struct cleanup *bkpt_chain; int header_of_multiple = 0; @@ -4743,15 +4774,6 @@ print_one_breakpoint_location (struct breakpoint *b, /* 5 and 6 */ - strcpy (wrap_indent, " "); - if (opts.addressprint) - { - if (print_address_bits <= 32) - strcat (wrap_indent, " "); - else - strcat (wrap_indent, " "); - } - if (b->ops != NULL && b->ops->print_one != NULL) { /* Although the print_one can possibly print all locations, @@ -4816,7 +4838,7 @@ print_one_breakpoint_location (struct breakpoint *b, } annotate_field (5); if (!header_of_multiple) - print_breakpoint_location (b, loc, wrap_indent, stb); + print_breakpoint_location (b, loc); if (b->loc) *last_loc = b->loc; break; @@ -4972,7 +4994,6 @@ print_one_breakpoint_location (struct breakpoint *b, } do_cleanups (bkpt_chain); - do_cleanups (old_chain); } static void diff --git a/gdb/ui-out.c b/gdb/ui-out.c index 53ad963..72a34f8 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -1141,6 +1141,28 @@ ui_out_data (struct ui_out *uiout) return uiout->data; } +/* Access table field parameters. */ +int +ui_out_query_field (struct ui_out *uiout, int colno, + int *width, int *alignment, char **col_name) +{ + struct ui_out_hdr *hdr; + + if (!uiout->table.flag) + return 0; + + for (hdr = uiout->table.header_first; hdr; hdr = hdr->next) + if (hdr->colno == colno) + { + *width = hdr->width; + *alignment = hdr->alignment; + *col_name = hdr->col_name; + return 1; + } + + return 0; +} + /* Initalize private members at startup. */ struct ui_out * diff --git a/gdb/ui-out.h b/gdb/ui-out.h index 4ad0651..5265902 100644 --- a/gdb/ui-out.h +++ b/gdb/ui-out.h @@ -156,6 +156,9 @@ extern int ui_out_get_verblvl (struct ui_out *uiout); extern int ui_out_test_flags (struct ui_out *uiout, int mask); +extern int ui_out_query_field (struct ui_out *uiout, int colno, + int *width, int *alignment, char **col_name); + #if 0 extern void ui_out_result_begin (struct ui_out *uiout, char *class); -- 2.7.4