public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 3/4] Introduce field_unsigned
  2019-07-02 15:36 [PATCH v2 0/4] Remove many uses of field_fmt Tom Tromey
@ 2019-07-02 15:36 ` Tom Tromey
  2019-07-02 15:36 ` [PATCH v2 1/4] Use field_core_addr in more places Tom Tromey
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2019-07-02 15:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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-02  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.
---
 gdb/ChangeLog       | 17 +++++++++++++++++
 gdb/cli-out.c       | 13 +++++++++++++
 gdb/cli-out.h       |  3 +++
 gdb/disasm.c        |  2 +-
 gdb/mi/mi-out.c     | 10 ++++++++++
 gdb/mi/mi-out.h     |  3 +++
 gdb/record-btrace.c | 14 +++-----------
 gdb/symfile.c       | 12 ++++++------
 gdb/ui-out.c        | 14 ++++++++++++++
 gdb/ui-out.h        |  4 ++++
 10 files changed, 74 insertions(+), 18 deletions(-)

diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 55c8d2b3b1b..8d6b426203f 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 eeb555fbbec..fd1d6274a9f 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 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/mi/mi-out.c b/gdb/mi/mi-out.c
index d8bee0f3927..dd99a2b7fb1 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 82f77592da8..1328684ed2b 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 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 d1c7b0e0034..8394c8a56b8 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2085,7 +2085,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);
 
@@ -2128,29 +2128,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 6851fd29c6a..65312aa4323 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 9eba70eedac..954fad7cf9a 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,
-- 
2.20.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 0/4] Remove many uses of field_fmt
@ 2019-07-02 15:36 Tom Tromey
  2019-07-02 15:36 ` [PATCH v2 3/4] Introduce field_unsigned Tom Tromey
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Tom Tromey @ 2019-07-02 15:36 UTC (permalink / raw)
  To: gdb-patches

Here's v2 of the series to remove many uses of field_fmt.

Compared to v1, this:

* Fixes the phex bug pointed out by Simon,
* Converts more uses of 0x%s to use hex_string_custom,
* Changes how field_unsigned is implemented, and
* Removes a FIXME from mi-out.c

Regression tested on x86-64 Fedora 29.

Tom


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/4] Use field_core_addr in more places
  2019-07-02 15:36 [PATCH v2 0/4] Remove many uses of field_fmt Tom Tromey
  2019-07-02 15:36 ` [PATCH v2 3/4] Introduce field_unsigned Tom Tromey
@ 2019-07-02 15:36 ` Tom Tromey
  2019-07-02 15:36 ` [PATCH v2 2/4] Use field_string " Tom Tromey
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2019-07-02 15:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes a few spots that use field_fmt to use field_core_addr
instead.

gdb/ChangeLog
2019-07-02  Tom Tromey  <tromey@adacore.com>

	* target.c (flash_erase_command): Use field_core_addr.
	* symfile.c (generic_load): Use field_core_addr.
	* sparc64-linux-tdep.c (sparc64_linux_handle_segmentation_fault):
	Use field_core_addr.
	* i386-linux-tdep.c (i386_linux_handle_segmentation_fault): Use
	field_core_addr.
---
 gdb/ChangeLog            | 9 +++++++++
 gdb/i386-linux-tdep.c    | 6 +++---
 gdb/sparc64-linux-tdep.c | 6 +++---
 gdb/symfile.c            | 2 +-
 gdb/target.c             | 2 +-
 5 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index 74f429b49af..b5c3ef2b71e 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -432,13 +432,13 @@ i386_linux_handle_segmentation_fault (struct gdbarch *gdbarch,
     uiout->field_string ("sigcode-meaning", _("Lower bound violation"));
 
   uiout->text (_(" while accessing address "));
-  uiout->field_fmt ("bound-access", "%s", paddress (gdbarch, access));
+  uiout->field_core_addr ("bound-access", gdbarch, access);
 
   uiout->text (_("\nBounds: [lower = "));
-  uiout->field_fmt ("lower-bound", "%s", paddress (gdbarch, lower_bound));
+  uiout->field_core_addr ("lower-bound", gdbarch, lower_bound);
 
   uiout->text (_(", upper = "));
-  uiout->field_fmt ("upper-bound", "%s", paddress (gdbarch, upper_bound));
+  uiout->field_core_addr ("upper-bound", gdbarch, upper_bound);
 
   uiout->text (_("]"));
 }
diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c
index 158db97ec61..563d21e4b4c 100644
--- a/gdb/sparc64-linux-tdep.c
+++ b/gdb/sparc64-linux-tdep.c
@@ -150,19 +150,19 @@ sparc64_linux_handle_segmentation_fault (struct gdbarch *gdbarch,
       uiout->text ("\n");
       uiout->field_string ("sigcode-meaning", _("ADI disabled"));
       uiout->text (_(" while accessing address "));
-      uiout->field_fmt ("bound-access", "%s", paddress (gdbarch, addr));
+      uiout->field_core_addr ("bound-access", gdbarch, addr);
       break;
     case SEGV_ADIDERR:	/* disrupting mismatch */
       uiout->text ("\n");
       uiout->field_string ("sigcode-meaning", _("ADI deferred mismatch"));
       uiout->text (_(" while accessing address "));
-      uiout->field_fmt ("bound-access", "%s", paddress (gdbarch, addr));
+      uiout->field_core_addr ("bound-access", gdbarch, addr);
       break;
     case SEGV_ADIPERR:	/* precise mismatch */
       uiout->text ("\n");
       uiout->field_string ("sigcode-meaning", _("ADI precise mismatch"));
       uiout->text (_(" while accessing address "));
-      uiout->field_fmt ("bound-access", "%s", paddress (gdbarch, addr));
+      uiout->field_core_addr ("bound-access", gdbarch, addr);
       break;
     default:
       break;
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 59647bfe9d8..d1c7b0e0034 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2083,7 +2083,7 @@ generic_load (const char *args, int from_tty)
   CORE_ADDR entry = bfd_get_start_address (loadfile_bfd.get ());
   entry = gdbarch_addr_bits_remove (target_gdbarch (), entry);
   uiout->text ("Start address ");
-  uiout->field_fmt ("address", "%s", paddress (target_gdbarch (), entry));
+  uiout->field_core_addr ("address", target_gdbarch (), entry);
   uiout->text (", load size ");
   uiout->field_fmt ("load-size", "%lu", total_progress.data_count);
   uiout->text ("\n");
diff --git a/gdb/target.c b/gdb/target.c
index 1c04095fd63..febb3390339 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3793,7 +3793,7 @@ flash_erase_command (const char *cmd, int from_tty)
 	  ui_out_emit_tuple tuple_emitter (current_uiout, "erased-regions");
 
           current_uiout->message (_("Erasing flash memory region at address "));
-          current_uiout->field_fmt ("address", "%s", paddress (gdbarch, m.lo));
+          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->message ("\n");
-- 
2.20.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 2/4] Use field_string in more places
  2019-07-02 15:36 [PATCH v2 0/4] Remove many uses of field_fmt Tom Tromey
  2019-07-02 15:36 ` [PATCH v2 3/4] Introduce field_unsigned Tom Tromey
  2019-07-02 15:36 ` [PATCH v2 1/4] Use field_core_addr in more places Tom Tromey
@ 2019-07-02 15:36 ` Tom Tromey
  2019-07-02 15:53   ` Andrew Burgess
  2019-07-02 15:42 ` [PATCH v2 4/4] Fix a FIXME in mi-out.c Tom Tromey
  2019-07-02 15:59 ` [PATCH v2 0/4] Remove many uses of field_fmt Simon Marchi
  4 siblings, 1 reply; 9+ messages in thread
From: Tom Tromey @ 2019-07-02 15:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This replaces uses of field_fmt with a "%s" format string to use
field_string instead.  Some spots using "0x%s" are changed to use
plain "%s" with hex_string_custom.

