[35/55] Introduce generic_value_print_int

Message ID 20191208182958.10181-36-tom@tromey.com
State New
Headers show
Series
  • Remove val_print
Related show

Commit Message

Tom Tromey Dec. 8, 2019, 6:29 p.m.
This adds generic_value_print_int, a value-based analogue of
generic_val_print_int.

gdb/ChangeLog
2019-12-08  Tom Tromey  <tom@tromey.com>

	* valprint.c (generic_value_print_int): New function.
	(generic_value_print): Use it.

Change-Id: Ie7526750beb0d03ed214b0f544be5130752e961e
---
 gdb/ChangeLog  |  5 +++++
 gdb/valprint.c | 16 ++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

-- 
2.17.2

Patch

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 5b1b9cff804..44ae99783b6 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -808,6 +808,19 @@  generic_val_print_int (struct type *type,
 			      original_value, &opts, 0, stream);
 }
 
+/* generic_value_print helper for TYPE_CODE_INT.  */
+
+static void
+generic_value_print_int (struct value *val, struct ui_file *stream,
+			 const struct value_print_options *options)
+{
+  struct value_print_options opts = *options;
+
+  opts.format = (options->format ? options->format
+		 : options->output_format);
+  value_print_scalar_formatted (val, &opts, 0, stream);
+}
+
 /* generic_val_print helper for TYPE_CODE_CHAR.  */
 
 static void
@@ -1108,8 +1121,7 @@  generic_value_print (struct value *val, struct ui_file *stream, int recurse,
       /* FALLTHROUGH */
 
     case TYPE_CODE_INT:
-      generic_val_print_int (type, 0, stream,
-			     val, options);
+      generic_value_print_int (val, stream, options);
       break;
 
     case TYPE_CODE_CHAR: