From patchwork Tue Jul 9 15:24:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 33632 Received: (qmail 82508 invoked by alias); 9 Jul 2019 15:24:42 -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 82437 invoked by uid 89); 9 Jul 2019 15:24:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.4 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= 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; Tue, 09 Jul 2019 15:24:40 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id CB9DF561B3; Tue, 9 Jul 2019 11:24:38 -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 fWEx1WnU5ft8; Tue, 9 Jul 2019 11:24:38 -0400 (EDT) Received: from murgatroyd.Home (174-29-36-25.hlrn.qwest.net [174.29.36.25]) (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 779A8561B0; Tue, 9 Jul 2019 11:24:38 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v3 2/4] Use field_string in more places Date: Tue, 9 Jul 2019 09:24:34 -0600 Message-Id: <20190709152436.14078-3-tromey@adacore.com> In-Reply-To: <20190709152436.14078-1-tromey@adacore.com> References: <20190709152436.14078-1-tromey@adacore.com> MIME-Version: 1.0 This replaces uses of field_fmt with a "%s" format string to use field_string instead. Also, one use of "%9lx" is replaced with a call to phex_nz; the '9' is dropped as it is implicit in the field width. gdb/ChangeLog 2019-07-09 Tom Tromey * 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. * infrun.c (print_signal_received_reason): Use field_string. * i386-tdep.c (i386_mpx_print_bounds): Use field_string. * breakpoint.c (maybe_print_thread_hit_breakpoint): Use field_string. * ada-tasks.c (print_ada_task_info): Use field_string. --- gdb/ChangeLog | 11 +++++++++++ gdb/ada-tasks.c | 9 ++++----- gdb/breakpoint.c | 4 ++-- gdb/i386-tdep.c | 2 +- gdb/infrun.c | 4 ++-- gdb/mi/mi-interp.c | 2 +- gdb/mi/mi-main.c | 2 +- gdb/target.c | 2 +- 8 files changed, 23 insertions(+), 13 deletions(-) diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c index 9c07f0ca226..95c0f564acd 100644 --- a/gdb/ada-tasks.c +++ b/gdb/ada-tasks.c @@ -1089,7 +1089,7 @@ print_ada_task_info (struct ui_out *uiout, uiout->field_int ("id", taskno); /* Print the Task ID. */ - uiout->field_fmt ("task-id", "%9lx", (long) task_info->task_id); + uiout->field_string ("task-id", phex_nz (task_info->task_id)); /* Print the associated Thread ID. */ if (uiout->is_mi_like_p ()) @@ -1129,10 +1129,9 @@ print_ada_task_info (struct ui_out *uiout, uiout->field_string ("state", task_states[task_info->state]); /* Finally, print the task name. */ - uiout->field_fmt ("name", - "%s", - task_info->name[0] != '\0' ? task_info->name - : _("")); + uiout->field_string ("name", + task_info->name[0] != '\0' ? task_info->name + : _("")); uiout->text ("\n"); } diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 00fd76220e2..d122b56b03d 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4489,13 +4489,13 @@ maybe_print_thread_hit_breakpoint (struct ui_out *uiout) struct thread_info *thr = inferior_thread (); uiout->text ("Thread "); - uiout->field_fmt ("thread-id", "%s", print_thread_id (thr)); + uiout->field_string ("thread-id", print_thread_id (thr)); name = thr->name != NULL ? thr->name : target_thread_name (thr); if (name != NULL) { uiout->text (" \""); - uiout->field_fmt ("name", "%s", name); + uiout->field_string ("name", name); uiout->text ("\""); } diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 3b8dac73c6e..aac9baa0aac 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -8914,7 +8914,7 @@ i386_mpx_print_bounds (const CORE_ADDR bt_entry[4]) size = (size > -1 ? size + 1 : size); uiout->text (", size = "); - uiout->field_fmt ("size", "%s", plongest (size)); + uiout->field_string ("size", plongest (size)); uiout->text (", metadata = "); uiout->field_core_addr ("metadata", gdbarch, bt_entry[3]); diff --git a/gdb/infrun.c b/gdb/infrun.c index c60ed306bd1..2dc41892365 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -7690,13 +7690,13 @@ print_signal_received_reason (struct ui_out *uiout, enum gdb_signal siggnal) const char *name; uiout->text ("\nThread "); - uiout->field_fmt ("thread-id", "%s", print_thread_id (thr)); + uiout->field_string ("thread-id", print_thread_id (thr)); name = thr->name != NULL ? thr->name : target_thread_name (thr); if (name != NULL) { uiout->text (" \""); - uiout->field_fmt ("name", "%s", name); + uiout->field_string ("name", name); uiout->text ("\""); } } diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index ab1f9138876..03ab169fdf5 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -1172,7 +1172,7 @@ mi_memory_changed (struct inferior *inferior, CORE_ADDR memaddr, mi_uiout->field_fmt ("thread-group", "i%d", inferior->num); mi_uiout->field_core_addr ("addr", target_gdbarch (), memaddr); - mi_uiout->field_fmt ("len", "%s", hex_string (len)); + mi_uiout->field_string ("len", hex_string (len)); /* Append 'type=code' into notification if MEMADDR falls in the range of sections contain code. */ diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index da8c81f9e22..26ffeb0751c 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -746,7 +746,7 @@ list_available_thread_groups (const std::set &ids, int recurse) ui_out_emit_tuple tuple_emitter (uiout, NULL); - uiout->field_fmt ("id", "%s", pid->c_str ()); + uiout->field_string ("id", pid->c_str ()); uiout->field_string ("type", "process"); if (cmd) uiout->field_string ("description", cmd->c_str ()); diff --git a/gdb/target.c b/gdb/target.c index b3cfc53cca1..a19a9bce133 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3795,7 +3795,7 @@ flash_erase_command (const char *cmd, int from_tty) current_uiout->message (_("Erasing flash memory region at address ")); current_uiout->field_core_addr ("address", gdbarch, m.lo); current_uiout->message (", size = "); - current_uiout->field_fmt ("size", "%s", hex_string (m.hi - m.lo)); + current_uiout->field_string ("size", hex_string (m.hi - m.lo)); current_uiout->message ("\n"); } }