gdb/ChangeLog
2019-07-02  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.
	* spu-tdep.c (info_spu_event_command, info_spu_signal_command)
	(info_spu_mailbox_list, info_spu_dma_cmdlist)
	(info_spu_dma_command, info_spu_proxydma_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      | 15 ++++++++++
 gdb/ada-tasks.c    | 10 +++----
 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/spu-tdep.c     | 70 +++++++++++++++++++++++++++-------------------
 gdb/target.c       |  2 +-
 9 files changed, 69 insertions(+), 42 deletions(-)

diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 9c07f0ca226..d5ec855f69d 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -1089,7 +1089,8 @@ 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",
+			   hex_string_custom (task_info->task_id, 9));
 
       /* Print the associated Thread ID.  */
       if (uiout->is_mi_like_p ())
@@ -1129,10 +1130,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
-						   : _("<no name>"));
+      uiout->field_string ("name",
+			   task_info->name[0] != '\0' ? task_info->name
+			   : _("<no name>"));
 
       uiout->text ("\n");
     }
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 8422db8b571..5cdebddfc5d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -4490,13 +4490,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 00c1f8d7499..42fb8b26463 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 4fd92f1bac2..f1f10fd30ff 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 ad1a06cae0b..76583ff494b 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 13c310d494c..dc4feedb6f4 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -746,7 +746,7 @@ list_available_thread_groups (const std::set<int> &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/spu-tdep.c b/gdb/spu-tdep.c
index a2ac3149d4d..95303fc7e8f 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -2096,10 +2096,12 @@ info_spu_event_command (const char *args, int from_tty)
   ui_out_emit_tuple tuple_emitter (current_uiout, "SPUInfoEvent");
 
   current_uiout->text (_("Event Status "));
-  current_uiout->field_fmt ("event_status", "0x%s", phex (event_status, 4));
+  current_uiout->field_string ("event_status",
+			       hex_string_custom (event_status, 4));
   current_uiout->text ("\n");
   current_uiout->text (_("Event Mask   "));
-  current_uiout->field_fmt ("event_mask", "0x%s", phex (event_mask, 4));
+  current_uiout->field_string ("event_mask",
+			       hex_string_custom (event_mask, 4));
   current_uiout->text ("\n");
 }
 
@@ -2168,10 +2170,12 @@ info_spu_signal_command (const char *args, int from_tty)
   if (current_uiout->is_mi_like_p ())
     {
       current_uiout->field_int ("signal1_pending", signal1_pending);
-      current_uiout->field_fmt ("signal1", "0x%s", phex_nz (signal1, 4));
+      current_uiout->field_string ("signal1",
+				   hex_string_custom (signal1, 4));
       current_uiout->field_int ("signal1_type", signal1_type);
       current_uiout->field_int ("signal2_pending", signal2_pending);
-      current_uiout->field_fmt ("signal2", "0x%s", phex_nz (signal2, 4));
+      current_uiout->field_string ("signal2",
+				   hex_string_custom (signal2, 4));
       current_uiout->field_int ("signal2_type", signal2_type);
     }
   else
@@ -2218,7 +2222,7 @@ info_spu_mailbox_list (gdb_byte *buf, int nr, enum bfd_endian byte_order,
 	ULONGEST val;
 	ui_out_emit_tuple tuple_emitter (current_uiout, "mbox");
 	val = extract_unsigned_integer (buf + 4*i, 4, byte_order);
-	current_uiout->field_fmt (field, "0x%s", phex (val, 4));
+	current_uiout->field_string (field, hex_string_custom (val, 4));
       }
 
       current_uiout->text ("\n");
@@ -2421,20 +2425,26 @@ info_spu_dma_cmdlist (gdb_byte *buf, int nr, enum bfd_endian byte_order)
 	current_uiout->field_int ("rid", rclass_id);
 
 	if (ea_valid_p)
