From patchwork Mon Jul 1 20:00:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33508 Received: (qmail 55824 invoked by alias); 1 Jul 2019 20:01:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 55751 invoked by uid 89); 1 Jul 2019 20:01:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:4378, highest X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 01 Jul 2019 20:01:02 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 5D3B1560F2; Mon, 1 Jul 2019 16:01:01 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id gg2Wzjtayq+L; Mon, 1 Jul 2019 16:01:01 -0400 (EDT) Received: from murgatroyd.Home (174-29-48-143.hlrn.qwest.net [174.29.48.143]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 08D2C56078; Mon, 1 Jul 2019 16:01:00 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/3] Introduce field_unsigned Date: Mon, 1 Jul 2019 14:00:58 -0600 Message-Id: <20190701200058.16235-4-tromey@adacore.com> In-Reply-To: <20190701200058.16235-1-tromey@adacore.com> References: <20190701200058.16235-1-tromey@adacore.com> MIME-Version: 1.0 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 * 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) : 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);