From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 3/3] Introduce field_unsigned
Date: Mon, 01 Jul 2019 20:01:00 -0000 [thread overview]
Message-ID: <20190701200058.16235-4-tromey@adacore.com> (raw)
In-Reply-To: <20190701200058.16235-1-tromey@adacore.com>
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.
gdb/ChangeLog
2019-07-01 Tom Tromey <tromey@adacore.com>
* 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.
---
gdb/ChangeLog | 11 +++++++++++
gdb/disasm.c | 2 +-
gdb/record-btrace.c | 14 +++-----------
gdb/symfile.c | 12 ++++++------
gdb/ui-out.h | 6 ++++++
5 files changed, 27 insertions(+), 18 deletions(-)
diff --git a/gdb/disasm.c b/gdb/disasm.c
index 4e58cb67f93..927b092ce2c 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/record-btrace.c b/gdb/record-btrace.c
index 21085d5c62c..313f1ac7d1e 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -623,14 +623,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
@@ -1032,9 +1024,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
@@ -1155,7 +1147,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 58049a544b5..9b71ad6b3a4 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2083,7 +2083,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);
@@ -2126,29 +2126,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.h b/gdb/ui-out.h
index 9eba70eedac..cf074ebcef4 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -121,6 +121,12 @@ class ui_out
void field_fmt (const char *fldname, const char *format, ...)
ATTRIBUTE_PRINTF (3, 4);
+ /* Like field_int, but print an unsigned value. */
+ void field_unsigned (const char *fldname, ULONGEST value)
+ {
+ field_string (fldname, pulongest (value));
+ }
+
void spaces (int numspaces);
void text (const char *string);
void message (const char *format, ...) ATTRIBUTE_PRINTF (2, 3);
--
2.20.1
next prev parent reply other threads:[~2019-07-01 20:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-01 20:01 [PATCH 0/3] replace many uses of field_fmt Tom Tromey
2019-07-01 20:01 ` [PATCH 1/3] Use field_core_addr in more places Tom Tromey
2019-07-02 9:40 ` Andrew Burgess
2019-07-01 20:01 ` Tom Tromey [this message]
2019-07-02 6:43 ` [PATCH 3/3] Introduce field_unsigned Metzger, Markus T
2019-07-02 12:23 ` Tom Tromey
2019-07-02 12:41 ` Metzger, Markus T
2019-07-02 15:01 ` Tom Tromey
2019-07-01 20:01 ` [PATCH 2/3] Use field_string in more places Tom Tromey
2019-07-02 9:39 ` Andrew Burgess
2019-07-02 12:24 ` Tom Tromey
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=20190701200058.16235-4-tromey@adacore.com \
--to=tromey@adacore.com \
--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).