-	  current_uiout->field_fmt ("ea", "0x%s", phex (mfc_ea, 8));
+	  current_uiout->field_string ("ea", phex (mfc_ea, 8));
 	else
 	  current_uiout->field_skip ("ea");
 
-	current_uiout->field_fmt ("lsa", "0x%05x", mfc_lsa << 4);
+	current_uiout->field_string ("lsa",
+				     hex_string_custom (mfc_lsa << 4, 5));
 	if (qw_valid_p)
-	  current_uiout->field_fmt ("size", "0x%05x", mfc_size << 4);
+	  current_uiout->field_string ("size",
+				       hex_string_custom (mfc_size << 4, 5));
 	else
-	  current_uiout->field_fmt ("size", "0x%05x", mfc_size);
+	  current_uiout->field_string ("size",
+				       hex_string_custom (mfc_size, 5));
 
 	if (list_valid_p)
 	  {
-	    current_uiout->field_fmt ("lstaddr", "0x%05x", list_lsa << 3);
-	    current_uiout->field_fmt ("lstsize", "0x%05x", list_size << 3);
+	    current_uiout->field_string ("lstaddr",
+					 hex_string_custom (list_lsa << 3, 5));
+	    current_uiout->field_string ("lstsize",
+					 hex_string_custom (list_size << 3,
+							    5));
 	  }
 	else
 	  {
@@ -2494,16 +2504,18 @@ info_spu_dma_command (const char *args, int from_tty)
 
   if (current_uiout->is_mi_like_p ())
     {
-      current_uiout->field_fmt ("dma_info_type", "0x%s",
-				phex_nz (dma_info_type, 4));
-      current_uiout->field_fmt ("dma_info_mask", "0x%s",
-				phex_nz (dma_info_mask, 4));
-      current_uiout->field_fmt ("dma_info_status", "0x%s",
-				phex_nz (dma_info_status, 4));
-      current_uiout->field_fmt ("dma_info_stall_and_notify", "0x%s",
-				phex_nz (dma_info_stall_and_notify, 4));
-      current_uiout->field_fmt ("dma_info_atomic_command_status", "0x%s",
-				phex_nz (dma_info_atomic_command_status, 4));
+      current_uiout->field_string ("dma_info_type",
+				   hex_string_custom (dma_info_type, 4));
+      current_uiout->field_string ("dma_info_mask",
+				   hex_string_custom (dma_info_mask, 4));
+      current_uiout->field_string ("dma_info_status",
+				   hex_string_custom (dma_info_status, 4));
+      current_uiout->field_string
+	("dma_info_stall_and_notify",
+	 hex_string_custom (dma_info_stall_and_notify, 4));
+      current_uiout->field_string
+	("dma_info_atomic_command_status",
+	 hex_string_custom (dma_info_atomic_command_status, 4));
     }
   else
     {
@@ -2564,12 +2576,12 @@ info_spu_proxydma_command (const char *args, int from_tty)
 
   if (current_uiout->is_mi_like_p ())
     {
-      current_uiout->field_fmt ("proxydma_info_type", "0x%s",
-				phex_nz (dma_info_type, 4));
-      current_uiout->field_fmt ("proxydma_info_mask", "0x%s",
-				phex_nz (dma_info_mask, 4));
-      current_uiout->field_fmt ("proxydma_info_status", "0x%s",
-				phex_nz (dma_info_status, 4));
+      current_uiout->field_string ("proxydma_info_type",
+				   hex_string_custom (dma_info_type, 4));
+      current_uiout->field_string ("proxydma_info_mask",
+				   hex_string_custom (dma_info_mask, 4));
+      current_uiout->field_string ("proxydma_info_status",
+				   hex_string_custom (dma_info_status, 4));
     }
   else
     {
@@ -2584,9 +2596,9 @@ info_spu_proxydma_command (const char *args, int from_tty)
 	}
 
       printf_filtered (_("Tag-Group Status  0x%s\n"),
-		       phex (dma_info_status, 4));
+		       hex_string_custom (dma_info_status, 4));
       printf_filtered (_("Tag-Group Mask    0x%s (%s)\n"),
-		       phex (dma_info_mask, 4), query_msg);
+		       hex_string_custom (dma_info_mask, 4), query_msg);
       printf_filtered ("\n");
     }
 
