summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2011-02-28 15:21:21 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2011-02-28 15:21:21 +0000
commit170b53b2b6ca83fe08123b53fad469ba8e92aed4 (patch)
treeb702af87ab0ae241089a219cd62eb989407a9427
parent81896e36e82ae1d86cdcdb011021860eb3fb7049 (diff)
downloadbinutils-170b53b2b6ca83fe08123b53fad469ba8e92aed4.tar.gz
binutils-170b53b2b6ca83fe08123b53fad469ba8e92aed4.tar.bz2
binutils-170b53b2b6ca83fe08123b53fad469ba8e92aed4.zip
* 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.
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/breakpoint.c61
-rw-r--r--gdb/ui-out.c22
-rw-r--r--gdb/ui-out.h3
4 files changed, 75 insertions, 20 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 682c9f1b356..a821470f5f4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2011-02-28 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * 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 <brobecker@adacore.com>
From Michael Snyder <msnyder@vmware.com>
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 490084e59c5..a38fed9ae98 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 53ad963a648..72a34f88d9e 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 4ad0651ad37..5265902265f 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);