aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-07-01 12:14:48 -0600
committerTom Tromey <tromey@adacore.com>2019-07-15 09:31:18 -0600
commit1f77b012e61ec11c92a35223fdfed598c6d2f4e9 (patch)
tree46a7d4bb2e7366a33728a40cfde72f0dfaf5c4fb
parent33eca68072e73d984fc139dde45b8140b94757cb (diff)
downloadgdb-1f77b012e61ec11c92a35223fdfed598c6d2f4e9.zip
gdb-1f77b012e61ec11c92a35223fdfed598c6d2f4e9.tar.gz
gdb-1f77b012e61ec11c92a35223fdfed598c6d2f4e9.tar.bz2
Introduce field_unsigned
This adds field_unsigned and changes various places using field_fmt with "%u" to use this instead. This also replaces an existing equivalent helper function in record-btrace.c. 2019-07-15 Tom Tromey <tromey@adacore.com> * mi/mi-out.h (class mi_ui_out) <do_field_unsigned>: Declare. * mi/mi-out.c (mi_ui_out::do_field_unsigned): New method. * cli-out.h (class cli_ui_out) <do_field_unsigned>: Declare. * cli-out.c (cli_ui_out::do_field_int): New method. * ui-out.c (ui_out::field_unsigned): New method. * symfile.c (generic_load): Use field_unsigned. (print_transfer_performance): Likewise. * record-btrace.c (ui_out_field_uint): Remove. (btrace_call_history_insn_range, btrace_call_history): Use field_unsigned. * disasm.c (gdb_pretty_print_disassembler::pretty_print_insn): Use field_unsigned. * ui-out.h (class ui_out) <field_unsigned>: New method. <do_field_unsigned>: Likewise.
-rw-r--r--gdb/ChangeLog17
-rw-r--r--gdb/cli-out.c13
-rw-r--r--gdb/cli-out.h3
-rw-r--r--gdb/disasm.c2
-rw-r--r--gdb/mi/mi-out.c10
-rw-r--r--gdb/mi/mi-out.h3
-rw-r--r--gdb/record-btrace.c14
-rw-r--r--gdb/symfile.c12
-rw-r--r--gdb/ui-out.c14
-rw-r--r--gdb/ui-out.h4
10 files changed, 74 insertions, 18 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ae33039..1b08595 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,22 @@
2019-07-15 Tom Tromey <tromey@adacore.com>
+ * mi/mi-out.h (class mi_ui_out) <do_field_unsigned>: Declare.
+ * mi/mi-out.c (mi_ui_out::do_field_unsigned): New method.
+ * cli-out.h (class cli_ui_out) <do_field_unsigned>: Declare.
+ * cli-out.c (cli_ui_out::do_field_int): New method.
+ * ui-out.c (ui_out::field_unsigned): New method.
+ * symfile.c (generic_load): Use field_unsigned.
+ (print_transfer_performance): Likewise.
+ * record-btrace.c (ui_out_field_uint): Remove.
+ (btrace_call_history_insn_range, btrace_call_history): Use
+ field_unsigned.
+ * disasm.c (gdb_pretty_print_disassembler::pretty_print_insn): Use
+ field_unsigned.
+ * ui-out.h (class ui_out) <field_unsigned>: New method.
+ <do_field_unsigned>: Likewise.
+
+2019-07-15 Tom Tromey <tromey@adacore.com>
+
* mi/mi-main.c (list_available_thread_groups): Use field_string.
* mi/mi-interp.c (mi_memory_changed): Use field_string.
* target.c (flash_erase_command): Use field_string.
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 55c8d2b..8d6b426 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -105,6 +105,19 @@ cli_ui_out::do_field_int (int fldno, int width, ui_align alignment,
ui_out_style_kind::DEFAULT);
}
+/* output an unsigned field */
+
+void
+cli_ui_out::do_field_unsigned (int fldno, int width, ui_align alignment,
+ const char *fldname, ULONGEST value)
+{
+ if (m_suppress_output)
+ return;
+
+ do_field_string (fldno, width, alignment, fldname, pulongest (value),
+ ui_out_style_kind::DEFAULT);
+}
+
/* used to omit a field */
void
diff --git a/gdb/cli-out.h b/gdb/cli-out.h
index eeb555f..fd1d627 100644
--- a/gdb/cli-out.h
+++ b/gdb/cli-out.h
@@ -47,6 +47,9 @@ protected:
virtual void do_end (ui_out_type type) override;
virtual void do_field_int (int fldno, int width, ui_align align,
const char *fldname, int value) override;
+ virtual void do_field_unsigned (int fldno, int width, ui_align align,
+ const char *fldname, ULONGEST value)
+ override;
virtual void do_field_skip (int fldno, int width, ui_align align,
const char *fldname) override;
virtual void do_field_string (int fldno, int width, ui_align align,
diff --git a/gdb/disasm.c b/gdb/disasm.c
index 4e51bc5..5e1dd6e 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -209,7 +209,7 @@ gdb_pretty_print_disassembler::pretty_print_insn (struct ui_out *uiout,
if (insn->number != 0)
{
- uiout->field_fmt ("insn-number", "%u", insn->number);
+ uiout->field_unsigned ("insn-number", insn->number);
uiout->text ("\t");
}
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index d8bee0f..dd99a2b 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -105,6 +105,16 @@ mi_ui_out::do_field_int (int fldno, int width, ui_align alignment,
ui_out_style_kind::DEFAULT);
}
+/* Output an unsigned field. */
+
+void
+mi_ui_out::do_field_unsigned (int fldno, int width, ui_align alignment,
+ const char *fldname, ULONGEST value)
+{
+ do_field_string (fldno, width, alignment, fldname, pulongest (value),
+ ui_out_style_kind::DEFAULT);
+}
+
/* Used to omit a field. */
void
diff --git a/gdb/mi/mi-out.h b/gdb/mi/mi-out.h
index 82f7759..1328684 100644
--- a/gdb/mi/mi-out.h
+++ b/gdb/mi/mi-out.h
@@ -54,6 +54,9 @@ protected:
virtual void do_end (ui_out_type type) override;
virtual void do_field_int (int fldno, int width, ui_align align,
const char *fldname, int value) override;
+ virtual void do_field_unsigned (int fldno, int width, ui_align align,
+ const char *fldname, ULONGEST value)
+ override;
virtual void do_field_skip (int fldno, int width, ui_align align,
const char *fldname) override;
virtual void do_field_string (int fldno, int width, ui_align align,
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 73e7e32..77f2e7c 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -624,14 +624,6 @@ btrace_ui_out_decode_error (struct ui_out *uiout, int errcode,
uiout->text (_("]\n"));
}
-/* Print an unsigned int. */
-
-static void
-ui_out_field_uint (struct ui_out *uiout, const char *fld, unsigned int val)
-{
- uiout->field_fmt (fld, "%u", val);
-}
-
/* A range of source lines. */
struct btrace_line_range
@@ -1033,9 +1025,9 @@ btrace_call_history_insn_range (struct ui_out *uiout,
begin = bfun->insn_offset;
end = begin + size - 1;
- ui_out_field_uint (uiout, "insn begin", begin);
+ uiout->field_unsigned ("insn begin", begin);
uiout->text (",");
- ui_out_field_uint (uiout, "insn end", end);
+ uiout->field_unsigned ("insn end", end);
}
/* Compute the lowest and highest source line for the instructions in BFUN
@@ -1156,7 +1148,7 @@ btrace_call_history (struct ui_out *uiout,
msym = bfun->msym;
/* Print the function index. */
- ui_out_field_uint (uiout, "index", bfun->number);
+ uiout->field_unsigned ("index", bfun->number);
uiout->text ("\t");
/* Indicate gaps in the trace. */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index caa0e79..d2b88fc 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2097,7 +2097,7 @@ generic_load (const char *args, int from_tty)
uiout->text ("Start address ");
uiout->field_core_addr ("address", target_gdbarch (), entry);
uiout->text (", load size ");
- uiout->field_fmt ("load-size", "%lu", total_progress.data_count);
+ uiout->field_unsigned ("load-size", total_progress.data_count);
uiout->text ("\n");
regcache_write_pc (get_current_regcache (), entry);
@@ -2140,29 +2140,29 @@ print_transfer_performance (struct ui_file *stream,
if (uiout->is_mi_like_p ())
{
- uiout->field_fmt ("transfer-rate", "%lu", rate * 8);
+ uiout->field_unsigned ("transfer-rate", rate * 8);
uiout->text (" bits/sec");
}
else if (rate < 1024)
{
- uiout->field_fmt ("transfer-rate", "%lu", rate);
+ uiout->field_unsigned ("transfer-rate", rate);
uiout->text (" bytes/sec");
}
else
{
- uiout->field_fmt ("transfer-rate", "%lu", rate / 1024);
+ uiout->field_unsigned ("transfer-rate", rate / 1024);
uiout->text (" KB/sec");
}
}
else
{
- uiout->field_fmt ("transferred-bits", "%lu", (data_count * 8));
+ uiout->field_unsigned ("transferred-bits", (data_count * 8));
uiout->text (" bits in <1 sec");
}
if (write_count > 0)
{
uiout->text (", ");
- uiout->field_fmt ("write-rate", "%lu", data_count / write_count);
+ uiout->field_unsigned ("write-rate", data_count / write_count);
uiout->text (" bytes/write");
}
uiout->text (".\n");
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index 6851fd2..65312aa 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -462,6 +462,20 @@ ui_out::field_fmt_int (int input_width, ui_align input_align,
do_field_int (fldno, input_width, input_align, fldname, value);
}
+/* See ui-out.h. */
+
+void
+ui_out::field_unsigned (const char *fldname, ULONGEST value)
+{
+ int fldno;
+ int width;
+ ui_align align;
+
+ verify_field (&fldno, &width, &align);
+
+ do_field_unsigned (fldno, width, align, fldname, value);
+}
+
/* Documented in ui-out.h. */
void
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index 8574204..afc1c41 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -110,6 +110,8 @@ class ui_out
void field_int (const char *fldname, int value);
void field_fmt_int (int width, ui_align align, const char *fldname,
int value);
+ /* Like field_int, but print an unsigned value. */
+ void field_unsigned (const char *fldname, ULONGEST value);
void field_core_addr (const char *fldname, struct gdbarch *gdbarch,
CORE_ADDR address);
void field_string (const char *fldname, const char *string,
@@ -157,6 +159,8 @@ class ui_out
virtual void do_end (ui_out_type type) = 0;
virtual void do_field_int (int fldno, int width, ui_align align,
const char *fldname, int value) = 0;
+ virtual void do_field_unsigned (int fldno, int width, ui_align align,
+ const char *fldname, ULONGEST value) = 0;
virtual void do_field_skip (int fldno, int width, ui_align align,
const char *fldname) = 0;
virtual void do_field_string (int fldno, int width, ui_align align,