diff --git a/gdb/target.c b/gdb/target.c
index febb3390339..417b795d47f 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");
         }
     }
-- 
2.20.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 4/4] Fix a FIXME in mi-out.c
  2019-07-02 15:36 [PATCH v2 0/4] Remove many uses of field_fmt Tom Tromey
                   ` (2 preceding siblings ...)
  2019-07-02 15:36 ` [PATCH v2 2/4] Use field_string " Tom Tromey
@ 2019-07-02 15:42 ` Tom Tromey
  2019-07-02 15:59 ` [PATCH v2 0/4] Remove many uses of field_fmt Simon Marchi
  4 siblings, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2019-07-02 15:42 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes a FIXME comment from mi_ui_out::do_field_int, by
replacing a printf with a use of plongest.

gdb/ChangeLog
2019-07-02  Tom Tromey  <tromey@adacore.com>

	* mi/mi-out.c (mi_ui_out::do_field_int): Use plongest.
---
 gdb/ChangeLog   | 4 ++++
 gdb/mi/mi-out.c | 5 +----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index dd99a2b7fb1..75e3f0313d8 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -98,10 +98,7 @@ void
 mi_ui_out::do_field_int (int fldno, int width, ui_align alignment,
 			 const char *fldname, int value)
 {
-  char buffer[20];	/* FIXME: how many chars long a %d can become? */
-
-  xsnprintf (buffer, sizeof (buffer), "%d", value);
-  do_field_string (fldno, width, alignment, fldname, buffer,
+  do_field_string (fldno, width, alignment, fldname, plongest (value),
 		   ui_out_style_kind::DEFAULT);
 }
 
-- 
2.20.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/4] Use field_string in more places
  2019-07-02 15:36 ` [PATCH v2 2/4] Use field_string " Tom Tromey
@ 2019-07-02 15:53   ` Andrew Burgess
  2019-07-09 15:21     ` Tom Tromey
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Burgess @ 2019-07-02 15:53 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

* Tom Tromey <tromey@adacore.com> [2019-07-02 09:36:00 -0600]:

> This replaces uses of field_fmt with a "%s" format string to use
> field_string instead.  Some spots using "0x%s" are changed to use
> plain "%s" with hex_string_custom.
> 
> gdb/ChangeLog
> 2019-07-02  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.
> 	* spu-tdep.c (info_spu_event_command, info_spu_signal_command)
> 	(info_spu_mailbox_list, info_spu_dma_cmdlist)
> 	(info_spu_dma_command, info_spu_proxydma_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      | 15 ++++++++++
>  gdb/ada-tasks.c    | 10 +++----
>  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/spu-tdep.c     | 70 +++++++++++++++++++++++++++-------------------
>  gdb/target.c       |  2 +-
>  9 files changed, 69 insertions(+), 42 deletions(-)
> 
> diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
> index 9c07f0ca226..d5ec855f69d 100644
> --- a/gdb/ada-tasks.c
> +++ b/gdb/ada-tasks.c
> @@ -1089,7 +1089,8 @@ 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",
> +			   hex_string_custom (task_info->task_id, 9));
>  
>        /* Print the associated Thread ID.  */
>        if (uiout->is_mi_like_p ())
> @@ -1129,10 +1130,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
> -						   : _("<no name>"));
> +      uiout->field_string ("name",
> +			   task_info->name[0] != '\0' ? task_info->name
> +			   : _("<no name>"));
>  
>        uiout->text ("\n");
>      }
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index 8422db8b571..5cdebddfc5d 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -4490,13 +4490,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 00c1f8d7499..42fb8b26463 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 4fd92f1bac2..f1f10fd30ff 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 ad1a06cae0b..76583ff494b 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 13c310d494c..dc4feedb6f4 100644
> --- a/gdb/mi/mi-main.c
> +++ b/gdb/mi/mi-main.c
> @@ -746,7 +746,7 @@ list_available_thread_groups (const std::set<int> &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/spu-tdep.c b/gdb/spu-tdep.c
> index a2ac3149d4d..95303fc7e8f 100644
> --- a/gdb/spu-tdep.c
> +++ b/gdb/spu-tdep.c
> @@ -2096,10 +2096,12 @@ info_spu_event_command (const char *args, int from_tty)
>    ui_out_emit_tuple tuple_emitter (current_uiout, "SPUInfoEvent");
>  
>    current_uiout->text (_("Event Status "));
> -  current_uiout->field_fmt ("event_status", "0x%s", phex (event_status, 4));
> +  current_uiout->field_string ("event_status",
> +			       hex_string_custom (event_status, 4));

I don't know if it matters, but this will reduce the number of 0s that
are printed, if 'event_status = 1' then  phex (event_status, 4) will
return '00000001' while hex_string_custom will return '0001'.

I'm not an SPU user so have no opinion either way...

Thanks,
Andrew



>    current_uiout->text ("\n");
>    current_uiout->text (_("Event Mask   "));
> -  current_uiout->field_fmt ("event_mask", "0x%s", phex (event_mask, 4));
> +  current_uiout->field_string ("event_mask",
> +			       hex_string_custom (event_mask, 4));
>    current_uiout->text ("\n");
>  }
>  
> @@ -2168,10 +2170,12 @@ info_spu_signal_command (const char *args, int from_tty)
>    if (current_uiout->is_mi_like_p ())
>      {
>        current_uiout->field_int ("signal1_pending", signal1_pending);
> -      current_uiout->field_fmt ("signal1", "0x%s", phex_nz (signal1, 4));
> +      current_uiout->field_string ("signal1",
> +				   hex_string_custom (signal1, 4));
>        current_uiout->field_int ("signal1_type", signal1_type);
>        current_uiout->field_int ("signal2_pending", signal2_pending);
> -      current_uiout->field_fmt ("signal2", "0x%s", phex_nz (signal2, 4));
> +      current_uiout->field_string ("signal2",
> +				   hex_string_custom (signal2, 4));
>        current_uiout->field_int ("signal2_type", signal2_type);
>      }
>    else
> @@ -2218,7 +2222,7 @@ info_spu_mailbox_list (gdb_byte *buf, int nr, enum bfd_endian byte_order,
>  	ULONGEST val;
>  	ui_out_emit_tuple tuple_emitter (current_uiout, "mbox");
>  	val = extract_unsigned_integer (buf + 4*i, 4, byte_order);
> -	current_uiout->field_fmt (field, "0x%s", phex (val, 4));
> +	current_uiout->field_string (field, hex_string_custom (val, 4));
>        }
>  
>        current_uiout->text ("\n");
> @@ -2421,20 +2425,26 @@ info_spu_dma_cmdlist (gdb_byte *buf, int nr, enum bfd_endian byte_order)
>  	current_uiout->field_int ("rid", rclass_id);
>  
>  	if (ea_valid_p)
> -	  current_uiout->field_fmt ("ea", "0x%s", phex (mfc_ea, 8));
> +	  current_uiout->field_string ("ea", phex (mfc_ea, 8));
>  	else
>  	  current_uiout->field_skip ("ea");
>  
> -	current_uiout->field_fmt ("lsa", "0x%05x", mfc_lsa << 4);
> +	current_uiout->field_string ("lsa",
> +				     hex_string_custom (mfc_lsa << 4, 5));
>  	if (qw_valid_p)
> -	  current_uiout->field_fmt ("size", "0x%05x", mfc_size << 4);
> +	  current_uiout->field_string ("size",
> +				       hex_string_custom (mfc_size << 4, 5));
>  	else
> -	  current_uiout->field_fmt ("size", "0x%05x", mfc_size);
> +	  current_uiout->field_string ("size",
> +				       hex_string_custom (mfc_size, 5));
>  
>  	if (list_valid_p)
>  	  {
> -	    current_uiout->field_fmt ("lstaddr", "0x%05x", list_lsa << 3);
> -	    current_uiout->field_fmt ("lstsize", "0x%05x", list_size << 3);
> +	    current_uiout->field_string ("lstaddr",
> +					 hex_string_custom (list_lsa << 3, 5));
> +	    current_uiout->field_string ("lstsize",
> +					 hex_string_custom (list_size << 3,
> +							    5));
>  	  }
>  	else
>  	  {
> @@ -2494,16 +2504,18 @@ info_spu_dma_command (const char *args, int from_tty)
>  
>    if (current_uiout->is_mi_like_p ())
>      {
> -      current_uiout->field_fmt ("dma_info_type", "0x%s",
> -				phex_nz (dma_info_type, 4));
> -      current_uiout->field_fmt ("dma_info_mask", "0x%s",
> -				phex_nz (dma_info_mask, 4));
> -      current_uiout->field_fmt ("dma_info_status", "0x%s",
> -				phex_nz (dma_info_status, 4));
> -      current_uiout->field_fmt ("dma_info_stall_and_notify", "0x%s",
> -				phex_nz (dma_info_stall_and_notify, 4));
> -      current_uiout->field_fmt ("dma_info_atomic_command_status", "0x%s",
> -				phex_nz (dma_info_atomic_command_status, 4));
> +      current_uiout->field_string ("dma_info_type",
> +				   hex_string_custom (dma_info_type, 4));
> +      current_uiout->field_string ("dma_info_mask",
> +				   hex_string_custom (dma_info_mask, 4));
> +      current_uiout->field_string ("dma_info_status",
> +				   hex_string_custom (dma_info_status, 4));
> +      current_uiout->field_string
> +	("dma_info_stall_and_notify",
> +	 hex_string_custom (dma_info_stall_and_notify, 4));
> +      current_uiout->field_string
> +	("dma_info_atomic_command_status",
> +	 hex_string_custom (dma_info_atomic_command_status, 4));
>      }
>    else
>      {
> @@ -2564,12 +2576,12 @@ info_spu_proxydma_command (const char *args, int from_tty)
>  
>    if (current_uiout->is_mi_like_p ())
>      {
> -      current_uiout->field_fmt ("proxydma_info_type", "0x%s",
> -				phex_nz (dma_info_type, 4));
> -      current_uiout->field_fmt ("proxydma_info_mask", "0x%s",
> -				phex_nz (dma_info_mask, 4));
> -      current_uiout->field_fmt ("proxydma_info_status", "0x%s",
> -				phex_nz (dma_info_status, 4));
> +      current_uiout->field_string ("proxydma_info_type",
> +				   hex_string_custom (dma_info_type, 4));
> +      current_uiout->field_string ("proxydma_info_mask",
> +				   hex_string_custom (dma_info_mask, 4));
> +      current_uiout->field_string ("proxydma_info_status",
> +				   hex_string_custom (dma_info_status, 4));
>      }
>    else
>      {
> @@ -2584,9 +2596,9 @@ info_spu_proxydma_command (const char *args, int from_tty)
>  	}
>  
>        printf_filtered (_("Tag-Group Status  0x%s\n"),
> -		       phex (dma_info_status, 4));
> +		       hex_string_custom (dma_info_status, 4));
>        printf_filtered (_("Tag-Group Mask    0x%s (%s)\n"),
> -		       phex (dma_info_mask, 4), query_msg);
> +		       hex_string_custom (dma_info_mask, 4), query_msg);
>        printf_filtered ("\n");
>      }
>  
> diff --git a/gdb/target.c b/gdb/target.c
> index febb3390339..417b795d47f 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");
>          }
>      }
> -- 
> 2.20.1
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/4] Remove many uses of field_fmt
  2019-07-02 15:36 [PATCH v2 0/4] Remove many uses of field_fmt Tom Tromey
                   ` (3 preceding siblings ...)
  2019-07-02 15:42 ` [PATCH v2 4/4] Fix a FIXME in mi-out.c Tom Tromey
@ 2019-07-02 15:59 ` Simon Marchi
  2019-07-02 16:12   ` Tom Tromey
  4 siblings, 1 reply; 9+ messages in thread
From: Simon Marchi @ 2019-07-02 15:59 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2019-07-02 11:35 a.m., Tom Tromey wrote:
> Here's v2 of the series to remove many uses of field_fmt.
> 
> Compared to v1, this:
> 
> * Fixes the phex bug pointed out by Simon,

s/Simon/Andrew/ :)

> * Converts more uses of 0x%s to use hex_string_custom,
> * Changes how field_unsigned is implemented, and
> * Removes a FIXME from mi-out.c
> 
> Regression tested on x86-64 Fedora 29.
> 
> Tom
> 
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 0/4] Remove many uses of field_fmt
  2019-07-02 15:59 ` [PATCH v2 0/4] Remove many uses of field_fmt Simon Marchi
@ 2019-07-02 16:12   ` Tom Tromey
  0 siblings, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2019-07-02 16:12 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>> * Fixes the phex bug pointed out by Simon,

Simon> s/Simon/Andrew/ :)

Oops, sorry about that.

Tom

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/4] Use field_string in more places
  2019-07-02 15:53   ` Andrew Burgess
@ 2019-07-09 15:21     ` Tom Tromey
  0 siblings, 0 replies; 9+ messages in thread
From: Tom Tromey @ 2019-07-09 15:21 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: Tom Tromey, gdb-patches

>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

>> +  current_uiout->field_string ("event_status",
>> +			       hex_string_custom (event_status, 4));

Andrew> I don't know if it matters, but this will reduce the number of 0s that
Andrew> are printed, if 'event_status = 1' then  phex (event_status, 4) will
Andrew> return '00000001' while hex_string_custom will return '0001'.

Andrew> I'm not an SPU user so have no opinion either way...

I don't know either.  I looked into this a bit and it seems like a messy
area of gdb:

* hex_string and hex_string_custom take a signed argument, which IMO
  doesn't make sense.

* hex_string is basically phex_nz with the 0x prefix; but
  hex_string_custom differs in its truncation behavior from phex.

* core_addr_to_string and core_addr_to_string_nz exist; though some
  spots choose to print a CORE_ADDR using one of the hex_string
  functions; and of course there is paddress and (I just learned this
  one) print_core_address.

* paddress probably should be renamed paddress_nz and print_core_address
  to paddress, but of course this would be super confusing; and anyway
  it seems like it would make more sense to standardize on a single way
  to print addresses, or maybe at least a user- (rather than
  patch-writer-) configurable one.


Faced with this I chose to flee, and I'm dropping the SPU bits from my
patch.  Also I felt this made sense because the SPU code is slated to be
removed.

Tom

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-07-09 15:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-02 15:36 [PATCH v2 0/4] Remove many uses of field_fmt Tom Tromey
2019-07-02 15:36 ` [PATCH v2 3/4] Introduce field_unsigned Tom Tromey
2019-07-02 15:36 ` [PATCH v2 1/4] Use field_core_addr in more places Tom Tromey
2019-07-02 15:36 ` [PATCH v2 2/4] Use field_string " Tom Tromey
2019-07-02 15:53   ` Andrew Burgess
2019-07-09 15:21     ` Tom Tromey
2019-07-02 15:42 ` [PATCH v2 4/4] Fix a FIXME in mi-out.c Tom Tromey
2019-07-02 15:59 ` [PATCH v2 0/4] Remove many uses of field_fmt Simon Marchi
2019-07-02 16:12   ` Tom Tromey

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).