public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 10/55] Introduce la_value_print_inner
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (15 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 35/55] Introduce generic_value_print_int Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 25/55] Convert Modula-2 printing to value-based API Tom Tromey
                   ` (38 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The plan for removing val_print is, essentially, to first duplicate
printing code as needed to use the value API; and then remove the
val_print code.  This makes it possible to do the changes
incrementally while keeping everything working.

This adds a new la_value_print_inner function pointer to struct
language_defn.  Eventually this will replace la_val_print.  This patch
also changes printing to prefer this API, when available -- but no
language defines it yet.

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

	* valprint.c (do_val_print): Call la_value_print_inner, if
	available.
	* rust-lang.c (rust_language_defn): Update.
	* p-lang.c (pascal_language_defn): Update.
	* opencl-lang.c (opencl_language_defn): Update.
	* objc-lang.c (objc_language_defn): Update.
	* m2-lang.c (m2_language_defn): Update.
	* language.h (struct language_defn) <la_value_print_inner>: New
	member.
	* language.c (unknown_language_defn, auto_language_defn): Update.
	* go-lang.c (go_language_defn): Update.
	* f-lang.c (f_language_defn): Update.
	* d-lang.c (d_language_defn): Update.
	* c-lang.c (c_language_defn, cplus_language_defn)
	(asm_language_defn, minimal_language_defn): Update.
	* ada-lang.c (ada_language_defn): Update.

Change-Id: I63727fa194511c3d7297db62efe23f8a503ba770
---
 gdb/ChangeLog     | 19 +++++++++++++++++++
 gdb/ada-lang.c    |  1 +
 gdb/c-lang.c      |  4 ++++
 gdb/d-lang.c      |  1 +
 gdb/f-lang.c      |  1 +
 gdb/go-lang.c     |  1 +
 gdb/language.c    |  2 ++
 gdb/language.h    |  7 +++++++
 gdb/m2-lang.c     |  1 +
 gdb/objc-lang.c   |  1 +
 gdb/opencl-lang.c |  1 +
 gdb/p-lang.c      |  1 +
 gdb/rust-lang.c   |  1 +
 gdb/valprint.c    | 10 +++++++---
 14 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 3289a8e5c8e..eeccfae69ac 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -14114,6 +14114,7 @@ extern const struct language_defn ada_language_defn = {
   ada_print_type,               /* Print a type using appropriate syntax */
   ada_print_typedef,            /* Print a typedef using appropriate syntax */
   ada_val_print,                /* Print a value using appropriate syntax */
+  nullptr,			/* la_value_print_inner */
   ada_value_print,              /* Print a top-level value */
   ada_read_var_value,		/* la_read_var_value */
   NULL,                         /* Language specific skip_trampoline */
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 846970af7b9..24c2eef747a 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -904,6 +904,7 @@ extern const struct language_defn c_language_defn =
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_val_print,			/* Print a value using appropriate syntax */
+  nullptr,			/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
@@ -1049,6 +1050,7 @@ extern const struct language_defn cplus_language_defn =
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_val_print,			/* Print a value using appropriate syntax */
+  nullptr,			/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   cplus_skip_trampoline,	/* Language specific skip_trampoline */
@@ -1103,6 +1105,7 @@ extern const struct language_defn asm_language_defn =
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_val_print,			/* Print a value using appropriate syntax */
+  nullptr,			/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
@@ -1157,6 +1160,7 @@ extern const struct language_defn minimal_language_defn =
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_val_print,			/* Print a value using appropriate syntax */
+  nullptr,			/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 1701976da78..5ce2314ae14 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -225,6 +225,7 @@ extern const struct language_defn d_language_defn =
   c_print_typedef,		/* Print a typedef using appropriate
 				   syntax.  */
   d_val_print,			/* Print a value using appropriate syntax.  */
+  nullptr,			/* la_value_print_inner */
   c_value_print,		/* Print a top-level value.  */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline.  */
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 022918efa2d..b8a684e5cf5 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -647,6 +647,7 @@ extern const struct language_defn f_language_defn =
   f_print_type,			/* Print a type using appropriate syntax */
   f_print_typedef,		/* Print a typedef using appropriate syntax */
   f_val_print,			/* Print a value using appropriate syntax */
+  nullptr,			/* la_value_print_inner */
   c_value_print,		/* FIXME */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index bf2eb1b6f71..38eb0d74836 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -596,6 +596,7 @@ extern const struct language_defn go_language_defn =
   c_print_typedef,		/* Print a typedef using appropriate
 				   syntax.  */
   go_val_print,			/* Print a value using appropriate syntax.  */
+  nullptr,			/* la_value_print_inner */
   c_value_print,		/* Print a top-level value.  */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline.  */
diff --git a/gdb/language.c b/gdb/language.c
index 6ab0ca323d2..00b301e46e2 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -858,6 +858,7 @@ const struct language_defn unknown_language_defn =
   unk_lang_print_type,		/* Print a type using appropriate syntax */
   default_print_typedef,	/* Print a typedef using appropriate syntax */
   unk_lang_val_print,		/* Print a value using appropriate syntax */
+  nullptr,			/* la_value_print_inner */
   unk_lang_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   unk_lang_trampoline,		/* Language specific skip_trampoline */
@@ -909,6 +910,7 @@ const struct language_defn auto_language_defn =
   unk_lang_print_type,		/* Print a type using appropriate syntax */
   default_print_typedef,	/* Print a typedef using appropriate syntax */
   unk_lang_val_print,		/* Print a value using appropriate syntax */
+  nullptr,			/* la_value_print_inner */
   unk_lang_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   unk_lang_trampoline,		/* Language specific skip_trampoline */
diff --git a/gdb/language.h b/gdb/language.h
index 5fc25a235ff..89cd71c5055 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -231,6 +231,13 @@ struct language_defn
 			  struct value *val,
 			  const struct value_print_options *options);
 
+    /* Print a value using syntax appropriate for this language.
+       RECURSE is the recursion depth.  It is zero-based.  */
+
+    void (*la_value_print_inner) (struct value *, struct ui_file *,
+				  int recurse,
+				  const struct value_print_options *);
+
     /* Print a top-level value using syntax appropriate for this language.  */
 
     void (*la_value_print) (struct value *, struct ui_file *,
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 2d2dfe31018..924ee0a549c 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -394,6 +394,7 @@ extern const struct language_defn m2_language_defn =
   m2_print_type,		/* Print a type using appropriate syntax */
   m2_print_typedef,		/* Print a typedef using appropriate syntax */
   m2_val_print,			/* Print a value using appropriate syntax */
+  nullptr,			/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index e2a6e800b55..e6cb42e60a2 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -382,6 +382,7 @@ extern const struct language_defn objc_language_defn = {
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_val_print,			/* Print a value using appropriate syntax */
+  nullptr,			/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   objc_skip_trampoline, 	/* Language specific skip_trampoline */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 5d03210b569..8ebb35b9e62 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1061,6 +1061,7 @@ extern const struct language_defn opencl_language_defn =
   opencl_print_type,		/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_val_print,			/* Print a value using appropriate syntax */
+  nullptr,			/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 33cb6e635d8..3229c3e9c9f 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -448,6 +448,7 @@ extern const struct language_defn pascal_language_defn =
   pascal_print_type,		/* Print a type using appropriate syntax */
   pascal_print_typedef,		/* Print a typedef using appropriate syntax */
   pascal_val_print,		/* Print a value using appropriate syntax */
+  nullptr,			/* la_value_print_inner */
   pascal_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index f9adb5d07cc..bacd351ef6c 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -2146,6 +2146,7 @@ extern const struct language_defn rust_language_defn =
   rust_print_type,		/* Print a type using appropriate syntax */
   rust_print_typedef,		/* Print a typedef using appropriate syntax */
   rust_val_print,		/* Print a value using appropriate syntax */
+  nullptr,			/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 20763338aff..d595a1d54e6 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1066,9 +1066,13 @@ do_val_print (struct value *full_value,
 
   try
     {
-      language->la_val_print (type, embedded_offset, address,
-			      stream, recurse, val,
-			      &local_opts);
+      if (full_value != nullptr && language->la_value_print_inner != nullptr)
+	language->la_value_print_inner (full_value, stream, recurse,
+					&local_opts);
+      else
+	language->la_val_print (type, embedded_offset, address,
+				stream, recurse, val,
+				&local_opts);
     }
   catch (const gdb_exception_error &except)
     {
-- 
2.17.2

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

* [PATCH 11/55] Introduce generic_value_print
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (9 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 41/55] Introduce c_value_print_int Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-09  4:05   ` Christian Biesinger via gdb-patches
  2019-12-08 18:30 ` [PATCH 09/55] Use common_val_print in c-valprint.c Tom Tromey
                   ` (44 subsequent siblings)
  55 siblings, 1 reply; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces generic_value_print, which is a value-based analogue
to generic_val_print.  For now this is unused and simply calls
generic_val_print, but subsequent patches will both change this
function to work using the value API directly, and convert callers of
generic_val_print to call this instead.

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

	* valprint.h (generic_value_print): Declare.
	* valprint.c (generic_value_print): New function.

Change-Id: I00b9ef91c1f3bf351b0e13e9873b849e80dfd944
---
 gdb/ChangeLog  |  5 +++++
 gdb/valprint.c | 12 ++++++++++++
 gdb/valprint.h | 11 +++++++++++
 3 files changed, 28 insertions(+)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index d595a1d54e6..0e13e2b2d62 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1007,6 +1007,18 @@ generic_val_print (struct type *type,
     }
 }
 
+/* See valprint.h.  */
+
+void
+generic_value_print (struct value *val, struct ui_file *stream, int recurse,
+		     const struct value_print_options *options,
+		     const struct generic_val_print_decorations *decorations)
+{
+  generic_val_print (value_type (val), value_embedded_offset (val),
+		     value_address (val), stream, recurse, val, options,
+		     decorations);
+}
+
 /* Helper function for val_print and common_val_print that does the
    work.  Arguments are as to val_print, but FULL_VALUE, if given, is
    the value to be printed.  */
diff --git a/gdb/valprint.h b/gdb/valprint.h
index c63ac8de19b..e4b90404fa2 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -211,6 +211,17 @@ extern void generic_val_print (struct type *type,
 			       const struct value_print_options *options,
 			       const struct generic_val_print_decorations *);
 
+/* Print a value in a generic way.  VAL is the value, STREAM is where
+   to print it, RECURSE is the recursion depth, OPTIONS describe how
+   the printing should be done, and D is the language-specific
+   decorations object.  Note that structs and unions cannot be printed
+   by this function.  */
+
+extern void generic_value_print (struct value *val, struct ui_file *stream,
+				 int recurse,
+				 const struct value_print_options *options,
+				 const struct generic_val_print_decorations *d);
+
 extern void generic_emit_char (int c, struct type *type, struct ui_file *stream,
 			       int quoter, const char *encoding);
 
-- 
2.17.2

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

* [PATCH 20/55] Introduce f_value_print_innner
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (4 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 32/55] Remove generic_val_print_flags Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 22/55] Convert Rust printing to value-based API Tom Tromey
                   ` (49 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces f_value_print_innner.

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

	* f-valprint.c (f_value_print_innner): New function.
	* f-lang.h (f_value_print_innner): Declare.
	* f-lang.c (f_language_defn): Use f_value_print_innner.

Change-Id: Idad231ae7a8fd07a65fc82f13d790b1fae899ba2
---
 gdb/ChangeLog    |  6 ++++++
 gdb/f-lang.c     |  2 +-
 gdb/f-lang.h     |  6 ++++++
 gdb/f-valprint.c | 10 ++++++++++
 4 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index b8a684e5cf5..0d587ea020b 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -647,7 +647,7 @@ extern const struct language_defn f_language_defn =
   f_print_type,			/* Print a type using appropriate syntax */
   f_print_typedef,		/* Print a typedef using appropriate syntax */
   f_val_print,			/* Print a value using appropriate syntax */
-  nullptr,			/* la_value_print_inner */
+  f_value_print_innner,		/* la_value_print_inner */
   c_value_print,		/* FIXME */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index cf6024c4454..8b0f3f262df 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -41,6 +41,12 @@ extern void f_val_print (struct type *, int, CORE_ADDR,
 			 struct value *,
 			 const struct value_print_options *);
 
+/* Implement la_value_print_inner for Fortran.  */
+
+extern void f_value_print_innner (struct value *val, struct ui_file *stream,
+				  int recurse,
+				  const struct value_print_options *options);
+
 /* Language-specific data structures */
 
 /* A common block.  */
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 10aeb7dc53d..9eccabbcd52 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -370,6 +370,16 @@ f_val_print (struct type *type, int embedded_offset,
     }
 }
 
+/* See f-lang.h.  */
+
+void
+f_value_print_innner (struct value *val, struct ui_file *stream, int recurse,
+		      const struct value_print_options *options)
+{
+  f_val_print (value_type (val), value_embedded_offset (val),
+	       value_address (val), stream, recurse, val, options);
+}
+
 static void
 info_common_command_for_block (const struct block *block, const char *comname,
 			       int *any_printed)
-- 
2.17.2

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

* [PATCH 22/55] Convert Rust printing to value-based API
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (5 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 20/55] Introduce f_value_print_innner Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 13/55] Two simple uses of value_print_scalar_formatted Tom Tromey
                   ` (48 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

From: Tom Tromey <tromey@adacore.com>

For Rust, it was simple to convert the printing code to the
value-based API all at once.

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

	* rust-lang.c (val_print_struct, rust_print_enum): Use the value
	API.
	(rust_val_print): Rewrite.
	(rust_value_print_inner): New function, from rust_val_print.
	(rust_language_defn): Use rust_value_print_inner.

Change-Id: I1abdc2b1fb63023476b3ef9bc77d71fb5bb5be25
---
 gdb/ChangeLog   |   8 ++++
 gdb/rust-lang.c | 117 +++++++++++++++++++++++++-----------------------
 2 files changed, 69 insertions(+), 56 deletions(-)

diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index bacd351ef6c..bbeccf6ad43 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -351,6 +351,10 @@ rust_printstr (struct ui_file *stream, struct type *type,
 
 \f
 
+static void rust_value_print_inner (struct value *val, struct ui_file *stream,
+				    int recurse,
+				    const struct value_print_options *options);
+
 /* Helper function to print a string slice.  */
 
 static void
@@ -369,13 +373,12 @@ rust_val_print_str (struct ui_file *stream, struct value *val,
 /* rust_val_print helper for structs and untagged unions.  */
 
 static void
-val_print_struct (struct type *type, int embedded_offset,
-		  CORE_ADDR address, struct ui_file *stream,
-		  int recurse, struct value *val,
+val_print_struct (struct value *val, struct ui_file *stream, int recurse,
 		  const struct value_print_options *options)
 {
   int i;
   int first_field;
+  struct type *type = check_typedef (value_type (val));
 
   if (rust_slice_type_p (type) && strcmp (TYPE_NAME (type), "&str") == 0)
     {
@@ -386,7 +389,7 @@ val_print_struct (struct type *type, int embedded_offset,
 	 However, RUST_VAL_PRINT_STR looks up the fields of the string
 	 inside VAL, assuming that VAL is the string.
 	 So, recreate VAL as a value representing just the string.  */
-      val = value_at_lazy (type, value_address (val) + embedded_offset);
+      val = value_at_lazy (type, value_address (val));
       rust_val_print_str (stream, val, options);
       return;
     }
@@ -440,11 +443,8 @@ val_print_struct (struct type *type, int embedded_offset,
 	  fputs_filtered (": ", stream);
         }
 
-      val_print (TYPE_FIELD_TYPE (type, i),
-		 embedded_offset + TYPE_FIELD_BITPOS (type, i) / 8,
-		 address,
-		 stream, recurse + 1, val, &opts,
-		 current_language);
+      rust_value_print_inner (value_field (val, i), stream, recurse + 1,
+			      &opts);
     }
 
   if (options->prettyformat)
@@ -462,12 +462,11 @@ val_print_struct (struct type *type, int embedded_offset,
 /* rust_val_print helper for discriminated unions (Rust enums).  */
 
 static void
-rust_print_enum (struct type *type, int embedded_offset,
-		 CORE_ADDR address, struct ui_file *stream,
-		 int recurse, struct value *val,
+rust_print_enum (struct value *val, struct ui_file *stream, int recurse,
 		 const struct value_print_options *options)
 {
   struct value_print_options opts = *options;
+  struct type *type = check_typedef (value_type (val));
 
   opts.deref_ref = 0;
 
@@ -482,7 +481,6 @@ rust_print_enum (struct type *type, int embedded_offset,
 
   const gdb_byte *valaddr = value_contents_for_printing (val);
   struct field *variant_field = rust_enum_variant (type, valaddr);
-  embedded_offset += FIELD_BITPOS (*variant_field) / 8;
   struct type *variant_type = FIELD_TYPE (*variant_field);
 
   int nfields = TYPE_NFIELDS (variant_type);
@@ -506,6 +504,10 @@ rust_print_enum (struct type *type, int embedded_offset,
       fprintf_filtered (stream, "{");
     }
 
+  struct value *union_value = value_field (val, 0);
+  int fieldno = (variant_field - &TYPE_FIELD (value_type (union_value), 0));
+  val = value_field (union_value, fieldno);
+
   bool first_field = true;
   for (int j = 0; j < TYPE_NFIELDS (variant_type); j++)
     {
@@ -517,12 +519,8 @@ rust_print_enum (struct type *type, int embedded_offset,
 	fprintf_filtered (stream, "%s: ",
 			  TYPE_FIELD_NAME (variant_type, j));
 
-      val_print (TYPE_FIELD_TYPE (variant_type, j),
-		 (embedded_offset
-		  + TYPE_FIELD_BITPOS (variant_type, j) / 8),
-		 address,
-		 stream, recurse + 1, val, &opts,
-		 current_language);
+      rust_value_print_inner (value_field (val, j), stream, recurse + 1,
+			      &opts);
     }
 
   if (is_tuple)
@@ -553,9 +551,24 @@ rust_val_print (struct type *type, int embedded_offset,
 		struct value *val,
 		const struct value_print_options *options)
 {
-  const gdb_byte *valaddr = value_contents_for_printing (val);
+  generic_val_print (type, embedded_offset, address, stream,
+		     recurse, val, options, &rust_decorations);
+}
 
-  type = check_typedef (type);
+/* la_value_print_inner implementation for Rust.  */
+static void
+rust_value_print_inner (struct value *val, struct ui_file *stream,
+			int recurse,
+			const struct value_print_options *options)
+{
+  struct value_print_options opts = *options;
+  opts.deref_ref = 1;
+
+  if (opts.prettyformat == Val_prettyformat_default)
+    opts.prettyformat = (opts.prettyformat_structs
+			 ? Val_prettyformat : Val_no_prettyformat);
+
+  struct type *type = check_typedef (value_type (val));
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_PTR:
@@ -565,34 +578,32 @@ rust_val_print (struct type *type, int embedded_offset,
 	if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY
 	    && rust_u8_type_p (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (type)))
 	    && get_array_bounds (TYPE_TARGET_TYPE (type), &low_bound,
-				 &high_bound)) {
-	  /* We have a pointer to a byte string, so just print
-	     that.  */
-	  struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
-	  CORE_ADDR addr;
-	  struct gdbarch *arch = get_type_arch (type);
-	  int unit_size = gdbarch_addressable_memory_unit_size (arch);
+				 &high_bound))
+	  {
+	    /* We have a pointer to a byte string, so just print
+	       that.  */
+	    struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
+	    CORE_ADDR addr = value_as_address (val);
+	    struct gdbarch *arch = get_type_arch (type);
 
-	  addr = unpack_pointer (type, valaddr + embedded_offset * unit_size);
-	  if (options->addressprint)
-	    {
-	      fputs_filtered (paddress (arch, addr), stream);
-	      fputs_filtered (" ", stream);
-	    }
+	    if (opts.addressprint)
+	      {
+		fputs_filtered (paddress (arch, addr), stream);
+		fputs_filtered (" ", stream);
+	      }
 
-	  fputs_filtered ("b", stream);
-	  val_print_string (TYPE_TARGET_TYPE (elttype), "ASCII", addr,
-			    high_bound - low_bound + 1, stream,
-			    options);
-	  break;
-	}
+	    fputs_filtered ("b", stream);
+	    val_print_string (TYPE_TARGET_TYPE (elttype), "ASCII", addr,
+			      high_bound - low_bound + 1, stream,
+			      &opts);
+	    break;
+	  }
       }
-      /* Fall through.  */
+      goto generic_print;
 
     case TYPE_CODE_METHODPTR:
     case TYPE_CODE_MEMBERPTR:
-      c_val_print (type, embedded_offset, address, stream,
-		   recurse, val, options);
+      c_value_print_inner (val, stream, recurse, &opts);
       break;
 
     case TYPE_CODE_INT:
@@ -607,8 +618,6 @@ rust_val_print (struct type *type, int embedded_offset,
 
     case TYPE_CODE_STRING:
       {
-	struct gdbarch *arch = get_type_arch (type);
-	int unit_size = gdbarch_addressable_memory_unit_size (arch);
 	LONGEST low_bound, high_bound;
 
 	if (!get_array_bounds (type, &low_bound, &high_bound))
@@ -619,8 +628,8 @@ rust_val_print (struct type *type, int embedded_offset,
 	   encoding.  */
 	fputs_filtered ("b", stream);
 	rust_printstr (stream, TYPE_TARGET_TYPE (type),
-		       valaddr + embedded_offset * unit_size,
-		       high_bound - low_bound + 1, "ASCII", 0, options);
+		       value_contents_for_printing (val),
+		       high_bound - low_bound + 1, "ASCII", 0, &opts);
       }
       break;
 
@@ -642,24 +651,20 @@ rust_val_print (struct type *type, int embedded_offset,
 	 for printing a union is same as that for a struct, the only
 	 difference is that the input type will have overlapping
 	 fields.  */
-      val_print_struct (type, embedded_offset, address, stream,
-			recurse, val, options);
+      val_print_struct (val, stream, recurse, &opts);
       break;
 
     case TYPE_CODE_STRUCT:
       if (rust_enum_p (type))
-	rust_print_enum (type, embedded_offset, address, stream,
-			 recurse, val, options);
+	rust_print_enum (val, stream, recurse, &opts);
       else
-	val_print_struct (type, embedded_offset, address, stream,
-			  recurse, val, options);
+	val_print_struct (val, stream, recurse, &opts);
       break;
 
     default:
     generic_print:
       /* Nothing special yet.  */
-      generic_val_print (type, embedded_offset, address, stream,
-			 recurse, val, options, &rust_decorations);
+      generic_value_print (val, stream, recurse, &opts, &rust_decorations);
     }
 }
 
@@ -2146,7 +2151,7 @@ extern const struct language_defn rust_language_defn =
   rust_print_type,		/* Print a type using appropriate syntax */
   rust_print_typedef,		/* Print a typedef using appropriate syntax */
   rust_val_print,		/* Print a value using appropriate syntax */
-  nullptr,			/* la_value_print_inner */
+  rust_value_print_inner,	/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
-- 
2.17.2

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

* [PATCH 07/55] Use common_val_print in f-valprint.c
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (13 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 24/55] Convert D printing to value-based API Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 35/55] Introduce generic_value_print_int Tom Tromey
                   ` (40 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes a couple spots in f-valprint.c to use common_val_print
rather than val_print.

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

	* f-valprint.c (f77_print_array_1, f_val_print): Use
	common_val_print.

Change-Id: Ie5f834695005e32f01706abadabfdb45e70be076
---
 gdb/ChangeLog    |  5 +++++
 gdb/f-valprint.c | 11 +++--------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 35dc90dcb0f..10aeb7dc53d 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -156,10 +156,7 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
 	{
 	  struct value *elt = value_subscript ((struct value *)val, i);
 
-	  val_print (value_type (elt),
-		     value_embedded_offset (elt),
-		     value_address (elt), stream, recurse,
-		     elt, options, current_language);
+	  common_val_print (elt, stream, recurse, options, current_language);
 
 	  if (i != upperbound)
 	    fprintf_filtered (stream, ", ");
@@ -345,10 +342,8 @@ f_val_print (struct type *type, int embedded_offset,
 		  fputs_filtered (" = ", stream);
 		}
 
-	      val_print (value_type (field),
-			 value_embedded_offset (field),
-			 value_address (field), stream, recurse + 1,
-			 field, options, current_language);
+	      common_val_print (field, stream, recurse + 1,
+				options, current_language);
 
 	      ++printed_field;
 	    }
-- 
2.17.2

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

* [PATCH 04/55] Use common_val_print in infcmd.c
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
  2019-12-08 18:30 ` [PATCH 06/55] Use common_val_print in riscv-tdep.c Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 16/55] Make pascal_object_print_value_fields static Tom Tromey
                   ` (53 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes some spots in infcmd.c to use common_val_print (which,
despite its name, is a value-based API) rather than val_print.

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

	* infcmd.c (default_print_one_register_info): Use
	common_val_print.

Change-Id: I13efb6db9f1bf4cb90aa3eac1702a633074e192b
---
 gdb/ChangeLog |  5 +++++
 gdb/infcmd.c  | 12 +++---------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 2a253469e74..c8b444bfd65 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2221,9 +2221,7 @@ default_print_one_register_info (struct ui_file *file,
       get_user_print_options (&opts);
       opts.deref_ref = 1;
 
-      val_print (regtype,
-		 value_embedded_offset (val), 0,
-		 &format_stream, 0, val, &opts, current_language);
+      common_val_print (val, &format_stream, 0, &opts, current_language);
 
       if (print_raw_format)
 	{
@@ -2241,9 +2239,7 @@ default_print_one_register_info (struct ui_file *file,
       /* Print the register in hex.  */
       get_formatted_print_options (&opts, 'x');
       opts.deref_ref = 1;
-      val_print (regtype,
-		 value_embedded_offset (val), 0,
-		 &format_stream, 0, val, &opts, current_language);
+      common_val_print (val, &format_stream, 0, &opts, current_language);
       /* If not a vector register, print it also according to its
 	 natural format.  */
       if (print_raw_format && TYPE_VECTOR (regtype) == 0)
@@ -2251,9 +2247,7 @@ default_print_one_register_info (struct ui_file *file,
 	  pad_to_column (format_stream, value_column_2);
 	  get_user_print_options (&opts);
 	  opts.deref_ref = 1;
-	  val_print (regtype,
-		     value_embedded_offset (val), 0,
-		     &format_stream, 0, val, &opts, current_language);
+	  common_val_print (val, &format_stream, 0, &opts, current_language);
 	}
     }
 
-- 
2.17.2

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

* [PATCH 24/55] Convert D printing to value-based API
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (12 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 19/55] Introduce pascal_value_print_inner Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 07/55] Use common_val_print in f-valprint.c Tom Tromey
                   ` (41 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

As with Rust and Go, it was straightforward to convert D to the
value-based API directly.

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

	* d-valprint.c (dynamic_array_type): Call d_value_print_inner.
	(d_value_print_inner): New function.
	* d-lang.h (d_value_print_inner): Declare.
	* d-lang.c (d_language_defn): Use d_value_print_inner.

Change-Id: I9f9fefdf804f3fba17452ec55ef1d05bbcf03c92
---
 gdb/ChangeLog    |  7 +++++++
 gdb/d-lang.c     |  2 +-
 gdb/d-lang.h     |  6 ++++++
 gdb/d-valprint.c | 28 +++++++++++++++++++++++++---
 4 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 5ce2314ae14..ce4324c3f86 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -225,7 +225,7 @@ extern const struct language_defn d_language_defn =
   c_print_typedef,		/* Print a typedef using appropriate
 				   syntax.  */
   d_val_print,			/* Print a value using appropriate syntax.  */
-  nullptr,			/* la_value_print_inner */
+  d_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value.  */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline.  */
diff --git a/gdb/d-lang.h b/gdb/d-lang.h
index 956c1923a69..51d3f17aa51 100644
--- a/gdb/d-lang.h
+++ b/gdb/d-lang.h
@@ -84,4 +84,10 @@ extern void d_val_print (struct type *type,
 			 struct value *val,
 			 const struct value_print_options *options);
 
+/* Implement la_value_print_inner for D.  */
+
+extern void d_value_print_inner (struct value *val,
+				 struct ui_file *stream, int recurse,
+				 const struct value_print_options *options);
+
 #endif /* !defined (D_LANG_H) */
diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c
index 54652364a8f..5dbaf700eeb 100644
--- a/gdb/d-valprint.c
+++ b/gdb/d-valprint.c
@@ -63,9 +63,7 @@ dynamic_array_type (struct type *type,
       ival = value_at (true_type, addr);
       true_type = value_type (ival);
 
-      d_val_print (true_type,
-		   value_embedded_offset (ival), addr,
-		   stream, recurse + 1, ival, options);
+      d_value_print_inner (ival, stream, recurse + 1, options);
       return 0;
     }
   return 1;
@@ -94,3 +92,27 @@ d_val_print (struct type *type, int embedded_offset,
 		     recurse, val, options);
     }
 }
+
+/* See d-lang.h.  */
+
+void
+d_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
+		     const struct value_print_options *options)
+{
+  int ret;
+
+  struct type *type = check_typedef (value_type (val));
+  switch (TYPE_CODE (type))
+    {
+      case TYPE_CODE_STRUCT:
+	ret = dynamic_array_type (type, value_embedded_offset (val),
+				  value_address (val),
+				  stream, recurse, val, options);
+	if (ret == 0)
+	  break;
+	/* Fall through.  */
+      default:
+	c_value_print_inner (val, stream, recurse, options);
+	break;
+    }
+}
-- 
2.17.2

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

* [PATCH 09/55] Use common_val_print in c-valprint.c
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (10 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 11/55] Introduce generic_value_print Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2020-01-15  5:09   ` Simon Marchi
  2019-12-08 18:30 ` [PATCH 19/55] Introduce pascal_value_print_inner Tom Tromey
                   ` (43 subsequent siblings)
  55 siblings, 1 reply; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes c_value_print to call common_val_print.  This is more
complicated than the usual sort of common_val_print change, due to the
handling of RTTI.

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

	* c-valprint.c (c_value_print): Use common_val_print.

Change-Id: Ifae442de4e508a90a2ccdc4f31792bfe47f79e6f
---
 gdb/ChangeLog    |  4 ++++
 gdb/c-valprint.c | 53 ++++++++++++++++--------------------------------
 2 files changed, 22 insertions(+), 35 deletions(-)

diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 607fb80c58f..d20a411252f 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -567,7 +567,7 @@ void
 c_value_print (struct value *val, struct ui_file *stream, 
 	       const struct value_print_options *options)
 {
-  struct type *type, *real_type, *val_type;
+  struct type *type, *real_type;
   int full, using_enc;
   LONGEST top;
   struct value_print_options opts = *options;
@@ -581,11 +581,7 @@ c_value_print (struct value *val, struct ui_file *stream,
      C++: if it is a member pointer, we will take care
      of that when we print it.  */
 
-  /* Preserve the original type before stripping typedefs.  We prefer
-     to pass down the original type when possible, but for local
-     checks it is better to look past the typedefs.  */
-  val_type = value_type (val);
-  type = check_typedef (val_type);
+  type = check_typedef (value_type (val));
 
   if (TYPE_CODE (type) == TYPE_CODE_PTR || TYPE_IS_REFERENCE (type))
     {
@@ -593,12 +589,12 @@ c_value_print (struct value *val, struct ui_file *stream,
          type is indicated by the quoted string anyway.
          (Don't use c_textual_element_type here; quoted strings
          are always exactly (char *), (wchar_t *), or the like.  */
-      if (TYPE_CODE (val_type) == TYPE_CODE_PTR
-	  && TYPE_NAME (val_type) == NULL
-	  && TYPE_NAME (TYPE_TARGET_TYPE (val_type)) != NULL
-	  && (strcmp (TYPE_NAME (TYPE_TARGET_TYPE (val_type)),
+      if (TYPE_CODE (type) == TYPE_CODE_PTR
+	  && TYPE_NAME (type) == NULL
+	  && TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL
+	  && (strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)),
 		      "char") == 0
-	      || textual_name (TYPE_NAME (TYPE_TARGET_TYPE (val_type)))))
+	      || textual_name (TYPE_NAME (TYPE_TARGET_TYPE (type)))))
 	{
 	  /* Print nothing.  */
 	}
@@ -624,7 +620,6 @@ c_value_print (struct value *val, struct ui_file *stream,
 	      if (real_type)
 		{
 		  /* RTTI entry found.  */
-		  type = real_type;
 
 		  /* Need to adjust pointer value.  */
 		  val = value_from_pointer (real_type,
@@ -637,14 +632,11 @@ c_value_print (struct value *val, struct ui_file *stream,
 	    }
 
 	  if (is_ref)
-	    {
-	      val = value_ref (value_ind (val), refcode);
-	      type = value_type (val);
-	    }
+	    val = value_ref (value_ind (val), refcode);
 
+	  type = value_type (val);
 	  type_print (type, "", stream, -1);
 	  fprintf_filtered (stream, ") ");
-	  val_type = type;
 	}
       else
 	{
@@ -667,36 +659,27 @@ c_value_print (struct value *val, struct ui_file *stream,
 	  /* We have RTTI information, so use it.  */
 	  val = value_full_object (val, real_type, 
 				   full, top, using_enc);
+	  /* In a destructor we might see a real type that is a
+	     superclass of the object's type.  In this case it is
+	     better to leave the object as-is.  */
+	  if (!(full
+		&& (TYPE_LENGTH (real_type)
+		    < TYPE_LENGTH (value_enclosing_type (val)))))
+	    val = value_cast (real_type, val);
 	  fprintf_filtered (stream, "(%s%s) ",
 			    TYPE_NAME (real_type),
 			    full ? "" : _(" [incomplete object]"));
 	  /* Print out object: enclosing type is same as real_type if
 	     full.  */
-	  val_print (value_enclosing_type (val),
-		     0,
-		     value_address (val), stream, 0,
-		     val, &opts, current_language);
-	  return;
-          /* Note: When we look up RTTI entries, we don't get any
-             information on const or volatile attributes.  */
 	}
       else if (type != check_typedef (value_enclosing_type (val)))
 	{
 	  /* No RTTI information, so let's do our best.  */
 	  fprintf_filtered (stream, "(%s ?) ",
 			    TYPE_NAME (value_enclosing_type (val)));
-	  val_print (value_enclosing_type (val),
-		     0,
-		     value_address (val), stream, 0,
-		     val, &opts, current_language);
-	  return;
+	  val = value_cast (value_enclosing_type (val), val);
 	}
-      /* Otherwise, we end up at the return outside this "if".  */
     }
 
-  val_print (val_type,
-	     value_embedded_offset (val),
-	     value_address (val),
-	     stream, 0,
-	     val, &opts, current_language);
+  common_val_print (val, stream, 0, &opts, current_language);
 }
-- 
2.17.2

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

* [PATCH 25/55] Convert Modula-2 printing to value-based API
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (16 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 10/55] Introduce la_value_print_inner Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:31 ` [PATCH 29/55] Initial rewrite of generic_value_print Tom Tromey
                   ` (37 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This finishes the conversion of Modula-2 printing to the value-based
API.  It does so by copying the body of m2_val_print into
m2_value_print_inner, and then introducing new functions as needed to
use the value API.

The "val_" API code continues to exist, because it's still possible
for it to be called via some paths.  This code will all be removed at
the end of the series.

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

	* m2-valprint.c (m2_print_unbounded_array): New overload.
	(m2_print_unbounded_array): Update.
	(m2_print_array_contents): Take a struct value.
	(m2_value_print_inner): Rewrite.

Change-Id: I015c2929297dcff727eaaf887fb351bacd32cd6c
---
 gdb/ChangeLog     |   7 ++
 gdb/m2-valprint.c | 224 ++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 214 insertions(+), 17 deletions(-)

diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index 9ad5ca3e0b2..12f62ad1e83 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -35,10 +35,8 @@ static int print_unpacked_pointer (struct type *type,
 				   const struct value_print_options *options,
 				   struct ui_file *stream);
 static void
-m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
-			 int embedded_offset, CORE_ADDR address,
+m2_print_array_contents (struct value *val,
 			 struct ui_file *stream, int recurse,
-			 struct value *val,
 			 const struct value_print_options *options,
 			 int len);
 
@@ -158,6 +156,31 @@ m2_print_long_set (struct type *type, const gdb_byte *valaddr,
     }
 }
 
+static void
+m2_print_unbounded_array (struct value *value,
+			  struct ui_file *stream, int recurse,
+			  const struct value_print_options *options)
+{
+  CORE_ADDR addr;
+  LONGEST len;
+  struct value *val;
+
+  struct type *type = check_typedef (value_type (value));
+  const gdb_byte *valaddr = value_contents_for_printing (value);
+
+  addr = unpack_pointer (TYPE_FIELD_TYPE (type, 0),
+			 (TYPE_FIELD_BITPOS (type, 0) / 8) +
+			 valaddr);
+
+  val = value_at_lazy (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0)),
+		       addr);
+  len = unpack_field_as_long (type, valaddr, 1);
+
+  fprintf_filtered (stream, "{");  
+  m2_print_array_contents (val, stream, recurse, options, len);
+  fprintf_filtered (stream, ", HIGH = %d}", (int) len);
+}
+
 static void
 m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
 			  int embedded_offset, CORE_ADDR address,
@@ -179,10 +202,7 @@ m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
   len = unpack_field_as_long (type, valaddr + embedded_offset, 1);
 
   fprintf_filtered (stream, "{");  
-  m2_print_array_contents (value_type (val),
-			   value_contents_for_printing (val),
-			   value_embedded_offset (val), addr, stream,
-			   recurse, val, options, len);
+  m2_print_array_contents (val, stream, recurse, options, len);
   fprintf_filtered (stream, ", HIGH = %d}", (int) len);
 }
 
@@ -261,14 +281,12 @@ print_variable_at_address (struct type *type,
                              separated values.  */
 
 static void
-m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
-			 int embedded_offset, CORE_ADDR address,
+m2_print_array_contents (struct value *val,
 			 struct ui_file *stream, int recurse,
-			 struct value *val,
 			 const struct value_print_options *options,
 			 int len)
 {
-  type = check_typedef (type);
+  struct type *type = check_typedef (value_type (val));
 
   if (TYPE_LENGTH (type) > 0)
     {
@@ -280,13 +298,12 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
 	   || ((current_language->la_language == language_m2)
 	       && (TYPE_CODE (type) == TYPE_CODE_CHAR)))
 	  && (options->format == 0 || options->format == 's'))
-	val_print_string (type, NULL, address, len+1, stream, options);
+	val_print_string (type, NULL, value_address (val), len+1, stream,
+			  options);
       else
 	{
 	  fprintf_filtered (stream, "{");
-	  val_print_array_elements (type, embedded_offset,
-				    address, stream, recurse, val,
-				    options, 0);
+	  value_print_array_elements (val, stream, recurse, options, 0);
 	  fprintf_filtered (stream, "}");
 	}
     }
@@ -510,6 +527,179 @@ void
 m2_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
 		      const struct value_print_options *options)
 {
-  m2_val_print (value_type (val), value_embedded_offset (val),
-		value_address (val), stream, recurse, val, options);
+  unsigned len;
+  struct type *elttype;
+  CORE_ADDR addr;
+  const gdb_byte *valaddr = value_contents_for_printing (val);
+  const CORE_ADDR address = value_address (val);
+
+  struct type *type = check_typedef (value_type (val));
+  switch (TYPE_CODE (type))
+    {
+    case TYPE_CODE_ARRAY:
+      if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
+	{
+	  elttype = check_typedef (TYPE_TARGET_TYPE (type));
+	  len = TYPE_LENGTH (type) / TYPE_LENGTH (elttype);
+	  if (options->prettyformat_arrays)
+	    print_spaces_filtered (2 + 2 * recurse, stream);
+	  /* For an array of chars, print with string syntax.  */
+	  if (TYPE_LENGTH (elttype) == 1 &&
+	      ((TYPE_CODE (elttype) == TYPE_CODE_INT)
+	       || ((current_language->la_language == language_m2)
+		   && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
+	      && (options->format == 0 || options->format == 's'))
+	    {
+	      /* If requested, look for the first null char and only print
+	         elements up to it.  */
+	      if (options->stop_print_at_null)
+		{
+		  unsigned int temp_len;
+
+		  /* Look for a NULL char.  */
+		  for (temp_len = 0;
+		       (valaddr[temp_len]
+			&& temp_len < len && temp_len < options->print_max);
+		       temp_len++);
+		  len = temp_len;
+		}
+
+	      LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type),
+			       valaddr, len, NULL, 0, options);
+	    }
+	  else
+	    {
+	      fprintf_filtered (stream, "{");
+	      value_print_array_elements (val, stream, recurse,
+					  options, 0);
+	      fprintf_filtered (stream, "}");
+	    }
+	  break;
+	}
+      /* Array of unspecified length: treat like pointer to first elt.  */
+      print_unpacked_pointer (type, address, address, options, stream);
+      break;
+
+    case TYPE_CODE_PTR:
+      if (TYPE_CONST (type))
+	print_variable_at_address (type, valaddr, stream, recurse, options);
+      else if (options->format && options->format != 's')
+	value_print_scalar_formatted (val, options, 0, stream);
+      else
+	{
+	  addr = unpack_pointer (type, valaddr);
+	  print_unpacked_pointer (type, addr, address, options, stream);
+	}
+      break;
+
+    case TYPE_CODE_UNION:
+      if (recurse && !options->unionprint)
+	{
+	  fprintf_filtered (stream, "{...}");
+	  break;
+	}
+      /* Fall through.  */
+    case TYPE_CODE_STRUCT:
+      if (m2_is_long_set (type))
+	m2_print_long_set (type, valaddr, 0, address, stream);
+      else if (m2_is_unbounded_array (type))
+	m2_print_unbounded_array (val, stream, recurse, options);
+      else
+	cp_print_value_fields (type, type, 0,
+			       address, stream, recurse, val,
+			       options, NULL, 0);
+      break;
+
+    case TYPE_CODE_SET:
+      elttype = TYPE_INDEX_TYPE (type);
+      elttype = check_typedef (elttype);
+      if (TYPE_STUB (elttype))
+	{
+	  fprintf_styled (stream, metadata_style.style (),
+			  _("<incomplete type>"));
+	  break;
+	}
+      else
+	{
+	  struct type *range = elttype;
+	  LONGEST low_bound, high_bound;
+	  int i;
+	  int need_comma = 0;
+
+	  fputs_filtered ("{", stream);
+
+	  i = get_discrete_bounds (range, &low_bound, &high_bound);
+	maybe_bad_bstring:
+	  if (i < 0)
+	    {
+	      fputs_styled (_("<error value>"), metadata_style.style (),
+			    stream);
+	      goto done;
+	    }
+
+	  for (i = low_bound; i <= high_bound; i++)
+	    {
+	      int element = value_bit_index (type, valaddr, i);
+
+	      if (element < 0)
+		{
+		  i = element;
+		  goto maybe_bad_bstring;
+		}
+	      if (element)
+		{
+		  if (need_comma)
+		    fputs_filtered (", ", stream);
+		  print_type_scalar (range, i, stream);
+		  need_comma = 1;
+
+		  if (i + 1 <= high_bound
+		      && value_bit_index (type, valaddr, ++i))
+		    {
+		      int j = i;
+
+		      fputs_filtered ("..", stream);
+		      while (i + 1 <= high_bound
+			     && value_bit_index (type, valaddr, ++i))
+			j = i;
+		      print_type_scalar (range, j, stream);
+		    }
+		}
+	    }
+	done:
+	  fputs_filtered ("}", stream);
+	}
+      break;
+
+    case TYPE_CODE_RANGE:
+      if (TYPE_LENGTH (type) == TYPE_LENGTH (TYPE_TARGET_TYPE (type)))
+	{
+	  struct value *v = value_cast (TYPE_TARGET_TYPE (type), val);
+	  m2_value_print_inner (v, stream, recurse, options);
+	  break;
+	}
+      /* FIXME: create_static_range_type does not set the unsigned bit in a
+         range type (I think it probably should copy it from the target
+         type), so we won't print values which are too large to
+         fit in a signed integer correctly.  */
+      /* FIXME: Doesn't handle ranges of enums correctly.  (Can't just
+         print with the target type, though, because the size of our type
+         and the target type might differ).  */
+      /* FALLTHROUGH */
+
+    case TYPE_CODE_REF:
+    case TYPE_CODE_ENUM:
+    case TYPE_CODE_FUNC:
+    case TYPE_CODE_INT:
+    case TYPE_CODE_FLT:
+    case TYPE_CODE_METHOD:
+    case TYPE_CODE_VOID:
+    case TYPE_CODE_ERROR:
+    case TYPE_CODE_UNDEF:
+    case TYPE_CODE_BOOL:
+    case TYPE_CODE_CHAR:
+    default:
+      generic_value_print (val, stream, recurse, options, &m2_decorations);
+      break;
+    }
 }
-- 
2.17.2

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

* [PATCH 13/55] Two simple uses of value_print_scalar_formatted
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (6 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 22/55] Convert Rust printing to value-based API Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 30/55] Introduce generic_value_print_ptr Tom Tromey
                   ` (47 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A couple of spots could be easily converted to use
value_print_scalar_formatted.  This patch makes this change.

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

	* printcmd.c (print_formatted): Use value_print_scalar_formatted.
	* mips-tdep.c (mips_print_register): Use
	value_print_scalar_formatted.

Change-Id: Icb05b23148a13cf4257b8c7c05796389566f217d
---
 gdb/ChangeLog   | 6 ++++++
 gdb/mips-tdep.c | 5 +----
 gdb/printcmd.c  | 5 +----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 0852851595f..721c030b44b 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -6373,10 +6373,7 @@ mips_print_register (struct ui_file *file, struct frame_info *frame,
     fprintf_filtered (file, ": ");
 
   get_formatted_print_options (&opts, 'x');
-  val_print_scalar_formatted (value_type (val),
-			      value_embedded_offset (val),
-			      val,
-			      &opts, 0, file);
+  value_print_scalar_formatted (val, &opts, 0, file);
 }
 
 /* Print IEEE exception condition bits in FLAGS.  */
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index f7674cf1d01..9071a796c0e 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -321,10 +321,7 @@ print_formatted (struct value *val, int size,
   else
     /* User specified format, so don't look to the type to tell us
        what to do.  */
-    val_print_scalar_formatted (type,
-				value_embedded_offset (val),
-				val,
-				options, size, stream);
+    value_print_scalar_formatted (val, options, size, stream);
 }
 
 /* Return builtin floating point type of same length as TYPE.
-- 
2.17.2

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

* [PATCH 00/55] Remove val_print
@ 2019-12-08 18:30 Tom Tromey
  2019-12-08 18:30 ` [PATCH 06/55] Use common_val_print in riscv-tdep.c Tom Tromey
                   ` (55 more replies)
  0 siblings, 56 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches

I've long wanted to remove the val_print API.  It is used for the
lowest level of value printing, and works by passing around an
"exploded" value -- the type, offset, content, and address are passed
as separate parameters.  However, at some point we also had to start
passing around the original outer-most value as well (to check content
validity), which made the entire exercise a bit of a travesty.

I had put off this refactoring because I couldn't think of a
reviewable way to do it.  However, recently I realized I could
temporarily duplicate a lot of the code, rewriting as it made sense,
and then at the end flip a switch to enable the new paths, while
deleting the old API.  This is the approach taken by this series.

This is mildly ugly in two ways.

First, it duplicates code.  Of course, this is temporary, because the
duplication is entirely removed in the final patch.  So, I don't
consider it a big deal.

Second, there are some spots in the middle of this series that
introduce some regressions.  I tried to prevent this, but it turned
out to be difficult to do.  I am hoping that others agree with me that
this is ok in this case; but if not I can try again.

Patch #3 might not strictly be required.  It exists to preserve the
output in one particular case, but it's not clear if this is intended
behavior or just a historical accident.

It's possible that this series could result in too much memory
allocation when printing very large objects.  If this is a problem, I
think it's possible to implement content sharing in struct value --
one of the nice things about C++ is that it makes this sort of thing
more practical.

While this series eliminates most of the val_print code, a few
vestiges remain.  Some low-level printing routines for particular
types still accept old-style parameters.  This could be cleaned up,
but I haven't done so because this series is already too long.

There's a lot of duplication in the value-printing code.  For example,
the Pascal code seems to be a cut-and-paste of the C++ code; I doubt
(but don't really know) whether Pascal even has virtual base classes
to worry about.  So, another possible future direction would be to
share even more of this code across languages.

Regression tested by the buildbot.  I don't propose checking this in
until after the 9.1 branch has been made.

Let me know what you think.

Tom


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

* [PATCH 48/55] Rewrite ada_value_print_1 floating point case
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (2 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 16/55] Make pascal_object_print_value_fields static Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 32/55] Remove generic_val_print_flags Tom Tromey
                   ` (51 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This rewrites the TYPE_CODE_FLT case in ada_value_print_1 to be purely
value-based.

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

	* ada-valprint.c (ada_value_print_1) <TYPE_CODE_FLT>: Rewrite.

Change-Id: I05c0c13d910c551ee9f69d948bb7889e28dd32c1
---
 gdb/ChangeLog      |  4 ++++
 gdb/ada-valprint.c | 11 ++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index b3fb9512f57..0286ced7c30 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -1291,9 +1291,14 @@ ada_value_print_1 (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_FLT:
-      ada_val_print_flt (type, valaddr, 0, 0,
-			 address, stream, recurse, val,
-			 options);
+      if (options->format)
+	{
+	  common_val_print (val, stream, recurse, options,
+			    language_def (language_c));
+	  break;
+	}
+
+      ada_print_floating (valaddr, type, stream);
       break;
 
     case TYPE_CODE_UNION:
-- 
2.17.2

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

* [PATCH 35/55] Introduce generic_value_print_int
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (14 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 07/55] Use common_val_print in f-valprint.c Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 10/55] Introduce la_value_print_inner Tom Tromey
                   ` (39 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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

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:
-- 
2.17.2

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

* [PATCH 19/55] Introduce pascal_value_print_inner
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (11 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 09/55] Use common_val_print in c-valprint.c Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 24/55] Convert D printing to value-based API Tom Tromey
                   ` (42 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces pascal_value_print_inner.

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

	* p-valprint.c (pascal_value_print_inner): New function.
	* p-lang.h (pascal_value_print_inner): Declare.
	* p-lang.c (pascal_language_defn): Use pascal_value_print_inner.

Change-Id: I2e560738ac59e2ee99874e65920d3f60ea179bc7
---
 gdb/ChangeLog    |  6 ++++++
 gdb/p-lang.c     |  2 +-
 gdb/p-lang.h     |  5 +++++
 gdb/p-valprint.c | 13 +++++++++++++
 4 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 3229c3e9c9f..85020c4bedc 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -448,7 +448,7 @@ extern const struct language_defn pascal_language_defn =
   pascal_print_type,		/* Print a type using appropriate syntax */
   pascal_print_typedef,		/* Print a typedef using appropriate syntax */
   pascal_val_print,		/* Print a value using appropriate syntax */
-  nullptr,			/* la_value_print_inner */
+  pascal_value_print_inner,	/* la_value_print_inner */
   pascal_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index 1376bc2c94a..fafc86c78c4 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -42,6 +42,11 @@ extern void pascal_val_print (struct type *, int,
 			      struct value *,
 			      const struct value_print_options *);
 
+/* Implement la_value_print_inner for Pascal.  */
+
+extern void pascal_value_print_inner (struct value *, struct ui_file *, int,
+				      const struct value_print_options *);
+
 extern void pascal_value_print (struct value *, struct ui_file *,
 				const struct value_print_options *);
 
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 9420509066b..c24b8edfdeb 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -425,6 +425,19 @@ pascal_val_print (struct type *type,
 	     TYPE_CODE (type));
     }
 }
+
+/* See p-lang.h.  */
+
+void
+pascal_value_print_inner (struct value *val, struct ui_file *stream,
+			  int recurse,
+			  const struct value_print_options *options)
+
+{
+  pascal_val_print (value_type (val), value_embedded_offset (val),
+		    value_address (val), stream, recurse, val, options);
+}
+
 \f
 void
 pascal_value_print (struct value *val, struct ui_file *stream,
-- 
2.17.2

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

* [PATCH 41/55] Introduce c_value_print_int
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (8 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 30/55] Introduce generic_value_print_ptr Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 11/55] Introduce generic_value_print Tom Tromey
                   ` (45 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds c_value_print_int, a value-based analogue of
c_val_print_int.

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

	* c-valprint.c (c_value_print_int): New function.
	(c_value_print_inner): Use it.

Change-Id: I49259bd8bdbb14a66a98df4de449fb3bdfb1e157
---
 gdb/ChangeLog    |  5 +++++
 gdb/c-valprint.c | 35 ++++++++++++++++++++++++++++++++---
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index f50c49abbfd..9b75d4d0404 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -502,6 +502,37 @@ c_val_print_int (struct type *type, struct type *unresolved_type,
     }
 }
 
+/* c_value_print helper for TYPE_CODE_INT.  */
+
+static void
+c_value_print_int (struct value *val, struct ui_file *stream,
+		   const struct value_print_options *options)
+{
+  if (options->format || options->output_format)
+    {
+      struct value_print_options opts = *options;
+
+      opts.format = (options->format ? options->format
+		     : options->output_format);
+      value_print_scalar_formatted (val, &opts, 0, stream);
+    }
+  else
+    {
+      value_print_scalar_formatted (val, options, 0, stream);
+      /* C and C++ has no single byte int type, char is used
+	 instead.  Since we don't know whether the value is really
+	 intended to be used as an integer or a character, print
+	 the character equivalent as well.  */
+      struct type *type = value_type (val);
+      const gdb_byte *valaddr = value_contents_for_printing (val);
+      if (c_textual_element_type (type, options->format))
+	{
+	  fputs_filtered (" ", stream);
+	  LA_PRINT_CHAR (unpack_long (type, valaddr), type, stream);
+	}
+    }
+}
+
 /* c_val_print helper for TYPE_CODE_MEMBERPTR.  */
 
 static void
@@ -602,7 +633,6 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
 		     const struct value_print_options *options)
 {
   struct type *type = value_type (val);
-  struct type *unresolved_type = type;
   CORE_ADDR address = value_address (val);
   const gdb_byte *valaddr = value_contents_for_printing (val);
 
@@ -633,8 +663,7 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_INT:
-      c_val_print_int (type, unresolved_type, valaddr, 0, stream,
-		       val, options);
+      c_value_print_int (val, stream, options);
       break;
 
     case TYPE_CODE_MEMBERPTR:
-- 
2.17.2

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

* [PATCH 06/55] Use common_val_print in riscv-tdep.c
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 04/55] Use common_val_print in infcmd.c Tom Tromey
                   ` (54 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes some spots in riscv-tdep.c to use common_val_print rather
than val_print.

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

	* riscv-tdep.c (riscv_print_one_register_info): Use
	common_val_print.

Change-Id: Ibb4b545b288d74f0b7e7dc92f0861b92cc63d81f
---
 gdb/ChangeLog    |  5 +++++
 gdb/riscv-tdep.c | 12 +++---------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index d262b7d07e7..3582bfa8d36 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -693,9 +693,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch,
       get_user_print_options (&opts);
       opts.deref_ref = 1;
 
-      val_print (regtype,
-		 value_embedded_offset (val), 0,
-		 file, 0, val, &opts, current_language);
+      common_val_print (val, file, 0, &opts, current_language);
 
       if (print_raw_format)
 	{
@@ -712,9 +710,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch,
       /* Print the register in hex.  */
       get_formatted_print_options (&opts, 'x');
       opts.deref_ref = 1;
-      val_print (regtype,
-		 value_embedded_offset (val), 0,
-		 file, 0, val, &opts, current_language);
+      common_val_print (val, file, 0, &opts, current_language);
 
       if (print_raw_format)
 	{
@@ -848,9 +844,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch,
 		  get_user_print_options (&opts);
 		  opts.deref_ref = 1;
 		  fprintf_filtered (file, "\t");
-		  val_print (regtype,
-			     value_embedded_offset (val), 0,
-			     file, 0, val, &opts, current_language);
+		  common_val_print (val, file, 0, &opts, current_language);
 		}
 	    }
 	}
-- 
2.17.2

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

* [PATCH 32/55] Remove generic_val_print_flags
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (3 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 48/55] Rewrite ada_value_print_1 floating point case Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 20/55] Introduce f_value_print_innner Tom Tromey
                   ` (50 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This remove generic_val_print_flags in favor of using the value-based
API where possible.

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

	* valprint.c (generic_val_print_flags): Remove.
	(generic_val_print, generic_value_print): Update.
	(val_print_type_code_flags): Add original_value parameter.

Change-Id: Ideb43d103717afdf28d81130e8d1fe77a6a9ea09
---
 gdb/ChangeLog  |  6 ++++++
 gdb/valprint.c | 43 ++++++++++++++++---------------------------
 2 files changed, 22 insertions(+), 27 deletions(-)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index fe7ffa78abc..c6de058fa23 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -87,7 +87,8 @@ static void set_input_radix_1 (int, unsigned);
 static void set_output_radix_1 (int, unsigned);
 
 static void val_print_type_code_flags (struct type *type,
-				       const gdb_byte *valaddr,
+				       struct value *original_value,
+				       int embedded_offset,
 				       struct ui_file *stream);
 
 #define PRINT_MAX_DEFAULT 200	/* Start print_max off at this value.  */
@@ -704,26 +705,6 @@ generic_val_print_enum (struct type *type,
   generic_val_print_enum_1 (type, val, stream);
 }
 
-/* generic_val_print helper for TYPE_CODE_FLAGS.  */
-
-static void
-generic_val_print_flags (struct type *type,
-			 int embedded_offset, struct ui_file *stream,
-			 struct value *original_value,
-			 const struct value_print_options *options)
-
-{
-  if (options->format)
-    val_print_scalar_formatted (type, embedded_offset, original_value,
-				options, 0, stream);
-  else
-    {
-      const gdb_byte *valaddr = value_contents_for_printing (original_value);
-
-      val_print_type_code_flags (type, valaddr + embedded_offset, stream);
-    }
-}
-
 /* generic_val_print helper for TYPE_CODE_FUNC and TYPE_CODE_METHOD.  */
 
 static void
@@ -954,8 +935,12 @@ generic_val_print (struct type *type,
       break;
 
     case TYPE_CODE_FLAGS:
-      generic_val_print_flags (type, embedded_offset, stream,
-			       original_value, options);
+      if (options->format)
+	val_print_scalar_formatted (type, embedded_offset,
+				    original_value, options, 0, stream);
+      else
+	val_print_type_code_flags (type, original_value, embedded_offset,
+				   stream);
       break;
 
     case TYPE_CODE_FUNC:
@@ -1065,8 +1050,10 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_FLAGS:
-      generic_val_print_flags (type, 0, stream,
-			       val, options);
+      if (options->format)
+	value_print_scalar_formatted (val, options, 0, stream);
+      else
+	val_print_type_code_flags (type, val, 0, stream);
       break;
 
     case TYPE_CODE_FUNC:
@@ -1385,9 +1372,11 @@ value_print (struct value *val, struct ui_file *stream,
 }
 
 static void
-val_print_type_code_flags (struct type *type, const gdb_byte *valaddr,
-			   struct ui_file *stream)
+val_print_type_code_flags (struct type *type, struct value *original_value,
+			   int embedded_offset, struct ui_file *stream)
 {
+  const gdb_byte *valaddr = (value_contents_for_printing (original_value)
+			     + embedded_offset);
   ULONGEST val = unpack_long (type, valaddr);
   int field, nfields = TYPE_NFIELDS (type);
   struct gdbarch *gdbarch = get_type_arch (type);
-- 
2.17.2

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

* [PATCH 16/55] Make pascal_object_print_value_fields static
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
  2019-12-08 18:30 ` [PATCH 06/55] Use common_val_print in riscv-tdep.c Tom Tromey
  2019-12-08 18:30 ` [PATCH 04/55] Use common_val_print in infcmd.c Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 48/55] Rewrite ada_value_print_1 floating point case Tom Tromey
                   ` (52 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

pascal_object_print_value_fields is only needed in p-valprint.c, so
make it static.

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

	* p-valprint.c (pascal_object_print_value_fields): Now static.
	* p-lang.h (pascal_object_print_value_fields): Don't declare.

Change-Id: I0000d3b5fda2fb27b5808779bff2464e56f8621a
---
 gdb/ChangeLog    |  5 +++++
 gdb/p-lang.h     |  8 --------
 gdb/p-valprint.c | 10 +++++++++-
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index 7d1d285bd94..1376bc2c94a 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -72,14 +72,6 @@ extern void
   pascal_type_print_varspec_prefix (struct type *, struct ui_file *, int, int,
 				    const struct type_print_options *);
 
-extern void pascal_object_print_value_fields (struct type *, const gdb_byte *,
-					      LONGEST,
-					      CORE_ADDR, struct ui_file *,
-					      int,
-					      struct value *,
-					      const struct value_print_options *,
-					      struct type **, int);
-
 extern int pascal_object_is_vtbl_ptr_type (struct type *);
 
 extern int pascal_object_is_vtbl_member (struct type *);
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 198d6b6c3e4..9420509066b 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -42,6 +42,14 @@
 #include "cli/cli-style.h"
 \f
 
+static void pascal_object_print_value_fields (struct type *, const gdb_byte *,
+					      LONGEST,
+					      CORE_ADDR, struct ui_file *,
+					      int,
+					      struct value *,
+					      const struct value_print_options *,
+					      struct type **, int);
+
 /* Decorations for Pascal.  */
 
 static const struct generic_val_print_decorations p_decorations =
@@ -529,7 +537,7 @@ pascal_object_is_vtbl_member (struct type *type)
    DONT_PRINT is an array of baseclass types that we
    should not print, or zero if called from top level.  */
 
-void
+static void
 pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
 				  LONGEST offset,
 				  CORE_ADDR address, struct ui_file *stream,
-- 
2.17.2

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

* [PATCH 30/55] Introduce generic_value_print_ptr
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (7 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 13/55] Two simple uses of value_print_scalar_formatted Tom Tromey
@ 2019-12-08 18:30 ` Tom Tromey
  2019-12-08 18:30 ` [PATCH 41/55] Introduce c_value_print_int Tom Tromey
                   ` (46 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces generic_value_print_ptr, a value-based analogue of
generic_val_print_ptr, and changes generic_value_print to use it.

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

	* valprint.c (generic_value_print): Call generic_value_print_ptr.
	* valprint.c (generic_value_print_ptr): New function.

Change-Id: I733b2bb5a074dd98bdb4cc1d60ae9b166532d15d
---
 gdb/ChangeLog  |  5 +++++
 gdb/valprint.c | 26 ++++++++++++++++++++++----
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 562a2acdda1..980dd3b024e 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -488,6 +488,26 @@ generic_val_print_ptr (struct type *type,
     }
 }
 
+/* generic_value_print helper for TYPE_CODE_PTR.  */
+
+static void
+generic_value_print_ptr (struct value *val, struct ui_file *stream,
+			 const struct value_print_options *options)
+{
+
+  if (options->format && options->format != 's')
+    value_print_scalar_formatted (val, options, 0, stream);
+  else
+    {
+      struct type *type = check_typedef (value_type (val));
+      struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
+      const gdb_byte *valaddr = value_contents_for_printing (val);
+      CORE_ADDR addr = unpack_pointer (type, valaddr);
+
+      print_unpacked_pointer (type, elttype, addr, stream, options);
+    }
+}
+
 
 /* generic_val_print helper for TYPE_CODE_MEMBERPTR.  */
 
@@ -1026,13 +1046,11 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_MEMBERPTR:
-      generic_val_print_memberptr (type, 0, stream,
-				   val, options);
+      value_print_scalar_formatted (val, options, 0, stream);
       break;
 
     case TYPE_CODE_PTR:
-      generic_val_print_ptr (type, 0, stream,
-			     val, options);
+      generic_value_print_ptr (val, stream, options);
       break;
 
     case TYPE_CODE_REF:
-- 
2.17.2

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

* [PATCH 02/55] Refactor val_print and common_val_print
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (27 preceding siblings ...)
  2019-12-08 18:31 ` [PATCH 26/55] Convert Fortran printing to value-based API Tom Tromey
@ 2019-12-08 18:31 ` Tom Tromey
  2019-12-08 18:31 ` [PATCH 33/55] Simplify generic_val_print_func Tom Tromey
                   ` (26 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes val_print and common_val_print to use a new helper
function.  A theme in the coming patches is that calls to val_print
itself should be removed.  This is the first such patch; at the end of
the series, we'll remove val_print and simplify do_val_print.

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

	* valprint.c (do_val_print): New function, from val_print.
	(val_print): Use do_val_print.
	(common_val_print): Use do_val_print.

Change-Id: I09056cff7b7154995812029808704223f2e049bd
---
 gdb/ChangeLog  |  6 +++++
 gdb/valprint.c | 72 ++++++++++++++++++++++++++++++--------------------
 2 files changed, 50 insertions(+), 28 deletions(-)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 5bc860f13f1..62c78b95ad2 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1007,31 +1007,17 @@ generic_val_print (struct type *type,
     }
 }
 
-/* Print using the given LANGUAGE the data of type TYPE located at
-   VAL's contents buffer + EMBEDDED_OFFSET (within GDB), which came
-   from the inferior at address ADDRESS + EMBEDDED_OFFSET, onto
-   stdio stream STREAM according to OPTIONS.  VAL is the whole object
-   that came from ADDRESS.
-
-   The language printers will pass down an adjusted EMBEDDED_OFFSET to
-   further helper subroutines as subfields of TYPE are printed.  In
-   such cases, VAL is passed down unadjusted, so
-   that VAL can be queried for metadata about the contents data being
-   printed, using EMBEDDED_OFFSET as an offset into VAL's contents
-   buffer.  For example: "has this field been optimized out", or "I'm
-   printing an object while inspecting a traceframe; has this
-   particular piece of data been collected?".
+/* Helper function for val_print and common_val_print that does the
+   work.  Arguments are as to val_print, but FULL_VALUE, if given, is
+   the value to be printed.  */
 
-   RECURSE indicates the amount of indentation to supply before
-   continuation lines; this amount is roughly twice the value of
-   RECURSE.  */
-
-void
-val_print (struct type *type, LONGEST embedded_offset,
-	   CORE_ADDR address, struct ui_file *stream, int recurse,
-	   struct value *val,
-	   const struct value_print_options *options,
-	   const struct language_defn *language)
+static void
+do_val_print (struct value *full_value,
+	      struct type *type, LONGEST embedded_offset,
+	      CORE_ADDR address, struct ui_file *stream, int recurse,
+	      struct value *val,
+	      const struct value_print_options *options,
+	      const struct language_defn *language)
 {
   int ret = 0;
   struct value_print_options local_opts = *options;
@@ -1091,6 +1077,36 @@ val_print (struct type *type, LONGEST embedded_offset,
     }
 }
 
+/* Print using the given LANGUAGE the data of type TYPE located at
+   VAL's contents buffer + EMBEDDED_OFFSET (within GDB), which came
+   from the inferior at address ADDRESS + EMBEDDED_OFFSET, onto
+   stdio stream STREAM according to OPTIONS.  VAL is the whole object
+   that came from ADDRESS.
+
+   The language printers will pass down an adjusted EMBEDDED_OFFSET to
+   further helper subroutines as subfields of TYPE are printed.  In
+   such cases, VAL is passed down unadjusted, so
+   that VAL can be queried for metadata about the contents data being
+   printed, using EMBEDDED_OFFSET as an offset into VAL's contents
+   buffer.  For example: "has this field been optimized out", or "I'm
+   printing an object while inspecting a traceframe; has this
+   particular piece of data been collected?".
+
+   RECURSE indicates the amount of indentation to supply before
+   continuation lines; this amount is roughly twice the value of
+   RECURSE.  */
+
+void
+val_print (struct type *type, LONGEST embedded_offset,
+	   CORE_ADDR address, struct ui_file *stream, int recurse,
+	   struct value *val,
+	   const struct value_print_options *options,
+	   const struct language_defn *language)
+{
+  do_val_print (nullptr, type, embedded_offset, address, stream,
+		recurse, val, options, language);
+}
+
 /* See valprint.h.  */
 
 bool
@@ -1188,10 +1204,10 @@ common_val_print (struct value *val, struct ui_file *stream, int recurse,
   if (value_lazy (val))
     value_fetch_lazy (val);
 
-  val_print (value_type (val),
-	     value_embedded_offset (val), value_address (val),
-	     stream, recurse,
-	     val, options, language);
+  do_val_print (val, value_type (val),
+		value_embedded_offset (val), value_address (val),
+		stream, recurse,
+		val, options, language);
 }
 
 /* Print on stream STREAM the value VAL according to OPTIONS.  The value
-- 
2.17.2

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

* [PATCH 26/55] Convert Fortran printing to value-based API
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (26 preceding siblings ...)
  2019-12-08 18:31 ` [PATCH 42/55] Introduce c_value_print_memberptr Tom Tromey
@ 2019-12-08 18:31 ` Tom Tromey
  2019-12-08 18:31 ` [PATCH 02/55] Refactor val_print and common_val_print Tom Tromey
                   ` (27 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This finishes the conversion of the Fortran printing code to the
value-based API.  The body of f_val_print is copied into
f_value_print_innner, and then modified as needed to use the value
API.

Note that not all calls must be updated.  For example, f77_print_array
remains "val-like", because it does not result in any calls to
val_print (f77_print_array_1 calls common_val_print, which is
nominally value-based).

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

	* f-valprint.c (f_value_print_innner): Rewrite.

Change-Id: I5b805076f203e25688d0954adedc00531175b0c5
---
 gdb/ChangeLog    |   4 ++
 gdb/f-valprint.c | 146 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 148 insertions(+), 2 deletions(-)

diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 9eccabbcd52..cd1977b05cf 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -376,8 +376,150 @@ void
 f_value_print_innner (struct value *val, struct ui_file *stream, int recurse,
 		      const struct value_print_options *options)
 {
-  f_val_print (value_type (val), value_embedded_offset (val),
-	       value_address (val), stream, recurse, val, options);
+  struct type *type = check_typedef (value_type (val));
+  struct gdbarch *gdbarch = get_type_arch (type);
+  int printed_field = 0; /* Number of fields printed.  */
+  struct type *elttype;
+  CORE_ADDR addr;
+  int index;
+  const gdb_byte *valaddr = value_contents_for_printing (val);
+  const CORE_ADDR address = value_address (val);
+
+  switch (TYPE_CODE (type))
+    {
+    case TYPE_CODE_STRING:
+      f77_get_dynamic_length_of_aggregate (type);
+      LA_PRINT_STRING (stream, builtin_type (gdbarch)->builtin_char,
+		       valaddr, TYPE_LENGTH (type), NULL, 0, options);
+      break;
+
+    case TYPE_CODE_ARRAY:
+      if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_CHAR)
+	{
+	  fprintf_filtered (stream, "(");
+	  f77_print_array (type, valaddr, 0,
+			   address, stream, recurse, val, options);
+	  fprintf_filtered (stream, ")");
+	}
+      else
+	{
+	  struct type *ch_type = TYPE_TARGET_TYPE (type);
+
+	  f77_get_dynamic_length_of_aggregate (type);
+	  LA_PRINT_STRING (stream, ch_type, valaddr,
+			   TYPE_LENGTH (type) / TYPE_LENGTH (ch_type),
+			   NULL, 0, options);
+	}
+      break;
+
+    case TYPE_CODE_PTR:
+      if (options->format && options->format != 's')
+	{
+	  value_print_scalar_formatted (val, options, 0, stream);
+	  break;
+	}
+      else
+	{
+	  int want_space = 0;
+
+	  addr = unpack_pointer (type, valaddr);
+	  elttype = check_typedef (TYPE_TARGET_TYPE (type));
+
+	  if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
+	    {
+	      /* Try to print what function it points to.  */
+	      print_function_pointer_address (options, gdbarch, addr, stream);
+	      return;
+	    }
+
+	  if (options->symbol_print)
+	    want_space = print_address_demangle (options, gdbarch, addr,
+						 stream, demangle);
+	  else if (options->addressprint && options->format != 's')
+	    {
+	      fputs_filtered (paddress (gdbarch, addr), stream);
+	      want_space = 1;
+	    }
+
+	  /* For a pointer to char or unsigned char, also print the string
+	     pointed to, unless pointer is null.  */
+	  if (TYPE_LENGTH (elttype) == 1
+	      && TYPE_CODE (elttype) == TYPE_CODE_INT
+	      && (options->format == 0 || options->format == 's')
+	      && addr != 0)
+	    {
+	      if (want_space)
+		fputs_filtered (" ", stream);
+	      val_print_string (TYPE_TARGET_TYPE (type), NULL, addr, -1,
+				stream, options);
+	    }
+	  return;
+	}
+      break;
+
+    case TYPE_CODE_INT:
+      if (options->format || options->output_format)
+	{
+	  struct value_print_options opts = *options;
+
+	  opts.format = (options->format ? options->format
+			 : options->output_format);
+	  value_print_scalar_formatted (val, &opts, 0, stream);
+	}
+      else
+	value_print_scalar_formatted (val, options, 0, stream);
+      break;
+
+    case TYPE_CODE_STRUCT:
+    case TYPE_CODE_UNION:
+      /* Starting from the Fortran 90 standard, Fortran supports derived
+         types.  */
+      fprintf_filtered (stream, "( ");
+      for (index = 0; index < TYPE_NFIELDS (type); index++)
+        {
+	  struct value *field = value_field (val, index);
+
+	  struct type *field_type = check_typedef (TYPE_FIELD_TYPE (type, index));
+
+
+	  if (TYPE_CODE (field_type) != TYPE_CODE_FUNC)
+	    {
+	      const char *field_name;
+
+	      if (printed_field > 0)
+		fputs_filtered (", ", stream);
+
+	      field_name = TYPE_FIELD_NAME (type, index);
+	      if (field_name != NULL)
+		{
+		  fputs_filtered (field_name, stream);
+		  fputs_filtered (" = ", stream);
+		}
+
+	      common_val_print (field, stream, recurse + 1,
+				options, current_language);
+
+	      ++printed_field;
+	    }
+	 }
+      fprintf_filtered (stream, " )");
+      break;     
+
+    case TYPE_CODE_REF:
+    case TYPE_CODE_FUNC:
+    case TYPE_CODE_FLAGS:
+    case TYPE_CODE_FLT:
+    case TYPE_CODE_VOID:
+    case TYPE_CODE_ERROR:
+    case TYPE_CODE_RANGE:
+    case TYPE_CODE_UNDEF:
+    case TYPE_CODE_COMPLEX:
+    case TYPE_CODE_BOOL:
+    case TYPE_CODE_CHAR:
+    default:
+      generic_value_print (val, stream, recurse, options, &f_decorations);
+      break;
+    }
 }
 
 static void
-- 
2.17.2

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

* [PATCH 18/55] Introduce m2_value_print_inner
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (23 preceding siblings ...)
  2019-12-08 18:31 ` [PATCH 14/55] Introduce value_print_array_elements Tom Tromey
@ 2019-12-08 18:31 ` Tom Tromey
  2019-12-08 18:31 ` [PATCH 05/55] Use common_val_print in mi-main.c Tom Tromey
                   ` (30 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces m2_value_print_inner.

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

	* m2-valprint.c (m2_value_print_inner): New function.
	* m2-lang.h (m2_value_print_inner): Declare.
	* m2-lang.c (m2_language_defn): Use m2_value_print_inner.

Change-Id: I17b9a7146d8cc342ab2b095ee7b2b1e8a5c08726
---
 gdb/ChangeLog     |  6 ++++++
 gdb/m2-lang.c     |  2 +-
 gdb/m2-lang.h     |  5 +++++
 gdb/m2-valprint.c | 10 ++++++++++
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 924ee0a549c..476abcb987e 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -394,7 +394,7 @@ extern const struct language_defn m2_language_defn =
   m2_print_type,		/* Print a type using appropriate syntax */
   m2_print_typedef,		/* Print a typedef using appropriate syntax */
   m2_val_print,			/* Print a value using appropriate syntax */
-  nullptr,			/* la_value_print_inner */
+  m2_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h
index 96058bb4f48..49414ffcc86 100644
--- a/gdb/m2-lang.h
+++ b/gdb/m2-lang.h
@@ -40,6 +40,11 @@ extern void m2_val_print (struct type *, int, CORE_ADDR,
 			  struct value *,
 			  const struct value_print_options *);
 
+/* Implement la_value_print_inner for Modula-2.  */
+
+extern void m2_value_print_inner (struct value *, struct ui_file *, int,
+				  const struct value_print_options *);
+
 extern int get_long_set_bounds (struct type *type, LONGEST *low,
 				LONGEST *high);
 
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index 4dc0fe18e6a..9ad5ca3e0b2 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -503,3 +503,13 @@ m2_val_print (struct type *type, int embedded_offset,
       break;
     }
 }
+
+/* See m2-lang.h.  */
+
+void
+m2_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
+		      const struct value_print_options *options)
+{
+  m2_val_print (value_type (val), value_embedded_offset (val),
+		value_address (val), stream, recurse, val, options);
+}
-- 
2.17.2

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

* [PATCH 42/55] Introduce c_value_print_memberptr
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (25 preceding siblings ...)
  2019-12-08 18:31 ` [PATCH 05/55] Use common_val_print in mi-main.c Tom Tromey
@ 2019-12-08 18:31 ` Tom Tromey
  2019-12-08 18:31 ` [PATCH 26/55] Convert Fortran printing to value-based API Tom Tromey
                   ` (28 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds c_value_print_memberptr, a value-based analogue of
c_val_print_memberptr.

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

	* c-valprint.c (c_value_print_memberptr): New function.
	(c_value_print_inner): Use it.

Change-Id: I44e28c6c7d352eb91f8c94a232d65c9dda87f461
---
 gdb/ChangeLog    |  5 +++++
 gdb/c-valprint.c | 20 ++++++++++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 9b75d4d0404..694f87fea95 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -553,6 +553,23 @@ c_val_print_memberptr (struct type *type, const gdb_byte *valaddr,
     }
 }
 
+/* c_value_print helper for TYPE_CODE_MEMBERPTR.  */
+
+static void
+c_value_print_memberptr (struct value *val, struct ui_file *stream,
+			 int recurse,
+			 const struct value_print_options *options)
+{
+  if (!options->format)
+    {
+      struct type *type = check_typedef (value_type (val));
+      const gdb_byte *valaddr = value_contents_for_printing (val);
+      cp_print_class_member (valaddr, type, stream, "&");
+    }
+  else
+    generic_value_print (val, stream, recurse, options, &c_decorations);
+}
+
 /* See val_print for a description of the various parameters of this
    function; they are identical.  */
 
@@ -667,8 +684,7 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_MEMBERPTR:
-      c_val_print_memberptr (type, valaddr, 0, address, stream,
-			     recurse, val, options);
+      c_value_print_memberptr (val, stream, recurse, options);
       break;
 
     case TYPE_CODE_REF:
-- 
2.17.2

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

* [PATCH 46/55] Rewrite ada_value_print_inner
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (18 preceding siblings ...)
  2019-12-08 18:31 ` [PATCH 29/55] Initial rewrite of generic_value_print Tom Tromey
@ 2019-12-08 18:31 ` Tom Tromey
  2019-12-08 18:31 ` [PATCH 03/55] Introduce common_val_print_checked Tom Tromey
                   ` (35 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This rewrites ada_value_print_inner, introducing a new
ada_value_print_1, an analogue of ada_val_print_1.  Because it was
simple to do, this also converts ada_val_print_gnat_array to be
valued-based and updates the uses.

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

	* ada-valprint.c (ada_val_print_gnat_array): Take a struct value;
	call common_val_print.
	(ada_val_print_1): Update.
	(ada_value_print_1): New function.
	(ada_value_print_inner): Rewrite.

Change-Id: If2525ec5bb1ac46b828d41105eca2a616d94819b
---
 gdb/ChangeLog      |   8 +++
 gdb/ada-valprint.c | 120 +++++++++++++++++++++++++++++++++++++++------
 2 files changed, 112 insertions(+), 16 deletions(-)

diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 609e5af7481..83033d9ee8c 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -761,16 +761,14 @@ ada_val_print_string (struct type *type, const gdb_byte *valaddr,
    thin pointers, etc).  */
 
 static void
-ada_val_print_gnat_array (struct type *type, const gdb_byte *valaddr,
-			  int offset, CORE_ADDR address,
+ada_val_print_gnat_array (struct value *val,
 			  struct ui_file *stream, int recurse,
-			  struct value *original_value,
 			  const struct value_print_options *options)
 {
-  struct value *mark = value_mark ();
-  struct value *val;
+  scoped_value_mark free_values;
+
+  struct type *type = ada_check_typedef (value_type (val));
 
-  val = value_from_contents_and_address (type, valaddr + offset, address);
   /* If this is a reference, coerce it now.  This helps taking care
      of the case where ADDRESS is meaningless because original_value
      was not an lval.  */
@@ -785,11 +783,8 @@ ada_val_print_gnat_array (struct type *type, const gdb_byte *valaddr,
       fprintf_filtered (stream, "0x0");
     }
   else
-    val_print (value_type (val),
-	       value_embedded_offset (val), value_address (val),
-	       stream, recurse, val, options,
-	       language_def (language_ada));
-  value_free_to_mark (mark);
+    common_val_print (val, stream, recurse, options,
+		      language_def (language_ada));
 }
 
 /* Implement Ada val_print'ing for the case where TYPE is
@@ -1132,9 +1127,10 @@ ada_val_print_1 (struct type *type,
       || (ada_is_constrained_packed_array_type (type)
 	  && TYPE_CODE (type) != TYPE_CODE_PTR))
     {
-      ada_val_print_gnat_array (type, valaddr, offset, address,
-				stream, recurse, original_value,
-				options);
+      struct value *val = value_from_contents_and_address (type,
+							   valaddr + offset,
+							   address);
+      ada_val_print_gnat_array (val, stream, recurse, options);
       return;
     }
 
@@ -1219,6 +1215,90 @@ ada_val_print (struct type *type,
     }
 }
 
+/* See the comment on ada_value_print.  This function differs in that
+   it does not catch evaluation errors (leaving that to
+   ada_value_print).  */
+
+static void
+ada_value_print_1 (struct value *val, struct ui_file *stream, int recurse,
+		   const struct value_print_options *options)
+{
+  struct type *type = ada_check_typedef (value_type (val));
+
+  if (ada_is_array_descriptor_type (type)
+      || (ada_is_constrained_packed_array_type (type)
+	  && TYPE_CODE (type) != TYPE_CODE_PTR))
+    {
+      ada_val_print_gnat_array (val, stream, recurse, options);
+      return;
+    }
+
+  val = ada_to_fixed_value (val);
+  type = value_type (val);
+  struct type *saved_type = type;
+
+  const gdb_byte *valaddr = value_contents_for_printing (val);
+  CORE_ADDR address = value_address (val);
+  type = ada_check_typedef (resolve_dynamic_type (type, valaddr, address));
+  if (type != saved_type)
+    {
+      val = value_copy (val);
+      deprecated_set_value_type (val, saved_type);
+    }
+
+  switch (TYPE_CODE (type))
+    {
+    default:
+      common_val_print (val, stream, recurse, options,
+			language_def (language_c));
+      break;
+
+    case TYPE_CODE_PTR:
+      ada_val_print_ptr (type, valaddr, 0, 0,
+			 address, stream, recurse, val,
+			 options);
+      break;
+
+    case TYPE_CODE_INT:
+    case TYPE_CODE_RANGE:
+      ada_val_print_num (type, valaddr, 0, 0,
+			 address, stream, recurse, val,
+			 options);
+      break;
+
+    case TYPE_CODE_ENUM:
+      ada_val_print_enum (type, valaddr, 0, 0,
+			  address, stream, recurse, val,
+			  options);
+      break;
+
+    case TYPE_CODE_FLT:
+      ada_val_print_flt (type, valaddr, 0, 0,
+			 address, stream, recurse, val,
+			 options);
+      break;
+
+    case TYPE_CODE_UNION:
+    case TYPE_CODE_STRUCT:
+      ada_val_print_struct_union (type, valaddr, 0, 0,
+				  address, stream, recurse,
+				  val, options);
+      break;
+
+    case TYPE_CODE_ARRAY:
+      ada_val_print_array (type, valaddr, 0, 0,
+			   address, stream, recurse, val,
+			   options);
+      return;
+
+    case TYPE_CODE_REF:
+      ada_val_print_ref (type, valaddr, 0, 0,
+			 address, stream, recurse, val,
+			 options);
+      break;
+    }
+}
+
 /* See ada-lang.h.  */
 
 void
@@ -1226,8 +1306,16 @@ ada_value_print_inner (struct value *val, struct ui_file *stream,
 		       int recurse,
 		       const struct value_print_options *options)
 {
-  ada_val_print (value_type (val), value_embedded_offset (val),
-		 value_address (val), stream, recurse, val, options);
+  try
+    {
+      ada_value_print_1 (val, stream, recurse, options);
+    }
+  catch (const gdb_exception_error &except)
+    {
+      fprintf_styled (stream, metadata_style.style (),
+		      _("<error reading variable: %s>"),
+		      except.what ());
+    }
 }
 
 void
-- 
2.17.2

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

* [PATCH 38/55] Introduce generic_value_print_complex
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (21 preceding siblings ...)
  2019-12-08 18:31 ` [PATCH 34/55] Introduce generic_value_print_bool Tom Tromey
@ 2019-12-08 18:31 ` Tom Tromey
  2019-12-08 18:31 ` [PATCH 14/55] Introduce value_print_array_elements Tom Tromey
                   ` (32 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds generic_value_print_complex, a value-based analogue of
generic_val_print_complex.

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

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

Change-Id: Ie3a455dc94226eaf7943bed8fd2520be87c067bd
---
 gdb/ChangeLog  |  5 +++++
 gdb/valprint.c | 27 +++++++++++++++++++++++++--
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 630b6567cd0..251eae2d844 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -940,6 +940,30 @@ generic_val_print_complex (struct type *type,
   fprintf_filtered (stream, "%s", decorations->complex_suffix);
 }
 
+/* generic_value_print helper for TYPE_CODE_COMPLEX.  */
+
+static void
+generic_value_print_complex (struct value *val, struct ui_file *stream,
+			     const struct value_print_options *options,
+			     const struct generic_val_print_decorations
+			       *decorations)
+{
+  fprintf_filtered (stream, "%s", decorations->complex_prefix);
+
+  struct type *type = check_typedef (value_type (val));
+  struct value *real_part
+    = value_from_component (val, TYPE_TARGET_TYPE (type), 0);
+  value_print_scalar_formatted (real_part, options, 0, stream);
+  fprintf_filtered (stream, "%s", decorations->complex_infix);
+
+  struct value *imag_part
+    = value_from_component (val, TYPE_TARGET_TYPE (type),
+			    TYPE_LENGTH (TYPE_TARGET_TYPE (type)));
+
+  value_print_scalar_formatted (imag_part, options, 0, stream);
+  fprintf_filtered (stream, "%s", decorations->complex_suffix);
+}
+
 /* A generic val_print that is suitable for use by language
    implementations of the la_val_print method.  This function can
    handle most type codes, though not all, notably exception
@@ -1180,8 +1204,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_COMPLEX:
-      generic_val_print_complex (type, 0, stream,
-				 val, options, decorations);
+      generic_value_print_complex (val, stream, options, decorations);
       break;
 
     case TYPE_CODE_UNION:
-- 
2.17.2

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

* [PATCH 29/55] Initial rewrite of generic_value_print
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (17 preceding siblings ...)
  2019-12-08 18:30 ` [PATCH 25/55] Convert Modula-2 printing to value-based API Tom Tromey
@ 2019-12-08 18:31 ` Tom Tromey
  2019-12-08 18:31 ` [PATCH 46/55] Rewrite ada_value_print_inner Tom Tromey
                   ` (36 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This rewrites generic_value_print, by copying in the body of
generic_val_print and making the needed adjustments.

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

	* valprint.c (generic_value_print): Rewrite.

Change-Id: I4bef96d94afee1ff4673f995d0306e059863a03d
---
 gdb/ChangeLog  |   4 ++
 gdb/valprint.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 106 insertions(+), 3 deletions(-)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index b2506dc6fc4..562a2acdda1 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1014,9 +1014,108 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
 		     const struct value_print_options *options,
 		     const struct generic_val_print_decorations *decorations)
 {
-  generic_val_print (value_type (val), value_embedded_offset (val),
-		     value_address (val), stream, recurse, val, options,
-		     decorations);
+  struct type *type = value_type (val);
+  struct type *unresolved_type = type;
+
+  type = check_typedef (type);
+  switch (TYPE_CODE (type))
+    {
+    case TYPE_CODE_ARRAY:
+      generic_val_print_array (type, 0, value_address (val), stream,
+			       recurse, val, options, decorations);
+      break;
+
+    case TYPE_CODE_MEMBERPTR:
+      generic_val_print_memberptr (type, 0, stream,
+				   val, options);
+      break;
+
+    case TYPE_CODE_PTR:
+      generic_val_print_ptr (type, 0, stream,
+			     val, options);
+      break;
+
+    case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
+      generic_val_print_ref (type, 0, stream, recurse,
+			     val, options);
+      break;
+
+    case TYPE_CODE_ENUM:
+      generic_val_print_enum (type, 0, stream,
+			      val, options);
+      break;
+
+    case TYPE_CODE_FLAGS:
+      generic_val_print_flags (type, 0, stream,
+			       val, options);
+      break;
+
+    case TYPE_CODE_FUNC:
+    case TYPE_CODE_METHOD:
+      generic_val_print_func (type, 0, value_address (val), stream,
+			      val, options);
+      break;
+
+    case TYPE_CODE_BOOL:
+      generic_val_print_bool (type, 0, stream,
+			      val, options, decorations);
+      break;
+
+    case TYPE_CODE_RANGE:
+      /* FIXME: create_static_range_type does not set the unsigned bit in a
+         range type (I think it probably should copy it from the
+         target type), so we won't print values which are too large to
+         fit in a signed integer correctly.  */
+      /* FIXME: Doesn't handle ranges of enums correctly.  (Can't just
+         print with the target type, though, because the size of our
+         type and the target type might differ).  */
+
+      /* FALLTHROUGH */
+
+    case TYPE_CODE_INT:
+      generic_val_print_int (type, 0, stream,
+			     val, options);
+      break;
+
+    case TYPE_CODE_CHAR:
+      generic_val_print_char (type, unresolved_type, 0,
+			      stream, val, options);
+      break;
+
+    case TYPE_CODE_FLT:
+    case TYPE_CODE_DECFLOAT:
+      generic_val_print_float (type, 0, stream,
+			       val, options);
+      break;
+
+    case TYPE_CODE_VOID:
+      fputs_filtered (decorations->void_name, stream);
+      break;
+
+    case TYPE_CODE_ERROR:
+      fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type));
+      break;
+
+    case TYPE_CODE_UNDEF:
+      /* This happens (without TYPE_STUB set) on systems which don't use
+         dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar"
+         and no complete type for struct foo in that file.  */
+      fprintf_styled (stream, metadata_style.style (), _("<incomplete type>"));
+      break;
+
+    case TYPE_CODE_COMPLEX:
+      generic_val_print_complex (type, 0, stream,
+				 val, options, decorations);
+      break;
+
+    case TYPE_CODE_UNION:
+    case TYPE_CODE_STRUCT:
+    case TYPE_CODE_METHODPTR:
+    default:
+      error (_("Unhandled type code %d in symbol table."),
+	     TYPE_CODE (type));
+    }
 }
 
 /* Helper function for val_print and common_val_print that does the
-- 
2.17.2

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

* [PATCH 33/55] Simplify generic_val_print_func
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (28 preceding siblings ...)
  2019-12-08 18:31 ` [PATCH 02/55] Refactor val_print and common_val_print Tom Tromey
@ 2019-12-08 18:31 ` Tom Tromey
  2019-12-08 18:32 ` [PATCH 28/55] Convert Pascal to value-based API Tom Tromey
                   ` (25 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes the call to val_print_scalar_formatted from
generic_val_print_func, allowing generic_value_print to call the
value-based variant instead.

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

	* valprint.c (generic_val_print_func): Simplify.
	(generic_val_print, generic_value_print): Update.

Change-Id: Id93d45b00c4be05e52e1ade15a7e33df206ac7f0
---
 gdb/ChangeLog  |  5 +++++
 gdb/valprint.c | 41 +++++++++++++++++++++--------------------
 2 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index c6de058fa23..5c25f98faf8 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -716,22 +716,16 @@ generic_val_print_func (struct type *type,
 {
   struct gdbarch *gdbarch = get_type_arch (type);
 
-  if (options->format)
-    {
-      val_print_scalar_formatted (type, embedded_offset,
-				  original_value, options, 0, stream);
-    }
-  else
-    {
-      /* FIXME, we should consider, at least for ANSI C language,
-         eliminating the distinction made between FUNCs and POINTERs
-         to FUNCs.  */
-      fprintf_filtered (stream, "{");
-      type_print (type, "", stream, -1);
-      fprintf_filtered (stream, "} ");
-      /* Try to print what function it points to, and its address.  */
-      print_address_demangle (options, gdbarch, address, stream, demangle);
-    }
+  gdb_assert (!options->format);
+
+  /* FIXME, we should consider, at least for ANSI C language,
+     eliminating the distinction made between FUNCs and POINTERs to
+     FUNCs.  */
+  fprintf_filtered (stream, "{");
+  type_print (type, "", stream, -1);
+  fprintf_filtered (stream, "} ");
+  /* Try to print what function it points to, and its address.  */
+  print_address_demangle (options, gdbarch, address, stream, demangle);
 }
 
 /* generic_val_print helper for TYPE_CODE_BOOL.  */
@@ -945,8 +939,12 @@ generic_val_print (struct type *type,
 
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
-      generic_val_print_func (type, embedded_offset, address, stream,
-			      original_value, options);
+      if (options->format)
+	val_print_scalar_formatted (type, embedded_offset,
+				    original_value, options, 0, stream);
+      else
+	generic_val_print_func (type, embedded_offset, address, stream,
+				original_value, options);
       break;
 
     case TYPE_CODE_BOOL:
@@ -1058,8 +1056,11 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
 
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
-      generic_val_print_func (type, 0, value_address (val), stream,
-			      val, options);
+      if (options->format)
+	value_print_scalar_formatted (val, options, 0, stream);
+      else
+	generic_val_print_func (type, 0, value_address (val), stream,
+				val, options);
       break;
 
     case TYPE_CODE_BOOL:
-- 
2.17.2

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

* [PATCH 05/55] Use common_val_print in mi-main.c
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (24 preceding siblings ...)
  2019-12-08 18:31 ` [PATCH 18/55] Introduce m2_value_print_inner Tom Tromey
@ 2019-12-08 18:31 ` Tom Tromey
  2019-12-08 18:31 ` [PATCH 42/55] Introduce c_value_print_memberptr Tom Tromey
                   ` (29 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes a spot in mi-main.c to use common_val_print rather than
val_print.

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

	* mi/mi-main.c (output_register): Use common_val_print.

Change-Id: Ibb791b97c47337609470cbe7baf4684f3b3decab
---
 gdb/ChangeLog    | 4 ++++
 gdb/mi/mi-main.c | 4 +---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index c14897a5f71..6afe191ad0c 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1136,9 +1136,7 @@ output_register (struct frame_info *frame, int regnum, int format,
 
   get_formatted_print_options (&opts, format);
   opts.deref_ref = 1;
-  val_print (value_type (val),
-	     value_embedded_offset (val), 0,
-	     &stb, 0, val, &opts, current_language);
+  common_val_print (val, &stb, 0, &opts, current_language);
   uiout->field_stream ("value", stb);
 }
 
-- 
2.17.2

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

* [PATCH 03/55] Introduce common_val_print_checked
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (19 preceding siblings ...)
  2019-12-08 18:31 ` [PATCH 46/55] Rewrite ada_value_print_inner Tom Tromey
@ 2019-12-08 18:31 ` Tom Tromey
  2019-12-09  4:06   ` Christian Biesinger via gdb-patches
  2019-12-08 18:31 ` [PATCH 34/55] Introduce generic_value_print_bool Tom Tromey
                   ` (34 subsequent siblings)
  55 siblings, 1 reply; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A (much) later patch will remove the call to value_check_printable
from common_val_print.  This will needed to preserve some details of
how optimized-out structures are printed.

However, doing this will also break dw2-op-out-param.exp.  Making the
change causes "bt" to print:

However, the test wants to see:

... operand2=<optimized out>

That is, a wholly-optimized out structure should not print its fields.

So, this patch introduces a new common_val_print_checked, which calls
value_check_printable first, and then arranges to use it in the one
spot that affects the test suite.

I was not completely sure if it would be preferable to change the
test.  However, I reasoned that, assuming this output was intentional
in the first place, in a backtrace space is at a premium and so this
is a reasonable approach.  In other spots calling common_val_print,
this behavior is probably unintended, or at least a "don't care".

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

	* valprint.h (common_val_print_checked): Declare.
	* valprint.c (common_val_print_checked): New function.
	* stack.c (print_frame_arg): Use common_val_print_checked.

Change-Id: I6802b6bf9b4aa30b399bb133e5c848b24ad16d7a
---
 gdb/ChangeLog  |  6 ++++++
 gdb/stack.c    |  2 +-
 gdb/valprint.c | 13 +++++++++++++
 gdb/valprint.h |  8 ++++++++
 4 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/gdb/stack.c b/gdb/stack.c
index cc7b7e5bbe0..26229983f8b 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -486,7 +486,7 @@ print_frame_arg (const frame_print_options &fp_opts,
 	      vp_opts.summary
 		= fp_opts.print_frame_arguments == print_frame_arguments_scalars;
 
-	      common_val_print (arg->val, &stb, 2, &vp_opts, language);
+	      common_val_print_checked (arg->val, &stb, 2, &vp_opts, language);
 	    }
 	  catch (const gdb_exception_error &except)
 	    {
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 62c78b95ad2..20763338aff 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1210,6 +1210,19 @@ common_val_print (struct value *val, struct ui_file *stream, int recurse,
 		val, options, language);
 }
 
+/* See valprint.h.  */
+
+void
+common_val_print_checked (struct value *val, struct ui_file *stream,
+			  int recurse,
+			  const struct value_print_options *options,
+			  const struct language_defn *language)
+{
+  if (!value_check_printable (val, stream, options))
+    return;
+  common_val_print (val, stream, recurse, options, language);
+}
+
 /* Print on stream STREAM the value VAL according to OPTIONS.  The value
    is printed using the current_language syntax.  */
 
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 24b731ab357..c63ac8de19b 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -282,4 +282,12 @@ extern bool val_print_check_max_depth (struct ui_file *stream, int recurse,
 				       const struct value_print_options *opts,
 				       const struct language_defn *language);
 
+/* Like common_val_print, but call value_check_printable first.  */
+
+extern void common_val_print_checked
+  (struct value *val,
+   struct ui_file *stream, int recurse,
+   const struct value_print_options *options,
+   const struct language_defn *language);
+
 #endif
-- 
2.17.2

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

* [PATCH 14/55] Introduce value_print_array_elements
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (22 preceding siblings ...)
  2019-12-08 18:31 ` [PATCH 38/55] Introduce generic_value_print_complex Tom Tromey
@ 2019-12-08 18:31 ` Tom Tromey
  2020-01-15  5:47   ` Simon Marchi
  2019-12-08 18:31 ` [PATCH 18/55] Introduce m2_value_print_inner Tom Tromey
                   ` (31 subsequent siblings)
  55 siblings, 1 reply; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces value_print_array_elements, which is an analogue of
val_print_array_elements that uses the value API.

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

	* valprint.c (value_print_array_elements): New function.
	* valprint.h (value_print_array_elements): Declare.

Change-Id: I82d7666ce30b8cae3689fbf392177b08ef861a3b
---
 gdb/ChangeLog  |   5 ++
 gdb/valprint.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/valprint.h |   6 +++
 3 files changed, 137 insertions(+)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index d09a42926e2..b2506dc6fc4 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -2184,6 +2184,132 @@ val_print_array_elements (struct type *type,
     }
 }
 
+/* See valprint.h.  */
+
+void
+value_print_array_elements (struct value *val, struct ui_file *stream,
+			    int recurse,
+			    const struct value_print_options *options,
+			    unsigned int i)
+{
+  unsigned int things_printed = 0;
+  unsigned len;
+  struct type *elttype, *index_type, *base_index_type;
+  unsigned eltlen;
+  /* Position of the array element we are examining to see
+     whether it is repeated.  */
+  unsigned int rep1;
+  /* Number of repetitions we have detected so far.  */
+  unsigned int reps;
+  LONGEST low_bound, high_bound;
+  LONGEST low_pos, high_pos;
+
+  struct type *type = check_typedef (value_type (val));
+
+  elttype = TYPE_TARGET_TYPE (type);
+  eltlen = type_length_units (check_typedef (elttype));
+  index_type = TYPE_INDEX_TYPE (type);
+
+  if (get_array_bounds (type, &low_bound, &high_bound))
+    {
+      if (TYPE_CODE (index_type) == TYPE_CODE_RANGE)
+	base_index_type = TYPE_TARGET_TYPE (index_type);
+      else
+	base_index_type = index_type;
+
+      /* Non-contiguous enumerations types can by used as index types
+	 in some languages (e.g. Ada).  In this case, the array length
+	 shall be computed from the positions of the first and last
+	 literal in the enumeration type, and not from the values
+	 of these literals.  */
+      if (!discrete_position (base_index_type, low_bound, &low_pos)
+	  || !discrete_position (base_index_type, high_bound, &high_pos))
+	{
+	  warning (_("unable to get positions in array, use bounds instead"));
+	  low_pos = low_bound;
+	  high_pos = high_bound;
+	}
+
+      /* The array length should normally be HIGH_POS - LOW_POS + 1.
+         But we have to be a little extra careful, because some languages
+	 such as Ada allow LOW_POS to be greater than HIGH_POS for
+	 empty arrays.  In that situation, the array length is just zero,
+	 not negative!  */
+      if (low_pos > high_pos)
+	len = 0;
+      else
+	len = high_pos - low_pos + 1;
+    }
+  else
+    {
+      warning (_("unable to get bounds of array, assuming null array"));
+      low_bound = 0;
+      len = 0;
+    }
+
+  annotate_array_section_begin (i, elttype);
+
+  for (; i < len && things_printed < options->print_max; i++)
+    {
+      scoped_value_mark free_values;
+
+      if (i != 0)
+	{
+	  if (options->prettyformat_arrays)
+	    {
+	      fprintf_filtered (stream, ",\n");
+	      print_spaces_filtered (2 + 2 * recurse, stream);
+	    }
+	  else
+	    {
+	      fprintf_filtered (stream, ", ");
+	    }
+	}
+      wrap_here (n_spaces (2 + 2 * recurse));
+      maybe_print_array_index (index_type, i + low_bound,
+                               stream, options);
+
+      rep1 = i + 1;
+      reps = 1;
+      /* Only check for reps if repeat_count_threshold is not set to
+	 UINT_MAX (unlimited).  */
+      if (options->repeat_count_threshold < UINT_MAX)
+	{
+	  while (rep1 < len
+		 && value_contents_eq (val, i * eltlen,
+				       val, rep1 * eltlen,
+				       eltlen))
+	    {
+	      ++reps;
+	      ++rep1;
+	    }
+	}
+
+      struct value *element = value_from_component (val, elttype, eltlen * i);
+      common_val_print (element, stream, recurse + 1, options,
+			current_language);
+
+      if (reps > options->repeat_count_threshold)
+	{
+	  annotate_elt_rep (reps);
+	  fprintf_filtered (stream, " %p[<repeats %u times>%p]",
+			    metadata_style.style ().ptr (), reps, nullptr);
+	  annotate_elt_rep_end ();
+
+	  i = rep1 - 1;
+	  things_printed += options->repeat_count_threshold;
+	}
+      else
+	{
+	  annotate_elt ();
+	  things_printed++;
+	}
+    }
+  annotate_array_section_end ();
+  if (i < len)
+    fprintf_filtered (stream, "...");
+}
+
 /* Read LEN bytes of target memory at address MEMADDR, placing the
    results in GDB's memory at MYADDR.  Returns a count of the bytes
    actually read, and optionally a target_xfer_status value in the
diff --git a/gdb/valprint.h b/gdb/valprint.h
index f1c93aa26b6..68b1083c742 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -134,6 +134,12 @@ extern void val_print_array_elements (struct type *, LONGEST,
 				      const struct value_print_options *,
 				      unsigned int);
 
+/* Print elements of an array.  */
+
+extern void value_print_array_elements (struct value *, struct ui_file *, int,
+					const struct value_print_options *,
+					unsigned int);
+
 extern void val_print_scalar_formatted (struct type *,
 					LONGEST,
 					struct value *,
-- 
2.17.2

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

* [PATCH 34/55] Introduce generic_value_print_bool
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (20 preceding siblings ...)
  2019-12-08 18:31 ` [PATCH 03/55] Introduce common_val_print_checked Tom Tromey
@ 2019-12-08 18:31 ` Tom Tromey
  2019-12-08 18:31 ` [PATCH 38/55] Introduce generic_value_print_complex Tom Tromey
                   ` (33 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds generic_value_print_bool, a value-based analogue of
generic_val_print_bool.

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

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

Change-Id: I4f802a26430d4f430c32b605273d927e460bb20a
---
 gdb/ChangeLog  |  5 +++++
 gdb/valprint.c | 32 ++++++++++++++++++++++++++++++--
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 5c25f98faf8..5b1b9cff804 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -763,6 +763,35 @@ generic_val_print_bool (struct type *type,
     }
 }
 
+/* generic_value_print helper for TYPE_CODE_BOOL.  */
+
+static void
+generic_value_print_bool
+  (struct value *value, struct ui_file *stream,
+   const struct value_print_options *options,
+   const struct generic_val_print_decorations *decorations)
+{
+  if (options->format || options->output_format)
+    {
+      struct value_print_options opts = *options;
+      opts.format = (options->format ? options->format
+		     : options->output_format);
+      value_print_scalar_formatted (value, &opts, 0, stream);
+    }
+  else
+    {
+      const gdb_byte *valaddr = value_contents_for_printing (value);
+      struct type *type = check_typedef (value_type (value));
+      LONGEST val = unpack_long (type, valaddr);
+      if (val == 0)
+	fputs_filtered (decorations->false_name, stream);
+      else if (val == 1)
+	fputs_filtered (decorations->true_name, stream);
+      else
+	print_longest (stream, 'd', 0, val);
+    }
+}
+
 /* generic_val_print helper for TYPE_CODE_INT.  */
 
 static void
@@ -1064,8 +1093,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_BOOL:
-      generic_val_print_bool (type, 0, stream,
-			      val, options, decorations);
+      generic_value_print_bool (val, stream, options, decorations);
       break;
 
     case TYPE_CODE_RANGE:
-- 
2.17.2

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

* [PATCH 27/55] Rewrite pascal_value_print_inner
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (34 preceding siblings ...)
  2019-12-08 18:32 ` [PATCH 23/55] Convert Go printing to value-based API Tom Tromey
@ 2019-12-08 18:32 ` Tom Tromey
  2019-12-08 18:32 ` [PATCH 44/55] Introduce cp_print_value_fields and c_value_print_struct Tom Tromey
                   ` (19 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This rewrites pascal_value_print_inner, copying in the body of
pascal_val_print_inner and adusting as needed.  This will form the
base of future changes to fully convert this to using the value-based
API.

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

	* p-valprint.c (pascal_value_print_inner): Rewrite.

Change-Id: I1e22b498b5ffda0a201366136e87e9ff802104e4
---
 gdb/ChangeLog    |   4 +
 gdb/p-valprint.c | 338 ++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 340 insertions(+), 2 deletions(-)

diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index c24b8edfdeb..5fccf8cb01d 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -434,8 +434,342 @@ pascal_value_print_inner (struct value *val, struct ui_file *stream,
 			  const struct value_print_options *options)
 
 {
-  pascal_val_print (value_type (val), value_embedded_offset (val),
-		    value_address (val), stream, recurse, val, options);
+  struct type *type = check_typedef (value_type (val));
+  struct gdbarch *gdbarch = get_type_arch (type);
+  enum bfd_endian byte_order = type_byte_order (type);
+  unsigned int i = 0;	/* Number of characters printed */
+  unsigned len;
+  struct type *elttype;
+  unsigned eltlen;
+  int length_pos, length_size, string_pos;
+  struct type *char_type;
+  CORE_ADDR addr;
+  int want_space = 0;
+  const gdb_byte *valaddr = value_contents_for_printing (val);
+
+  switch (TYPE_CODE (type))
+    {
+    case TYPE_CODE_ARRAY:
+      {
+	LONGEST low_bound, high_bound;
+
+	if (get_array_bounds (type, &low_bound, &high_bound))
+	  {
+	    len = high_bound - low_bound + 1;
+	    elttype = check_typedef (TYPE_TARGET_TYPE (type));
+	    eltlen = TYPE_LENGTH (elttype);
+	    if (options->prettyformat_arrays)
+	      {
+		print_spaces_filtered (2 + 2 * recurse, stream);
+	      }
+	    /* If 's' format is used, try to print out as string.
+	       If no format is given, print as string if element type
+	       is of TYPE_CODE_CHAR and element size is 1,2 or 4.  */
+	    if (options->format == 's'
+		|| ((eltlen == 1 || eltlen == 2 || eltlen == 4)
+		    && TYPE_CODE (elttype) == TYPE_CODE_CHAR
+		    && options->format == 0))
+	      {
+		/* If requested, look for the first null char and only print
+		   elements up to it.  */
+		if (options->stop_print_at_null)
+		  {
+		    unsigned int temp_len;
+
+		    /* Look for a NULL char.  */
+		    for (temp_len = 0;
+			 extract_unsigned_integer (valaddr + temp_len * eltlen,
+						   eltlen, byte_order)
+			   && temp_len < len && temp_len < options->print_max;
+			 temp_len++);
+		    len = temp_len;
+		  }
+
+		LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type),
+				 valaddr, len, NULL, 0, options);
+		i = len;
+	      }
+	    else
+	      {
+		fprintf_filtered (stream, "{");
+		/* If this is a virtual function table, print the 0th
+		   entry specially, and the rest of the members normally.  */
+		if (pascal_object_is_vtbl_ptr_type (elttype))
+		  {
+		    i = 1;
+		    fprintf_filtered (stream, "%d vtable entries", len - 1);
+		  }
+		else
+		  {
+		    i = 0;
+		  }
+		value_print_array_elements (val, stream, recurse, options, i);
+		fprintf_filtered (stream, "}");
+	      }
+	    break;
+	  }
+	/* Array of unspecified length: treat like pointer to first elt.  */
+	addr = value_address (val);
+      }
+      goto print_unpacked_pointer;
+
+    case TYPE_CODE_PTR:
+      if (options->format && options->format != 's')
+	{
+	  value_print_scalar_formatted (val, options, 0, stream);
+	  break;
+	}
+      if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
+	{
+	  /* Print the unmangled name if desired.  */
+	  /* Print vtable entry - we only get here if we ARE using
+	     -fvtable_thunks.  (Otherwise, look under TYPE_CODE_STRUCT.)  */
+	  /* Extract the address, assume that it is unsigned.  */
+	  addr = extract_unsigned_integer (valaddr,
+					   TYPE_LENGTH (type), byte_order);
+	  print_address_demangle (options, gdbarch, addr, stream, demangle);
+	  break;
+	}
+      check_typedef (TYPE_TARGET_TYPE (type));
+
+      addr = unpack_pointer (type, valaddr);
+    print_unpacked_pointer:
+      elttype = check_typedef (TYPE_TARGET_TYPE (type));
+
+      if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
+	{
+	  /* Try to print what function it points to.  */
+	  print_address_demangle (options, gdbarch, addr, stream, demangle);
+	  return;
+	}
+
+      if (options->addressprint && options->format != 's')
+	{
+	  fputs_filtered (paddress (gdbarch, addr), stream);
+	  want_space = 1;
+	}
+
+      /* For a pointer to char or unsigned char, also print the string
+	 pointed to, unless pointer is null.  */
+      if (((TYPE_LENGTH (elttype) == 1
+	   && (TYPE_CODE (elttype) == TYPE_CODE_INT
+	      || TYPE_CODE (elttype) == TYPE_CODE_CHAR))
+	  || ((TYPE_LENGTH (elttype) == 2 || TYPE_LENGTH (elttype) == 4)
+	      && TYPE_CODE (elttype) == TYPE_CODE_CHAR))
+	  && (options->format == 0 || options->format == 's')
+	  && addr != 0)
+	{
+	  if (want_space)
+	    fputs_filtered (" ", stream);
+	  /* No wide string yet.  */
+	  i = val_print_string (elttype, NULL, addr, -1, stream, options);
+	}
+      /* Also for pointers to pascal strings.  */
+      /* Note: this is Free Pascal specific:
+	 as GDB does not recognize stabs pascal strings
+	 Pascal strings are mapped to records
+	 with lowercase names PM.  */
+      if (is_pascal_string_type (elttype, &length_pos, &length_size,
+				 &string_pos, &char_type, NULL)
+	  && addr != 0)
+	{
+	  ULONGEST string_length;
+	  gdb_byte *buffer;
+
+	  if (want_space)
+	    fputs_filtered (" ", stream);
+	  buffer = (gdb_byte *) xmalloc (length_size);
+	  read_memory (addr + length_pos, buffer, length_size);
+	  string_length = extract_unsigned_integer (buffer, length_size,
+						    byte_order);
+	  xfree (buffer);
+	  i = val_print_string (char_type, NULL,
+				addr + string_pos, string_length,
+				stream, options);
+	}
+      else if (pascal_object_is_vtbl_member (type))
+	{
+	  /* Print vtbl's nicely.  */
+	  CORE_ADDR vt_address = unpack_pointer (type, valaddr);
+	  struct bound_minimal_symbol msymbol =
+	    lookup_minimal_symbol_by_pc (vt_address);
+
+	  /* If 'symbol_print' is set, we did the work above.  */
+	  if (!options->symbol_print
+	      && (msymbol.minsym != NULL)
+	      && (vt_address == BMSYMBOL_VALUE_ADDRESS (msymbol)))
+	    {
+	      if (want_space)
+		fputs_filtered (" ", stream);
+	      fputs_filtered ("<", stream);
+	      fputs_filtered (msymbol.minsym->print_name (), stream);
+	      fputs_filtered (">", stream);
+	      want_space = 1;
+	    }
+	  if (vt_address && options->vtblprint)
+	    {
+	      struct value *vt_val;
+	      struct symbol *wsym = NULL;
+	      struct type *wtype;
+
+	      if (want_space)
+		fputs_filtered (" ", stream);
+
+	      if (msymbol.minsym != NULL)
+		{
+		  const char *search_name = msymbol.minsym->search_name ();
+		  wsym = lookup_symbol_search_name (search_name, NULL,
+						    VAR_DOMAIN).symbol;
+		}
+
+	      if (wsym)
+		{
+		  wtype = SYMBOL_TYPE (wsym);
+		}
+	      else
+		{
+		  wtype = TYPE_TARGET_TYPE (type);
+		}
+	      vt_val = value_at (wtype, vt_address);
+	      common_val_print (vt_val, stream, recurse + 1, options,
+				current_language);
+	      if (options->prettyformat)
+		{
+		  fprintf_filtered (stream, "\n");
+		  print_spaces_filtered (2 + 2 * recurse, stream);
+		}
+	    }
+	}
+
+      return;
+
+    case TYPE_CODE_REF:
+    case TYPE_CODE_ENUM:
+    case TYPE_CODE_FLAGS:
+    case TYPE_CODE_FUNC:
+    case TYPE_CODE_RANGE:
+    case TYPE_CODE_INT:
+    case TYPE_CODE_FLT:
+    case TYPE_CODE_VOID:
+    case TYPE_CODE_ERROR:
+    case TYPE_CODE_UNDEF:
+    case TYPE_CODE_BOOL:
+    case TYPE_CODE_CHAR:
+      generic_value_print (val, stream, recurse, options, &p_decorations);
+      break;
+
+    case TYPE_CODE_UNION:
+      if (recurse && !options->unionprint)
+	{
+	  fprintf_filtered (stream, "{...}");
+	  break;
+	}
+      /* Fall through.  */
+    case TYPE_CODE_STRUCT:
+      if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
+	{
+	  /* Print the unmangled name if desired.  */
+	  /* Print vtable entry - we only get here if NOT using
+	     -fvtable_thunks.  (Otherwise, look under TYPE_CODE_PTR.)  */
+	  /* Extract the address, assume that it is unsigned.  */
+	  print_address_demangle
+	    (options, gdbarch,
+	     extract_unsigned_integer (valaddr
+				       + TYPE_FIELD_BITPOS (type,
+							    VTBL_FNADDR_OFFSET) / 8,
+				       TYPE_LENGTH (TYPE_FIELD_TYPE (type,
+								     VTBL_FNADDR_OFFSET)),
+				       byte_order),
+	     stream, demangle);
+	}
+      else
+	{
+          if (is_pascal_string_type (type, &length_pos, &length_size,
+                                     &string_pos, &char_type, NULL))
+	    {
+	      len = extract_unsigned_integer (valaddr + length_pos,
+					      length_size, byte_order);
+	      LA_PRINT_STRING (stream, char_type, valaddr + string_pos,
+			       len, NULL, 0, options);
+	    }
+	  else
+	    pascal_object_print_value_fields (type, valaddr, 0,
+					      value_address (val), stream,
+					      recurse, val, options,
+					      NULL, 0);
+	}
+      break;
+
+    case TYPE_CODE_SET:
+      elttype = TYPE_INDEX_TYPE (type);
+      elttype = check_typedef (elttype);
+      if (TYPE_STUB (elttype))
+	{
+	  fprintf_styled (stream, metadata_style.style (), "<incomplete type>");
+	  break;
+	}
+      else
+	{
+	  struct type *range = elttype;
+	  LONGEST low_bound, high_bound;
+	  int need_comma = 0;
+
+	  fputs_filtered ("[", stream);
+
+	  int bound_info = get_discrete_bounds (range, &low_bound, &high_bound);
+	  if (low_bound == 0 && high_bound == -1 && TYPE_LENGTH (type) > 0)
+	    {
+	      /* If we know the size of the set type, we can figure out the
+	      maximum value.  */
+	      bound_info = 0;
+	      high_bound = TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1;
+	      TYPE_HIGH_BOUND (range) = high_bound;
+	    }
+	maybe_bad_bstring:
+	  if (bound_info < 0)
+	    {
+	      fputs_styled ("<error value>", metadata_style.style (), stream);
+	      goto done;
+	    }
+
+	  for (i = low_bound; i <= high_bound; i++)
+	    {
+	      int element = value_bit_index (type, valaddr, i);
+
+	      if (element < 0)
+		{
+		  i = element;
+		  goto maybe_bad_bstring;
+		}
+	      if (element)
+		{
+		  if (need_comma)
+		    fputs_filtered (", ", stream);
+		  print_type_scalar (range, i, stream);
+		  need_comma = 1;
+
+		  if (i + 1 <= high_bound
+		      && value_bit_index (type, valaddr, ++i))
+		    {
+		      int j = i;
+
+		      fputs_filtered ("..", stream);
+		      while (i + 1 <= high_bound
+			     && value_bit_index (type, valaddr, ++i))
+			j = i;
+		      print_type_scalar (range, j, stream);
+		    }
+		}
+	    }
+	done:
+	  fputs_filtered ("]", stream);
+	}
+      break;
+
+    default:
+      error (_("Invalid pascal type code %d in symbol table."),
+	     TYPE_CODE (type));
+    }
 }
 
 \f
-- 
2.17.2

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

* [PATCH 51/55] Convert ada_value_print to value-based API
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (42 preceding siblings ...)
  2019-12-08 18:32 ` [PATCH 54/55] Change extension language pretty-printers to use value API Tom Tromey
@ 2019-12-08 18:32 ` Tom Tromey
  2019-12-08 18:50 ` [PATCH 55/55] Remove val_print Tom Tromey
                   ` (11 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This converts ada_value_print to the value-based API by using
common_val_print rather than val_print.

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

	* ada-valprint.c (ada_value_print): Use common_val_print.

Change-Id: I63a3490b7175042bd212c593d3749fd5baebf1a5
---
 gdb/ChangeLog      | 4 ++++
 gdb/ada-valprint.c | 5 +----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 1764b70d1e1..f0baa9945a2 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -1424,7 +1424,6 @@ ada_value_print (struct value *val0, struct ui_file *stream,
 		 const struct value_print_options *options)
 {
   struct value *val = ada_to_fixed_value (val0);
-  CORE_ADDR address = value_address (val);
   struct type *type = ada_check_typedef (value_type (val));
   struct value_print_options opts;
 
@@ -1464,7 +1463,5 @@ ada_value_print (struct value *val0, struct ui_file *stream,
 
   opts = *options;
   opts.deref_ref = 1;
-  val_print (type,
-	     value_embedded_offset (val), address,
-	     stream, 0, val, &opts, current_language);
+  common_val_print (val, stream, 0, &opts, current_language);
 }
-- 
2.17.2

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

* [PATCH 15/55] Simplify c_val_print_array
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (39 preceding siblings ...)
  2019-12-08 18:32 ` [PATCH 01/55] Use scoped_value_mark in value_print Tom Tromey
@ 2019-12-08 18:32 ` Tom Tromey
  2019-12-08 18:32 ` [PATCH 39/55] Rewrite c_value_print_inner Tom Tromey
                   ` (14 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This slightly simplifies c_val_print_array by moving a variable to a
more inner scope and removing a dead assignment.

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

	* c-valprint.c (c_val_print_array): Simplify.

Change-Id: I75bbd574b5619d71045f504112b53ac0f4f1aaf7
---
 gdb/ChangeLog    | 4 ++++
 gdb/c-valprint.c | 7 +------
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index d20a411252f..5753a5869c3 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -247,7 +247,6 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr,
       LONGEST low_bound, high_bound;
       int eltlen, len;
       enum bfd_endian byte_order = type_byte_order (type);
-      unsigned int i = 0;	/* Number of characters printed.  */
 
       if (!get_array_bounds (type, &low_bound, &high_bound))
 	error (_("Could not determine the array high bound"));
@@ -307,10 +306,10 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr,
 	  LA_PRINT_STRING (stream, unresolved_elttype,
 			   valaddr + embedded_offset * unit_size, len,
 			   NULL, force_ellipses, options);
-	  i = len;
 	}
       else
 	{
+	  unsigned int i = 0;
 	  fprintf_filtered (stream, "{");
 	  /* If this is a virtual function table, print the 0th
 	     entry specially, and the rest of the members
@@ -321,10 +320,6 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr,
 	      fprintf_filtered (stream, _("%d vtable entries"),
 				len - 1);
 	    }
-	  else
-	    {
-	      i = 0;
-	    }
 	  val_print_array_elements (type, embedded_offset,
 				    address, stream,
 				    recurse, original_value, options, i);
-- 
2.17.2

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

* [PATCH 43/55] Introduce c_value_print_array
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (31 preceding siblings ...)
  2019-12-08 18:32 ` [PATCH 52/55] Introduce ada_value_print_array Tom Tromey
@ 2019-12-08 18:32 ` Tom Tromey
  2019-12-08 18:32 ` [PATCH 12/55] Introduce value_print_scalar_formatted Tom Tromey
                   ` (22 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds c_value_print_array, a value-based analogue of
c_val_print_array.

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

	* c-valprint.c (c_value_print_array): New function.
	(c_value_print_inner): Use it.

Change-Id: I4dd5af7c5cb0ad48922bc1bac818246f7645343f
---
 gdb/ChangeLog    |  5 +++
 gdb/c-valprint.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 102 insertions(+), 2 deletions(-)

diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 694f87fea95..eaf7ef2eafe 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -335,6 +335,102 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr,
     }
 }
 
+/* c_value_print helper for TYPE_CODE_ARRAY.  */
+
+static void
+c_value_print_array (struct value *val,
+		     struct ui_file *stream, int recurse,
+		     const struct value_print_options *options)
+{
+  struct type *type = check_typedef (value_type (val));
+  CORE_ADDR address = value_address (val);
+  const gdb_byte *valaddr = value_contents_for_printing (val);
+  struct type *unresolved_elttype = TYPE_TARGET_TYPE (type);
+  struct type *elttype = check_typedef (unresolved_elttype);
+
+  if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (unresolved_elttype) > 0)
+    {
+      LONGEST low_bound, high_bound;
+      int eltlen, len;
+      enum bfd_endian byte_order = type_byte_order (type);
+
+      if (!get_array_bounds (type, &low_bound, &high_bound))
+	error (_("Could not determine the array high bound"));
+
+      eltlen = TYPE_LENGTH (elttype);
+      len = high_bound - low_bound + 1;
+      if (options->prettyformat_arrays)
+	{
+	  print_spaces_filtered (2 + 2 * recurse, stream);
+	}
+
+      /* Print arrays of textual chars with a string syntax, as
+	 long as the entire array is valid.  */
+      if (c_textual_element_type (unresolved_elttype,
+				  options->format)
+	  && value_bytes_available (val, 0, TYPE_LENGTH (type))
+	  && !value_bits_any_optimized_out (val, 0,
+					    TARGET_CHAR_BIT * TYPE_LENGTH (type)))
+	{
+	  int force_ellipses = 0;
+
+	  /* If requested, look for the first null char and only
+	     print elements up to it.  */
+	  if (options->stop_print_at_null)
+	    {
+	      unsigned int temp_len;
+
+	      for (temp_len = 0;
+		   (temp_len < len
+		    && temp_len < options->print_max
+		    && extract_unsigned_integer (valaddr + temp_len * eltlen,
+						 eltlen, byte_order) != 0);
+		   ++temp_len)
+		;
+
+	      /* Force LA_PRINT_STRING to print ellipses if
+		 we've printed the maximum characters and
+		 the next character is not \000.  */
+	      if (temp_len == options->print_max && temp_len < len)
+		{
+		  ULONGEST ival
+		    = extract_unsigned_integer (valaddr + temp_len * eltlen,
+						eltlen, byte_order);
+		  if (ival != 0)
+		    force_ellipses = 1;
+		}
+
+	      len = temp_len;
+	    }
+
+	  LA_PRINT_STRING (stream, unresolved_elttype, valaddr, len,
+			   NULL, force_ellipses, options);
+	}
+      else
+	{
+	  unsigned int i = 0;
+	  fprintf_filtered (stream, "{");
+	  /* If this is a virtual function table, print the 0th
+	     entry specially, and the rest of the members
+	     normally.  */
+	  if (cp_is_vtbl_ptr_type (elttype))
+	    {
+	      i = 1;
+	      fprintf_filtered (stream, _("%d vtable entries"),
+				len - 1);
+	    }
+	  value_print_array_elements (val, stream, recurse, options, i);
+	  fprintf_filtered (stream, "}");
+	}
+    }
+  else
+    {
+      /* Array of unspecified length: treat like pointer to first elt.  */
+      print_unpacked_pointer (type, elttype, unresolved_elttype, valaddr,
+			      0, address, stream, recurse, options);
+    }
+}
+
 /* c_val_print helper for TYPE_CODE_PTR.  */
 
 static void
@@ -657,8 +753,7 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_ARRAY:
-      c_val_print_array (type, valaddr, 0, address, stream,
-			 recurse, val, options);
+      c_value_print_array (val, stream, recurse, options);
       break;
 
     case TYPE_CODE_METHODPTR:
-- 
2.17.2

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

* [PATCH 23/55] Convert Go printing to value-based API
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (33 preceding siblings ...)
  2019-12-08 18:32 ` [PATCH 12/55] Introduce value_print_scalar_formatted Tom Tromey
@ 2019-12-08 18:32 ` Tom Tromey
  2019-12-08 18:32 ` [PATCH 27/55] Rewrite pascal_value_print_inner Tom Tromey
                   ` (20 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces go_value_print_inner, a modified copy of go_val_print.
Unlike some of the other languages, Go was straightforward to convert
to the value-based API all at once, so this patch takes that approach.

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

	* go-valprint.c (go_value_print_inner): New function.
	* go-lang.h (go_value_print_inner): Declare.
	* go-lang.c (go_language_defn): Use go_value_print_inner.

Change-Id: Ie0bc393633a11e56991ea82f9fc45e48604c1a17
---
 gdb/ChangeLog     |  6 ++++++
 gdb/go-lang.c     |  2 +-
 gdb/go-lang.h     |  6 ++++++
 gdb/go-valprint.c | 37 +++++++++++++++++++++++++++++++++++++
 4 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 38eb0d74836..7e092229583 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -596,7 +596,7 @@ extern const struct language_defn go_language_defn =
   c_print_typedef,		/* Print a typedef using appropriate
 				   syntax.  */
   go_val_print,			/* Print a value using appropriate syntax.  */
-  nullptr,			/* la_value_print_inner */
+  go_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value.  */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline.  */
diff --git a/gdb/go-lang.h b/gdb/go-lang.h
index 18748b0acbe..19dc43cd33d 100644
--- a/gdb/go-lang.h
+++ b/gdb/go-lang.h
@@ -88,4 +88,10 @@ extern void go_val_print (struct type *type,
 			  struct value *val,
 			  const struct value_print_options *options);
 
+/* Implement la_value_print_inner for Go.  */
+
+extern void go_value_print_inner (struct value *value,
+				  struct ui_file *stream, int recurse,
+				  const struct value_print_options *options);
+
 #endif /* !defined (GO_LANG_H) */
diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c
index 64761b98221..5282aa2e34b 100644
--- a/gdb/go-valprint.c
+++ b/gdb/go-valprint.c
@@ -122,3 +122,40 @@ go_val_print (struct type *type, int embedded_offset,
 	break;
     }
 }
+
+/* See go-lang.h.  */
+
+void
+go_value_print_inner (struct value *val, struct ui_file *stream,
+		      int recurse, const struct value_print_options *options)
+{
+  struct type *type = check_typedef (value_type (val));
+
+  switch (TYPE_CODE (type))
+    {
+      case TYPE_CODE_STRUCT:
+	{
+	  enum go_type go_type = go_classify_struct_type (type);
+
+	  switch (go_type)
+	    {
+	    case GO_TYPE_STRING:
+	      if (! options->raw)
+		{
+		  print_go_string (type, value_embedded_offset (val),
+				   value_address (val),
+				   stream, recurse, val, options);
+		  return;
+		}
+	      break;
+	    default:
+	      break;
+	    }
+	}
+	/* Fall through.  */
+
+      default:
+	c_value_print_inner (val, stream, recurse, options);
+	break;
+    }
+}
-- 
2.17.2

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

* [PATCH 52/55] Introduce ada_value_print_array
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (30 preceding siblings ...)
  2019-12-08 18:32 ` [PATCH 28/55] Convert Pascal to value-based API Tom Tromey
@ 2019-12-08 18:32 ` Tom Tromey
  2019-12-08 18:32 ` [PATCH 43/55] Introduce c_value_print_array Tom Tromey
                   ` (23 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds ada_value_print_array, a value-based analogue of
ada_val_print_array.  It also removes some unused parameters from a
couple of helper functions.

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

	* ada-valprint.c (val_print_packed_array_elements): Remove
	bitoffset and val parameters.  Call common_val_print.
	(ada_val_print_string): Remove offset, address, and original_value
	parameters.
	(ada_val_print_array): Update.
	(ada_value_print_array): New function.
	(ada_value_print_1): Call it.

Change-Id: I3f0773f264e70ec95f5e98ab25fd6460d6e5afb8
---
 gdb/ChangeLog      | 10 +++++++
 gdb/ada-valprint.c | 71 +++++++++++++++++++++++++++++++---------------
 2 files changed, 58 insertions(+), 23 deletions(-)

diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index f0baa9945a2..c83782a0760 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -112,17 +112,15 @@ print_optional_low_bound (struct ui_file *stream, struct type *type,
 }
 
 /*  Version of val_print_array_elements for GNAT-style packed arrays.
-    Prints elements of packed array of type TYPE at bit offset
-    BITOFFSET from VALADDR on STREAM.  Formats according to OPTIONS and
-    separates with commas.  RECURSE is the recursion (nesting) level.
-    TYPE must have been decoded (as by ada_coerce_to_simple_array).  */
+    Prints elements of packed array of type TYPE from VALADDR on
+    STREAM.  Formats according to OPTIONS and separates with commas.
+    RECURSE is the recursion (nesting) level.  TYPE must have been
+    decoded (as by ada_coerce_to_simple_array).  */
 
 static void
 val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
-				 int offset,
-				 int bitoffset, struct ui_file *stream,
+				 int offset, struct ui_file *stream,
 				 int recurse,
-				 struct value *val,
 				 const struct value_print_options *options)
 {
   unsigned int i;
@@ -230,9 +228,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	  struct value_print_options opts = *options;
 
 	  opts.deref_ref = 0;
-	  val_print (elttype,
-		     value_embedded_offset (v0), 0, stream,
-		     recurse + 1, v0, &opts, current_language);
+	  common_val_print (v0, stream, recurse + 1, &opts, current_language);
 	  annotate_elt_rep (i - i0);
 	  fprintf_filtered (stream, _(" %p[<repeats %u times>%p]"),
 			    metadata_style.style ().ptr (), i - i0, nullptr);
@@ -262,9 +258,8 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 		  maybe_print_array_index (index_type, j + low,
 					   stream, options);
 		}
-	      val_print (elttype,
-			 value_embedded_offset (v0), 0, stream,
-			 recurse + 1, v0, &opts, current_language);
+	      common_val_print (v0, stream, recurse + 1, &opts,
+				current_language);
 	      annotate_elt ();
 	    }
 	}
@@ -714,9 +709,8 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 
 static void
 ada_val_print_string (struct type *type, const gdb_byte *valaddr,
-		      int offset, int offset_aligned, CORE_ADDR address,
+		      int offset_aligned,
 		      struct ui_file *stream, int recurse,
-		      struct value *original_value,
 		      const struct value_print_options *options)
 {
   enum bfd_endian byte_order = type_byte_order (type);
@@ -1126,9 +1120,8 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
   if (ada_is_string_type (type)
       && (options->format == 0 || options->format == 's'))
     {
-      ada_val_print_string (type, valaddr, offset, offset_aligned,
-			    address, stream, recurse, original_value,
-			    options);
+      ada_val_print_string (type, valaddr, offset_aligned,
+			    stream, recurse, options);
       return;
     }
 
@@ -1136,8 +1129,7 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
   print_optional_low_bound (stream, type, options);
   if (TYPE_FIELD_BITSIZE (type, 0) > 0)
     val_print_packed_array_elements (type, valaddr, offset_aligned,
-				     0, stream, recurse,
-				     original_value, options);
+				     stream, recurse, options);
   else
     val_print_array_elements (type, offset_aligned, address,
 			      stream, recurse, original_value,
@@ -1145,6 +1137,41 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
   fprintf_filtered (stream, ")");
 }
 
+/* Implement Ada value_print'ing for the case where TYPE is a
+   TYPE_CODE_ARRAY.  */
+
+static void
+ada_value_print_array (struct value *val, struct ui_file *stream, int recurse,
+		       const struct value_print_options *options)
+{
+  struct type *type = ada_check_typedef (value_type (val));
+
+  /* For an array of characters, print with string syntax.  */
+  if (ada_is_string_type (type)
+      && (options->format == 0 || options->format == 's'))
+    {
+      const gdb_byte *valaddr = value_contents_for_printing (val);
+      int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr;
+
+      ada_val_print_string (type, valaddr, offset_aligned, stream, recurse,
+			    options);
+      return;
+    }
+
+  fprintf_filtered (stream, "(");
+  print_optional_low_bound (stream, type, options);
+  if (TYPE_FIELD_BITSIZE (type, 0) > 0)
+    {
+      const gdb_byte *valaddr = value_contents_for_printing (val);
+      int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr;
+      val_print_packed_array_elements (type, valaddr, offset_aligned,
+				       stream, recurse, options);
+    }
+  else
+    value_print_array_elements (val, stream, recurse, options, 0);
+  fprintf_filtered (stream, ")");
+}
+
 /* Implement Ada val_print'ing for the case where TYPE is
    a TYPE_CODE_REF.  */
 
@@ -1387,9 +1414,7 @@ ada_value_print_1 (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_ARRAY:
-      ada_val_print_array (type, valaddr, 0, 0,
-			   address, stream, recurse, val,
-			   options);
+      ada_value_print_array (val, stream, recurse, options);
       return;
 
     case TYPE_CODE_REF:
-- 
2.17.2

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

* [PATCH 01/55] Use scoped_value_mark in value_print
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (38 preceding siblings ...)
  2019-12-08 18:32 ` [PATCH 40/55] Introduce c_value_print_ptr Tom Tromey
@ 2019-12-08 18:32 ` Tom Tromey
  2019-12-08 18:32 ` [PATCH 15/55] Simplify c_val_print_array Tom Tromey
                   ` (15 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

From: Tom Tromey <tromey@adacore.com>

Switching the low-level printing to use the value API means we will be
using more temporary values.  This adds a scoped_value_mark to
value_print, so that these intermediates are destroyed in a timely
way.

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

	* valprint.c (value_print): Use scoped_value_mark.

Change-Id: I7aad76b8387b87bd46a920f7865725e677a74934
---
 gdb/ChangeLog  | 4 ++++
 gdb/valprint.c | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 1e3071b4322..5bc860f13f1 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1201,6 +1201,8 @@ void
 value_print (struct value *val, struct ui_file *stream,
 	     const struct value_print_options *options)
 {
+  scoped_value_mark free_values;
+
   if (!value_check_printable (val, stream, options))
     return;
 
-- 
2.17.2

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

* [PATCH 54/55] Change extension language pretty-printers to use value API
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (41 preceding siblings ...)
  2019-12-08 18:32 ` [PATCH 39/55] Rewrite c_value_print_inner Tom Tromey
@ 2019-12-08 18:32 ` Tom Tromey
  2019-12-08 18:32 ` [PATCH 51/55] Convert ada_value_print to value-based API Tom Tromey
                   ` (12 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes the extension language pretty-printers to use the value
API.

Note that new functions were needed, for both Guile and Python.
Currently both languages always wrap values by removing the values
from the value chain.  This makes sense to avoid strange behavior with
watchpoints, and to avoid excessive memory use.  However, when
printing, it's important to leave the passed-in value untouched, in
case pretty-printing does nothing -- that way the caller can still
access it.

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

	* valprint.c (do_val_print): Update.
	* python/python-internal.h (gdbpy_apply_val_pretty_printer): Take
	a struct value.
	(value_to_value_object_no_release): Declare.
	* python/py-value.c (value_to_value_object_no_release): New
	function.
	* python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Take a
	struct value.
	* guile/scm-value.c (vlscm_scm_from_value_no_release): New
	function.
	* guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer): Take
	a struct value.
	* guile/guile-internal.h (vlscm_scm_from_value_no_release):
	Declare.
	(gdbscm_apply_val_pretty_printer): Take a struct value.
	* extension.h (apply_ext_lang_val_pretty_printer): Take a struct
	value.
	* extension.c (apply_ext_lang_val_pretty_printer): Take a struct
	value.
	* extension-priv.h (struct extension_language_ops)
	<apply_val_pretty_printer>: Take a struct value.
	* cp-valprint.c (cp_print_value): Create a struct value.
	(cp_print_value): Update.

Change-Id: I49245df133fd0ab82d072c0b0479d38b600d0eda
---
 gdb/ChangeLog                | 26 ++++++++++++++++++++++++++
 gdb/cp-valprint.c            | 28 +++++++++++++++-------------
 gdb/extension-priv.h         | 17 ++++++-----------
 gdb/extension.c              | 19 ++++++-------------
 gdb/extension.h              |  6 ++----
 gdb/guile/guile-internal.h   |  5 ++---
 gdb/guile/scm-pretty-print.c | 16 ++++++----------
 gdb/guile/scm-value.c        | 18 ++++++++++++++++++
 gdb/python/py-prettyprint.c  | 17 ++++++-----------
 gdb/python/py-value.c        | 21 +++++++++++++++++++++
 gdb/python/python-internal.h |  5 ++---
 gdb/valprint.c               | 17 +++++++++--------
 12 files changed, 119 insertions(+), 76 deletions(-)

diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 143d77cb223..282eb0864a7 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -841,13 +841,15 @@ cp_print_value (struct type *type, struct type *real_type,
 	      /* Attempt to run an extension language pretty-printer on the
 		 baseclass if possible.  */
 	      if (!options->raw)
-		result
-		  = apply_ext_lang_val_pretty_printer (baseclass,
-						       thisoffset + boffset,
-						       value_address (base_val),
-						       stream, recurse,
-						       base_val, options,
-						       current_language);
+		{
+		  struct value *v
+		    = value_from_component (base_val, baseclass,
+					    thisoffset + boffset);
+		  result
+		    = apply_ext_lang_val_pretty_printer (v, stream, recurse,
+							 options,
+							 current_language);
+		}
 
 	      if (!result)
 		cp_print_value_fields (baseclass, thistype,
@@ -999,19 +1001,19 @@ cp_print_value (struct value *val, struct ui_file *stream,
 	    }
 	  else
 	    {
+	      struct value *baseclass_val = value_primitive_field (val, 0,
+								   i, type);
+
 	      /* Attempt to run an extension language pretty-printer on the
 		 baseclass if possible.  */
 	      if (!options->raw)
 		result
-		  = apply_ext_lang_val_pretty_printer (baseclass, boffset,
-						       value_address (base_val),
-						       stream, recurse,
-						       base_val, options,
+		  = apply_ext_lang_val_pretty_printer (baseclass_val, stream,
+						       recurse, options,
 						       current_language);
 
 	      if (!result)
-		cp_print_value_fields (value_primitive_field (val, 0, i, type),
-				       stream, recurse, options,
+		cp_print_value_fields (baseclass_val, stream, recurse, options,
 				       ((struct type **)
 					obstack_base (&dont_print_vb_obstack)),
 				       0);
diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h
index 97594f853a2..694df278aad 100644
--- a/gdb/extension-priv.h
+++ b/gdb/extension-priv.h
@@ -152,19 +152,14 @@ struct extension_language_ops
   void (*free_type_printers) (const struct extension_language_defn *,
 			      struct ext_lang_type_printers *);
 
-  /* Try to pretty-print a value of type TYPE located at VAL's contents
-     buffer + EMBEDDED_OFFSET, which came from the inferior at address
-     ADDRESS + EMBEDDED_OFFSET, onto stdio stream STREAM according to
-     OPTIONS.
-     VAL is the whole object that came from ADDRESS.
-     Returns EXT_LANG_RC_OK upon success, EXT_LANG_RC_NOP if the value
-     is not recognized, and EXT_LANG_RC_ERROR if an error was encountered.  */
+  /* Try to pretty-print a value, onto stdio stream STREAM according
+     to OPTIONS.  VAL is the object to print.  Returns EXT_LANG_RC_OK
+     upon success, EXT_LANG_RC_NOP if the value is not recognized, and
+     EXT_LANG_RC_ERROR if an error was encountered.  */
   enum ext_lang_rc (*apply_val_pretty_printer)
     (const struct extension_language_defn *,
-     struct type *type,
-     LONGEST embedded_offset, CORE_ADDR address,
-     struct ui_file *stream, int recurse,
-     struct value *val, const struct value_print_options *options,
+     struct value *val, struct ui_file *stream, int recurse,
+     const struct value_print_options *options,
      const struct language_defn *language);
 
   /* GDB access to the "frame filter" feature.
diff --git a/gdb/extension.c b/gdb/extension.c
index 1fb4b48003a..4ece206cc37 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -470,12 +470,9 @@ ext_lang_type_printers::~ext_lang_type_printers ()
     }
 }
 \f
-/* Try to pretty-print a value of type TYPE located at VAL's contents
-   buffer + EMBEDDED_OFFSET, which came from the inferior at address
-   ADDRESS + EMBEDDED_OFFSET, onto stdio stream STREAM according to
-   OPTIONS.
-   VAL is the whole object that came from ADDRESS.
-   Returns non-zero if the value was successfully pretty-printed.
+/* Try to pretty-print a value onto stdio stream STREAM according to
+   OPTIONS.  VAL is the object to print.  Returns non-zero if the
+   value was successfully pretty-printed.
 
    Extension languages are tried in the order specified by
    extension_languages.  The first one to provide a pretty-printed
@@ -488,10 +485,8 @@ ext_lang_type_printers::~ext_lang_type_printers ()
    errors that trigger an exception in the extension language.  */
 
 int
-apply_ext_lang_val_pretty_printer (struct type *type,
-				   LONGEST embedded_offset, CORE_ADDR address,
+apply_ext_lang_val_pretty_printer (struct value *val,
 				   struct ui_file *stream, int recurse,
-				   struct value *val,
 				   const struct value_print_options *options,
 				   const struct language_defn *language)
 {
@@ -504,10 +499,8 @@ apply_ext_lang_val_pretty_printer (struct type *type,
 
       if (extlang->ops->apply_val_pretty_printer == NULL)
 	continue;
-      rc = extlang->ops->apply_val_pretty_printer (extlang, type,
-						   embedded_offset, address,
-						   stream, recurse, val,
-						   options, language);
+      rc = extlang->ops->apply_val_pretty_printer (extlang, val, stream,
+						   recurse, options, language);
       switch (rc)
 	{
 	case EXT_LANG_RC_OK:
diff --git a/gdb/extension.h b/gdb/extension.h
index fc8e3e2c0ba..bf6fd3e3e58 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -282,10 +282,8 @@ extern char *apply_ext_lang_type_printers (struct ext_lang_type_printers *,
 					   struct type *);
 
 extern int apply_ext_lang_val_pretty_printer
-  (struct type *type,
-   LONGEST embedded_offset, CORE_ADDR address,
-   struct ui_file *stream, int recurse,
-   struct value *val, const struct value_print_options *options,
+  (struct value *value, struct ui_file *stream, int recurse,
+   const struct value_print_options *options,
    const struct language_defn *language);
 
 extern enum ext_lang_bt_status apply_ext_lang_frame_filter
diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h
index 3ae6618a7bc..3444c406d55 100644
--- a/gdb/guile/guile-internal.h
+++ b/gdb/guile/guile-internal.h
@@ -579,6 +579,7 @@ extern struct value *vlscm_scm_to_value (SCM scm);
 extern int vlscm_is_value (SCM scm);
 
 extern SCM vlscm_scm_from_value (struct value *value);
+extern SCM vlscm_scm_from_value_no_release (struct value *value);
 
 extern struct value *vlscm_convert_typed_value_from_scheme
   (const char *func_name, int obj_arg_pos, SCM obj,
@@ -602,10 +603,8 @@ extern void gdbscm_preserve_values
 
 extern enum ext_lang_rc gdbscm_apply_val_pretty_printer
   (const struct extension_language_defn *,
-   struct type *type,
-   LONGEST embedded_offset, CORE_ADDR address,
-   struct ui_file *stream, int recurse,
    struct value *val,
+   struct ui_file *stream, int recurse,
    const struct value_print_options *options,
    const struct language_defn *language);
 
diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index 630a062148e..e7289a71786 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -943,36 +943,32 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 
 enum ext_lang_rc
 gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang,
-				 struct type *type,
-				 LONGEST embedded_offset, CORE_ADDR address,
+				 struct value *value,
 				 struct ui_file *stream, int recurse,
-				 struct value *val,
 				 const struct value_print_options *options,
 				 const struct language_defn *language)
 {
+  struct type *type = value_type (value);
   struct gdbarch *gdbarch = get_type_arch (type);
   SCM exception = SCM_BOOL_F;
   SCM printer = SCM_BOOL_F;
   SCM val_obj = SCM_BOOL_F;
-  struct value *value;
   enum display_hint hint;
   enum ext_lang_rc result = EXT_LANG_RC_NOP;
   enum string_repr_result print_result;
 
-  if (value_lazy (val))
-    value_fetch_lazy (val);
+  if (value_lazy (value))
+    value_fetch_lazy (value);
 
   /* No pretty-printer support for unavailable values.  */
-  if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type)))
+  if (!value_bytes_available (value, 0, TYPE_LENGTH (type)))
     return EXT_LANG_RC_NOP;
 
   if (!gdb_scheme_initialized)
     return EXT_LANG_RC_NOP;
 
   /* Instantiate the printer.  */
-  value = value_from_component (val, type, embedded_offset);
-
-  val_obj = vlscm_scm_from_value (value);
+  val_obj = vlscm_scm_from_value_no_release (value);
   if (gdbscm_is_exception (val_obj))
     {
       exception = val_obj;
diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c
index 8aa4cfa345b..7398a2d8332 100644
--- a/gdb/guile/scm-value.c
+++ b/gdb/guile/scm-value.c
@@ -261,6 +261,24 @@ vlscm_scm_from_value (struct value *value)
   return v_scm;
 }
 
+/* Create a new <gdb:value> object that encapsulates VALUE.
+   The value is not released from the all_values chain.  */
+
+SCM
+vlscm_scm_from_value_no_release (struct value *value)
+{
+  /* N.B. It's important to not cause any side-effects until we know the
+     conversion worked.  */
+  SCM v_scm = vlscm_make_value_smob ();
+  value_smob *v_smob = (value_smob *) SCM_SMOB_DATA (v_scm);
+
+  value_incref (value);
+  v_smob->value = value;
+  vlscm_remember_scheme_value (v_smob);
+
+  return v_scm;
+}
+
 /* Returns the <gdb:value> object in SELF.
    Throws an exception if SELF is not a <gdb:value> object.  */
 
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index a4df48fe19a..a5aed9c91ac 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -558,22 +558,20 @@ print_children (PyObject *printer, const char *hint,
 
 enum ext_lang_rc
 gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
-				struct type *type,
-				LONGEST embedded_offset, CORE_ADDR address,
+				struct value *value,
 				struct ui_file *stream, int recurse,
-				struct value *val,
 				const struct value_print_options *options,
 				const struct language_defn *language)
 {
+  struct type *type = value_type (value);
   struct gdbarch *gdbarch = get_type_arch (type);
-  struct value *value;
   enum string_repr_result print_result;
 
-  if (value_lazy (val))
-    value_fetch_lazy (val);
+  if (value_lazy (value))
+    value_fetch_lazy (value);
 
   /* No pretty-printer support for unavailable values.  */
-  if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type)))
+  if (!value_bytes_available (value, 0, TYPE_LENGTH (type)))
     return EXT_LANG_RC_NOP;
 
   if (!gdb_python_initialized)
@@ -581,10 +579,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
 
   gdbpy_enter enter_py (gdbarch, language);
 
-  /* Instantiate the printer.  */
-  value = value_from_component (val, type, embedded_offset);
-
-  gdbpy_ref<> val_obj (value_to_value_object (value));
+  gdbpy_ref<> val_obj (value_to_value_object_no_release (value));
   if (val_obj == NULL)
     {
       print_stack_unless_memory_error (stream);
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 1ca2dc5c719..5a967329f2d 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -1788,6 +1788,27 @@ value_to_value_object (struct value *val)
   return (PyObject *) val_obj;
 }
 
+/* Returns an object for a value, but without releasing it from the
+   all_values chain.  */
+PyObject *
+value_to_value_object_no_release (struct value *val)
+{
+  value_object *val_obj;
+
+  val_obj = PyObject_New (value_object, &value_object_type);
+  if (val_obj != NULL)
+    {
+      value_incref (val);
+      val_obj->value = val;
+      val_obj->address = NULL;
+      val_obj->type = NULL;
+      val_obj->dynamic_type = NULL;
+      note_value (val_obj);
+    }
+
+  return (PyObject *) val_obj;
+}
+
 /* Returns a borrowed reference to the struct value corresponding to
    the given value object.  */
 struct value *
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 703c60032c0..a60af21458e 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -391,10 +391,8 @@ extern int gdbpy_auto_load_enabled (const struct extension_language_defn *);
 
 extern enum ext_lang_rc gdbpy_apply_val_pretty_printer
   (const struct extension_language_defn *,
-   struct type *type,
-   LONGEST embedded_offset, CORE_ADDR address,
+   struct value *value,
    struct ui_file *stream, int recurse,
-   struct value *val,
    const struct value_print_options *options,
    const struct language_defn *language);
 extern enum ext_lang_bt_status gdbpy_apply_frame_filter
@@ -454,6 +452,7 @@ PyObject *symbol_to_symbol_object (struct symbol *sym);
 PyObject *block_to_block_object (const struct block *block,
 				 struct objfile *objfile);
 PyObject *value_to_value_object (struct value *v);
+PyObject *value_to_value_object_no_release (struct value *v);
 PyObject *type_to_type_object (struct type *);
 PyObject *frame_info_to_frame_object (struct frame_info *frame);
 PyObject *symtab_to_linetable_object (PyObject *symtab);
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 251eae2d844..56f06be6b9c 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1253,9 +1253,13 @@ do_val_print (struct value *full_value,
 
   if (!options->raw)
     {
-      ret = apply_ext_lang_val_pretty_printer (type, embedded_offset,
-					       address, stream, recurse,
-					       val, options, language);
+      struct value *v = full_value;
+
+      if (v == nullptr)
+	v = value_from_component (val, type, embedded_offset);
+
+      ret = apply_ext_lang_val_pretty_printer (v, stream, recurse, options,
+					       language);
       if (ret)
 	return;
     }
@@ -1451,11 +1455,8 @@ value_print (struct value *val, struct ui_file *stream,
   if (!options->raw)
     {
       int r
-	= apply_ext_lang_val_pretty_printer (value_type (val),
-					     value_embedded_offset (val),
-					     value_address (val),
-					     stream, 0,
-					     val, options, current_language);
+	= apply_ext_lang_val_pretty_printer (val, stream, 0, options,
+					     current_language);
 
       if (r)
 	return;
-- 
2.17.2

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

* [PATCH 40/55] Introduce c_value_print_ptr
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (37 preceding siblings ...)
  2019-12-08 18:32 ` [PATCH 08/55] Use common_val_print in cp-valprint.c Tom Tromey
@ 2019-12-08 18:32 ` Tom Tromey
  2020-01-15  6:01   ` Simon Marchi
  2019-12-08 18:32 ` [PATCH 01/55] Use scoped_value_mark in value_print Tom Tromey
                   ` (16 subsequent siblings)
  55 siblings, 1 reply; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds c_value_print_ptr, a value-based analogue of
c_val_print_ptr.

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

	* c-valprint.c (c_value_print_ptr): New function.
	(c_value_print_inner): Use it.

Change-Id: Iba7917a57d5d67c51a76014c4bcb82c0353f6453
---
 gdb/ChangeLog    |  5 +++++
 gdb/c-valprint.c | 40 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index af7a386fb78..f50c49abbfd 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -375,6 +375,43 @@ c_val_print_ptr (struct type *type, const gdb_byte *valaddr,
     }
 }
 
+/* c_val_print helper for TYPE_CODE_PTR.  */
+
+static void
+c_value_print_ptr (struct value*val, struct ui_file *stream, int recurse,
+		   const struct value_print_options *options)
+{
+  if (options->format && options->format != 's')
+    {
+      value_print_scalar_formatted (val, options, 0, stream);
+      return;
+    }
+
+  struct type *type = check_typedef (value_type (val));
+  struct gdbarch *arch = get_type_arch (type);
+  const gdb_byte *valaddr = value_contents_for_printing (val);
+
+  if (options->vtblprint && cp_is_vtbl_ptr_type (type))
+    {
+      /* Print the unmangled name if desired.  */
+      /* Print vtable entry - we only get here if we ARE using
+	 -fvtable_thunks.  (Otherwise, look under
+	 TYPE_CODE_STRUCT.)  */
+      CORE_ADDR addr = extract_typed_address (valaddr, type);
+
+      print_function_pointer_address (options, arch, addr, stream);
+    }
+  else
+    {
+      struct type *unresolved_elttype = TYPE_TARGET_TYPE (type);
+      struct type *elttype = check_typedef (unresolved_elttype);
+      CORE_ADDR addr = unpack_pointer (type, valaddr);
+
+      print_unpacked_pointer (type, elttype, unresolved_elttype, valaddr,
+			      0, addr, stream, recurse, options);
+    }
+}
+
 /* c_val_print helper for TYPE_CODE_STRUCT.  */
 
 static void
@@ -582,8 +619,7 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_PTR:
-      c_val_print_ptr (type, valaddr, 0, stream, recurse,
-		       val, options);
+      c_value_print_ptr (val, stream, recurse, options);
       break;
 
     case TYPE_CODE_UNION:
-- 
2.17.2

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

* [PATCH 08/55] Use common_val_print in cp-valprint.c
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (36 preceding siblings ...)
  2019-12-08 18:32 ` [PATCH 44/55] Introduce cp_print_value_fields and c_value_print_struct Tom Tromey
@ 2019-12-08 18:32 ` Tom Tromey
  2019-12-08 18:32 ` [PATCH 40/55] Introduce c_value_print_ptr Tom Tromey
                   ` (17 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes a spot in cp-valprint.c to use common_val_print rather
than val_print.

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

	* cp-valprint.c (cp_print_static_field): Use common_val_print.

Change-Id: Ib967e82c7b01409509adcd9c3bf5ae04a9541cff
---
 gdb/ChangeLog     | 4 ++++
 gdb/cp-valprint.c | 6 +-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 0ec84f6799e..9a26ab322a4 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -684,11 +684,7 @@ cp_print_static_field (struct type *type,
 
   opts = *options;
   opts.deref_ref = 0;
-  val_print (type,
-	     value_embedded_offset (val),
-	     value_address (val),
-	     stream, recurse, val,
-	     &opts, current_language);
+  common_val_print (val, stream, recurse, &opts, current_language);
 }
 
 /* Find the field in *SELF, or its non-virtual base classes, with
-- 
2.17.2

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

* [PATCH 28/55] Convert Pascal to value-based API
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (29 preceding siblings ...)
  2019-12-08 18:31 ` [PATCH 33/55] Simplify generic_val_print_func Tom Tromey
@ 2019-12-08 18:32 ` Tom Tromey
  2020-01-15  5:57   ` Simon Marchi
  2019-12-08 18:32 ` [PATCH 52/55] Introduce ada_value_print_array Tom Tromey
                   ` (24 subsequent siblings)
  55 siblings, 1 reply; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This finishes the conversion of Pascal to the value-based API, by
introducing two more value-based analogues of existing val-print
functions.

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

	* p-valprint.c (pascal_object_print_value_fields)
	(pascal_object_print_value): New functions.

Change-Id: I8901fd99dffea9708dde299188f153de23ace357
---
 gdb/ChangeLog    |   5 +
 gdb/p-valprint.c | 304 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 309 insertions(+)

diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 5fccf8cb01d..e02f70ab3ab 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -50,6 +50,11 @@ static void pascal_object_print_value_fields (struct type *, const gdb_byte *,
 					      const struct value_print_options *,
 					      struct type **, int);
 
+static void pascal_object_print_value_fields (struct value *, struct ui_file *,
+					      int,
+					      const struct value_print_options *,
+					      struct type **, int);
+
 /* Decorations for Pascal.  */
 
 static const struct generic_val_print_decorations p_decorations =
@@ -833,6 +838,10 @@ static void pascal_object_print_value (struct type *, const gdb_byte *,
 				       const struct value_print_options *,
 				       struct type **);
 
+static void pascal_object_print_value (struct value *, struct ui_file *, int,
+				       const struct value_print_options *,
+				       struct type **);
+
 /* It was changed to this after 2.4.5.  */
 const char pascal_vtbl_ptr_name[] =
 {'_', '_', 'v', 't', 'b', 'l', '_', 'p', 't', 'r', '_', 't', 'y', 'p', 'e', 0};
@@ -1056,6 +1065,182 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
   fprintf_filtered (stream, "}");
 }
 
+/* Mutually recursive subroutines of pascal_object_print_value and
+   c_val_print to print out a structure's fields:
+   pascal_object_print_val_fields and pascal_object_print_value.
+
+   TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the
+   same meanings as in pascal_object_print_value and c_val_print.
+
+   DONT_PRINT is an array of baseclass types that we
+   should not print, or zero if called from top level.  */
+
+static void
+pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
+				  int recurse,
+				  const struct value_print_options *options,
+				  struct type **dont_print_vb,
+				  int dont_print_statmem)
+{
+  int i, len, n_baseclasses;
+  char *last_dont_print
+    = (char *) obstack_next_free (&dont_print_statmem_obstack);
+
+  struct type *type = check_typedef (value_type (val));
+
+  fprintf_filtered (stream, "{");
+  len = TYPE_NFIELDS (type);
+  n_baseclasses = TYPE_N_BASECLASSES (type);
+
+  /* Print out baseclasses such that we don't print
+     duplicates of virtual baseclasses.  */
+  if (n_baseclasses > 0)
+    pascal_object_print_value (val, stream, recurse + 1,
+			       options, dont_print_vb);
+
+  if (!len && n_baseclasses == 1)
+    fprintf_styled (stream, metadata_style.style (), "<No data fields>");
+  else
+    {
+      struct obstack tmp_obstack = dont_print_statmem_obstack;
+      int fields_seen = 0;
+      const gdb_byte *valaddr = value_contents_for_printing (val);
+
+      if (dont_print_statmem == 0)
+	{
+	  /* If we're at top level, carve out a completely fresh
+	     chunk of the obstack and use that until this particular
+	     invocation returns.  */
+	  obstack_finish (&dont_print_statmem_obstack);
+	}
+
+      for (i = n_baseclasses; i < len; i++)
+	{
+	  /* If requested, skip printing of static fields.  */
+	  if (!options->pascal_static_field_print
+	      && field_is_static (&TYPE_FIELD (type, i)))
+	    continue;
+	  if (fields_seen)
+	    fprintf_filtered (stream, ", ");
+	  else if (n_baseclasses > 0)
+	    {
+	      if (options->prettyformat)
+		{
+		  fprintf_filtered (stream, "\n");
+		  print_spaces_filtered (2 + 2 * recurse, stream);
+		  fputs_filtered ("members of ", stream);
+		  fputs_filtered (TYPE_NAME (type), stream);
+		  fputs_filtered (": ", stream);
+		}
+	    }
+	  fields_seen = 1;
+
+	  if (options->prettyformat)
+	    {
+	      fprintf_filtered (stream, "\n");
+	      print_spaces_filtered (2 + 2 * recurse, stream);
+	    }
+	  else
+	    {
+	      wrap_here (n_spaces (2 + 2 * recurse));
+	    }
+
+	  annotate_field_begin (TYPE_FIELD_TYPE (type, i));
+
+	  if (field_is_static (&TYPE_FIELD (type, i)))
+	    fputs_filtered ("static ", stream);
+	  fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i),
+				   language_cplus,
+				   DMGL_PARAMS | DMGL_ANSI);
+	  annotate_field_name_end ();
+	  fputs_filtered (" = ", stream);
+	  annotate_field_value ();
+
+	  if (!field_is_static (&TYPE_FIELD (type, i))
+	      && TYPE_FIELD_PACKED (type, i))
+	    {
+	      struct value *v;
+
+	      /* Bitfields require special handling, especially due to byte
+	         order problems.  */
+	      if (TYPE_FIELD_IGNORE (type, i))
+		{
+		  fputs_styled ("<optimized out or zero length>",
+				metadata_style.style (), stream);
+		}
+	      else if (value_bits_synthetic_pointer (val,
+						     TYPE_FIELD_BITPOS (type,
+									i),
+						     TYPE_FIELD_BITSIZE (type,
+									 i)))
+		{
+		  fputs_styled (_("<synthetic pointer>"),
+				metadata_style.style (), stream);
+		}
+	      else
+		{
+		  struct value_print_options opts = *options;
+
+		  v = value_field_bitfield (type, i, valaddr, 0, val);
+
+		  opts.deref_ref = 0;
+		  common_val_print (v, stream, recurse + 1, &opts,
+				    current_language);
+		}
+	    }
+	  else
+	    {
+	      if (TYPE_FIELD_IGNORE (type, i))
+		{
+		  fputs_styled ("<optimized out or zero length>",
+				metadata_style.style (), stream);
+		}
+	      else if (field_is_static (&TYPE_FIELD (type, i)))
+		{
+		  /* struct value *v = value_static_field (type, i);
+		     v4.17 specific.  */
+		  struct value *v;
+
+		  v = value_field_bitfield (type, i, valaddr, 0, val);
+
+		  if (v == NULL)
+		    val_print_optimized_out (NULL, stream);
+		  else
+		    pascal_object_print_static_field (v, stream, recurse + 1,
+						      options);
+		}
+	      else
+		{
+		  struct value_print_options opts = *options;
+
+		  opts.deref_ref = 0;
+
+		  struct value *v = value_primitive_field (val, 0, i,
+							   value_type (val));
+		  common_val_print (v, stream, recurse + 1, &opts,
+				    current_language);
+		}
+	    }
+	  annotate_field_end ();
+	}
+
+      if (dont_print_statmem == 0)
+	{
+	  /* Free the space used to deal with the printing
+	     of the members from top level.  */
+	  obstack_free (&dont_print_statmem_obstack, last_dont_print);
+	  dont_print_statmem_obstack = tmp_obstack;
+	}
+
+      if (options->prettyformat)
+	{
+	  fprintf_filtered (stream, "\n");
+	  print_spaces_filtered (2 * recurse, stream);
+	}
+    }
+  fprintf_filtered (stream, "}");
+}
+
 /* Special val_print routine to avoid printing multiple copies of virtual
    baseclasses.  */
 
@@ -1182,6 +1367,125 @@ pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
     }
 }
 
+/* Special val_print routine to avoid printing multiple copies of virtual
+   baseclasses.  */
+
+static void
+pascal_object_print_value (struct value *val, struct ui_file *stream,
+			   int recurse,
+			   const struct value_print_options *options,
+			   struct type **dont_print_vb)
+{
+  struct type **last_dont_print
+    = (struct type **) obstack_next_free (&dont_print_vb_obstack);
+  struct obstack tmp_obstack = dont_print_vb_obstack;
+  struct type *type = check_typedef (value_type (val));
+  int i, n_baseclasses = TYPE_N_BASECLASSES (type);
+
+  if (dont_print_vb == 0)
+    {
+      /* If we're at top level, carve out a completely fresh
+         chunk of the obstack and use that until this particular
+         invocation returns.  */
+      /* Bump up the high-water mark.  Now alpha is omega.  */
+      obstack_finish (&dont_print_vb_obstack);
+    }
+
+  for (i = 0; i < n_baseclasses; i++)
+    {
+      LONGEST boffset = 0;
+      struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
+      const char *basename = TYPE_NAME (baseclass);
+      int skip = 0;
+
+      if (BASETYPE_VIA_VIRTUAL (type, i))
+	{
+	  struct type **first_dont_print
+	    = (struct type **) obstack_base (&dont_print_vb_obstack);
+
+	  int j = (struct type **) obstack_next_free (&dont_print_vb_obstack)
+	    - first_dont_print;
+
+	  while (--j >= 0)
+	    if (baseclass == first_dont_print[j])
+	      goto flush_it;
+
+	  obstack_ptr_grow (&dont_print_vb_obstack, baseclass);
+	}
+
+      struct value *base_value;
+      try
+	{
+	  base_value = value_primitive_field (val, 0, i, type);
+	}
+      catch (const gdb_exception_error &ex)
+	{
+	  if (ex.error == NOT_AVAILABLE_ERROR)
+	    skip = -1;
+	  else
+	    skip = 1;
+	}
+
+      if (skip == 0)
+	{
+	  /* The virtual base class pointer might have been clobbered by the
+	     user program. Make sure that it still points to a valid memory
+	     location.  */
+
+	  if (boffset < 0 || boffset >= TYPE_LENGTH (type))
+	    {
+	      CORE_ADDR address= value_address (val);
+	      gdb::byte_vector buf (TYPE_LENGTH (baseclass));
+
+	      if (target_read_memory (address + boffset, buf.data (),
+				      TYPE_LENGTH (baseclass)) != 0)
+		skip = 1;
+	      base_value = value_from_contents_and_address (baseclass,
+							    buf.data (),
+							    address + boffset);
+	      baseclass = value_type (base_value);
+	      boffset = 0;
+	    }
+	}
+
+      if (options->prettyformat)
+	{
+	  fprintf_filtered (stream, "\n");
+	  print_spaces_filtered (2 * recurse, stream);
+	}
+      fputs_filtered ("<", stream);
+      /* Not sure what the best notation is in the case where there is no
+         baseclass name.  */
+
+      fputs_filtered (basename ? basename : "", stream);
+      fputs_filtered ("> = ", stream);
+
+      if (skip < 0)
+	val_print_unavailable (stream);
+      else if (skip > 0)
+	val_print_invalid_address (stream);
+      else
+	pascal_object_print_value_fields
+	  (base_value, stream, recurse, options,
+	   (struct type **) obstack_base (&dont_print_vb_obstack),
+	   0);
+      fputs_filtered (", ", stream);
+
+    flush_it:
+      ;
+    }
+
+  if (dont_print_vb == 0)
+    {
+      /* Free the space used to deal with the printing
+         of this type from top level.  */
+      obstack_free (&dont_print_vb_obstack, last_dont_print);
+      /* Reset watermark so that we can continue protecting
+         ourselves from whatever we were protecting ourselves.  */
+      dont_print_vb_obstack = tmp_obstack;
+    }
+}
+
 /* Print value of a static member.
    To avoid infinite recursion when printing a class that contains
    a static instance of the class, we keep the addresses of all printed
-- 
2.17.2

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

* [PATCH 12/55] Introduce value_print_scalar_formatted
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (32 preceding siblings ...)
  2019-12-08 18:32 ` [PATCH 43/55] Introduce c_value_print_array Tom Tromey
@ 2019-12-08 18:32 ` Tom Tromey
  2020-01-15  5:15   ` Simon Marchi
  2019-12-08 18:32 ` [PATCH 23/55] Convert Go printing to value-based API Tom Tromey
                   ` (21 subsequent siblings)
  55 siblings, 1 reply; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces a value_print_scalar_formatted, which is an analogue
of val_print_scalar_formatted that uses the value API.

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

	* valprint.h (value_print_scalar_formatted): Declare.
	* valprint.c (value_print_scalar_formatted): New function.

Change-Id: Ie2b9ee80d53af8a99116b4b7a93dc16f420fb404
---
 gdb/ChangeLog  |  5 +++++
 gdb/valprint.c | 40 ++++++++++++++++++++++++++++++++++++++++
 gdb/valprint.h | 10 ++++++++++
 3 files changed, 55 insertions(+)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 0e13e2b2d62..d09a42926e2 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1365,6 +1365,46 @@ val_print_scalar_formatted (struct type *type,
 			    options, size, stream);
 }
 
+/* See valprint.h.  */
+
+void
+value_print_scalar_formatted (struct value *val,
+			      const struct value_print_options *options,
+			      int size,
+			      struct ui_file *stream)
+{
+  struct type *type = check_typedef (value_type (val));
+
+  gdb_assert (val != NULL);
+
+  /* If we get here with a string format, try again without it.  Go
+     all the way back to the language printers, which may call us
+     again.  */
+  if (options->format == 's')
+    {
+      struct value_print_options opts = *options;
+      opts.format = 0;
+      opts.deref_ref = 0;
+      common_val_print (val, stream, 0, &opts, current_language);
+      return;
+    }
+
+  /* value_contents_for_printing fetches all VAL's contents.  They are
+     needed to check whether VAL is optimized-out or unavailable
+     below.  */
+  const gdb_byte *valaddr = value_contents_for_printing (val);
+
+  /* A scalar object that does not have all bits available can't be
+     printed, because all bits contribute to its representation.  */
+  if (value_bits_any_optimized_out (val, 0,
+				    TARGET_CHAR_BIT * TYPE_LENGTH (type)))
+    val_print_optimized_out (val, stream);
+  else if (!value_bytes_available (val, 0, TYPE_LENGTH (type)))
+    val_print_unavailable (stream);
+  else
+    print_scalar_formatted (valaddr, type, options, size, stream);
+}
+
 /* Print a number according to FORMAT which is one of d,u,x,o,b,h,w,g.
    The raison d'etre of this function is to consolidate printing of 
    LONG_LONG's into this one function.  The format chars b,h,w,g are 
diff --git a/gdb/valprint.h b/gdb/valprint.h
index e4b90404fa2..f1c93aa26b6 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -141,6 +141,16 @@ extern void val_print_scalar_formatted (struct type *,
 					int,
 					struct ui_file *);
 
+/* Print a scalar according to OPTIONS and SIZE on STREAM.  Format i
+   is not supported at this level.
+
+   This is how the elements of an array or structure are printed
+   with a format.  */
+
+extern void value_print_scalar_formatted (struct value *,
+					  const struct value_print_options *,
+					  int, struct ui_file *);
+
 extern void print_binary_chars (struct ui_file *, const gdb_byte *,
 				unsigned int, enum bfd_endian, bool);
 
-- 
2.17.2

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

* [PATCH 39/55] Rewrite c_value_print_inner
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (40 preceding siblings ...)
  2019-12-08 18:32 ` [PATCH 15/55] Simplify c_val_print_array Tom Tromey
@ 2019-12-08 18:32 ` Tom Tromey
  2019-12-08 18:32 ` [PATCH 54/55] Change extension language pretty-printers to use value API Tom Tromey
                   ` (13 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This rewrites c_value_print_inner, copying in the body of
c_val_print_inner and adusting as needed.  This will form the base of
future changes to fully convert this to using the value-based API

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

	* c-valprint.c (c_value_print_inner): Rewrite.

Change-Id: I128fdc78f22c8014e402f9cacb623216a3b0e4db
---
 gdb/ChangeLog    |  4 +++
 gdb/c-valprint.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 410771b03d7..af7a386fb78 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -564,8 +564,67 @@ void
 c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
 		     const struct value_print_options *options)
 {
-  c_val_print (value_type (val), value_embedded_offset (val),
-	       value_address (val), stream, recurse, val, options);
+  struct type *type = value_type (val);
+  struct type *unresolved_type = type;
+  CORE_ADDR address = value_address (val);
+  const gdb_byte *valaddr = value_contents_for_printing (val);
+
+  type = check_typedef (type);
+  switch (TYPE_CODE (type))
+    {
+    case TYPE_CODE_ARRAY:
+      c_val_print_array (type, valaddr, 0, address, stream,
+			 recurse, val, options);
+      break;
+
+    case TYPE_CODE_METHODPTR:
+      cplus_print_method_ptr (valaddr, type, stream);
+      break;
+
+    case TYPE_CODE_PTR:
+      c_val_print_ptr (type, valaddr, 0, stream, recurse,
+		       val, options);
+      break;
+
+    case TYPE_CODE_UNION:
+      c_val_print_union (type, valaddr, 0, address, stream,
+			 recurse, val, options);
+      break;
+
+    case TYPE_CODE_STRUCT:
+      c_val_print_struct (type, valaddr, 0, address, stream,
+			  recurse, val, options);
+      break;
+
+    case TYPE_CODE_INT:
+      c_val_print_int (type, unresolved_type, valaddr, 0, stream,
+		       val, options);
+      break;
+
+    case TYPE_CODE_MEMBERPTR:
+      c_val_print_memberptr (type, valaddr, 0, address, stream,
+			     recurse, val, options);
+      break;
+
+    case TYPE_CODE_REF:
+    case TYPE_CODE_RVALUE_REF:
+    case TYPE_CODE_ENUM:
+    case TYPE_CODE_FLAGS:
+    case TYPE_CODE_FUNC:
+    case TYPE_CODE_METHOD:
+    case TYPE_CODE_BOOL:
+    case TYPE_CODE_RANGE:
+    case TYPE_CODE_FLT:
+    case TYPE_CODE_DECFLOAT:
+    case TYPE_CODE_VOID:
+    case TYPE_CODE_ERROR:
+    case TYPE_CODE_UNDEF:
+    case TYPE_CODE_COMPLEX:
+    case TYPE_CODE_CHAR:
+    default:
+      generic_value_print (val, stream, recurse, options, &c_decorations);
+      break;
+    }
 }
 
 \f
-- 
2.17.2

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

* [PATCH 44/55] Introduce cp_print_value_fields and c_value_print_struct
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (35 preceding siblings ...)
  2019-12-08 18:32 ` [PATCH 27/55] Rewrite pascal_value_print_inner Tom Tromey
@ 2019-12-08 18:32 ` Tom Tromey
  2020-01-15  6:15   ` Simon Marchi
  2019-12-08 18:32 ` [PATCH 08/55] Use common_val_print in cp-valprint.c Tom Tromey
                   ` (18 subsequent siblings)
  55 siblings, 1 reply; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds cp_print_value_fields and c_value_print_struct, value-based
analogues of the corresponding val-printing functions.  Note that the
Modula-2 printing code also calls cp_print_val_fields, and so is
updated to call the function function.

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

	* m2-valprint.c (m2_value_print_inner): Use
	cp_print_value_fields.
	* cp-valprint.c	(cp_print_value_fields): New function.
	* c-valprint.c (c_value_print_struct): New function.
	(c_value_print_inner): Use c_value_print_struct.
	* c-lang.h (cp_print_value_fields): Declare.

Change-Id: Iac162891972988b968a736ba14720a4a4acbf92e
---
 gdb/ChangeLog     |   9 ++
 gdb/c-lang.h      |   5 +
 gdb/c-valprint.c  |  36 ++++--
 gdb/cp-valprint.c | 275 ++++++++++++++++++++++++++++++++++++++++++++++
 gdb/m2-valprint.c |   4 +-
 5 files changed, 319 insertions(+), 10 deletions(-)

diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 8523a0b68c5..96244531149 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -135,6 +135,11 @@ extern void c_type_print_base (struct type *, struct ui_file *,
 extern void cp_print_class_member (const gdb_byte *, struct type *,
 				   struct ui_file *, const char *);
 
+extern void cp_print_value_fields (struct value *,
+				   struct ui_file *, int,
+				   const struct value_print_options *,
+				   struct type **, int);
+
 extern void cp_print_value_fields (struct type *, struct type *,
 				   LONGEST, CORE_ADDR,
 				   struct ui_file *, int,
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index eaf7ef2eafe..8637ba976af 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -540,6 +540,34 @@ c_val_print_struct (struct type *type, const gdb_byte *valaddr,
 				NULL, 0);
 }
 
+/* c_value_print helper for TYPE_CODE_STRUCT and TYPE_CODE_UNION.  */
+
+static void
+c_value_print_struct (struct value *val, struct ui_file *stream, int recurse,
+		      const struct value_print_options *options)
+{
+  struct type *type = check_typedef (value_type (val));
+
+  if (TYPE_CODE (type) == TYPE_CODE_UNION && recurse && !options->unionprint)
+    fprintf_filtered (stream, "{...}");
+  else if (options->vtblprint && cp_is_vtbl_ptr_type (type))
+    {
+      /* Print the unmangled name if desired.  */
+      /* Print vtable entry - we only get here if NOT using
+	 -fvtable_thunks.  (Otherwise, look under
+	 TYPE_CODE_PTR.)  */
+      struct gdbarch *gdbarch = get_type_arch (type);
+      int offset = TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8;
+      struct type *field_type = TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET);
+      const gdb_byte *valaddr = value_contents_for_printing (val);
+      CORE_ADDR addr = extract_typed_address (valaddr + offset, field_type);
+
+      print_function_pointer_address (options, gdbarch, addr, stream);
+    }
+  else
+    cp_print_value_fields (val, stream, recurse, options, NULL, 0);
+}
+
 /* c_val_print helper for TYPE_CODE_UNION.  */
 
 static void
@@ -746,7 +774,6 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
 		     const struct value_print_options *options)
 {
   struct type *type = value_type (val);
-  CORE_ADDR address = value_address (val);
   const gdb_byte *valaddr = value_contents_for_printing (val);
 
   type = check_typedef (type);
@@ -765,13 +792,8 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_UNION:
-      c_val_print_union (type, valaddr, 0, address, stream,
-			 recurse, val, options);
-      break;
-
     case TYPE_CODE_STRUCT:
-      c_val_print_struct (type, valaddr, 0, address, stream,
-			  recurse, val, options);
+      c_value_print_struct (val, stream, recurse, options);
       break;
 
     case TYPE_CODE_INT:
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 9a26ab322a4..77dbaae891f 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -324,6 +324,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 		    {
 		      CORE_ADDR addr;
 		      
+		      i_offset += value_embedded_offset (val);
 		      addr = extract_typed_address (valaddr + i_offset, i_type);
 		      print_function_pointer_address (opts,
 						      get_type_arch (type),
@@ -385,6 +386,280 @@ cp_print_value_fields (struct type *type, struct type *real_type,
   fprintf_filtered (stream, "}");
 }
 
+/* Mutually recursive subroutines of cp_print_value and c_val_print to
+   print out a structure's fields: cp_print_value_fields and
+   cp_print_value.
+
+   TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the same
+   meanings as in cp_print_value and c_val_print.
+
+   2nd argument REAL_TYPE is used to carry over the type of the
+   derived class across the recursion to base classes.
+
+   DONT_PRINT is an array of baseclass types that we should not print,
+   or zero if called from top level.  */
+
+void
+cp_print_value_fields (struct value *val, struct ui_file *stream,
+		       int recurse, const struct value_print_options *options,
+		       struct type **dont_print_vb,
+		       int dont_print_statmem)
+{
+  int i, len, n_baseclasses;
+  int fields_seen = 0;
+  static int last_set_recurse = -1;
+
+  struct type *type = check_typedef (value_type (val));
+  CORE_ADDR address = value_address (val);
+  
+  if (recurse == 0)
+    {
+      /* Any object can be left on obstacks only during an unexpected
+	 error.  */
+
+      if (obstack_object_size (&dont_print_statmem_obstack) > 0)
+	{
+	  obstack_free (&dont_print_statmem_obstack, NULL);
+	  obstack_begin (&dont_print_statmem_obstack,
+			 32 * sizeof (CORE_ADDR));
+	}
+      if (obstack_object_size (&dont_print_stat_array_obstack) > 0)
+	{
+	  obstack_free (&dont_print_stat_array_obstack, NULL);
+	  obstack_begin (&dont_print_stat_array_obstack,
+			 32 * sizeof (struct type *));
+	}
+    }
+
+  fprintf_filtered (stream, "{");
+  len = TYPE_NFIELDS (type);
+  n_baseclasses = TYPE_N_BASECLASSES (type);
+
+  /* First, print out baseclasses such that we don't print
+     duplicates of virtual baseclasses.  */
+
+  if (n_baseclasses > 0)
+    cp_print_value (type, type, 0, address, stream,
+		    recurse + 1, val, options,
+		    dont_print_vb);
+
+  /* Second, print out data fields */
+
+  /* If there are no data fields, skip this part */
+  if (len == n_baseclasses || !len)
+    fprintf_styled (stream, metadata_style.style (), "<No data fields>");
+  else
+    {
+      size_t statmem_obstack_initial_size = 0;
+      size_t stat_array_obstack_initial_size = 0;
+      struct type *vptr_basetype = NULL;
+      int vptr_fieldno;
+
+      if (dont_print_statmem == 0)
+	{
+	  statmem_obstack_initial_size =
+	    obstack_object_size (&dont_print_statmem_obstack);
+
+	  if (last_set_recurse != recurse)
+	    {
+	      stat_array_obstack_initial_size =
+		obstack_object_size (&dont_print_stat_array_obstack);
+
+	      last_set_recurse = recurse;
+	    }
+	}
+
+      vptr_fieldno = get_vptr_fieldno (type, &vptr_basetype);
+      for (i = n_baseclasses; i < len; i++)
+	{
+	  const gdb_byte *valaddr = value_contents_for_printing (val);
+
+	  /* If requested, skip printing of static fields.  */
+	  if (!options->static_field_print
+	      && field_is_static (&TYPE_FIELD (type, i)))
+	    continue;
+
+	  if (fields_seen)
+	    {
+	      fputs_filtered (",", stream);
+	      if (!options->prettyformat)
+		fputs_filtered (" ", stream);
+	    }
+	  else if (n_baseclasses > 0)
+	    {
+	      if (options->prettyformat)
+		{
+		  fprintf_filtered (stream, "\n");
+		  print_spaces_filtered (2 + 2 * recurse, stream);
+		  fputs_filtered ("members of ", stream);
+		  fputs_filtered (TYPE_NAME (type), stream);
+		  fputs_filtered (":", stream);
+		}
+	    }
+	  fields_seen = 1;
+
+	  if (options->prettyformat)
+	    {
+	      fprintf_filtered (stream, "\n");
+	      print_spaces_filtered (2 + 2 * recurse, stream);
+	    }
+	  else
+	    {
+	      wrap_here (n_spaces (2 + 2 * recurse));
+	    }
+
+	  annotate_field_begin (TYPE_FIELD_TYPE (type, i));
+
+	  if (field_is_static (&TYPE_FIELD (type, i)))
+	    fputs_filtered ("static ", stream);
+	  fprintf_symbol_filtered (stream,
+				   TYPE_FIELD_NAME (type, i),
+				   current_language->la_language,
+				   DMGL_PARAMS | DMGL_ANSI);
+	  annotate_field_name_end ();
+
+	  /* We tweak various options in a few cases below.  */
+	  value_print_options options_copy = *options;
+	  value_print_options *opts = &options_copy;
+
+	  /* Do not print leading '=' in case of anonymous
+	     unions.  */
+	  if (strcmp (TYPE_FIELD_NAME (type, i), ""))
+	    fputs_filtered (" = ", stream);
+	  else
+	    {
+	      /* If this is an anonymous field then we want to consider it
+		 as though it is at its parent's depth when it comes to the
+		 max print depth.  */
+	      if (opts->max_depth != -1 && opts->max_depth < INT_MAX)
+		++opts->max_depth;
+	    }
+	  annotate_field_value ();
+
+	  if (!field_is_static (&TYPE_FIELD (type, i))
+	      && TYPE_FIELD_PACKED (type, i))
+	    {
+	      struct value *v;
+
+	      /* Bitfields require special handling, especially due to
+	         byte order problems.  */
+	      if (TYPE_FIELD_IGNORE (type, i))
+		{
+		  fputs_styled ("<optimized out or zero length>",
+				metadata_style.style (), stream);
+		}
+	      else if (value_bits_synthetic_pointer (val,
+						     TYPE_FIELD_BITPOS (type,
+									i),
+						     TYPE_FIELD_BITSIZE (type,
+									 i)))
+		{
+		  fputs_styled (_("<synthetic pointer>"),
+				metadata_style.style (), stream);
+		}
+	      else
+		{
+		  opts->deref_ref = 0;
+
+		  v = value_field_bitfield (type, i, valaddr,
+					    value_embedded_offset (val), val);
+
+		  common_val_print (v, stream, recurse + 1,
+				    opts, current_language);
+		}
+	    }
+	  else
+	    {
+	      if (TYPE_FIELD_IGNORE (type, i))
+		{
+		  fputs_styled ("<optimized out or zero length>",
+				metadata_style.style (), stream);
+		}
+	      else if (field_is_static (&TYPE_FIELD (type, i)))
+		{
+		  try
+		    {
+		      struct value *v = value_static_field (type, i);
+
+		      cp_print_static_field (TYPE_FIELD_TYPE (type, i),
+					     v, stream, recurse + 1,
+					     opts);
+		    }
+		  catch (const gdb_exception_error &ex)
+		    {
+		      fprintf_styled (stream, metadata_style.style (),
+				      _("<error reading variable: %s>"),
+				      ex.what ());
+		    }
+		}
+	      else if (i == vptr_fieldno && type == vptr_basetype)
+		{
+		  int i_offset = TYPE_FIELD_BITPOS (type, i) / 8;
+		  struct type *i_type = TYPE_FIELD_TYPE (type, i);
+
+		  if (valprint_check_validity (stream, i_type, i_offset, val))
+		    {
+		      CORE_ADDR addr;
+		      
+		      addr = extract_typed_address (valaddr + i_offset, i_type);
+		      print_function_pointer_address (opts,
+						      get_type_arch (type),
+						      addr, stream);
+		    }
+		}
+	      else
+		{
+		  struct value *v = value_primitive_field (val, 0, i, type);
+		  opts->deref_ref = 0;
+		  common_val_print (v, stream, recurse + 1, opts,
+				    current_language);
+		}
+	    }
+	  annotate_field_end ();
+	}
+
+      if (dont_print_statmem == 0)
+	{
+	  size_t obstack_final_size =
+           obstack_object_size (&dont_print_statmem_obstack);
+
+	  if (obstack_final_size > statmem_obstack_initial_size)
+	    {
+	      /* In effect, a pop of the printed-statics stack.  */
+	      size_t shrink_bytes
+		= statmem_obstack_initial_size - obstack_final_size;
+	      obstack_blank_fast (&dont_print_statmem_obstack, shrink_bytes);
+	    }
+
+	  if (last_set_recurse != recurse)
+	    {
+	      obstack_final_size =
+		obstack_object_size (&dont_print_stat_array_obstack);
+	      
+	      if (obstack_final_size > stat_array_obstack_initial_size)
+		{
+		  void *free_to_ptr =
+		    (char *) obstack_next_free (&dont_print_stat_array_obstack)
+		    - (obstack_final_size
+		       - stat_array_obstack_initial_size);
+
+		  obstack_free (&dont_print_stat_array_obstack,
+				free_to_ptr);
+		}
+	      last_set_recurse = -1;
+	    }
+	}
+
+      if (options->prettyformat)
+	{
+	  fprintf_filtered (stream, "\n");
+	  print_spaces_filtered (2 * recurse, stream);
+	}
+    }				/* if there are data fields */
+
+  fprintf_filtered (stream, "}");
+}
+
 /* Like cp_print_value_fields, but find the runtime type of the object
    and pass it as the `real_type' argument to cp_print_value_fields.
    This function is a hack to work around the fact that
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index 12f62ad1e83..1f3907c41ab 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -605,9 +605,7 @@ m2_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
       else if (m2_is_unbounded_array (type))
 	m2_print_unbounded_array (val, stream, recurse, options);
       else
-	cp_print_value_fields (type, type, 0,
-			       address, stream, recurse, val,
-			       options, NULL, 0);
+	cp_print_value_fields (val, stream, recurse, options, NULL, 0);
       break;
 
     case TYPE_CODE_SET:
-- 
2.17.2

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

* [PATCH 55/55] Remove val_print
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (43 preceding siblings ...)
  2019-12-08 18:32 ` [PATCH 51/55] Convert ada_value_print to value-based API Tom Tromey
@ 2019-12-08 18:50 ` Tom Tromey
  2019-12-08 18:51 ` [PATCH 53/55] Change print_field_values to use value-based API Tom Tromey
                   ` (10 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:50 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

We can finally remove val_print and various helper functions that are
no longer needed.

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

	* value.h (val_print): Don't declare.
	* valprint.h (val_print_array_elements)
	(val_print_scalar_formatted, generic_val_print): Don't declare.
	* valprint.c (generic_val_print_array): Take a struct value.
	(generic_val_print_ptr, generic_val_print_memberptr)
	(generic_val_print_bool, generic_val_print_int)
	(generic_val_print_char, generic_val_print_complex)
	(generic_val_print): Remove.
	(generic_value_print): Update.
	(do_val_print): Remove unused parameters.  Don't call
	la_val_print.
	(val_print): Remove.
	(common_val_print): Update.  Don't call value_check_printable.
	(val_print_scalar_formatted, val_print_array_elements): Remove.
	* rust-lang.c (rust_val_print): Remove.
	(rust_language_defn): Update.
	* p-valprint.c (pascal_val_print): Remove.
	(pascal_value_print_inner): Update.
	(pascal_object_print_val_fields, pascal_object_print_val):
	Remove.
	(pascal_object_print_static_field): Update.
	* p-lang.h (pascal_val_print): Don't declare.
	* p-lang.c (pascal_language_defn): Update.
	* opencl-lang.c (opencl_language_defn): Update.
	* objc-lang.c (objc_language_defn): Update.
	* m2-valprint.c (m2_print_unbounded_array, m2_val_print): Remove.
	* m2-lang.h (m2_val_print): Don't declare.
	* m2-lang.c (m2_language_defn): Update.
	* language.h (struct language_defn) <la_val_print>: Remove.
	* language.c (unk_lang_value_print_inner): Rename.  Change
	argument types.
	(unknown_language_defn, auto_language_defn): Update.
	* go-valprint.c (go_val_print): Remove.
	* go-lang.h (go_val_print): Don't declare.
	* go-lang.c (go_language_defn): Update.
	* f-valprint.c (f_val_print): Remove.
	* f-lang.h (f_value_print): Don't declare.
	* f-lang.c (f_language_defn): Update.
	* d-valprint.c (d_val_print): Remove.
	* d-lang.h (d_value_print): Don't declare.
	* d-lang.c (d_language_defn): Update.
	* cp-valprint.c (cp_print_value_fields)
	(cp_print_value_fields_rtti, cp_print_value): Remove.
	(cp_print_static_field): Update.
	* c-valprint.c (c_val_print_array, c_val_print_ptr)
	(c_val_print_struct, c_val_print_union, c_val_print_int)
	(c_val_print_memberptr, c_val_print): Remove.
	* c-lang.h (c_val_print_array, cp_print_value_fields)
	(cp_print_value_fields_rtti): Don't declare.
	* c-lang.c (c_language_defn, cplus_language_defn)
	(asm_language_defn, minimal_language_defn): Update.
	* ada-valprint.c (ada_val_print_ptr, ada_val_print_num): Remove.
	(ada_val_print_enum): Take a struct value.
	(ada_val_print_flt, ada_val_print_array, ada_val_print_1)
	(ada_val_print): Remove.
	(ada_value_print_1): Update.
	(printable_val_type): Remove.
	* ada-lang.h (ada_val_print): Don't declare.
	* ada-lang.c (ada_language_defn): Update.

Change-Id: Ice0103a8cc363bb7a1021b927ef4c7a4e9c2985d
---
 gdb/ChangeLog      |  62 ++++
 gdb/ada-lang.c     |   1 -
 gdb/ada-lang.h     |   5 -
 gdb/ada-valprint.c | 309 +----------------
 gdb/c-lang.c       |   4 -
 gdb/c-lang.h       |  20 --
 gdb/c-valprint.c   | 330 ------------------
 gdb/cp-valprint.c  | 512 +--------------------------
 gdb/d-lang.c       |   1 -
 gdb/d-lang.h       |   8 -
 gdb/d-valprint.c   |  24 --
 gdb/f-lang.c       |   1 -
 gdb/f-lang.h       |   5 -
 gdb/f-valprint.c   | 162 ---------
 gdb/go-lang.c      |   1 -
 gdb/go-lang.h      |   8 -
 gdb/go-valprint.c  |  39 ---
 gdb/language.c     |  16 +-
 gdb/language.h     |  24 --
 gdb/m2-lang.c      |   1 -
 gdb/m2-lang.h      |   5 -
 gdb/m2-valprint.c  | 223 ------------
 gdb/objc-lang.c    |   1 -
 gdb/opencl-lang.c  |   1 -
 gdb/p-lang.c       |   1 -
 gdb/p-lang.h       |   5 -
 gdb/p-valprint.c   | 849 +++++----------------------------------------
 gdb/rust-lang.c    |  13 -
 gdb/valprint.c     | 566 +-----------------------------
 gdb/valprint.h     |  19 -
 gdb/value.h        |   7 -
 31 files changed, 169 insertions(+), 3054 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 42ebf31954a..932a1f98f28 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -14113,7 +14113,6 @@ extern const struct language_defn ada_language_defn = {
   emit_char,                    /* Function to print single char (not used) */
   ada_print_type,               /* Print a type using appropriate syntax */
   ada_print_typedef,            /* Print a typedef using appropriate syntax */
-  ada_val_print,                /* Print a value using appropriate syntax */
   ada_value_print_inner,	/* la_value_print_inner */
   ada_value_print,              /* Print a top-level value */
   ada_read_var_value,		/* la_read_var_value */
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index f9994340a68..00672807829 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -164,11 +164,6 @@ extern void ada_print_type (struct type *, const char *, struct ui_file *, int,
 extern void ada_print_typedef (struct type *type, struct symbol *new_symbol,
 			       struct ui_file *stream);
 
-extern void ada_val_print (struct type *, int, CORE_ADDR,
-			   struct ui_file *, int,
-			   struct value *,
-			   const struct value_print_options *);
-
 /* Implement la_value_print_inner for Ada.  */
 
 extern void ada_value_print_inner (struct value *, struct ui_file *, int,
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 6f69b633bd8..19e08b4ca38 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -274,12 +274,6 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
   value_free_to_mark (mark);
 }
 
-static struct type *
-printable_val_type (struct type *type, const gdb_byte *valaddr)
-{
-  return ada_to_fixed_type (ada_aligned_type (type), valaddr, 0, NULL, 1);
-}
-
 /* Print the character C on STREAM as part of the contents of a literal
    string whose delimiter is QUOTER.  TYPE_LEN is the length in bytes
    of the character.  */
@@ -781,32 +775,6 @@ ada_val_print_gnat_array (struct value *val,
 		      language_def (language_ada));
 }
 
-/* Implement Ada val_print'ing for the case where TYPE is
-   a TYPE_CODE_PTR.  */
-
-static void
-ada_val_print_ptr (struct type *type, const gdb_byte *valaddr,
-		   int offset, int offset_aligned, CORE_ADDR address,
-		   struct ui_file *stream, int recurse,
-		   struct value *original_value,
-		   const struct value_print_options *options)
-{
-  val_print (type, offset, address, stream, recurse,
-	     original_value, options, language_def (language_c));
-
-  if (ada_is_tag_type (type))
-    {
-      struct value *val =
-	value_from_contents_and_address (type,
-					 valaddr + offset_aligned,
-					 address + offset_aligned);
-      const char *name = ada_tag_name (val);
-
-      if (name != NULL)
-	fprintf_filtered (stream, " (%s)", name);
-    }
-}
-
 /* Implement Ada value_print'ing for the case where TYPE is a
    TYPE_CODE_PTR.  */
 
@@ -827,109 +795,6 @@ ada_value_print_ptr (struct value *val,
     }
 }
 
-/* Implement Ada val_print'ing for the case where TYPE is
-   a TYPE_CODE_INT or TYPE_CODE_RANGE.  */
-
-static void
-ada_val_print_num (struct type *type, const gdb_byte *valaddr,
-		   int offset, int offset_aligned, CORE_ADDR address,
-		   struct ui_file *stream, int recurse,
-		   struct value *original_value,
-		   const struct value_print_options *options)
-{
-  if (ada_is_fixed_point_type (type))
-    {
-      struct value *scale = ada_scaling_factor (type);
-      struct value *v = value_from_contents (type, valaddr + offset_aligned);
-      v = value_cast (value_type (scale), v);
-      v = value_binop (v, scale, BINOP_MUL);
-
-      const char *fmt = TYPE_LENGTH (type) < 4 ? "%.11g" : "%.17g";
-      std::string str
-	= target_float_to_string (value_contents (v), value_type (v), fmt);
-      fputs_filtered (str.c_str (), stream);
-      return;
-    }
-  else if (TYPE_CODE (type) == TYPE_CODE_RANGE
-	   && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ENUM
-	       || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_BOOL
-	       || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CHAR))
-    {
-      /* For enum-valued ranges, we want to recurse, because we'll end
-	 up printing the constant's name rather than its numeric
-	 value.  Character and fixed-point types are also printed
-	 differently, so recuse for those as well.  */
-      struct type *target_type = TYPE_TARGET_TYPE (type);
-
-      if (TYPE_LENGTH (type) != TYPE_LENGTH (target_type))
-	{
-	  /* Obscure case of range type that has different length from
-	     its base type.  Perform a conversion, or we will get a
-	     nonsense value.  Actually, we could use the same
-	     code regardless of lengths; I'm just avoiding a cast.  */
-	  struct value *v1
-	    = value_from_contents_and_address (type, valaddr + offset, 0);
-	  struct value *v = value_cast (target_type, v1);
-
-	  val_print (target_type,
-		     value_embedded_offset (v), 0, stream,
-		     recurse + 1, v, options,
-		     language_def (language_ada));
-	}
-      else
-	val_print (TYPE_TARGET_TYPE (type), offset,
-		   address, stream, recurse, original_value,
-		   options, language_def (language_ada));
-      return;
-    }
-  else
-    {
-      int format = (options->format ? options->format
-		    : options->output_format);
-
-      if (format)
-	{
-	  struct value_print_options opts = *options;
-
-	  opts.format = format;
-	  val_print_scalar_formatted (type, offset_aligned,
-				      original_value, &opts, 0, stream);
-	}
-      else if (ada_is_system_address_type (type))
-	{
-	  /* FIXME: We want to print System.Address variables using
-	     the same format as for any access type.  But for some
-	     reason GNAT encodes the System.Address type as an int,
-	     so we have to work-around this deficiency by handling
-	     System.Address values as a special case.  */
-
-	  struct gdbarch *gdbarch = get_type_arch (type);
-	  struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
-	  CORE_ADDR addr = extract_typed_address (valaddr + offset_aligned,
-						  ptr_type);
-
-	  fprintf_filtered (stream, "(");
-	  type_print (type, "", stream, -1);
-	  fprintf_filtered (stream, ") ");
-	  fputs_filtered (paddress (gdbarch, addr), stream);
-	}
-      else
-	{
-	  val_print_scalar_formatted (type, offset_aligned,
-				      original_value, options, 0, stream);
-	  if (ada_is_character_type (type))
-	    {
-	      LONGEST c;
-
-	      fputs_filtered (" ", stream);
-	      c = unpack_long (type, valaddr + offset_aligned);
-	      ada_printchar (c, type, stream);
-	    }
-	}
-      return;
-    }
-}
-
 /* Implement Ada val_print'ing for the case where TYPE is
    a TYPE_CODE_INT or TYPE_CODE_RANGE.  */
 
@@ -1016,10 +881,7 @@ ada_value_print_num (struct value *val, struct ui_file *stream, int recurse,
    a TYPE_CODE_ENUM.  */
 
 static void
-ada_val_print_enum (struct type *type, const gdb_byte *valaddr,
-		    int offset, int offset_aligned, CORE_ADDR address,
-		    struct ui_file *stream, int recurse,
-		    struct value *original_value,
+ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse,
 		    const struct value_print_options *options)
 {
   int i;
@@ -1028,11 +890,14 @@ ada_val_print_enum (struct type *type, const gdb_byte *valaddr,
 
   if (options->format)
     {
-      val_print_scalar_formatted (type, offset_aligned,
-				  original_value, options, 0, stream);
+      value_print_scalar_formatted (value, options, 0, stream);
       return;
     }
 
+  struct type *type = ada_check_typedef (value_type (value));
+  const gdb_byte *valaddr = value_contents_for_printing (value);
+  int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr;
+
   len = TYPE_NFIELDS (type);
   val = unpack_long (type, valaddr + offset_aligned);
   for (i = 0; i < len; i++)
@@ -1055,26 +920,6 @@ ada_val_print_enum (struct type *type, const gdb_byte *valaddr,
     print_longest (stream, 'd', 0, val);
 }
 
-/* Implement Ada val_print'ing for the case where TYPE is
-   a TYPE_CODE_FLT.  */
-
-static void
-ada_val_print_flt (struct type *type, const gdb_byte *valaddr,
-		   int offset, int offset_aligned, CORE_ADDR address,
-		   struct ui_file *stream, int recurse,
-		   struct value *original_value,
-		   const struct value_print_options *options)
-{
-  if (options->format)
-    {
-      val_print (type, offset, address, stream, recurse,
-		 original_value, options, language_def (language_c));
-      return;
-    }
-
-  ada_print_floating (valaddr + offset, type, stream);
-}
-
 /* Implement Ada val_print'ing for the case where TYPE is
    a TYPE_CODE_STRUCT or TYPE_CODE_UNION.  */
 
@@ -1106,37 +951,6 @@ ada_val_print_struct_union
   fprintf_filtered (stream, ")");
 }
 
-/* Implement Ada val_print'ing for the case where TYPE is
-   a TYPE_CODE_ARRAY.  */
-
-static void
-ada_val_print_array (struct type *type, const gdb_byte *valaddr,
-		     int offset, int offset_aligned, CORE_ADDR address,
-		     struct ui_file *stream, int recurse,
-		     struct value *original_value,
-		     const struct value_print_options *options)
-{
-  /* For an array of characters, print with string syntax.  */
-  if (ada_is_string_type (type)
-      && (options->format == 0 || options->format == 's'))
-    {
-      ada_val_print_string (type, valaddr, offset_aligned,
-			    stream, recurse, options);
-      return;
-    }
-
-  fprintf_filtered (stream, "(");
-  print_optional_low_bound (stream, type, options);
-  if (TYPE_FIELD_BITSIZE (type, 0) > 0)
-    val_print_packed_array_elements (type, valaddr, offset_aligned,
-				     stream, recurse, options);
-  else
-    val_print_array_elements (type, offset_aligned, address,
-			      stream, recurse, original_value,
-			      options, 0);
-  fprintf_filtered (stream, ")");
-}
-
 /* Implement Ada value_print'ing for the case where TYPE is a
    TYPE_CODE_ARRAY.  */
 
@@ -1235,113 +1049,6 @@ ada_val_print_ref (struct type *type, const gdb_byte *valaddr,
 		    options, language_def (language_ada));
 }
 
-/* See the comment on ada_val_print.  This function differs in that it
-   does not catch evaluation errors (leaving that to ada_val_print).  */
-
-static void
-ada_val_print_1 (struct type *type,
-		 int offset, CORE_ADDR address,
-		 struct ui_file *stream, int recurse,
-		 struct value *original_value,
-		 const struct value_print_options *options)
-{
-  int offset_aligned;
-  const gdb_byte *valaddr = value_contents_for_printing (original_value);
-
-  type = ada_check_typedef (type);
-
-  if (ada_is_array_descriptor_type (type)
-      || (ada_is_constrained_packed_array_type (type)
-	  && TYPE_CODE (type) != TYPE_CODE_PTR))
-    {
-      struct value *val = value_from_contents_and_address (type,
-							   valaddr + offset,
-							   address);
-      ada_val_print_gnat_array (val, stream, recurse, options);
-      return;
-    }
-
-  offset_aligned = offset + ada_aligned_value_addr (type, valaddr) - valaddr;
-  type = printable_val_type (type, valaddr + offset_aligned);
-  type = resolve_dynamic_type (type, valaddr + offset_aligned,
-			       address + offset_aligned);
-
-  switch (TYPE_CODE (type))
-    {
-    default:
-      val_print (type, offset, address, stream, recurse,
-		 original_value, options, language_def (language_c));
-      break;
-
-    case TYPE_CODE_PTR:
-      ada_val_print_ptr (type, valaddr, offset, offset_aligned,
-			 address, stream, recurse, original_value,
-			 options);
-      break;
-
-    case TYPE_CODE_INT:
-    case TYPE_CODE_RANGE:
-      ada_val_print_num (type, valaddr, offset, offset_aligned,
-			 address, stream, recurse, original_value,
-			 options);
-      break;
-
-    case TYPE_CODE_ENUM:
-      ada_val_print_enum (type, valaddr, offset, offset_aligned,
-			  address, stream, recurse, original_value,
-			  options);
-      break;
-
-    case TYPE_CODE_FLT:
-      ada_val_print_flt (type, valaddr, offset, offset_aligned,
-			 address, stream, recurse, original_value,
-			 options);
-      break;
-
-    case TYPE_CODE_UNION:
-    case TYPE_CODE_STRUCT:
-      ada_val_print_struct_union (type, valaddr, offset, offset_aligned,
-				  address, stream, recurse,
-				  original_value, options);
-      break;
-
-    case TYPE_CODE_ARRAY:
-      ada_val_print_array (type, valaddr, offset, offset_aligned,
-			   address, stream, recurse, original_value,
-			   options);
-      return;
-
-    case TYPE_CODE_REF:
-      ada_val_print_ref (type, valaddr, offset, offset_aligned,
-			 address, stream, recurse, original_value,
-			 options);
-      break;
-    }
-}
-
-/* See val_print for a description of the various parameters of this
-   function; they are identical.  */
-
-void
-ada_val_print (struct type *type,
-	       int embedded_offset, CORE_ADDR address,
-	       struct ui_file *stream, int recurse,
-	       struct value *val,
-	       const struct value_print_options *options)
-{
-  try
-    {
-      ada_val_print_1 (type, embedded_offset, address,
-		       stream, recurse, val, options);
-    }
-  catch (const gdb_exception_error &except)
-    {
-      fprintf_styled (stream, metadata_style.style (),
-		      _("<error reading variable: %s>"),
-		      except.what ());
-    }
-}
-
 /* See the comment on ada_value_print.  This function differs in that
    it does not catch evaluation errors (leaving that to
    ada_value_print).  */
@@ -1390,9 +1097,7 @@ ada_value_print_1 (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_ENUM:
-      ada_val_print_enum (type, valaddr, 0, 0,
-			  address, stream, recurse, val,
-			  options);
+      ada_val_print_enum (val, stream, recurse, options);
       break;
 
     case TYPE_CODE_FLT:
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 909c6de63d9..9ba342412e9 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -903,7 +903,6 @@ extern const struct language_defn c_language_defn =
   c_emit_char,			/* Print a single char */
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
-  c_val_print,			/* Print a value using appropriate syntax */
   c_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
@@ -1049,7 +1048,6 @@ extern const struct language_defn cplus_language_defn =
   c_emit_char,			/* Print a single char */
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
-  c_val_print,			/* Print a value using appropriate syntax */
   c_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
@@ -1104,7 +1102,6 @@ extern const struct language_defn asm_language_defn =
   c_emit_char,			/* Print a single char */
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
-  c_val_print,			/* Print a value using appropriate syntax */
   c_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
@@ -1159,7 +1156,6 @@ extern const struct language_defn minimal_language_defn =
   c_emit_char,			/* Print a single char */
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
-  c_val_print,			/* Print a value using appropriate syntax */
   c_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 96244531149..87a77c9e1ee 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -81,12 +81,6 @@ extern void c_print_typedef (struct type *,
 			     struct symbol *,
 			     struct ui_file *);
 
-extern void c_val_print (struct type *,
-			 int, CORE_ADDR,
-			 struct ui_file *, int,
-			 struct value *,
-			 const struct value_print_options *);
-
 /* Implement la_value_print_inner for the C family of languages.  */
 
 extern void c_value_print_inner (struct value *, struct ui_file *, int,
@@ -140,20 +134,6 @@ extern void cp_print_value_fields (struct value *,
 				   const struct value_print_options *,
 				   struct type **, int);
 
-extern void cp_print_value_fields (struct type *, struct type *,
-				   LONGEST, CORE_ADDR,
-				   struct ui_file *, int,
-				   struct value *,
-				   const struct value_print_options *,
-				   struct type **, int);
-
-extern void cp_print_value_fields_rtti (struct type *,
-					const gdb_byte *, LONGEST, CORE_ADDR,
-					struct ui_file *, int,
-					struct value *,
-					const struct value_print_options *,
-					struct type **, int);
-
 /* gcc-2.6 or later (when using -fvtable-thunks)
    emits a unique named type for a vtable entry.
    Some gdb code depends on that specific name.  */
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 8637ba976af..f2d153d1588 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -228,113 +228,6 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
     }
 }
 
-/* c_val_print helper for TYPE_CODE_ARRAY.  */
-
-static void
-c_val_print_array (struct type *type, const gdb_byte *valaddr,
-		   int embedded_offset, CORE_ADDR address,
-		   struct ui_file *stream, int recurse,
-		   struct value *original_value,
-		   const struct value_print_options *options)
-{
-  struct type *unresolved_elttype = TYPE_TARGET_TYPE (type);
-  struct type *elttype = check_typedef (unresolved_elttype);
-  struct gdbarch *arch = get_type_arch (type);
-  int unit_size = gdbarch_addressable_memory_unit_size (arch);
-
-  if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (unresolved_elttype) > 0)
-    {
-      LONGEST low_bound, high_bound;
-      int eltlen, len;
-      enum bfd_endian byte_order = type_byte_order (type);
-
-      if (!get_array_bounds (type, &low_bound, &high_bound))
-	error (_("Could not determine the array high bound"));
-
-      eltlen = TYPE_LENGTH (elttype);
-      len = high_bound - low_bound + 1;
-      if (options->prettyformat_arrays)
-	{
-	  print_spaces_filtered (2 + 2 * recurse, stream);
-	}
-
-      /* Print arrays of textual chars with a string syntax, as
-	 long as the entire array is valid.  */
-      if (c_textual_element_type (unresolved_elttype,
-				  options->format)
-	  && value_bytes_available (original_value, embedded_offset,
-				    TYPE_LENGTH (type))
-	  && !value_bits_any_optimized_out (original_value,
-					    TARGET_CHAR_BIT * embedded_offset,
-					    TARGET_CHAR_BIT * TYPE_LENGTH (type)))
-	{
-	  int force_ellipses = 0;
-
-	  /* If requested, look for the first null char and only
-	     print elements up to it.  */
-	  if (options->stop_print_at_null)
-	    {
-	      unsigned int temp_len;
-
-	      for (temp_len = 0;
-		   (temp_len < len
-		    && temp_len < options->print_max
-		    && extract_unsigned_integer (valaddr
-						 + embedded_offset * unit_size
-						 + temp_len * eltlen,
-						 eltlen, byte_order) != 0);
-		   ++temp_len)
-		;
-
-	      /* Force LA_PRINT_STRING to print ellipses if
-		 we've printed the maximum characters and
-		 the next character is not \000.  */
-	      if (temp_len == options->print_max && temp_len < len)
-		{
-		  ULONGEST val
-		    = extract_unsigned_integer (valaddr
-						+ embedded_offset * unit_size
-						+ temp_len * eltlen,
-						eltlen, byte_order);
-		  if (val != 0)
-		    force_ellipses = 1;
-		}
-
-	      len = temp_len;
-	    }
-
-	  LA_PRINT_STRING (stream, unresolved_elttype,
-			   valaddr + embedded_offset * unit_size, len,
-			   NULL, force_ellipses, options);
-	}
-      else
-	{
-	  unsigned int i = 0;
-	  fprintf_filtered (stream, "{");
-	  /* If this is a virtual function table, print the 0th
-	     entry specially, and the rest of the members
-	     normally.  */
-	  if (cp_is_vtbl_ptr_type (elttype))
-	    {
-	      i = 1;
-	      fprintf_filtered (stream, _("%d vtable entries"),
-				len - 1);
-	    }
-	  val_print_array_elements (type, embedded_offset,
-				    address, stream,
-				    recurse, original_value, options, i);
-	  fprintf_filtered (stream, "}");
-	}
-    }
-  else
-    {
-      /* Array of unspecified length: treat like pointer to first elt.  */
-      print_unpacked_pointer (type, elttype, unresolved_elttype, valaddr,
-			      embedded_offset, address + embedded_offset,
-			      stream, recurse, options);
-    }
-}
-
 /* c_value_print helper for TYPE_CODE_ARRAY.  */
 
 static void
@@ -433,46 +326,6 @@ c_value_print_array (struct value *val,
 
 /* c_val_print helper for TYPE_CODE_PTR.  */
 
-static void
-c_val_print_ptr (struct type *type, const gdb_byte *valaddr,
-		 int embedded_offset, struct ui_file *stream, int recurse,
-		 struct value *original_value,
-		 const struct value_print_options *options)
-{
-  struct gdbarch *arch = get_type_arch (type);
-  int unit_size = gdbarch_addressable_memory_unit_size (arch);
-
-  if (options->format && options->format != 's')
-    {
-      val_print_scalar_formatted (type, embedded_offset,
-				  original_value, options, 0, stream);
-    }
-  else if (options->vtblprint && cp_is_vtbl_ptr_type (type))
-    {
-      /* Print the unmangled name if desired.  */
-      /* Print vtable entry - we only get here if we ARE using
-	 -fvtable_thunks.  (Otherwise, look under
-	 TYPE_CODE_STRUCT.)  */
-      CORE_ADDR addr
-	= extract_typed_address (valaddr + embedded_offset, type);
-      struct gdbarch *gdbarch = get_type_arch (type);
-
-      print_function_pointer_address (options, gdbarch, addr, stream);
-    }
-  else
-    {
-      struct type *unresolved_elttype = TYPE_TARGET_TYPE (type);
-      struct type *elttype = check_typedef (unresolved_elttype);
-      CORE_ADDR addr = unpack_pointer (type,
-				       valaddr + embedded_offset * unit_size);
-
-      print_unpacked_pointer (type, elttype, unresolved_elttype, valaddr,
-			      embedded_offset, addr, stream, recurse, options);
-    }
-}
-
-/* c_val_print helper for TYPE_CODE_PTR.  */
-
 static void
 c_value_print_ptr (struct value*val, struct ui_file *stream, int recurse,
 		   const struct value_print_options *options)
@@ -508,38 +361,6 @@ c_value_print_ptr (struct value*val, struct ui_file *stream, int recurse,
     }
 }
 
-/* c_val_print helper for TYPE_CODE_STRUCT.  */
-
-static void
-c_val_print_struct (struct type *type, const gdb_byte *valaddr,
-		    int embedded_offset, CORE_ADDR address,
-		    struct ui_file *stream, int recurse,
-		    struct value *original_value,
-		    const struct value_print_options *options)
-{
-  if (options->vtblprint && cp_is_vtbl_ptr_type (type))
-    {
-      /* Print the unmangled name if desired.  */
-      /* Print vtable entry - we only get here if NOT using
-	 -fvtable_thunks.  (Otherwise, look under
-	 TYPE_CODE_PTR.)  */
-      struct gdbarch *gdbarch = get_type_arch (type);
-      int offset = (embedded_offset
-		    + TYPE_FIELD_BITPOS (type,
-					 VTBL_FNADDR_OFFSET) / 8);
-      struct type *field_type = TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET);
-      CORE_ADDR addr = extract_typed_address (valaddr + offset, field_type);
-
-      print_function_pointer_address (options, gdbarch, addr, stream);
-    }
-  else
-    cp_print_value_fields_rtti (type, valaddr,
-				embedded_offset, address,
-				stream, recurse,
-				original_value, options,
-				NULL, 0);
-}
-
 /* c_value_print helper for TYPE_CODE_STRUCT and TYPE_CODE_UNION.  */
 
 static void
@@ -568,64 +389,6 @@ c_value_print_struct (struct value *val, struct ui_file *stream, int recurse,
     cp_print_value_fields (val, stream, recurse, options, NULL, 0);
 }
 
-/* c_val_print helper for TYPE_CODE_UNION.  */
-
-static void
-c_val_print_union (struct type *type, const gdb_byte *valaddr,
-		   int embedded_offset, CORE_ADDR address,
-		   struct ui_file *stream, int recurse,
-		   struct value *original_value,
-		   const struct value_print_options *options)
-{
-  if (recurse && !options->unionprint)
-    {
-      fprintf_filtered (stream, "{...}");
-     }
-  else
-    {
-      c_val_print_struct (type, valaddr, embedded_offset, address, stream,
-			  recurse, original_value, options);
-    }
-}
-
-/* c_val_print helper for TYPE_CODE_INT.  */
-
-static void
-c_val_print_int (struct type *type, struct type *unresolved_type,
-		 const gdb_byte *valaddr, int embedded_offset,
-		 struct ui_file *stream, struct value *original_value,
-		 const struct value_print_options *options)
-{
-  struct gdbarch *arch = get_type_arch (type);
-  int unit_size = gdbarch_addressable_memory_unit_size (arch);
-
-  if (options->format || options->output_format)
-    {
-      struct value_print_options opts = *options;
-
-      opts.format = (options->format ? options->format
-		     : options->output_format);
-      val_print_scalar_formatted (type, embedded_offset,
-				  original_value, &opts, 0, stream);
-    }
-  else
-    {
-      val_print_scalar_formatted (type, embedded_offset,
-				  original_value, options, 0, stream);
-      /* C and C++ has no single byte int type, char is used
-	 instead.  Since we don't know whether the value is really
-	 intended to be used as an integer or a character, print
-	 the character equivalent as well.  */
-      if (c_textual_element_type (unresolved_type, options->format))
-	{
-	  fputs_filtered (" ", stream);
-	  LA_PRINT_CHAR (unpack_long (type,
-				      valaddr + embedded_offset * unit_size),
-			 unresolved_type, stream);
-	}
-    }
-}
-
 /* c_value_print helper for TYPE_CODE_INT.  */
 
 static void
@@ -657,26 +420,6 @@ c_value_print_int (struct value *val, struct ui_file *stream,
     }
 }
 
-/* c_val_print helper for TYPE_CODE_MEMBERPTR.  */
-
-static void
-c_val_print_memberptr (struct type *type, const gdb_byte *valaddr,
-		       int embedded_offset, CORE_ADDR address,
-		       struct ui_file *stream, int recurse,
-		       struct value *original_value,
-		       const struct value_print_options *options)
-{
-  if (!options->format)
-    {
-      cp_print_class_member (valaddr + embedded_offset, type, stream, "&");
-    }
-  else
-    {
-      generic_val_print (type, embedded_offset, address, stream,
-			 recurse, original_value, options, &c_decorations);
-    }
-}
-
 /* c_value_print helper for TYPE_CODE_MEMBERPTR.  */
 
 static void
@@ -694,79 +437,6 @@ c_value_print_memberptr (struct value *val, struct ui_file *stream,
     generic_value_print (val, stream, recurse, options, &c_decorations);
 }
 
-/* See val_print for a description of the various parameters of this
-   function; they are identical.  */
-
-void
-c_val_print (struct type *type,
-	     int embedded_offset, CORE_ADDR address,
-	     struct ui_file *stream, int recurse,
-	     struct value *original_value,
-	     const struct value_print_options *options)
-{
-  struct type *unresolved_type = type;
-  const gdb_byte *valaddr = value_contents_for_printing (original_value);
-
-  type = check_typedef (type);
-  switch (TYPE_CODE (type))
-    {
-    case TYPE_CODE_ARRAY:
-      c_val_print_array (type, valaddr, embedded_offset, address, stream,
-			 recurse, original_value, options);
-      break;
-
-    case TYPE_CODE_METHODPTR:
-      cplus_print_method_ptr (valaddr + embedded_offset, type, stream);
-      break;
-
-    case TYPE_CODE_PTR:
-      c_val_print_ptr (type, valaddr, embedded_offset, stream, recurse,
-		       original_value, options);
-      break;
-
-    case TYPE_CODE_UNION:
-      c_val_print_union (type, valaddr, embedded_offset, address, stream,
-			 recurse, original_value, options);
-      break;
-
-    case TYPE_CODE_STRUCT:
-      c_val_print_struct (type, valaddr, embedded_offset, address, stream,
-			  recurse, original_value, options);
-      break;
-
-    case TYPE_CODE_INT:
-      c_val_print_int (type, unresolved_type, valaddr, embedded_offset, stream,
-		       original_value, options);
-      break;
-
-    case TYPE_CODE_MEMBERPTR:
-      c_val_print_memberptr (type, valaddr, embedded_offset, address, stream,
-			     recurse, original_value, options);
-      break;
-
-    case TYPE_CODE_REF:
-    case TYPE_CODE_RVALUE_REF:
-    case TYPE_CODE_ENUM:
-    case TYPE_CODE_FLAGS:
-    case TYPE_CODE_FUNC:
-    case TYPE_CODE_METHOD:
-    case TYPE_CODE_BOOL:
-    case TYPE_CODE_RANGE:
-    case TYPE_CODE_FLT:
-    case TYPE_CODE_DECFLOAT:
-    case TYPE_CODE_VOID:
-    case TYPE_CODE_ERROR:
-    case TYPE_CODE_UNDEF:
-    case TYPE_CODE_COMPLEX:
-    case TYPE_CODE_CHAR:
-    default:
-      generic_val_print (type, embedded_offset, address,
-			 stream, recurse, original_value, options,
-			 &c_decorations);
-      break;
-    }
-}
-
 /* See c-lang.h.  */
 
 void
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 282eb0864a7..e14ead99ad1 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -47,13 +47,6 @@ static void cp_print_static_field (struct type *, struct value *,
 				   struct ui_file *, int,
 				   const struct value_print_options *);
 
-static void cp_print_value (struct type *, struct type *,
-			    LONGEST,
-			    CORE_ADDR, struct ui_file *,
-			    int, struct value *,
-			    const struct value_print_options *,
-			    struct type **);
-
 static void cp_print_value (struct value *, struct ui_file *,
 			    int, const struct value_print_options *,
 			    struct type **);
@@ -111,285 +104,6 @@ cp_is_vtbl_member (struct type *type)
   return 0;
 }
 
-/* Mutually recursive subroutines of cp_print_value and c_val_print to
-   print out a structure's fields: cp_print_value_fields and
-   cp_print_value.
-
-   TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the same
-   meanings as in cp_print_value and c_val_print.
-
-   2nd argument REAL_TYPE is used to carry over the type of the
-   derived class across the recursion to base classes.
-
-   DONT_PRINT is an array of baseclass types that we should not print,
-   or zero if called from top level.  */
-
-void
-cp_print_value_fields (struct type *type, struct type *real_type,
-		       LONGEST offset,
-		       CORE_ADDR address, struct ui_file *stream,
-		       int recurse, struct value *val,
-		       const struct value_print_options *options,
-		       struct type **dont_print_vb,
-		       int dont_print_statmem)
-{
-  int i, len, n_baseclasses;
-  int fields_seen = 0;
-  static int last_set_recurse = -1;
-
-  type = check_typedef (type);
-  
-  if (recurse == 0)
-    {
-      /* Any object can be left on obstacks only during an unexpected
-	 error.  */
-
-      if (obstack_object_size (&dont_print_statmem_obstack) > 0)
-	{
-	  obstack_free (&dont_print_statmem_obstack, NULL);
-	  obstack_begin (&dont_print_statmem_obstack,
-			 32 * sizeof (CORE_ADDR));
-	}
-      if (obstack_object_size (&dont_print_stat_array_obstack) > 0)
-	{
-	  obstack_free (&dont_print_stat_array_obstack, NULL);
-	  obstack_begin (&dont_print_stat_array_obstack,
-			 32 * sizeof (struct type *));
-	}
-    }
-
-  fprintf_filtered (stream, "{");
-  len = TYPE_NFIELDS (type);
-  n_baseclasses = TYPE_N_BASECLASSES (type);
-
-  /* First, print out baseclasses such that we don't print
-     duplicates of virtual baseclasses.  */
-
-  if (n_baseclasses > 0)
-    cp_print_value (type, real_type,
-		    offset, address, stream,
-		    recurse + 1, val, options,
-		    dont_print_vb);
-
-  /* Second, print out data fields */
-
-  /* If there are no data fields, skip this part */
-  if (len == n_baseclasses || !len)
-    fprintf_styled (stream, metadata_style.style (), "<No data fields>");
-  else
-    {
-      size_t statmem_obstack_initial_size = 0;
-      size_t stat_array_obstack_initial_size = 0;
-      struct type *vptr_basetype = NULL;
-      int vptr_fieldno;
-
-      if (dont_print_statmem == 0)
-	{
-	  statmem_obstack_initial_size =
-	    obstack_object_size (&dont_print_statmem_obstack);
-
-	  if (last_set_recurse != recurse)
-	    {
-	      stat_array_obstack_initial_size =
-		obstack_object_size (&dont_print_stat_array_obstack);
-
-	      last_set_recurse = recurse;
-	    }
-	}
-
-      vptr_fieldno = get_vptr_fieldno (type, &vptr_basetype);
-      for (i = n_baseclasses; i < len; i++)
-	{
-	  const gdb_byte *valaddr = value_contents_for_printing (val);
-
-	  /* If requested, skip printing of static fields.  */
-	  if (!options->static_field_print
-	      && field_is_static (&TYPE_FIELD (type, i)))
-	    continue;
-
-	  if (fields_seen)
-	    {
-	      fputs_filtered (",", stream);
-	      if (!options->prettyformat)
-		fputs_filtered (" ", stream);
-	    }
-	  else if (n_baseclasses > 0)
-	    {
-	      if (options->prettyformat)
-		{
-		  fprintf_filtered (stream, "\n");
-		  print_spaces_filtered (2 + 2 * recurse, stream);
-		  fputs_filtered ("members of ", stream);
-		  fputs_filtered (TYPE_NAME (type), stream);
-		  fputs_filtered (":", stream);
-		}
-	    }
-	  fields_seen = 1;
-
-	  if (options->prettyformat)
-	    {
-	      fprintf_filtered (stream, "\n");
-	      print_spaces_filtered (2 + 2 * recurse, stream);
-	    }
-	  else
-	    {
-	      wrap_here (n_spaces (2 + 2 * recurse));
-	    }
-
-	  annotate_field_begin (TYPE_FIELD_TYPE (type, i));
-
-	  if (field_is_static (&TYPE_FIELD (type, i)))
-	    fputs_filtered ("static ", stream);
-	  fprintf_symbol_filtered (stream,
-				   TYPE_FIELD_NAME (type, i),
-				   current_language->la_language,
-				   DMGL_PARAMS | DMGL_ANSI);
-	  annotate_field_name_end ();
-
-	  /* We tweak various options in a few cases below.  */
-	  value_print_options options_copy = *options;
-	  value_print_options *opts = &options_copy;
-
-	  /* Do not print leading '=' in case of anonymous
-	     unions.  */
-	  if (strcmp (TYPE_FIELD_NAME (type, i), ""))
-	    fputs_filtered (" = ", stream);
-	  else
-	    {
-	      /* If this is an anonymous field then we want to consider it
-		 as though it is at its parent's depth when it comes to the
-		 max print depth.  */
-	      if (opts->max_depth != -1 && opts->max_depth < INT_MAX)
-		++opts->max_depth;
-	    }
-	  annotate_field_value ();
-
-	  if (!field_is_static (&TYPE_FIELD (type, i))
-	      && TYPE_FIELD_PACKED (type, i))
-	    {
-	      struct value *v;
-
-	      /* Bitfields require special handling, especially due to
-	         byte order problems.  */
-	      if (TYPE_FIELD_IGNORE (type, i))
-		{
-		  fputs_styled ("<optimized out or zero length>",
-				metadata_style.style (), stream);
-		}
-	      else if (value_bits_synthetic_pointer (val,
-						     TYPE_FIELD_BITPOS (type,
-									i),
-						     TYPE_FIELD_BITSIZE (type,
-									 i)))
-		{
-		  fputs_styled (_("<synthetic pointer>"),
-				metadata_style.style (), stream);
-		}
-	      else
-		{
-		  opts->deref_ref = 0;
-
-		  v = value_field_bitfield (type, i, valaddr, offset, val);
-
-		  common_val_print (v, stream, recurse + 1,
-				    opts, current_language);
-		}
-	    }
-	  else
-	    {
-	      if (TYPE_FIELD_IGNORE (type, i))
-		{
-		  fputs_styled ("<optimized out or zero length>",
-				metadata_style.style (), stream);
-		}
-	      else if (field_is_static (&TYPE_FIELD (type, i)))
-		{
-		  try
-		    {
-		      struct value *v = value_static_field (type, i);
-
-		      cp_print_static_field (TYPE_FIELD_TYPE (type, i),
-					     v, stream, recurse + 1,
-					     opts);
-		    }
-		  catch (const gdb_exception_error &ex)
-		    {
-		      fprintf_styled (stream, metadata_style.style (),
-				      _("<error reading variable: %s>"),
-				      ex.what ());
-		    }
-		}
-	      else if (i == vptr_fieldno && type == vptr_basetype)
-		{
-		  int i_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8;
-		  struct type *i_type = TYPE_FIELD_TYPE (type, i);
-
-		  if (valprint_check_validity (stream, i_type, i_offset, val))
-		    {
-		      CORE_ADDR addr;
-		      
-		      i_offset += value_embedded_offset (val);
-		      addr = extract_typed_address (valaddr + i_offset, i_type);
-		      print_function_pointer_address (opts,
-						      get_type_arch (type),
-						      addr, stream);
-		    }
-		}
-	      else
-		{
-		  opts->deref_ref = 0;
-		  val_print (TYPE_FIELD_TYPE (type, i),
-			     offset + TYPE_FIELD_BITPOS (type, i) / 8,
-			     address,
-			     stream, recurse + 1, val, opts,
-			     current_language);
-		}
-	    }
-	  annotate_field_end ();
-	}
-
-      if (dont_print_statmem == 0)
-	{
-	  size_t obstack_final_size =
-           obstack_object_size (&dont_print_statmem_obstack);
-
-	  if (obstack_final_size > statmem_obstack_initial_size)
-	    {
-	      /* In effect, a pop of the printed-statics stack.  */
-	      size_t shrink_bytes
-		= statmem_obstack_initial_size - obstack_final_size;
-	      obstack_blank_fast (&dont_print_statmem_obstack, shrink_bytes);
-	    }
-
-	  if (last_set_recurse != recurse)
-	    {
-	      obstack_final_size =
-		obstack_object_size (&dont_print_stat_array_obstack);
-	      
-	      if (obstack_final_size > stat_array_obstack_initial_size)
-		{
-		  void *free_to_ptr =
-		    (char *) obstack_next_free (&dont_print_stat_array_obstack)
-		    - (obstack_final_size
-		       - stat_array_obstack_initial_size);
-
-		  obstack_free (&dont_print_stat_array_obstack,
-				free_to_ptr);
-		}
-	      last_set_recurse = -1;
-	    }
-	}
-
-      if (options->prettyformat)
-	{
-	  fprintf_filtered (stream, "\n");
-	  print_spaces_filtered (2 * recurse, stream);
-	}
-    }				/* if there are data fields */
-
-  fprintf_filtered (stream, "}");
-}
-
 /* Mutually recursive subroutines of cp_print_value and c_val_print to
    print out a structure's fields: cp_print_value_fields and
    cp_print_value.
@@ -662,222 +376,6 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
   fprintf_filtered (stream, "}");
 }
 
-/* Like cp_print_value_fields, but find the runtime type of the object
-   and pass it as the `real_type' argument to cp_print_value_fields.
-   This function is a hack to work around the fact that
-   common_val_print passes the embedded offset to val_print, but not
-   the enclosing type.  */
-
-void
-cp_print_value_fields_rtti (struct type *type,
-			    const gdb_byte *valaddr, LONGEST offset,
-			    CORE_ADDR address,
-			    struct ui_file *stream, int recurse,
-			    struct value *val,
-			    const struct value_print_options *options,
-			    struct type **dont_print_vb, 
-			    int dont_print_statmem)
-{
-  struct type *real_type = NULL;
-
-  /* We require all bits to be valid in order to attempt a
-     conversion.  */
-  if (!value_bits_any_optimized_out (val,
-				     TARGET_CHAR_BIT * offset,
-				     TARGET_CHAR_BIT * TYPE_LENGTH (type)))
-    {
-      struct value *value;
-      int full, using_enc;
-      LONGEST top;
-
-      /* Ugh, we have to convert back to a value here.  */
-      value = value_from_contents_and_address (type, valaddr + offset,
-					       address + offset);
-      type = value_type (value);
-      /* We don't actually care about most of the result here -- just
-	 the type.  We already have the correct offset, due to how
-	 val_print was initially called.  */
-      real_type = value_rtti_type (value, &full, &top, &using_enc);
-    }
-
-  if (!real_type)
-    real_type = type;
-
-  cp_print_value_fields (type, real_type, offset,
-			 address, stream, recurse, val, options,
-			 dont_print_vb, dont_print_statmem);
-}
-
-/* Special val_print routine to avoid printing multiple copies of
-   virtual baseclasses.  */
-
-static void
-cp_print_value (struct type *type, struct type *real_type,
-		LONGEST offset,
-		CORE_ADDR address, struct ui_file *stream,
-		int recurse, struct value *val,
-		const struct value_print_options *options,
-		struct type **dont_print_vb)
-{
-  struct type **last_dont_print
-    = (struct type **) obstack_next_free (&dont_print_vb_obstack);
-  struct obstack tmp_obstack = dont_print_vb_obstack;
-  int i, n_baseclasses = TYPE_N_BASECLASSES (type);
-  LONGEST thisoffset;
-  struct type *thistype;
-  const gdb_byte *valaddr = value_contents_for_printing (val);
-
-  if (dont_print_vb == 0)
-    {
-      /* If we're at top level, carve out a completely fresh chunk of
-         the obstack and use that until this particular invocation
-         returns.  */
-      /* Bump up the high-water mark.  Now alpha is omega.  */
-      obstack_finish (&dont_print_vb_obstack);
-    }
-
-  for (i = 0; i < n_baseclasses; i++)
-    {
-      LONGEST boffset = 0;
-      int skip = 0;
-      struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
-      const char *basename = TYPE_NAME (baseclass);
-      struct value *base_val = NULL;
-
-      if (BASETYPE_VIA_VIRTUAL (type, i))
-	{
-	  struct type **first_dont_print
-	    = (struct type **) obstack_base (&dont_print_vb_obstack);
-
-	  int j = (struct type **)
-	    obstack_next_free (&dont_print_vb_obstack) - first_dont_print;
-
-	  while (--j >= 0)
-	    if (baseclass == first_dont_print[j])
-	      goto flush_it;
-
-	  obstack_ptr_grow (&dont_print_vb_obstack, baseclass);
-	}
-
-      thisoffset = offset;
-      thistype = real_type;
-
-      try
-	{
-	  boffset = baseclass_offset (type, i, valaddr, offset, address, val);
-	}
-      catch (const gdb_exception_error &ex)
-	{
-	  if (ex.error == NOT_AVAILABLE_ERROR)
-	    skip = -1;
-	  else
-	    skip = 1;
-	}
-
-      if (skip == 0)
-	{
-	  if (BASETYPE_VIA_VIRTUAL (type, i))
-	    {
-	      /* The virtual base class pointer might have been
-		 clobbered by the user program. Make sure that it
-		 still points to a valid memory location.  */
-
-	      if ((boffset + offset) < 0
-		  || (boffset + offset) >= TYPE_LENGTH (real_type))
-		{
-		  gdb::byte_vector buf (TYPE_LENGTH (baseclass));
-
-		  if (target_read_memory (address + boffset, buf.data (),
-					  TYPE_LENGTH (baseclass)) != 0)
-		    skip = 1;
-		  base_val = value_from_contents_and_address (baseclass,
-							      buf.data (),
-							      address + boffset);
-		  baseclass = value_type (base_val);
-		  thisoffset = 0;
-		  boffset = 0;
-		  thistype = baseclass;
-		}
-	      else
-		{
-		  base_val = val;
-		}
-	    }
-	  else
-	    {
-	      base_val = val;
-	    }
-	}
-
-      /* Now do the printing.  */
-      if (options->prettyformat)
-	{
-	  fprintf_filtered (stream, "\n");
-	  print_spaces_filtered (2 * recurse, stream);
-	}
-      fputs_filtered ("<", stream);
-      /* Not sure what the best notation is in the case where there is
-         no baseclass name.  */
-      fputs_filtered (basename ? basename : "", stream);
-      fputs_filtered ("> = ", stream);
-
-      if (skip < 0)
-	val_print_unavailable (stream);
-      else if (skip > 0)
-	val_print_invalid_address (stream);
-      else
-	{
-	  int result = 0;
-
-	  if (options->max_depth > -1
-	      && recurse >= options->max_depth)
-	    {
-	      const struct language_defn *language = current_language;
-	      gdb_assert (language->la_struct_too_deep_ellipsis != NULL);
-	      fputs_filtered (language->la_struct_too_deep_ellipsis, stream);
-	    }
-	  else
-	    {
-	      /* Attempt to run an extension language pretty-printer on the
-		 baseclass if possible.  */
-	      if (!options->raw)
-		{
-		  struct value *v
-		    = value_from_component (base_val, baseclass,
-					    thisoffset + boffset);
-		  result
-		    = apply_ext_lang_val_pretty_printer (v, stream, recurse,
-							 options,
-							 current_language);
-		}
-
-	      if (!result)
-		cp_print_value_fields (baseclass, thistype,
-				       thisoffset + boffset,
-				       value_address (base_val),
-				       stream, recurse, base_val, options,
-				       ((struct type **)
-					obstack_base (&dont_print_vb_obstack)),
-				       0);
-	    }
-	}
-      fputs_filtered (", ", stream);
-
-    flush_it:
-      ;
-    }
-
-  if (dont_print_vb == 0)
-    {
-      /* Free the space used to deal with the printing
-         of this type from top level.  */
-      obstack_free (&dont_print_vb_obstack, last_dont_print);
-      /* Reset watermark so that we can continue protecting
-         ourselves from whatever we were protecting ourselves.  */
-      dont_print_vb_obstack = tmp_obstack;
-    }
-}
-
 /* Special val_print routine to avoid printing multiple copies of
    virtual baseclasses.  */
 
@@ -1063,7 +561,7 @@ cp_print_static_field (struct type *type,
   if (TYPE_CODE (real_type) == TYPE_CODE_STRUCT)
     {
       CORE_ADDR *first_dont_print;
-      CORE_ADDR addr;
+      CORE_ADDR addr = value_address (val);
       int i;
 
       first_dont_print
@@ -1073,7 +571,7 @@ cp_print_static_field (struct type *type,
 
       while (--i >= 0)
 	{
-	  if (value_address (val) == first_dont_print[i])
+	  if (addr == first_dont_print[i])
 	    {
 	      fputs_styled (_("<same as static member of an already"
 			      " seen type>"),
@@ -1082,13 +580,9 @@ cp_print_static_field (struct type *type,
 	    }
 	}
 
-      addr = value_address (val);
       obstack_grow (&dont_print_statmem_obstack, (char *) &addr,
 		    sizeof (CORE_ADDR));
-      cp_print_value_fields (type, value_enclosing_type (val),
-			     value_embedded_offset (val), addr,
-			     stream, recurse, val,
-			     options, NULL, 1);
+      cp_print_value_fields (val, stream, recurse, options, NULL, 1);
       return;
     }
 
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index ce4324c3f86..027aa9d6a68 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -224,7 +224,6 @@ extern const struct language_defn d_language_defn =
   c_print_type,			/* Print a type using appropriate syntax.  */
   c_print_typedef,		/* Print a typedef using appropriate
 				   syntax.  */
-  d_val_print,			/* Print a value using appropriate syntax.  */
   d_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value.  */
   default_read_var_value,	/* la_read_var_value */
diff --git a/gdb/d-lang.h b/gdb/d-lang.h
index 51d3f17aa51..babe4c83bdf 100644
--- a/gdb/d-lang.h
+++ b/gdb/d-lang.h
@@ -76,14 +76,6 @@ extern struct block_symbol d_lookup_symbol_nonlocal (const struct language_defn
 extern struct block_symbol d_lookup_nested_symbol (struct type *, const char *,
 						   const struct block *);
 
-/* Defined in d-valprint.c  */
-
-extern void d_val_print (struct type *type,
-			 int embedded_offset, CORE_ADDR address,
-			 struct ui_file *stream, int recurse,
-			 struct value *val,
-			 const struct value_print_options *options);
-
 /* Implement la_value_print_inner for D.  */
 
 extern void d_value_print_inner (struct value *val,
diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c
index 5dbaf700eeb..2204366d428 100644
--- a/gdb/d-valprint.c
+++ b/gdb/d-valprint.c
@@ -69,30 +69,6 @@ dynamic_array_type (struct type *type,
   return 1;
 }
 
-/* Implements the la_val_print routine for language D.  */
-void
-d_val_print (struct type *type, int embedded_offset,
-             CORE_ADDR address, struct ui_file *stream, int recurse,
-	     struct value *val,
-             const struct value_print_options *options)
-{
-  int ret;
-
-  type = check_typedef (type);
-  switch (TYPE_CODE (type))
-    {
-      case TYPE_CODE_STRUCT:
-	ret = dynamic_array_type (type, embedded_offset, address,
-				  stream, recurse, val, options);
-	if (ret == 0)
-	  break;
-	/* Fall through.  */
-      default:
-	c_val_print (type, embedded_offset, address, stream,
-		     recurse, val, options);
-    }
-}
-
 /* See d-lang.h.  */
 
 void
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 0d587ea020b..6747888e159 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -646,7 +646,6 @@ extern const struct language_defn f_language_defn =
   f_emit_char,			/* Function to print a single character */
   f_print_type,			/* Print a type using appropriate syntax */
   f_print_typedef,		/* Print a typedef using appropriate syntax */
-  f_val_print,			/* Print a value using appropriate syntax */
   f_value_print_innner,		/* la_value_print_inner */
   c_value_print,		/* FIXME */
   default_read_var_value,	/* la_read_var_value */
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index 8b0f3f262df..ea870ec6ab0 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -36,11 +36,6 @@ extern void f_print_typedef (struct type *type, struct symbol *new_symbol,
 extern void f_print_type (struct type *, const char *, struct ui_file *, int,
 			  int, const struct type_print_options *);
 
-extern void f_val_print (struct type *, int, CORE_ADDR,
-			 struct ui_file *, int,
-			 struct value *,
-			 const struct value_print_options *);
-
 /* Implement la_value_print_inner for Fortran.  */
 
 extern void f_value_print_innner (struct value *val, struct ui_file *stream,
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index cd1977b05cf..55b1edbc19f 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -208,168 +208,6 @@ static const struct generic_val_print_decorations f_decorations =
   "}"
 };
 
-/* See val_print for a description of the various parameters of this
-   function; they are identical.  */
-
-void
-f_val_print (struct type *type, int embedded_offset,
-	     CORE_ADDR address, struct ui_file *stream, int recurse,
-	     struct value *original_value,
-	     const struct value_print_options *options)
-{
-  struct gdbarch *gdbarch = get_type_arch (type);
-  int printed_field = 0; /* Number of fields printed.  */
-  struct type *elttype;
-  CORE_ADDR addr;
-  int index;
-  const gdb_byte *valaddr =value_contents_for_printing (original_value);
-
-  type = check_typedef (type);
-  switch (TYPE_CODE (type))
-    {
-    case TYPE_CODE_STRING:
-      f77_get_dynamic_length_of_aggregate (type);
-      LA_PRINT_STRING (stream, builtin_type (gdbarch)->builtin_char,
-		       valaddr + embedded_offset,
-		       TYPE_LENGTH (type), NULL, 0, options);
-      break;
-
-    case TYPE_CODE_ARRAY:
-      if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_CHAR)
-	{
-	  fprintf_filtered (stream, "(");
-	  f77_print_array (type, valaddr, embedded_offset,
-			   address, stream, recurse, original_value, options);
-	  fprintf_filtered (stream, ")");
-	}
-      else
-	{
-	  struct type *ch_type = TYPE_TARGET_TYPE (type);
-
-	  f77_get_dynamic_length_of_aggregate (type);
-	  LA_PRINT_STRING (stream, ch_type,
-			   valaddr + embedded_offset,
-			   TYPE_LENGTH (type) / TYPE_LENGTH (ch_type),
-			   NULL, 0, options);
-	}
-      break;
-
-    case TYPE_CODE_PTR:
-      if (options->format && options->format != 's')
-	{
-	  val_print_scalar_formatted (type, embedded_offset,
-				      original_value, options, 0, stream);
-	  break;
-	}
-      else
-	{
-	  int want_space = 0;
-
-	  addr = unpack_pointer (type, valaddr + embedded_offset);
-	  elttype = check_typedef (TYPE_TARGET_TYPE (type));
-
-	  if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
-	    {
-	      /* Try to print what function it points to.  */
-	      print_function_pointer_address (options, gdbarch, addr, stream);
-	      return;
-	    }
-
-	  if (options->symbol_print)
-	    want_space = print_address_demangle (options, gdbarch, addr,
-						 stream, demangle);
-	  else if (options->addressprint && options->format != 's')
-	    {
-	      fputs_filtered (paddress (gdbarch, addr), stream);
-	      want_space = 1;
-	    }
-
-	  /* For a pointer to char or unsigned char, also print the string
-	     pointed to, unless pointer is null.  */
-	  if (TYPE_LENGTH (elttype) == 1
-	      && TYPE_CODE (elttype) == TYPE_CODE_INT
-	      && (options->format == 0 || options->format == 's')
-	      && addr != 0)
-	    {
-	      if (want_space)
-		fputs_filtered (" ", stream);
-	      val_print_string (TYPE_TARGET_TYPE (type), NULL, addr, -1,
-				stream, options);
-	    }
-	  return;
-	}
-      break;
-
-    case TYPE_CODE_INT:
-      if (options->format || options->output_format)
-	{
-	  struct value_print_options opts = *options;
-
-	  opts.format = (options->format ? options->format
-			 : options->output_format);
-	  val_print_scalar_formatted (type, embedded_offset,
-				      original_value, &opts, 0, stream);
-	}
-      else
-	val_print_scalar_formatted (type, embedded_offset,
-				    original_value, options, 0, stream);
-      break;
-
-    case TYPE_CODE_STRUCT:
-    case TYPE_CODE_UNION:
-      /* Starting from the Fortran 90 standard, Fortran supports derived
-         types.  */
-      fprintf_filtered (stream, "( ");
-      for (index = 0; index < TYPE_NFIELDS (type); index++)
-        {
-	  struct value *field = value_field
-	    ((struct value *)original_value, index);
-
-	  struct type *field_type = check_typedef (TYPE_FIELD_TYPE (type, index));
-
-
-	  if (TYPE_CODE (field_type) != TYPE_CODE_FUNC)
-	    {
-	      const char *field_name;
-
-	      if (printed_field > 0)
-		fputs_filtered (", ", stream);
-
-	      field_name = TYPE_FIELD_NAME (type, index);
-	      if (field_name != NULL)
-		{
-		  fputs_filtered (field_name, stream);
-		  fputs_filtered (" = ", stream);
-		}
-
-	      common_val_print (field, stream, recurse + 1,
-				options, current_language);
-
-	      ++printed_field;
-	    }
-	 }
-      fprintf_filtered (stream, " )");
-      break;     
-
-    case TYPE_CODE_REF:
-    case TYPE_CODE_FUNC:
-    case TYPE_CODE_FLAGS:
-    case TYPE_CODE_FLT:
-    case TYPE_CODE_VOID:
-    case TYPE_CODE_ERROR:
-    case TYPE_CODE_RANGE:
-    case TYPE_CODE_UNDEF:
-    case TYPE_CODE_COMPLEX:
-    case TYPE_CODE_BOOL:
-    case TYPE_CODE_CHAR:
-    default:
-      generic_val_print (type, embedded_offset, address,
-			 stream, recurse, original_value, options,
-			 &f_decorations);
-      break;
-    }
-}
-
 /* See f-lang.h.  */
 
 void
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 7e092229583..59cf6c3ecb8 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -595,7 +595,6 @@ extern const struct language_defn go_language_defn =
   go_print_type,		/* Print a type using appropriate syntax.  */
   c_print_typedef,		/* Print a typedef using appropriate
 				   syntax.  */
-  go_val_print,			/* Print a value using appropriate syntax.  */
   go_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value.  */
   default_read_var_value,	/* la_read_var_value */
diff --git a/gdb/go-lang.h b/gdb/go-lang.h
index 19dc43cd33d..69c75510ca1 100644
--- a/gdb/go-lang.h
+++ b/gdb/go-lang.h
@@ -80,14 +80,6 @@ extern void go_print_type (struct type *type, const char *varstring,
 			   struct ui_file *stream, int show, int level,
 			   const struct type_print_options *flags);
 
-/* Defined in go-valprint.c.  */
-
-extern void go_val_print (struct type *type,
-			  int embedded_offset, CORE_ADDR address,
-			  struct ui_file *stream, int recurse,
-			  struct value *val,
-			  const struct value_print_options *options);
-
 /* Implement la_value_print_inner for Go.  */
 
 extern void go_value_print_inner (struct value *value,
diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c
index 5282aa2e34b..08342460a75 100644
--- a/gdb/go-valprint.c
+++ b/gdb/go-valprint.c
@@ -84,45 +84,6 @@ print_go_string (struct type *type,
   val_print_string (elt_type, NULL, addr, length, stream, options);
 }
 
-/* Implements the la_val_print routine for language Go.  */
-
-void
-go_val_print (struct type *type, int embedded_offset,
-	      CORE_ADDR address, struct ui_file *stream, int recurse,
-	      struct value *val,
-	      const struct value_print_options *options)
-{
-  type = check_typedef (type);
-
-  switch (TYPE_CODE (type))
-    {
-      case TYPE_CODE_STRUCT:
-	{
-	  enum go_type go_type = go_classify_struct_type (type);
-
-	  switch (go_type)
-	    {
-	    case GO_TYPE_STRING:
-	      if (! options->raw)
-		{
-		  print_go_string (type, embedded_offset, address,
-				   stream, recurse, val, options);
-		  return;
-		}
-	      break;
-	    default:
-	      break;
-	    }
-	}
-	/* Fall through.  */
-
-      default:
-	c_val_print (type, embedded_offset, address, stream,
-		     recurse, val, options);
-	break;
-    }
-}
-
 /* See go-lang.h.  */
 
 void
diff --git a/gdb/language.c b/gdb/language.c
index 00b301e46e2..3ae9841a329 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -790,14 +790,12 @@ unk_lang_print_type (struct type *type, const char *varstring,
 }
 
 static void
-unk_lang_val_print (struct type *type,
-		    int embedded_offset, CORE_ADDR address,
-		    struct ui_file *stream, int recurse,
-		    struct value *val,
-		    const struct value_print_options *options)
+unk_lang_value_print_inner (struct value *val,
+			    struct ui_file *stream, int recurse,
+			    const struct value_print_options *options)
 {
   error (_("internal error - unimplemented "
-	   "function unk_lang_val_print called."));
+	   "function unk_lang_value_print_inner called."));
 }
 
 static void
@@ -857,8 +855,7 @@ const struct language_defn unknown_language_defn =
   unk_lang_emit_char,
   unk_lang_print_type,		/* Print a type using appropriate syntax */
   default_print_typedef,	/* Print a typedef using appropriate syntax */
-  unk_lang_val_print,		/* Print a value using appropriate syntax */
-  nullptr,			/* la_value_print_inner */
+  unk_lang_value_print_inner,	/* la_value_print_inner */
   unk_lang_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   unk_lang_trampoline,		/* Language specific skip_trampoline */
@@ -909,8 +906,7 @@ const struct language_defn auto_language_defn =
   unk_lang_emit_char,
   unk_lang_print_type,		/* Print a type using appropriate syntax */
   default_print_typedef,	/* Print a typedef using appropriate syntax */
-  unk_lang_val_print,		/* Print a value using appropriate syntax */
-  nullptr,			/* la_value_print_inner */
+  unk_lang_value_print_inner,	/* la_value_print_inner */
   unk_lang_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   unk_lang_trampoline,		/* Language specific skip_trampoline */
diff --git a/gdb/language.h b/gdb/language.h
index 89cd71c5055..91916c7a18e 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -207,30 +207,6 @@ struct language_defn
     void (*la_print_typedef) (struct type *type, struct symbol *new_symbol,
 			      struct ui_file *stream);
 
-    /* Print a value using syntax appropriate for this language.
-       
-       TYPE is the type of the sub-object to be printed.
-
-       EMBEDDED_OFFSET is the offset into the outermost object of the
-       sub-object represented by TYPE.  This is the object which this
-       call should print.  Note that the enclosing type is not
-       available.
-
-       ADDRESS is the address in the inferior of the enclosing object.
-
-       STREAM is the stream on which the value is to be printed.
-
-       RECURSE is the recursion depth.  It is zero-based.
-
-       OPTIONS are the formatting options to be used when
-       printing.  */
-
-    void (*la_val_print) (struct type *type,
-			  int embedded_offset, CORE_ADDR address,
-			  struct ui_file *stream, int recurse,
-			  struct value *val,
-			  const struct value_print_options *options);
-
     /* Print a value using syntax appropriate for this language.
        RECURSE is the recursion depth.  It is zero-based.  */
 
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 476abcb987e..8d5c2d61aa7 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -393,7 +393,6 @@ extern const struct language_defn m2_language_defn =
   m2_emit_char,			/* Function to print a single character */
   m2_print_type,		/* Print a type using appropriate syntax */
   m2_print_typedef,		/* Print a typedef using appropriate syntax */
-  m2_val_print,			/* Print a value using appropriate syntax */
   m2_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h
index 49414ffcc86..f136b00e875 100644
--- a/gdb/m2-lang.h
+++ b/gdb/m2-lang.h
@@ -35,11 +35,6 @@ extern void m2_print_typedef (struct type *, struct symbol *,
 extern int m2_is_long_set (struct type *type);
 extern int m2_is_unbounded_array (struct type *type);
 
-extern void m2_val_print (struct type *, int, CORE_ADDR,
-			  struct ui_file *, int,
-			  struct value *,
-			  const struct value_print_options *);
-
 /* Implement la_value_print_inner for Modula-2.  */
 
 extern void m2_value_print_inner (struct value *, struct ui_file *, int,
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index 1f3907c41ab..105aa3ac842 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -181,31 +181,6 @@ m2_print_unbounded_array (struct value *value,
   fprintf_filtered (stream, ", HIGH = %d}", (int) len);
 }
 
-static void
-m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
-			  int embedded_offset, CORE_ADDR address,
-			  struct ui_file *stream, int recurse,
-			  const struct value_print_options *options)
-{
-  CORE_ADDR addr;
-  LONGEST len;
-  struct value *val;
-
-  type = check_typedef (type);
-
-  addr = unpack_pointer (TYPE_FIELD_TYPE (type, 0),
-			 (TYPE_FIELD_BITPOS (type, 0) / 8) +
-			 valaddr + embedded_offset);
-
-  val = value_at_lazy (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0)),
-		       addr);
-  len = unpack_field_as_long (type, valaddr + embedded_offset, 1);
-
-  fprintf_filtered (stream, "{");  
-  m2_print_array_contents (val, stream, recurse, options, len);
-  fprintf_filtered (stream, ", HIGH = %d}", (int) len);
-}
-
 static int
 print_unpacked_pointer (struct type *type,
 			CORE_ADDR address, CORE_ADDR addr,
@@ -323,204 +298,6 @@ static const struct generic_val_print_decorations m2_decorations =
   "}"
 };
 
-/* See val_print for a description of the various parameters of this
-   function; they are identical.  */
-
-void
-m2_val_print (struct type *type, int embedded_offset,
-	      CORE_ADDR address, struct ui_file *stream, int recurse,
-	      struct value *original_value,
-	      const struct value_print_options *options)
-{
-  unsigned len;
-  struct type *elttype;
-  CORE_ADDR addr;
-  const gdb_byte *valaddr = value_contents_for_printing (original_value);
-
-  type = check_typedef (type);
-  switch (TYPE_CODE (type))
-    {
-    case TYPE_CODE_ARRAY:
-      if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
-	{
-	  elttype = check_typedef (TYPE_TARGET_TYPE (type));
-	  len = TYPE_LENGTH (type) / TYPE_LENGTH (elttype);
-	  if (options->prettyformat_arrays)
-	    print_spaces_filtered (2 + 2 * recurse, stream);
-	  /* For an array of chars, print with string syntax.  */
-	  if (TYPE_LENGTH (elttype) == 1 &&
-	      ((TYPE_CODE (elttype) == TYPE_CODE_INT)
-	       || ((current_language->la_language == language_m2)
-		   && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
-	      && (options->format == 0 || options->format == 's'))
-	    {
-	      /* If requested, look for the first null char and only print
-	         elements up to it.  */
-	      if (options->stop_print_at_null)
-		{
-		  unsigned int temp_len;
-
-		  /* Look for a NULL char.  */
-		  for (temp_len = 0;
-		       (valaddr + embedded_offset)[temp_len]
-			 && temp_len < len && temp_len < options->print_max;
-		       temp_len++);
-		  len = temp_len;
-		}
-
-	      LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type),
-			       valaddr + embedded_offset, len, NULL,
-			       0, options);
-	    }
-	  else
-	    {
-	      fprintf_filtered (stream, "{");
-	      val_print_array_elements (type, embedded_offset,
-					address, stream,
-					recurse, original_value,
-					options, 0);
-	      fprintf_filtered (stream, "}");
-	    }
-	  break;
-	}
-      /* Array of unspecified length: treat like pointer to first elt.  */
-      print_unpacked_pointer (type, address, address, options, stream);
-      break;
-
-    case TYPE_CODE_PTR:
-      if (TYPE_CONST (type))
-	print_variable_at_address (type, valaddr + embedded_offset,
-				   stream, recurse, options);
-      else if (options->format && options->format != 's')
-	val_print_scalar_formatted (type, embedded_offset,
-				    original_value, options, 0, stream);
-      else
-	{
-	  addr = unpack_pointer (type, valaddr + embedded_offset);
-	  print_unpacked_pointer (type, addr, address, options, stream);
-	}
-      break;
-
-    case TYPE_CODE_UNION:
-      if (recurse && !options->unionprint)
-	{
-	  fprintf_filtered (stream, "{...}");
-	  break;
-	}
-      /* Fall through.  */
-    case TYPE_CODE_STRUCT:
-      if (m2_is_long_set (type))
-	m2_print_long_set (type, valaddr, embedded_offset, address,
-			   stream);
-      else if (m2_is_unbounded_array (type))
-	m2_print_unbounded_array (type, valaddr, embedded_offset,
-				  address, stream, recurse, options);
-      else
-	cp_print_value_fields (type, type, embedded_offset,
-			       address, stream, recurse, original_value,
-			       options, NULL, 0);
-      break;
-
-    case TYPE_CODE_SET:
-      elttype = TYPE_INDEX_TYPE (type);
-      elttype = check_typedef (elttype);
-      if (TYPE_STUB (elttype))
-	{
-	  fprintf_styled (stream, metadata_style.style (),
-			  _("<incomplete type>"));
-	  break;
-	}
-      else
-	{
-	  struct type *range = elttype;
-	  LONGEST low_bound, high_bound;
-	  int i;
-	  int need_comma = 0;
-
-	  fputs_filtered ("{", stream);
-
-	  i = get_discrete_bounds (range, &low_bound, &high_bound);
-	maybe_bad_bstring:
-	  if (i < 0)
-	    {
-	      fputs_styled (_("<error value>"), metadata_style.style (),
-			    stream);
-	      goto done;
-	    }
-
-	  for (i = low_bound; i <= high_bound; i++)
-	    {
-	      int element = value_bit_index (type, valaddr + embedded_offset,
-					     i);
-
-	      if (element < 0)
-		{
-		  i = element;
-		  goto maybe_bad_bstring;
-		}
-	      if (element)
-		{
-		  if (need_comma)
-		    fputs_filtered (", ", stream);
-		  print_type_scalar (range, i, stream);
-		  need_comma = 1;
-
-		  if (i + 1 <= high_bound
-		      && value_bit_index (type, valaddr + embedded_offset,
-					  ++i))
-		    {
-		      int j = i;
-
-		      fputs_filtered ("..", stream);
-		      while (i + 1 <= high_bound
-			     && value_bit_index (type,
-						 valaddr + embedded_offset,
-						 ++i))
-			j = i;
-		      print_type_scalar (range, j, stream);
-		    }
-		}
-	    }
-	done:
-	  fputs_filtered ("}", stream);
-	}
-      break;
-
-    case TYPE_CODE_RANGE:
-      if (TYPE_LENGTH (type) == TYPE_LENGTH (TYPE_TARGET_TYPE (type)))
-	{
-	  m2_val_print (TYPE_TARGET_TYPE (type), embedded_offset,
-			address, stream, recurse, original_value, options);
-	  break;
-	}
-      /* FIXME: create_static_range_type does not set the unsigned bit in a
-         range type (I think it probably should copy it from the target
-         type), so we won't print values which are too large to
-         fit in a signed integer correctly.  */
-      /* FIXME: Doesn't handle ranges of enums correctly.  (Can't just
-         print with the target type, though, because the size of our type
-         and the target type might differ).  */
-      /* FALLTHROUGH */
-
-    case TYPE_CODE_REF:
-    case TYPE_CODE_ENUM:
-    case TYPE_CODE_FUNC:
-    case TYPE_CODE_INT:
-    case TYPE_CODE_FLT:
-    case TYPE_CODE_METHOD:
-    case TYPE_CODE_VOID:
-    case TYPE_CODE_ERROR:
-    case TYPE_CODE_UNDEF:
-    case TYPE_CODE_BOOL:
-    case TYPE_CODE_CHAR:
-    default:
-      generic_val_print (type, embedded_offset, address,
-			 stream, recurse, original_value, options,
-			 &m2_decorations);
-      break;
-    }
-}
-
 /* See m2-lang.h.  */
 
 void
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index c1444163114..f78376c0e6b 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -381,7 +381,6 @@ extern const struct language_defn objc_language_defn = {
   c_emit_char,
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
-  c_val_print,			/* Print a value using appropriate syntax */
   c_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 7933e68b614..a943e313cfe 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1060,7 +1060,6 @@ extern const struct language_defn opencl_language_defn =
   c_emit_char,			/* Print a single char */
   opencl_print_type,		/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
-  c_val_print,			/* Print a value using appropriate syntax */
   c_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 85020c4bedc..8c21f1c8f3e 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -447,7 +447,6 @@ extern const struct language_defn pascal_language_defn =
   pascal_emit_char,		/* Print a single char */
   pascal_print_type,		/* Print a type using appropriate syntax */
   pascal_print_typedef,		/* Print a typedef using appropriate syntax */
-  pascal_val_print,		/* Print a value using appropriate syntax */
   pascal_value_print_inner,	/* la_value_print_inner */
   pascal_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index fafc86c78c4..fce308e2392 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -37,11 +37,6 @@ extern void pascal_print_type (struct type *, const char *, struct ui_file *,
 extern void pascal_print_typedef (struct type *, struct symbol *,
 				  struct ui_file *);
 
-extern void pascal_val_print (struct type *, int,
-			      CORE_ADDR, struct ui_file *, int,
-			      struct value *,
-			      const struct value_print_options *);
-
 /* Implement la_value_print_inner for Pascal.  */
 
 extern void pascal_value_print_inner (struct value *, struct ui_file *, int,
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index e02f70ab3ab..d09c8aae5f6 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -42,14 +42,6 @@
 #include "cli/cli-style.h"
 \f
 
-static void pascal_object_print_value_fields (struct type *, const gdb_byte *,
-					      LONGEST,
-					      CORE_ADDR, struct ui_file *,
-					      int,
-					      struct value *,
-					      const struct value_print_options *,
-					      struct type **, int);
-
 static void pascal_object_print_value_fields (struct value *, struct ui_file *,
 					      int,
 					      const struct value_print_options *,
@@ -69,16 +61,15 @@ static const struct generic_val_print_decorations p_decorations =
   "}"
 };
 
-/* See val_print for a description of the various parameters of this
-   function; they are identical.  */
+/* See p-lang.h.  */
 
 void
-pascal_val_print (struct type *type,
-		  int embedded_offset, CORE_ADDR address,
-		  struct ui_file *stream, int recurse,
-		  struct value *original_value,
-		  const struct value_print_options *options)
+pascal_value_print_inner (struct value *val, struct ui_file *stream,
+			  int recurse,
+			  const struct value_print_options *options)
+
 {
+  struct type *type = check_typedef (value_type (val));
   struct gdbarch *gdbarch = get_type_arch (type);
   enum bfd_endian byte_order = type_byte_order (type);
   unsigned int i = 0;	/* Number of characters printed */
@@ -89,9 +80,8 @@ pascal_val_print (struct type *type,
   struct type *char_type;
   CORE_ADDR addr;
   int want_space = 0;
-  const gdb_byte *valaddr = value_contents_for_printing (original_value);
+  const gdb_byte *valaddr = value_contents_for_printing (val);
 
-  type = check_typedef (type);
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_ARRAY:
@@ -123,17 +113,15 @@ pascal_val_print (struct type *type,
 
 		    /* Look for a NULL char.  */
 		    for (temp_len = 0;
-			 extract_unsigned_integer (valaddr + embedded_offset +
-						   temp_len * eltlen, eltlen,
-						   byte_order)
+			 extract_unsigned_integer (valaddr + temp_len * eltlen,
+						   eltlen, byte_order)
 			   && temp_len < len && temp_len < options->print_max;
 			 temp_len++);
 		    len = temp_len;
 		  }
 
 		LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type),
-				 valaddr + embedded_offset, len, NULL, 0,
-				 options);
+				 valaddr, len, NULL, 0, options);
 		i = len;
 	      }
 	    else
@@ -150,23 +138,20 @@ pascal_val_print (struct type *type,
 		  {
 		    i = 0;
 		  }
-		val_print_array_elements (type, embedded_offset,
-					  address, stream, recurse,
-					  original_value, options, i);
+		value_print_array_elements (val, stream, recurse, options, i);
 		fprintf_filtered (stream, "}");
 	      }
 	    break;
 	  }
 	/* Array of unspecified length: treat like pointer to first elt.  */
-	addr = address + embedded_offset;
+	addr = value_address (val);
       }
       goto print_unpacked_pointer;
 
     case TYPE_CODE_PTR:
       if (options->format && options->format != 's')
 	{
-	  val_print_scalar_formatted (type, embedded_offset,
-				      original_value, options, 0, stream);
+	  value_print_scalar_formatted (val, options, 0, stream);
 	  break;
 	}
       if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
@@ -175,14 +160,14 @@ pascal_val_print (struct type *type,
 	  /* Print vtable entry - we only get here if we ARE using
 	     -fvtable_thunks.  (Otherwise, look under TYPE_CODE_STRUCT.)  */
 	  /* Extract the address, assume that it is unsigned.  */
-	  addr = extract_unsigned_integer (valaddr + embedded_offset,
+	  addr = extract_unsigned_integer (valaddr,
 					   TYPE_LENGTH (type), byte_order);
 	  print_address_demangle (options, gdbarch, addr, stream, demangle);
 	  break;
 	}
       check_typedef (TYPE_TARGET_TYPE (type));
 
-      addr = unpack_pointer (type, valaddr + embedded_offset);
+      addr = unpack_pointer (type, valaddr);
     print_unpacked_pointer:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
 
@@ -240,8 +225,7 @@ pascal_val_print (struct type *type,
       else if (pascal_object_is_vtbl_member (type))
 	{
 	  /* Print vtbl's nicely.  */
-	  CORE_ADDR vt_address = unpack_pointer (type,
-						 valaddr + embedded_offset);
+	  CORE_ADDR vt_address = unpack_pointer (type, valaddr);
 	  struct bound_minimal_symbol msymbol =
 	    lookup_minimal_symbol_by_pc (vt_address);
 
@@ -306,9 +290,7 @@ pascal_val_print (struct type *type,
     case TYPE_CODE_UNDEF:
     case TYPE_CODE_BOOL:
     case TYPE_CODE_CHAR:
-      generic_val_print (type, embedded_offset, address,
-			 stream, recurse, original_value, options,
-			 &p_decorations);
+      generic_value_print (val, stream, recurse, options, &p_decorations);
       break;
 
     case TYPE_CODE_UNION:
@@ -327,7 +309,7 @@ pascal_val_print (struct type *type,
 	  /* Extract the address, assume that it is unsigned.  */
 	  print_address_demangle
 	    (options, gdbarch,
-	     extract_unsigned_integer (valaddr + embedded_offset
+	     extract_unsigned_integer (valaddr
 				       + TYPE_FIELD_BITPOS (type,
 							    VTBL_FNADDR_OFFSET) / 8,
 				       TYPE_LENGTH (TYPE_FIELD_TYPE (type,
@@ -340,18 +322,14 @@ pascal_val_print (struct type *type,
           if (is_pascal_string_type (type, &length_pos, &length_size,
                                      &string_pos, &char_type, NULL))
 	    {
-	      len = extract_unsigned_integer (valaddr + embedded_offset
-					      + length_pos, length_size,
-					      byte_order);
-	      LA_PRINT_STRING (stream, char_type,
-			       valaddr + embedded_offset + string_pos,
+	      len = extract_unsigned_integer (valaddr + length_pos,
+					      length_size, byte_order);
+	      LA_PRINT_STRING (stream, char_type, valaddr + string_pos,
 			       len, NULL, 0, options);
 	    }
 	  else
-	    pascal_object_print_value_fields (type, valaddr, embedded_offset,
-					      address, stream, recurse,
-					      original_value, options,
-					      NULL, 0);
+	    pascal_object_print_value_fields (val, stream, recurse,
+					      options, NULL, 0);
 	}
       break;
 
@@ -389,8 +367,7 @@ pascal_val_print (struct type *type,
 
 	  for (i = low_bound; i <= high_bound; i++)
 	    {
-	      int element = value_bit_index (type,
-					     valaddr + embedded_offset, i);
+	      int element = value_bit_index (type, valaddr, i);
 
 	      if (element < 0)
 		{
@@ -405,16 +382,13 @@ pascal_val_print (struct type *type,
 		  need_comma = 1;
 
 		  if (i + 1 <= high_bound
-		      && value_bit_index (type,
-					  valaddr + embedded_offset, ++i))
+		      && value_bit_index (type, valaddr, ++i))
 		    {
 		      int j = i;
 
 		      fputs_filtered ("..", stream);
 		      while (i + 1 <= high_bound
-			     && value_bit_index (type,
-						 valaddr + embedded_offset,
-						 ++i))
+			     && value_bit_index (type, valaddr, ++i))
 			j = i;
 		      print_type_scalar (range, j, stream);
 		    }
@@ -431,428 +405,75 @@ pascal_val_print (struct type *type,
     }
 }
 
-/* See p-lang.h.  */
-
+\f
 void
-pascal_value_print_inner (struct value *val, struct ui_file *stream,
-			  int recurse,
-			  const struct value_print_options *options)
-
+pascal_value_print (struct value *val, struct ui_file *stream,
+		    const struct value_print_options *options)
 {
-  struct type *type = check_typedef (value_type (val));
-  struct gdbarch *gdbarch = get_type_arch (type);
-  enum bfd_endian byte_order = type_byte_order (type);
-  unsigned int i = 0;	/* Number of characters printed */
-  unsigned len;
-  struct type *elttype;
-  unsigned eltlen;
-  int length_pos, length_size, string_pos;
-  struct type *char_type;
-  CORE_ADDR addr;
-  int want_space = 0;
-  const gdb_byte *valaddr = value_contents_for_printing (val);
-
-  switch (TYPE_CODE (type))
-    {
-    case TYPE_CODE_ARRAY:
-      {
-	LONGEST low_bound, high_bound;
+  struct type *type = value_type (val);
+  struct value_print_options opts = *options;
 
-	if (get_array_bounds (type, &low_bound, &high_bound))
-	  {
-	    len = high_bound - low_bound + 1;
-	    elttype = check_typedef (TYPE_TARGET_TYPE (type));
-	    eltlen = TYPE_LENGTH (elttype);
-	    if (options->prettyformat_arrays)
-	      {
-		print_spaces_filtered (2 + 2 * recurse, stream);
-	      }
-	    /* If 's' format is used, try to print out as string.
-	       If no format is given, print as string if element type
-	       is of TYPE_CODE_CHAR and element size is 1,2 or 4.  */
-	    if (options->format == 's'
-		|| ((eltlen == 1 || eltlen == 2 || eltlen == 4)
-		    && TYPE_CODE (elttype) == TYPE_CODE_CHAR
-		    && options->format == 0))
-	      {
-		/* If requested, look for the first null char and only print
-		   elements up to it.  */
-		if (options->stop_print_at_null)
-		  {
-		    unsigned int temp_len;
+  opts.deref_ref = 1;
 
-		    /* Look for a NULL char.  */
-		    for (temp_len = 0;
-			 extract_unsigned_integer (valaddr + temp_len * eltlen,
-						   eltlen, byte_order)
-			   && temp_len < len && temp_len < options->print_max;
-			 temp_len++);
-		    len = temp_len;
-		  }
+  /* If it is a pointer, indicate what it points to.
 
-		LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type),
-				 valaddr, len, NULL, 0, options);
-		i = len;
-	      }
-	    else
-	      {
-		fprintf_filtered (stream, "{");
-		/* If this is a virtual function table, print the 0th
-		   entry specially, and the rest of the members normally.  */
-		if (pascal_object_is_vtbl_ptr_type (elttype))
-		  {
-		    i = 1;
-		    fprintf_filtered (stream, "%d vtable entries", len - 1);
-		  }
-		else
-		  {
-		    i = 0;
-		  }
-		value_print_array_elements (val, stream, recurse, options, i);
-		fprintf_filtered (stream, "}");
-	      }
-	    break;
-	  }
-	/* Array of unspecified length: treat like pointer to first elt.  */
-	addr = value_address (val);
-      }
-      goto print_unpacked_pointer;
+     Print type also if it is a reference.
 
-    case TYPE_CODE_PTR:
-      if (options->format && options->format != 's')
+     Object pascal: if it is a member pointer, we will take care
+     of that when we print it.  */
+  if (TYPE_CODE (type) == TYPE_CODE_PTR
+      || TYPE_CODE (type) == TYPE_CODE_REF)
+    {
+      /* Hack:  remove (char *) for char strings.  Their
+         type is indicated by the quoted string anyway.  */
+      if (TYPE_CODE (type) == TYPE_CODE_PTR
+	  && TYPE_NAME (type) == NULL
+	  && TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL
+	  && strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char") == 0)
 	{
-	  value_print_scalar_formatted (val, options, 0, stream);
-	  break;
+	  /* Print nothing.  */
 	}
-      if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
+      else
 	{
-	  /* Print the unmangled name if desired.  */
-	  /* Print vtable entry - we only get here if we ARE using
-	     -fvtable_thunks.  (Otherwise, look under TYPE_CODE_STRUCT.)  */
-	  /* Extract the address, assume that it is unsigned.  */
-	  addr = extract_unsigned_integer (valaddr,
-					   TYPE_LENGTH (type), byte_order);
-	  print_address_demangle (options, gdbarch, addr, stream, demangle);
-	  break;
+	  fprintf_filtered (stream, "(");
+	  type_print (type, "", stream, -1);
+	  fprintf_filtered (stream, ") ");
 	}
-      check_typedef (TYPE_TARGET_TYPE (type));
+    }
+  common_val_print (val, stream, 0, &opts, current_language);
+}
 
-      addr = unpack_pointer (type, valaddr);
-    print_unpacked_pointer:
-      elttype = check_typedef (TYPE_TARGET_TYPE (type));
 
-      if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
-	{
-	  /* Try to print what function it points to.  */
-	  print_address_demangle (options, gdbarch, addr, stream, demangle);
-	  return;
-	}
+static void
+show_pascal_static_field_print (struct ui_file *file, int from_tty,
+				struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file, _("Printing of pascal static members is %s.\n"),
+		    value);
+}
 
-      if (options->addressprint && options->format != 's')
-	{
-	  fputs_filtered (paddress (gdbarch, addr), stream);
-	  want_space = 1;
-	}
+static struct obstack dont_print_vb_obstack;
+static struct obstack dont_print_statmem_obstack;
 
-      /* For a pointer to char or unsigned char, also print the string
-	 pointed to, unless pointer is null.  */
-      if (((TYPE_LENGTH (elttype) == 1
-	   && (TYPE_CODE (elttype) == TYPE_CODE_INT
-	      || TYPE_CODE (elttype) == TYPE_CODE_CHAR))
-	  || ((TYPE_LENGTH (elttype) == 2 || TYPE_LENGTH (elttype) == 4)
-	      && TYPE_CODE (elttype) == TYPE_CODE_CHAR))
-	  && (options->format == 0 || options->format == 's')
-	  && addr != 0)
-	{
-	  if (want_space)
-	    fputs_filtered (" ", stream);
-	  /* No wide string yet.  */
-	  i = val_print_string (elttype, NULL, addr, -1, stream, options);
-	}
-      /* Also for pointers to pascal strings.  */
-      /* Note: this is Free Pascal specific:
-	 as GDB does not recognize stabs pascal strings
-	 Pascal strings are mapped to records
-	 with lowercase names PM.  */
-      if (is_pascal_string_type (elttype, &length_pos, &length_size,
-				 &string_pos, &char_type, NULL)
-	  && addr != 0)
-	{
-	  ULONGEST string_length;
-	  gdb_byte *buffer;
+static void pascal_object_print_static_field (struct value *,
+					      struct ui_file *, int,
+					      const struct value_print_options *);
 
-	  if (want_space)
-	    fputs_filtered (" ", stream);
-	  buffer = (gdb_byte *) xmalloc (length_size);
-	  read_memory (addr + length_pos, buffer, length_size);
-	  string_length = extract_unsigned_integer (buffer, length_size,
-						    byte_order);
-	  xfree (buffer);
-	  i = val_print_string (char_type, NULL,
-				addr + string_pos, string_length,
-				stream, options);
-	}
-      else if (pascal_object_is_vtbl_member (type))
-	{
-	  /* Print vtbl's nicely.  */
-	  CORE_ADDR vt_address = unpack_pointer (type, valaddr);
-	  struct bound_minimal_symbol msymbol =
-	    lookup_minimal_symbol_by_pc (vt_address);
+static void pascal_object_print_value (struct value *, struct ui_file *, int,
+				       const struct value_print_options *,
+				       struct type **);
 
-	  /* If 'symbol_print' is set, we did the work above.  */
-	  if (!options->symbol_print
-	      && (msymbol.minsym != NULL)
-	      && (vt_address == BMSYMBOL_VALUE_ADDRESS (msymbol)))
-	    {
-	      if (want_space)
-		fputs_filtered (" ", stream);
-	      fputs_filtered ("<", stream);
-	      fputs_filtered (msymbol.minsym->print_name (), stream);
-	      fputs_filtered (">", stream);
-	      want_space = 1;
-	    }
-	  if (vt_address && options->vtblprint)
-	    {
-	      struct value *vt_val;
-	      struct symbol *wsym = NULL;
-	      struct type *wtype;
+/* It was changed to this after 2.4.5.  */
+const char pascal_vtbl_ptr_name[] =
+{'_', '_', 'v', 't', 'b', 'l', '_', 'p', 't', 'r', '_', 't', 'y', 'p', 'e', 0};
 
-	      if (want_space)
-		fputs_filtered (" ", stream);
+/* Return truth value for assertion that TYPE is of the type
+   "pointer to virtual function".  */
 
-	      if (msymbol.minsym != NULL)
-		{
-		  const char *search_name = msymbol.minsym->search_name ();
-		  wsym = lookup_symbol_search_name (search_name, NULL,
-						    VAR_DOMAIN).symbol;
-		}
-
-	      if (wsym)
-		{
-		  wtype = SYMBOL_TYPE (wsym);
-		}
-	      else
-		{
-		  wtype = TYPE_TARGET_TYPE (type);
-		}
-	      vt_val = value_at (wtype, vt_address);
-	      common_val_print (vt_val, stream, recurse + 1, options,
-				current_language);
-	      if (options->prettyformat)
-		{
-		  fprintf_filtered (stream, "\n");
-		  print_spaces_filtered (2 + 2 * recurse, stream);
-		}
-	    }
-	}
-
-      return;
-
-    case TYPE_CODE_REF:
-    case TYPE_CODE_ENUM:
-    case TYPE_CODE_FLAGS:
-    case TYPE_CODE_FUNC:
-    case TYPE_CODE_RANGE:
-    case TYPE_CODE_INT:
-    case TYPE_CODE_FLT:
-    case TYPE_CODE_VOID:
-    case TYPE_CODE_ERROR:
-    case TYPE_CODE_UNDEF:
-    case TYPE_CODE_BOOL:
-    case TYPE_CODE_CHAR:
-      generic_value_print (val, stream, recurse, options, &p_decorations);
-      break;
-
-    case TYPE_CODE_UNION:
-      if (recurse && !options->unionprint)
-	{
-	  fprintf_filtered (stream, "{...}");
-	  break;
-	}
-      /* Fall through.  */
-    case TYPE_CODE_STRUCT:
-      if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
-	{
-	  /* Print the unmangled name if desired.  */
-	  /* Print vtable entry - we only get here if NOT using
-	     -fvtable_thunks.  (Otherwise, look under TYPE_CODE_PTR.)  */
-	  /* Extract the address, assume that it is unsigned.  */
-	  print_address_demangle
-	    (options, gdbarch,
-	     extract_unsigned_integer (valaddr
-				       + TYPE_FIELD_BITPOS (type,
-							    VTBL_FNADDR_OFFSET) / 8,
-				       TYPE_LENGTH (TYPE_FIELD_TYPE (type,
-								     VTBL_FNADDR_OFFSET)),
-				       byte_order),
-	     stream, demangle);
-	}
-      else
-	{
-          if (is_pascal_string_type (type, &length_pos, &length_size,
-                                     &string_pos, &char_type, NULL))
-	    {
-	      len = extract_unsigned_integer (valaddr + length_pos,
-					      length_size, byte_order);
-	      LA_PRINT_STRING (stream, char_type, valaddr + string_pos,
-			       len, NULL, 0, options);
-	    }
-	  else
-	    pascal_object_print_value_fields (type, valaddr, 0,
-					      value_address (val), stream,
-					      recurse, val, options,
-					      NULL, 0);
-	}
-      break;
-
-    case TYPE_CODE_SET:
-      elttype = TYPE_INDEX_TYPE (type);
-      elttype = check_typedef (elttype);
-      if (TYPE_STUB (elttype))
-	{
-	  fprintf_styled (stream, metadata_style.style (), "<incomplete type>");
-	  break;
-	}
-      else
-	{
-	  struct type *range = elttype;
-	  LONGEST low_bound, high_bound;
-	  int need_comma = 0;
-
-	  fputs_filtered ("[", stream);
-
-	  int bound_info = get_discrete_bounds (range, &low_bound, &high_bound);
-	  if (low_bound == 0 && high_bound == -1 && TYPE_LENGTH (type) > 0)
-	    {
-	      /* If we know the size of the set type, we can figure out the
-	      maximum value.  */
-	      bound_info = 0;
-	      high_bound = TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1;
-	      TYPE_HIGH_BOUND (range) = high_bound;
-	    }
-	maybe_bad_bstring:
-	  if (bound_info < 0)
-	    {
-	      fputs_styled ("<error value>", metadata_style.style (), stream);
-	      goto done;
-	    }
-
-	  for (i = low_bound; i <= high_bound; i++)
-	    {
-	      int element = value_bit_index (type, valaddr, i);
-
-	      if (element < 0)
-		{
-		  i = element;
-		  goto maybe_bad_bstring;
-		}
-	      if (element)
-		{
-		  if (need_comma)
-		    fputs_filtered (", ", stream);
-		  print_type_scalar (range, i, stream);
-		  need_comma = 1;
-
-		  if (i + 1 <= high_bound
-		      && value_bit_index (type, valaddr, ++i))
-		    {
-		      int j = i;
-
-		      fputs_filtered ("..", stream);
-		      while (i + 1 <= high_bound
-			     && value_bit_index (type, valaddr, ++i))
-			j = i;
-		      print_type_scalar (range, j, stream);
-		    }
-		}
-	    }
-	done:
-	  fputs_filtered ("]", stream);
-	}
-      break;
-
-    default:
-      error (_("Invalid pascal type code %d in symbol table."),
-	     TYPE_CODE (type));
-    }
-}
-
-\f
-void
-pascal_value_print (struct value *val, struct ui_file *stream,
-		    const struct value_print_options *options)
-{
-  struct type *type = value_type (val);
-  struct value_print_options opts = *options;
-
-  opts.deref_ref = 1;
-
-  /* If it is a pointer, indicate what it points to.
-
-     Print type also if it is a reference.
-
-     Object pascal: if it is a member pointer, we will take care
-     of that when we print it.  */
-  if (TYPE_CODE (type) == TYPE_CODE_PTR
-      || TYPE_CODE (type) == TYPE_CODE_REF)
-    {
-      /* Hack:  remove (char *) for char strings.  Their
-         type is indicated by the quoted string anyway.  */
-      if (TYPE_CODE (type) == TYPE_CODE_PTR
-	  && TYPE_NAME (type) == NULL
-	  && TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL
-	  && strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char") == 0)
-	{
-	  /* Print nothing.  */
-	}
-      else
-	{
-	  fprintf_filtered (stream, "(");
-	  type_print (type, "", stream, -1);
-	  fprintf_filtered (stream, ") ");
-	}
-    }
-  common_val_print (val, stream, 0, &opts, current_language);
-}
-
-
-static void
-show_pascal_static_field_print (struct ui_file *file, int from_tty,
-				struct cmd_list_element *c, const char *value)
-{
-  fprintf_filtered (file, _("Printing of pascal static members is %s.\n"),
-		    value);
-}
-
-static struct obstack dont_print_vb_obstack;
-static struct obstack dont_print_statmem_obstack;
-
-static void pascal_object_print_static_field (struct value *,
-					      struct ui_file *, int,
-					      const struct value_print_options *);
-
-static void pascal_object_print_value (struct type *, const gdb_byte *,
-				       LONGEST,
-				       CORE_ADDR, struct ui_file *, int,
-				       struct value *,
-				       const struct value_print_options *,
-				       struct type **);
-
-static void pascal_object_print_value (struct value *, struct ui_file *, int,
-				       const struct value_print_options *,
-				       struct type **);
-
-/* It was changed to this after 2.4.5.  */
-const char pascal_vtbl_ptr_name[] =
-{'_', '_', 'v', 't', 'b', 'l', '_', 'p', 't', 'r', '_', 't', 'y', 'p', 'e', 0};
-
-/* Return truth value for assertion that TYPE is of the type
-   "pointer to virtual function".  */
-
-int
-pascal_object_is_vtbl_ptr_type (struct type *type)
-{
-  const char *type_name = TYPE_NAME (type);
+int
+pascal_object_is_vtbl_ptr_type (struct type *type)
+{
+  const char *type_name = TYPE_NAME (type);
 
   return (type_name != NULL
 	  && strcmp (type_name, pascal_vtbl_ptr_name) == 0);
@@ -883,188 +504,6 @@ pascal_object_is_vtbl_member (struct type *type)
   return 0;
 }
 
-/* Mutually recursive subroutines of pascal_object_print_value and
-   c_val_print to print out a structure's fields:
-   pascal_object_print_value_fields and pascal_object_print_value.
-
-   TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the
-   same meanings as in pascal_object_print_value and c_val_print.
-
-   DONT_PRINT is an array of baseclass types that we
-   should not print, or zero if called from top level.  */
-
-static void
-pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
-				  LONGEST offset,
-				  CORE_ADDR address, struct ui_file *stream,
-				  int recurse,
-				  struct value *val,
-				  const struct value_print_options *options,
-				  struct type **dont_print_vb,
-				  int dont_print_statmem)
-{
-  int i, len, n_baseclasses;
-  char *last_dont_print
-    = (char *) obstack_next_free (&dont_print_statmem_obstack);
-
-  type = check_typedef (type);
-
-  fprintf_filtered (stream, "{");
-  len = TYPE_NFIELDS (type);
-  n_baseclasses = TYPE_N_BASECLASSES (type);
-
-  /* Print out baseclasses such that we don't print
-     duplicates of virtual baseclasses.  */
-  if (n_baseclasses > 0)
-    pascal_object_print_value (type, valaddr, offset, address,
-			       stream, recurse + 1, val,
-			       options, dont_print_vb);
-
-  if (!len && n_baseclasses == 1)
-    fprintf_styled (stream, metadata_style.style (), "<No data fields>");
-  else
-    {
-      struct obstack tmp_obstack = dont_print_statmem_obstack;
-      int fields_seen = 0;
-
-      if (dont_print_statmem == 0)
-	{
-	  /* If we're at top level, carve out a completely fresh
-	     chunk of the obstack and use that until this particular
-	     invocation returns.  */
-	  obstack_finish (&dont_print_statmem_obstack);
-	}
-
-      for (i = n_baseclasses; i < len; i++)
-	{
-	  /* If requested, skip printing of static fields.  */
-	  if (!options->pascal_static_field_print
-	      && field_is_static (&TYPE_FIELD (type, i)))
-	    continue;
-	  if (fields_seen)
-	    fprintf_filtered (stream, ", ");
-	  else if (n_baseclasses > 0)
-	    {
-	      if (options->prettyformat)
-		{
-		  fprintf_filtered (stream, "\n");
-		  print_spaces_filtered (2 + 2 * recurse, stream);
-		  fputs_filtered ("members of ", stream);
-		  fputs_filtered (TYPE_NAME (type), stream);
-		  fputs_filtered (": ", stream);
-		}
-	    }
-	  fields_seen = 1;
-
-	  if (options->prettyformat)
-	    {
-	      fprintf_filtered (stream, "\n");
-	      print_spaces_filtered (2 + 2 * recurse, stream);
-	    }
-	  else
-	    {
-	      wrap_here (n_spaces (2 + 2 * recurse));
-	    }
-
-	  annotate_field_begin (TYPE_FIELD_TYPE (type, i));
-
-	  if (field_is_static (&TYPE_FIELD (type, i)))
-	    fputs_filtered ("static ", stream);
-	  fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i),
-				   language_cplus,
-				   DMGL_PARAMS | DMGL_ANSI);
-	  annotate_field_name_end ();
-	  fputs_filtered (" = ", stream);
-	  annotate_field_value ();
-
-	  if (!field_is_static (&TYPE_FIELD (type, i))
-	      && TYPE_FIELD_PACKED (type, i))
-	    {
-	      struct value *v;
-
-	      /* Bitfields require special handling, especially due to byte
-	         order problems.  */
-	      if (TYPE_FIELD_IGNORE (type, i))
-		{
-		  fputs_styled ("<optimized out or zero length>",
-				metadata_style.style (), stream);
-		}
-	      else if (value_bits_synthetic_pointer (val,
-						     TYPE_FIELD_BITPOS (type,
-									i),
-						     TYPE_FIELD_BITSIZE (type,
-									 i)))
-		{
-		  fputs_styled (_("<synthetic pointer>"),
-				metadata_style.style (), stream);
-		}
-	      else
-		{
-		  struct value_print_options opts = *options;
-
-		  v = value_field_bitfield (type, i, valaddr, offset, val);
-
-		  opts.deref_ref = 0;
-		  common_val_print (v, stream, recurse + 1, &opts,
-				    current_language);
-		}
-	    }
-	  else
-	    {
-	      if (TYPE_FIELD_IGNORE (type, i))
-		{
-		  fputs_styled ("<optimized out or zero length>",
-				metadata_style.style (), stream);
-		}
-	      else if (field_is_static (&TYPE_FIELD (type, i)))
-		{
-		  /* struct value *v = value_static_field (type, i);
-		     v4.17 specific.  */
-		  struct value *v;
-
-		  v = value_field_bitfield (type, i, valaddr, offset, val);
-
-		  if (v == NULL)
-		    val_print_optimized_out (NULL, stream);
-		  else
-		    pascal_object_print_static_field (v, stream, recurse + 1,
-						      options);
-		}
-	      else
-		{
-		  struct value_print_options opts = *options;
-
-		  opts.deref_ref = 0;
-		  /* val_print (TYPE_FIELD_TYPE (type, i),
-		     valaddr + TYPE_FIELD_BITPOS (type, i) / 8,
-		     address + TYPE_FIELD_BITPOS (type, i) / 8, 0,
-		     stream, format, 0, recurse + 1, pretty); */
-		  val_print (TYPE_FIELD_TYPE (type, i),
-			     offset + TYPE_FIELD_BITPOS (type, i) / 8,
-			     address, stream, recurse + 1, val, &opts,
-			     current_language);
-		}
-	    }
-	  annotate_field_end ();
-	}
-
-      if (dont_print_statmem == 0)
-	{
-	  /* Free the space used to deal with the printing
-	     of the members from top level.  */
-	  obstack_free (&dont_print_statmem_obstack, last_dont_print);
-	  dont_print_statmem_obstack = tmp_obstack;
-	}
-
-      if (options->prettyformat)
-	{
-	  fprintf_filtered (stream, "\n");
-	  print_spaces_filtered (2 * recurse, stream);
-	}
-    }
-  fprintf_filtered (stream, "}");
-}
-
 /* Mutually recursive subroutines of pascal_object_print_value and
    c_val_print to print out a structure's fields:
    pascal_object_print_val_fields and pascal_object_print_value.
@@ -1241,132 +680,6 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
   fprintf_filtered (stream, "}");
 }
 
-/* Special val_print routine to avoid printing multiple copies of virtual
-   baseclasses.  */
-
-static void
-pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
-			   LONGEST offset,
-			   CORE_ADDR address, struct ui_file *stream,
-			   int recurse,
-			   struct value *val,
-			   const struct value_print_options *options,
-			   struct type **dont_print_vb)
-{
-  struct type **last_dont_print
-    = (struct type **) obstack_next_free (&dont_print_vb_obstack);
-  struct obstack tmp_obstack = dont_print_vb_obstack;
-  int i, n_baseclasses = TYPE_N_BASECLASSES (type);
-
-  if (dont_print_vb == 0)
-    {
-      /* If we're at top level, carve out a completely fresh
-         chunk of the obstack and use that until this particular
-         invocation returns.  */
-      /* Bump up the high-water mark.  Now alpha is omega.  */
-      obstack_finish (&dont_print_vb_obstack);
-    }
-
-  for (i = 0; i < n_baseclasses; i++)
-    {
-      LONGEST boffset = 0;
-      struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
-      const char *basename = TYPE_NAME (baseclass);
-      const gdb_byte *base_valaddr = NULL;
-      LONGEST thisoffset;
-      int skip = 0;
-      gdb::byte_vector buf;
-
-      if (BASETYPE_VIA_VIRTUAL (type, i))
-	{
-	  struct type **first_dont_print
-	    = (struct type **) obstack_base (&dont_print_vb_obstack);
-
-	  int j = (struct type **) obstack_next_free (&dont_print_vb_obstack)
-	    - first_dont_print;
-
-	  while (--j >= 0)
-	    if (baseclass == first_dont_print[j])
-	      goto flush_it;
-
-	  obstack_ptr_grow (&dont_print_vb_obstack, baseclass);
-	}
-
-      thisoffset = offset;
-
-      try
-	{
-	  boffset = baseclass_offset (type, i, valaddr, offset, address, val);
-	}
-      catch (const gdb_exception_error &ex)
-	{
-	  if (ex.error == NOT_AVAILABLE_ERROR)
-	    skip = -1;
-	  else
-	    skip = 1;
-	}
-
-      if (skip == 0)
-	{
-	  /* The virtual base class pointer might have been clobbered by the
-	     user program. Make sure that it still points to a valid memory
-	     location.  */
-
-	  if (boffset < 0 || boffset >= TYPE_LENGTH (type))
-	    {
-	      buf.resize (TYPE_LENGTH (baseclass));
-
-	      base_valaddr = buf.data ();
-	      if (target_read_memory (address + boffset, buf.data (),
-				      TYPE_LENGTH (baseclass)) != 0)
-		skip = 1;
-	      address = address + boffset;
-	      thisoffset = 0;
-	      boffset = 0;
-	    }
-	  else
-	    base_valaddr = valaddr;
-	}
-
-      if (options->prettyformat)
-	{
-	  fprintf_filtered (stream, "\n");
-	  print_spaces_filtered (2 * recurse, stream);
-	}
-      fputs_filtered ("<", stream);
-      /* Not sure what the best notation is in the case where there is no
-         baseclass name.  */
-
-      fputs_filtered (basename ? basename : "", stream);
-      fputs_filtered ("> = ", stream);
-
-      if (skip < 0)
-	val_print_unavailable (stream);
-      else if (skip > 0)
-	val_print_invalid_address (stream);
-      else
-	pascal_object_print_value_fields (baseclass, base_valaddr,
-					  thisoffset + boffset, address,
-					  stream, recurse, val, options,
-		     (struct type **) obstack_base (&dont_print_vb_obstack),
-					  0);
-      fputs_filtered (", ", stream);
-
-    flush_it:
-      ;
-    }
-
-  if (dont_print_vb == 0)
-    {
-      /* Free the space used to deal with the printing
-         of this type from top level.  */
-      obstack_free (&dont_print_vb_obstack, last_dont_print);
-      /* Reset watermark so that we can continue protecting
-         ourselves from whatever we were protecting ourselves.  */
-      dont_print_vb_obstack = tmp_obstack;
-    }
-}
-
 /* Special val_print routine to avoid printing multiple copies of virtual
    baseclasses.  */
 
@@ -1536,12 +849,8 @@ pascal_object_print_static_field (struct value *val,
 		    sizeof (CORE_ADDR));
 
       type = check_typedef (type);
-      pascal_object_print_value_fields (type,
-					value_contents_for_printing (val),
-					value_embedded_offset (val),
-					addr,
-					stream, recurse,
-					val, options, NULL, 1);
+      pascal_object_print_value_fields (val, stream, recurse,
+					options, NULL, 1);
       return;
     }
 
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index bbeccf6ad43..8bcb5bdcaf4 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -543,18 +543,6 @@ static const struct generic_val_print_decorations rust_decorations =
   "]"
 };
 
-/* la_val_print implementation for Rust.  */
-
-static void
-rust_val_print (struct type *type, int embedded_offset,
-		CORE_ADDR address, struct ui_file *stream, int recurse,
-		struct value *val,
-		const struct value_print_options *options)
-{
-  generic_val_print (type, embedded_offset, address, stream,
-		     recurse, val, options, &rust_decorations);
-}
-
 /* la_value_print_inner implementation for Rust.  */
 static void
 rust_value_print_inner (struct value *val, struct ui_file *stream,
@@ -2150,7 +2138,6 @@ extern const struct language_defn rust_language_defn =
   rust_emitchar,		/* Print a single char */
   rust_print_type,		/* Print a type using appropriate syntax */
   rust_print_typedef,		/* Print a typedef using appropriate syntax */
-  rust_val_print,		/* Print a value using appropriate syntax */
   rust_value_print_inner,	/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 56f06be6b9c..3f3cdd7db3c 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -423,14 +423,13 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
 /* generic_val_print helper for TYPE_CODE_ARRAY.  */
 
 static void
-generic_val_print_array (struct type *type,
-			 int embedded_offset, CORE_ADDR address,
+generic_val_print_array (struct value *val,
 			 struct ui_file *stream, int recurse,
-			 struct value *original_value,
 			 const struct value_print_options *options,
 			 const struct
 			     generic_val_print_decorations *decorations)
 {
+  struct type *type = check_typedef (value_type (val));
   struct type *unresolved_elttype = TYPE_TARGET_TYPE (type);
   struct type *elttype = check_typedef (unresolved_elttype);
 
@@ -447,48 +446,18 @@ generic_val_print_array (struct type *type,
 	}
 
       fputs_filtered (decorations->array_start, stream);
-      val_print_array_elements (type, embedded_offset,
-				address, stream,
-				recurse, original_value, options, 0);
+      value_print_array_elements (val, stream, recurse, options, 0);
       fputs_filtered (decorations->array_end, stream);
     }
   else
     {
       /* Array of unspecified length: treat like pointer to first elt.  */
-      print_unpacked_pointer (type, elttype, address + embedded_offset, stream,
-			      options);
+      print_unpacked_pointer (type, elttype, value_address (val),
+			      stream, options);
     }
 
 }
 
-/* generic_val_print helper for TYPE_CODE_PTR.  */
-
-static void
-generic_val_print_ptr (struct type *type,
-		       int embedded_offset, struct ui_file *stream,
-		       struct value *original_value,
-		       const struct value_print_options *options)
-{
-  struct gdbarch *gdbarch = get_type_arch (type);
-  int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
-
-  if (options->format && options->format != 's')
-    {
-      val_print_scalar_formatted (type, embedded_offset,
-				  original_value, options, 0, stream);
-    }
-  else
-    {
-      struct type *unresolved_elttype = TYPE_TARGET_TYPE(type);
-      struct type *elttype = check_typedef (unresolved_elttype);
-      const gdb_byte *valaddr = value_contents_for_printing (original_value);
-      CORE_ADDR addr = unpack_pointer (type,
-				       valaddr + embedded_offset * unit_size);
-
-      print_unpacked_pointer (type, elttype, addr, stream, options);
-    }
-}
-
 /* generic_value_print helper for TYPE_CODE_PTR.  */
 
 static void
@@ -510,18 +479,6 @@ generic_value_print_ptr (struct value *val, struct ui_file *stream,
 }
 
 
-/* generic_val_print helper for TYPE_CODE_MEMBERPTR.  */
-
-static void
-generic_val_print_memberptr (struct type *type,
-			     int embedded_offset, struct ui_file *stream,
-			     struct value *original_value,
-			     const struct value_print_options *options)
-{
-  val_print_scalar_formatted (type, embedded_offset,
-			      original_value, options, 0, stream);
-}
-
 /* Print '@' followed by the address contained in ADDRESS_BUFFER.  */
 
 static void
@@ -728,41 +685,6 @@ generic_val_print_func (struct type *type,
   print_address_demangle (options, gdbarch, address, stream, demangle);
 }
 
-/* generic_val_print helper for TYPE_CODE_BOOL.  */
-
-static void
-generic_val_print_bool (struct type *type,
-			int embedded_offset, struct ui_file *stream,
-			struct value *original_value,
-			const struct value_print_options *options,
-			const struct generic_val_print_decorations *decorations)
-{
-  LONGEST val;
-  struct gdbarch *gdbarch = get_type_arch (type);
-  int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
-
-  if (options->format || options->output_format)
-    {
-      struct value_print_options opts = *options;
-      opts.format = (options->format ? options->format
-		     : options->output_format);
-      val_print_scalar_formatted (type, embedded_offset,
-				  original_value, &opts, 0, stream);
-    }
-  else
-    {
-      const gdb_byte *valaddr = value_contents_for_printing (original_value);
-
-      val = unpack_long (type, valaddr + embedded_offset * unit_size);
-      if (val == 0)
-	fputs_filtered (decorations->false_name, stream);
-      else if (val == 1)
-	fputs_filtered (decorations->true_name, stream);
-      else
-	print_longest (stream, 'd', 0, val);
-    }
-}
-
 /* generic_value_print helper for TYPE_CODE_BOOL.  */
 
 static void
@@ -792,22 +714,6 @@ generic_value_print_bool
     }
 }
 
-/* generic_val_print helper for TYPE_CODE_INT.  */
-
-static void
-generic_val_print_int (struct type *type,
-		       int embedded_offset, struct ui_file *stream,
-		       struct value *original_value,
-		       const struct value_print_options *options)
-{
-  struct value_print_options opts = *options;
-
-  opts.format = (options->format ? options->format
-		 : options->output_format);
-  val_print_scalar_formatted (type, embedded_offset,
-			      original_value, &opts, 0, stream);
-}
-
 /* generic_value_print helper for TYPE_CODE_INT.  */
 
 static void
@@ -821,42 +727,6 @@ generic_value_print_int (struct value *val, struct ui_file *stream,
   value_print_scalar_formatted (val, &opts, 0, stream);
 }
 
-/* generic_val_print helper for TYPE_CODE_CHAR.  */
-
-static void
-generic_val_print_char (struct type *type, struct type *unresolved_type,
-			int embedded_offset,
-			struct ui_file *stream,
-			struct value *original_value,
-			const struct value_print_options *options)
-{
-  LONGEST val;
-  struct gdbarch *gdbarch = get_type_arch (type);
-  int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
-
-  if (options->format || options->output_format)
-    {
-      struct value_print_options opts = *options;
-
-      opts.format = (options->format ? options->format
-		     : options->output_format);
-      val_print_scalar_formatted (type, embedded_offset,
-				  original_value, &opts, 0, stream);
-    }
-  else
-    {
-      const gdb_byte *valaddr = value_contents_for_printing (original_value);
-
-      val = unpack_long (type, valaddr + embedded_offset * unit_size);
-      if (TYPE_UNSIGNED (type))
-	fprintf_filtered (stream, "%u", (unsigned int) val);
-      else
-	fprintf_filtered (stream, "%d", (int) val);
-      fputs_filtered (" ", stream);
-      LA_PRINT_CHAR (val, unresolved_type, stream);
-    }
-}
-
 /* generic_value_print helper for TYPE_CODE_CHAR.  */
 
 static void
@@ -905,41 +775,6 @@ generic_val_print_float (struct type *type,
   print_floating (valaddr + embedded_offset * unit_size, type, stream);
 }
 
-/* generic_val_print helper for TYPE_CODE_COMPLEX.  */
-
-static void
-generic_val_print_complex (struct type *type,
-			   int embedded_offset, struct ui_file *stream,
-			   struct value *original_value,
-			   const struct value_print_options *options,
-			   const struct generic_val_print_decorations
-			     *decorations)
-{
-  struct gdbarch *gdbarch = get_type_arch (type);
-  int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
-  const gdb_byte *valaddr = value_contents_for_printing (original_value);
-
-  fprintf_filtered (stream, "%s", decorations->complex_prefix);
-  if (options->format)
-    val_print_scalar_formatted (TYPE_TARGET_TYPE (type),
-				embedded_offset, original_value, options, 0,
-				stream);
-  else
-    print_floating (valaddr + embedded_offset * unit_size,
-		    TYPE_TARGET_TYPE (type), stream);
-  fprintf_filtered (stream, "%s", decorations->complex_infix);
-  if (options->format)
-    val_print_scalar_formatted (TYPE_TARGET_TYPE (type),
-				embedded_offset
-				+ type_length_units (TYPE_TARGET_TYPE (type)),
-				original_value, options, 0, stream);
-  else
-    print_floating (valaddr + embedded_offset * unit_size
-		    + TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
-		    TYPE_TARGET_TYPE (type), stream);
-  fprintf_filtered (stream, "%s", decorations->complex_suffix);
-}
-
 /* generic_value_print helper for TYPE_CODE_COMPLEX.  */
 
 static void
@@ -964,144 +799,6 @@ generic_value_print_complex (struct value *val, struct ui_file *stream,
   fprintf_filtered (stream, "%s", decorations->complex_suffix);
 }
 
-/* A generic val_print that is suitable for use by language
-   implementations of the la_val_print method.  This function can
-   handle most type codes, though not all, notably exception
-   TYPE_CODE_UNION and TYPE_CODE_STRUCT, which must be implemented by
-   the caller.
-   
-   Most arguments are as to val_print.
-   
-   The additional DECORATIONS argument can be used to customize the
-   output in some small, language-specific ways.  */
-
-void
-generic_val_print (struct type *type,
-		   int embedded_offset, CORE_ADDR address,
-		   struct ui_file *stream, int recurse,
-		   struct value *original_value,
-		   const struct value_print_options *options,
-		   const struct generic_val_print_decorations *decorations)
-{
-  struct type *unresolved_type = type;
-
-  type = check_typedef (type);
-  switch (TYPE_CODE (type))
-    {
-    case TYPE_CODE_ARRAY:
-      generic_val_print_array (type, embedded_offset, address, stream,
-			       recurse, original_value, options, decorations);
-      break;
-
-    case TYPE_CODE_MEMBERPTR:
-      generic_val_print_memberptr (type, embedded_offset, stream,
-				   original_value, options);
-      break;
-
-    case TYPE_CODE_PTR:
-      generic_val_print_ptr (type, embedded_offset, stream,
-			     original_value, options);
-      break;
-
-    case TYPE_CODE_REF:
-    case TYPE_CODE_RVALUE_REF:
-      generic_val_print_ref (type, embedded_offset, stream, recurse,
-			     original_value, options);
-      break;
-
-    case TYPE_CODE_ENUM:
-      if (options->format)
-	val_print_scalar_formatted (type, embedded_offset,
-				    original_value, options, 0, stream);
-      else
-	generic_val_print_enum (type, embedded_offset, stream,
-				original_value, options);
-      break;
-
-    case TYPE_CODE_FLAGS:
-      if (options->format)
-	val_print_scalar_formatted (type, embedded_offset,
-				    original_value, options, 0, stream);
-      else
-	val_print_type_code_flags (type, original_value, embedded_offset,
-				   stream);
-      break;
-
-    case TYPE_CODE_FUNC:
-    case TYPE_CODE_METHOD:
-      if (options->format)
-	val_print_scalar_formatted (type, embedded_offset,
-				    original_value, options, 0, stream);
-      else
-	generic_val_print_func (type, embedded_offset, address, stream,
-				original_value, options);
-      break;
-
-    case TYPE_CODE_BOOL:
-      generic_val_print_bool (type, embedded_offset, stream,
-			      original_value, options, decorations);
-      break;
-
-    case TYPE_CODE_RANGE:
-      /* FIXME: create_static_range_type does not set the unsigned bit in a
-         range type (I think it probably should copy it from the
-         target type), so we won't print values which are too large to
-         fit in a signed integer correctly.  */
-      /* FIXME: Doesn't handle ranges of enums correctly.  (Can't just
-         print with the target type, though, because the size of our
-         type and the target type might differ).  */
-
-      /* FALLTHROUGH */
-
-    case TYPE_CODE_INT:
-      generic_val_print_int (type, embedded_offset, stream,
-			     original_value, options);
-      break;
-
-    case TYPE_CODE_CHAR:
-      generic_val_print_char (type, unresolved_type, embedded_offset,
-			      stream, original_value, options);
-      break;
-
-    case TYPE_CODE_FLT:
-    case TYPE_CODE_DECFLOAT:
-      if (options->format)
-	val_print_scalar_formatted (type, embedded_offset,
-				    original_value, options, 0, stream);
-      else
-	generic_val_print_float (type, embedded_offset, stream,
-				 original_value, options);
-      break;
-
-    case TYPE_CODE_VOID:
-      fputs_filtered (decorations->void_name, stream);
-      break;
-
-    case TYPE_CODE_ERROR:
-      fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type));
-      break;
-
-    case TYPE_CODE_UNDEF:
-      /* This happens (without TYPE_STUB set) on systems which don't use
-         dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar"
-         and no complete type for struct foo in that file.  */
-      fprintf_styled (stream, metadata_style.style (), _("<incomplete type>"));
-      break;
-
-    case TYPE_CODE_COMPLEX:
-      generic_val_print_complex (type, embedded_offset, stream,
-				 original_value, options, decorations);
-      break;
-
-    case TYPE_CODE_UNION:
-    case TYPE_CODE_STRUCT:
-    case TYPE_CODE_METHODPTR:
-    default:
-      error (_("Unhandled type code %d in symbol table."),
-	     TYPE_CODE (type));
-    }
-}
-
 /* See valprint.h.  */
 
 void
@@ -1115,8 +812,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_ARRAY:
-      generic_val_print_array (type, 0, value_address (val), stream,
-			       recurse, val, options, decorations);
+      generic_val_print_array (val, stream, recurse, options, decorations);
       break;
 
     case TYPE_CODE_MEMBERPTR:
@@ -1221,15 +917,13 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
    the value to be printed.  */
 
 static void
-do_val_print (struct value *full_value,
-	      struct type *type, LONGEST embedded_offset,
-	      CORE_ADDR address, struct ui_file *stream, int recurse,
-	      struct value *val,
+do_val_print (struct value *value, struct ui_file *stream, int recurse,
 	      const struct value_print_options *options,
 	      const struct language_defn *language)
 {
   int ret = 0;
   struct value_print_options local_opts = *options;
+  struct type *type = value_type (value);
   struct type *real_type = check_typedef (type);
 
   if (local_opts.prettyformat == Val_prettyformat_default)
@@ -1248,17 +942,12 @@ do_val_print (struct value *full_value,
       return;
     }
 
-  if (!valprint_check_validity (stream, real_type, embedded_offset, val))
+  if (!valprint_check_validity (stream, real_type, 0, value))
     return;
 
   if (!options->raw)
     {
-      struct value *v = full_value;
-
-      if (v == nullptr)
-	v = value_from_component (val, type, embedded_offset);
-
-      ret = apply_ext_lang_val_pretty_printer (v, stream, recurse, options,
+      ret = apply_ext_lang_val_pretty_printer (value, stream, recurse, options,
 					       language);
       if (ret)
 	return;
@@ -1279,13 +968,7 @@ do_val_print (struct value *full_value,
 
   try
     {
-      if (full_value != nullptr && language->la_value_print_inner != nullptr)
-	language->la_value_print_inner (full_value, stream, recurse,
-					&local_opts);
-      else
-	language->la_val_print (type, embedded_offset, address,
-				stream, recurse, val,
-				&local_opts);
+      language->la_value_print_inner (value, stream, recurse, &local_opts);
     }
   catch (const gdb_exception_error &except)
     {
@@ -1294,36 +977,6 @@ do_val_print (struct value *full_value,
     }
 }
 
-/* Print using the given LANGUAGE the data of type TYPE located at
-   VAL's contents buffer + EMBEDDED_OFFSET (within GDB), which came
-   from the inferior at address ADDRESS + EMBEDDED_OFFSET, onto
-   stdio stream STREAM according to OPTIONS.  VAL is the whole object
-   that came from ADDRESS.
-
-   The language printers will pass down an adjusted EMBEDDED_OFFSET to
-   further helper subroutines as subfields of TYPE are printed.  In
-   such cases, VAL is passed down unadjusted, so
-   that VAL can be queried for metadata about the contents data being
-   printed, using EMBEDDED_OFFSET as an offset into VAL's contents
-   buffer.  For example: "has this field been optimized out", or "I'm
-   printing an object while inspecting a traceframe; has this
-   particular piece of data been collected?".
-
-   RECURSE indicates the amount of indentation to supply before
-   continuation lines; this amount is roughly twice the value of
-   RECURSE.  */
-
-void
-val_print (struct type *type, LONGEST embedded_offset,
-	   CORE_ADDR address, struct ui_file *stream, int recurse,
-	   struct value *val,
-	   const struct value_print_options *options,
-	   const struct language_defn *language)
-{
-  do_val_print (nullptr, type, embedded_offset, address, stream,
-		recurse, val, options, language);
-}
-
 /* See valprint.h.  */
 
 bool
@@ -1408,9 +1061,6 @@ common_val_print (struct value *val, struct ui_file *stream, int recurse,
 		  const struct value_print_options *options,
 		  const struct language_defn *language)
 {
-  if (!value_check_printable (val, stream, options))
-    return;
-
   if (language->la_language == language_ada)
     /* The value might have a dynamic type, which would cause trouble
        below when trying to extract the value contents (since the value
@@ -1421,10 +1071,7 @@ common_val_print (struct value *val, struct ui_file *stream, int recurse,
   if (value_lazy (val))
     value_fetch_lazy (val);
 
-  do_val_print (val, value_type (val),
-		value_embedded_offset (val), value_address (val),
-		stream, recurse,
-		val, options, language);
+  do_val_print (val, stream, recurse, options, language);
 }
 
 /* See valprint.h.  */
@@ -1514,57 +1161,6 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
   fputs_filtered (" ]", stream);
 }
 
-/* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
-   according to OPTIONS and SIZE on STREAM.  Format i is not supported
-   at this level.
-
-   This is how the elements of an array or structure are printed
-   with a format.  */
-
-void
-val_print_scalar_formatted (struct type *type,
-			    LONGEST embedded_offset,
-			    struct value *val,
-			    const struct value_print_options *options,
-			    int size,
-			    struct ui_file *stream)
-{
-  struct gdbarch *arch = get_type_arch (type);
-  int unit_size = gdbarch_addressable_memory_unit_size (arch);
-
-  gdb_assert (val != NULL);
-
-  /* If we get here with a string format, try again without it.  Go
-     all the way back to the language printers, which may call us
-     again.  */
-  if (options->format == 's')
-    {
-      struct value_print_options opts = *options;
-      opts.format = 0;
-      opts.deref_ref = 0;
-      val_print (type, embedded_offset, 0, stream, 0, val, &opts,
-		 current_language);
-      return;
-    }
-
-  /* value_contents_for_printing fetches all VAL's contents.  They are
-     needed to check whether VAL is optimized-out or unavailable
-     below.  */
-  const gdb_byte *valaddr = value_contents_for_printing (val);
-
-  /* A scalar object that does not have all bits available can't be
-     printed, because all bits contribute to its representation.  */
-  if (value_bits_any_optimized_out (val,
-				    TARGET_CHAR_BIT * embedded_offset,
-				    TARGET_CHAR_BIT * TYPE_LENGTH (type)))
-    val_print_optimized_out (val, stream);
-  else if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type)))
-    val_print_unavailable (stream);
-  else
-    print_scalar_formatted (valaddr + embedded_offset * unit_size, type,
-			    options, size, stream);
-}
-
 /* See valprint.h.  */
 
 void
@@ -2246,144 +1842,6 @@ maybe_print_array_index (struct type *index_type, LONGEST index,
   LA_PRINT_ARRAY_INDEX (index_value, stream, options);
 }
 
-/*  Called by various <lang>_val_print routines to print elements of an
-   array in the form "<elem1>, <elem2>, <elem3>, ...".
-
-   (FIXME?)  Assumes array element separator is a comma, which is correct
-   for all languages currently handled.
-   (FIXME?)  Some languages have a notation for repeated array elements,
-   perhaps we should try to use that notation when appropriate.  */
-
-void
-val_print_array_elements (struct type *type,
-			  LONGEST embedded_offset,
-			  CORE_ADDR address, struct ui_file *stream,
-			  int recurse,
-			  struct value *val,
-			  const struct value_print_options *options,
-			  unsigned int i)
-{
-  unsigned int things_printed = 0;
-  unsigned len;
-  struct type *elttype, *index_type, *base_index_type;
-  unsigned eltlen;
-  /* Position of the array element we are examining to see
-     whether it is repeated.  */
-  unsigned int rep1;
-  /* Number of repetitions we have detected so far.  */
-  unsigned int reps;
-  LONGEST low_bound, high_bound;
-  LONGEST low_pos, high_pos;
-
-  elttype = TYPE_TARGET_TYPE (type);
-  eltlen = type_length_units (check_typedef (elttype));
-  index_type = TYPE_INDEX_TYPE (type);
-
-  if (get_array_bounds (type, &low_bound, &high_bound))
-    {
-      if (TYPE_CODE (index_type) == TYPE_CODE_RANGE)
-	base_index_type = TYPE_TARGET_TYPE (index_type);
-      else
-	base_index_type = index_type;
-
-      /* Non-contiguous enumerations types can by used as index types
-	 in some languages (e.g. Ada).  In this case, the array length
-	 shall be computed from the positions of the first and last
-	 literal in the enumeration type, and not from the values
-	 of these literals.  */
-      if (!discrete_position (base_index_type, low_bound, &low_pos)
-	  || !discrete_position (base_index_type, high_bound, &high_pos))
-	{
-	  warning (_("unable to get positions in array, use bounds instead"));
-	  low_pos = low_bound;
-	  high_pos = high_bound;
-	}
-
-      /* The array length should normally be HIGH_POS - LOW_POS + 1.
-         But we have to be a little extra careful, because some languages
-	 such as Ada allow LOW_POS to be greater than HIGH_POS for
-	 empty arrays.  In that situation, the array length is just zero,
-	 not negative!  */
-      if (low_pos > high_pos)
-	len = 0;
-      else
-	len = high_pos - low_pos + 1;
-    }
-  else
-    {
-      warning (_("unable to get bounds of array, assuming null array"));
-      low_bound = 0;
-      len = 0;
-    }
-
-  annotate_array_section_begin (i, elttype);
-
-  for (; i < len && things_printed < options->print_max; i++)
-    {
-      if (i != 0)
-	{
-	  if (options->prettyformat_arrays)
-	    {
-	      fprintf_filtered (stream, ",\n");
-	      print_spaces_filtered (2 + 2 * recurse, stream);
-	    }
-	  else
-	    {
-	      fprintf_filtered (stream, ", ");
-	    }
-	}
-      wrap_here (n_spaces (2 + 2 * recurse));
-      maybe_print_array_index (index_type, i + low_bound,
-                               stream, options);
-
-      rep1 = i + 1;
-      reps = 1;
-      /* Only check for reps if repeat_count_threshold is not set to
-	 UINT_MAX (unlimited).  */
-      if (options->repeat_count_threshold < UINT_MAX)
-	{
-	  while (rep1 < len
-		 && value_contents_eq (val,
-				       embedded_offset + i * eltlen,
-				       val,
-				       (embedded_offset
-					+ rep1 * eltlen),
-				       eltlen))
-	    {
-	      ++reps;
-	      ++rep1;
-	    }
-	}
-
-      if (reps > options->repeat_count_threshold)
-	{
-	  val_print (elttype, embedded_offset + i * eltlen,
-		     address, stream, recurse + 1, val, options,
-		     current_language);
-	  annotate_elt_rep (reps);
-	  fprintf_filtered (stream, " %p[<repeats %u times>%p]",
-			    metadata_style.style ().ptr (), reps, nullptr);
-	  annotate_elt_rep_end ();
-
-	  i = rep1 - 1;
-	  things_printed += options->repeat_count_threshold;
-	}
-      else
-	{
-	  val_print (elttype, embedded_offset + i * eltlen,
-		     address,
-		     stream, recurse + 1, val, options, current_language);
-	  annotate_elt ();
-	  things_printed++;
-	}
-    }
-  annotate_array_section_end ();
-  if (i < len)
-    {
-      fprintf_filtered (stream, "...");
-    }
-}
-
 /* See valprint.h.  */
 
 void
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 68b1083c742..249f0bfcfa0 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -128,11 +128,6 @@ extern void maybe_print_array_index (struct type *index_type, LONGEST index,
                                      struct ui_file *stream,
 				     const struct value_print_options *);
 
-extern void val_print_array_elements (struct type *, LONGEST,
-				      CORE_ADDR, struct ui_file *, int,
-				      struct value *,
-				      const struct value_print_options *,
-				      unsigned int);
 
 /* Print elements of an array.  */
 
@@ -140,13 +135,6 @@ extern void value_print_array_elements (struct value *, struct ui_file *, int,
 					const struct value_print_options *,
 					unsigned int);
 
-extern void val_print_scalar_formatted (struct type *,
-					LONGEST,
-					struct value *,
-					const struct value_print_options *,
-					int,
-					struct ui_file *);
-
 /* Print a scalar according to OPTIONS and SIZE on STREAM.  Format i
    is not supported at this level.
 
@@ -220,13 +208,6 @@ struct generic_val_print_decorations
 };
 
 
-extern void generic_val_print (struct type *type,
-			       int embedded_offset, CORE_ADDR address,
-			       struct ui_file *stream, int recurse,
-			       struct value *original_value,
-			       const struct value_print_options *options,
-			       const struct generic_val_print_decorations *);
-
 /* Print a value in a generic way.  VAL is the value, STREAM is where
    to print it, RECURSE is the recursion depth, OPTIONS describe how
    the printing should be done, and D is the language-specific
diff --git a/gdb/value.h b/gdb/value.h
index 08162474211..cae7937f10c 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -1097,13 +1097,6 @@ extern void value_print_array_elements (struct value *val,
 extern std::vector<value_ref_ptr> value_release_to_mark
     (const struct value *mark);
 
-extern void val_print (struct type *type,
-		       LONGEST embedded_offset, CORE_ADDR address,
-		       struct ui_file *stream, int recurse,
-		       struct value *val,
-		       const struct value_print_options *options,
-		       const struct language_defn *language);
-
 extern void common_val_print (struct value *val,
 			      struct ui_file *stream, int recurse,
 			      const struct value_print_options *options,
-- 
2.17.2

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

* [PATCH 17/55] Introduce c_value_print_inner
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (46 preceding siblings ...)
  2019-12-08 18:51 ` [PATCH 21/55] Introduce ada_value_print_inner Tom Tromey
@ 2019-12-08 18:51 ` Tom Tromey
  2019-12-08 18:51 ` [PATCH 50/55] Convert ada_val_print_ref to value-based API Tom Tromey
                   ` (7 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:51 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces c_value_print_inner, which implements the
la_value_print_inner method for the C family of languages.  In this
patch, it is just a simple wrapper of c_val_print.  However,
subsequent patches will convert it to use the value API.  The
transformation is done this way to make each patch easier to review.

Future patches will apply this same treatment to other languages as
well.

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

	* opencl-lang.c (opencl_language_defn): Use c_value_print_inner.
	* objc-lang.c (objc_language_defn): Use c_value_print_inner.
	* c-valprint.c (c_value_print_inner): New function.
	* c-lang.h (c_value_print_inner): Declare.
	* c-lang.c (c_language_defn, cplus_language_defn)
	(asm_language_defn, minimal_language_defn): Use
	c_value_print_inner.

Change-Id: I9b9fe017f5260154cd6d16c958827d3887fba5d2
---
 gdb/ChangeLog     | 10 ++++++++++
 gdb/c-lang.c      |  8 ++++----
 gdb/c-lang.h      |  5 +++++
 gdb/c-valprint.c  | 11 +++++++++++
 gdb/objc-lang.c   |  2 +-
 gdb/opencl-lang.c |  2 +-
 6 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 24c2eef747a..909c6de63d9 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -904,7 +904,7 @@ extern const struct language_defn c_language_defn =
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_val_print,			/* Print a value using appropriate syntax */
-  nullptr,			/* la_value_print_inner */
+  c_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
@@ -1050,7 +1050,7 @@ extern const struct language_defn cplus_language_defn =
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_val_print,			/* Print a value using appropriate syntax */
-  nullptr,			/* la_value_print_inner */
+  c_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   cplus_skip_trampoline,	/* Language specific skip_trampoline */
@@ -1105,7 +1105,7 @@ extern const struct language_defn asm_language_defn =
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_val_print,			/* Print a value using appropriate syntax */
-  nullptr,			/* la_value_print_inner */
+  c_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
@@ -1160,7 +1160,7 @@ extern const struct language_defn minimal_language_defn =
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_val_print,			/* Print a value using appropriate syntax */
-  nullptr,			/* la_value_print_inner */
+  c_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index de291fa8f13..8523a0b68c5 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -87,6 +87,11 @@ extern void c_val_print (struct type *,
 			 struct value *,
 			 const struct value_print_options *);
 
+/* Implement la_value_print_inner for the C family of languages.  */
+
+extern void c_value_print_inner (struct value *, struct ui_file *, int,
+				 const struct value_print_options *);
+
 extern void c_value_print (struct value *, struct ui_file *,
 			   const struct value_print_options *);
 
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 5753a5869c3..410771b03d7 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -557,6 +557,17 @@ c_val_print (struct type *type,
       break;
     }
 }
+
+/* See c-lang.h.  */
+
+void
+c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
+		     const struct value_print_options *options)
+{
+  c_val_print (value_type (val), value_embedded_offset (val),
+	       value_address (val), stream, recurse, val, options);
+}
+
 \f
 void
 c_value_print (struct value *val, struct ui_file *stream, 
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index e6cb42e60a2..c1444163114 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -382,7 +382,7 @@ extern const struct language_defn objc_language_defn = {
   c_print_type,			/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_val_print,			/* Print a value using appropriate syntax */
-  nullptr,			/* la_value_print_inner */
+  c_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   objc_skip_trampoline, 	/* Language specific skip_trampoline */
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 8ebb35b9e62..7933e68b614 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1061,7 +1061,7 @@ extern const struct language_defn opencl_language_defn =
   opencl_print_type,		/* Print a type using appropriate syntax */
   c_print_typedef,		/* Print a typedef using appropriate syntax */
   c_val_print,			/* Print a value using appropriate syntax */
-  nullptr,			/* la_value_print_inner */
+  c_value_print_inner,		/* la_value_print_inner */
   c_value_print,		/* Print a top-level value */
   default_read_var_value,	/* la_read_var_value */
   NULL,				/* Language specific skip_trampoline */
-- 
2.17.2

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

* [PATCH 21/55] Introduce ada_value_print_inner
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (45 preceding siblings ...)
  2019-12-08 18:51 ` [PATCH 53/55] Change print_field_values to use value-based API Tom Tromey
@ 2019-12-08 18:51 ` Tom Tromey
  2019-12-08 18:51 ` [PATCH 17/55] Introduce c_value_print_inner Tom Tromey
                   ` (8 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:51 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This introduces ada_value_print_inner.

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

	* ada-valprint.c (ada_value_print_inner): New function.
	* ada-lang.h (ada_value_print_inner): Declare.
	* ada-lang.c (ada_language_defn): Use ada_value_print_inner.

Change-Id: I88786b629ba0fe08f508b968f2a1a301dfe1c25f
---
 gdb/ChangeLog      |  6 ++++++
 gdb/ada-lang.c     |  2 +-
 gdb/ada-lang.h     |  5 +++++
 gdb/ada-valprint.c | 11 +++++++++++
 4 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index eeccfae69ac..42ebf31954a 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -14114,7 +14114,7 @@ extern const struct language_defn ada_language_defn = {
   ada_print_type,               /* Print a type using appropriate syntax */
   ada_print_typedef,            /* Print a typedef using appropriate syntax */
   ada_val_print,                /* Print a value using appropriate syntax */
-  nullptr,			/* la_value_print_inner */
+  ada_value_print_inner,	/* la_value_print_inner */
   ada_value_print,              /* Print a top-level value */
   ada_read_var_value,		/* la_read_var_value */
   NULL,                         /* Language specific skip_trampoline */
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 13a917affec..f9994340a68 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -169,6 +169,11 @@ extern void ada_val_print (struct type *, int, CORE_ADDR,
 			   struct value *,
 			   const struct value_print_options *);
 
+/* Implement la_value_print_inner for Ada.  */
+
+extern void ada_value_print_inner (struct value *, struct ui_file *, int,
+				   const struct value_print_options *);
+
 extern void ada_value_print (struct value *, struct ui_file *,
 			     const struct value_print_options *);
 
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 4bb9247f519..609e5af7481 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -1219,6 +1219,17 @@ ada_val_print (struct type *type,
     }
 }
 
+/* See ada-lang.h.  */
+
+void
+ada_value_print_inner (struct value *val, struct ui_file *stream,
+		       int recurse,
+		       const struct value_print_options *options)
+{
+  ada_val_print (value_type (val), value_embedded_offset (val),
+		 value_address (val), stream, recurse, val, options);
+}
+
 void
 ada_value_print (struct value *val0, struct ui_file *stream,
 		 const struct value_print_options *options)
-- 
2.17.2

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

* [PATCH 53/55] Change print_field_values to use value-based API
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (44 preceding siblings ...)
  2019-12-08 18:50 ` [PATCH 55/55] Remove val_print Tom Tromey
@ 2019-12-08 18:51 ` Tom Tromey
  2019-12-08 18:51 ` [PATCH 21/55] Introduce ada_value_print_inner Tom Tromey
                   ` (9 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:51 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This converts print_field_values to use the value-based API, by having
it call common_val_print rather than val_print.

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

	* ada-valprint.c (print_field_values): Call common_val_print.

Change-Id: I915def5ff4c304bafdf519356482da8cbc459fa6
---
 gdb/ChangeLog      |  4 ++++
 gdb/ada-valprint.c | 14 +++++++-------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index c83782a0760..6f69b633bd8 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -683,10 +683,7 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 		     bit_size, TYPE_FIELD_TYPE (type, i));
 	      opts = *options;
 	      opts.deref_ref = 0;
-	      val_print (TYPE_FIELD_TYPE (type, i),
-			 value_embedded_offset (v), 0,
-			 stream, recurse + 1, v,
-			 &opts, language);
+	      common_val_print (v, stream, recurse + 1, &opts, language);
 	    }
 	}
       else
@@ -694,9 +691,12 @@ print_field_values (struct type *type, const gdb_byte *valaddr,
 	  struct value_print_options opts = *options;
 
 	  opts.deref_ref = 0;
-	  val_print (TYPE_FIELD_TYPE (type, i),
-		     (offset + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT),
-		     0, stream, recurse + 1, val, &opts, language);
+
+	  LONGEST local_off = (offset + TYPE_FIELD_BITPOS (type, i)
+			       / HOST_CHAR_BIT);
+	  struct value *v = value_from_contents (TYPE_FIELD_TYPE (type, i),
+						 valaddr + local_off);
+	  common_val_print (v, stream, recurse + 1, &opts, language);
 	}
       annotate_field_end ();
     }
-- 
2.17.2

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

* [PATCH 50/55] Convert ada_val_print_ref to value-based API
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (47 preceding siblings ...)
  2019-12-08 18:51 ` [PATCH 17/55] Introduce c_value_print_inner Tom Tromey
@ 2019-12-08 18:51 ` Tom Tromey
  2019-12-08 18:52 ` [PATCH 45/55] Introduce cp_print_value Tom Tromey
                   ` (6 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:51 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This converts ada_val_print_ref to the value-based API by using
common_val_print rather than val_print.

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

	* ada-valprint.c (ada_val_print_ref): Use common_val_print.

Change-Id: I9f263131022e8ed759628fbd0dded464513c4762
---
 gdb/ChangeLog      | 4 ++++
 gdb/ada-valprint.c | 6 ++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index b5d113e1713..1764b70d1e1 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -1204,10 +1204,8 @@ ada_val_print_ref (struct type *type, const gdb_byte *valaddr,
   if (value_lazy (deref_val))
     value_fetch_lazy (deref_val);
 
-  val_print (value_type (deref_val),
-	     value_embedded_offset (deref_val),
-	     value_address (deref_val), stream, recurse + 1,
-	     deref_val, options, language_def (language_ada));
+  common_val_print (deref_val, stream, recurse + 1,
+		    options, language_def (language_ada));
 }
 
 /* See the comment on ada_val_print.  This function differs in that it
-- 
2.17.2

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

* [PATCH 45/55] Introduce cp_print_value
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (48 preceding siblings ...)
  2019-12-08 18:51 ` [PATCH 50/55] Convert ada_val_print_ref to value-based API Tom Tromey
@ 2019-12-08 18:52 ` Tom Tromey
  2019-12-08 18:52 ` [PATCH 37/55] Simplify generic_val_print_float Tom Tromey
                   ` (5 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds cp_print_value, a value-based analogue of cp_print_val, and
changes cp_print_value_fields to use it.

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

	* cp-valprint.c (cp_print_value_fields): Update.
	(cp_print_value): New function.

Change-Id: I8902ff3702eddd2ac2bfbfbd6a485b94b56eaba6
---
 gdb/ChangeLog     |   5 ++
 gdb/cp-valprint.c | 168 ++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 169 insertions(+), 4 deletions(-)

diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 77dbaae891f..143d77cb223 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -54,6 +54,10 @@ static void cp_print_value (struct type *, struct type *,
 			    const struct value_print_options *,
 			    struct type **);
 
+static void cp_print_value (struct value *, struct ui_file *,
+			    int, const struct value_print_options *,
+			    struct type **);
+
 
 /* GCC versions after 2.4.5 use this.  */
 const char vtbl_ptr_name[] = "__vtbl_ptr_type";
@@ -410,7 +414,6 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
   static int last_set_recurse = -1;
 
   struct type *type = check_typedef (value_type (val));
-  CORE_ADDR address = value_address (val);
   
   if (recurse == 0)
     {
@@ -439,9 +442,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
      duplicates of virtual baseclasses.  */
 
   if (n_baseclasses > 0)
-    cp_print_value (type, type, 0, address, stream,
-		    recurse + 1, val, options,
-		    dont_print_vb);
+    cp_print_value (val, stream, recurse + 1, options, dont_print_vb);
 
   /* Second, print out data fields */
 
@@ -601,6 +602,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 		    {
 		      CORE_ADDR addr;
 		      
+		      i_offset += value_embedded_offset (val);
 		      addr = extract_typed_address (valaddr + i_offset, i_type);
 		      print_function_pointer_address (opts,
 						      get_type_arch (type),
@@ -874,6 +876,164 @@ cp_print_value (struct type *type, struct type *real_type,
     }
 }
 
+/* Special val_print routine to avoid printing multiple copies of
+   virtual baseclasses.  */
+
+static void
+cp_print_value (struct value *val, struct ui_file *stream,
+		int recurse, const struct value_print_options *options,
+		struct type **dont_print_vb)
+{
+  struct type *type = check_typedef (value_type (val));
+  CORE_ADDR address = value_address (val);
+  struct type **last_dont_print
+    = (struct type **) obstack_next_free (&dont_print_vb_obstack);
+  struct obstack tmp_obstack = dont_print_vb_obstack;
+  int i, n_baseclasses = TYPE_N_BASECLASSES (type);
+  const gdb_byte *valaddr = value_contents_for_printing (val);
+
+  if (dont_print_vb == 0)
+    {
+      /* If we're at top level, carve out a completely fresh chunk of
+         the obstack and use that until this particular invocation
+         returns.  */
+      /* Bump up the high-water mark.  Now alpha is omega.  */
+      obstack_finish (&dont_print_vb_obstack);
+    }
+
+  for (i = 0; i < n_baseclasses; i++)
+    {
+      LONGEST boffset = 0;
+      int skip = 0;
+      struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
+      const char *basename = TYPE_NAME (baseclass);
+      struct value *base_val = NULL;
+
+      if (BASETYPE_VIA_VIRTUAL (type, i))
+	{
+	  struct type **first_dont_print
+	    = (struct type **) obstack_base (&dont_print_vb_obstack);
+
+	  int j = (struct type **)
+	    obstack_next_free (&dont_print_vb_obstack) - first_dont_print;
+
+	  while (--j >= 0)
+	    if (baseclass == first_dont_print[j])
+	      goto flush_it;
+
+	  obstack_ptr_grow (&dont_print_vb_obstack, baseclass);
+	}
+
+      try
+	{
+	  boffset = baseclass_offset (type, i, valaddr,
+				      value_embedded_offset (val),
+				      address, val);
+	}
+      catch (const gdb_exception_error &ex)
+	{
+	  if (ex.error == NOT_AVAILABLE_ERROR)
+	    skip = -1;
+	  else
+	    skip = 1;
+	}
+
+      if (skip == 0)
+	{
+	  if (BASETYPE_VIA_VIRTUAL (type, i))
+	    {
+	      /* The virtual base class pointer might have been
+		 clobbered by the user program. Make sure that it
+		 still points to a valid memory location.  */
+
+	      if (boffset < 0 || boffset >= TYPE_LENGTH (type))
+		{
+		  gdb::byte_vector buf (TYPE_LENGTH (baseclass));
+
+		  if (target_read_memory (address + boffset, buf.data (),
+					  TYPE_LENGTH (baseclass)) != 0)
+		    skip = 1;
+		  base_val = value_from_contents_and_address (baseclass,
+							      buf.data (),
+							      address + boffset);
+		  baseclass = value_type (base_val);
+		  boffset = 0;
+		}
+	      else
+		{
+		  base_val = val;
+		}
+	    }
+	  else
+	    {
+	      base_val = val;
+	    }
+	}
+
+      /* Now do the printing.  */
+      if (options->prettyformat)
+	{
+	  fprintf_filtered (stream, "\n");
+	  print_spaces_filtered (2 * recurse, stream);
+	}
+      fputs_filtered ("<", stream);
+      /* Not sure what the best notation is in the case where there is
+         no baseclass name.  */
+      fputs_filtered (basename ? basename : "", stream);
+      fputs_filtered ("> = ", stream);
+
+      if (skip < 0)
+	val_print_unavailable (stream);
+      else if (skip > 0)
+	val_print_invalid_address (stream);
+      else
+	{
+	  int result = 0;
+
+	  if (options->max_depth > -1
+	      && recurse >= options->max_depth)
+	    {
+	      const struct language_defn *language = current_language;
+	      gdb_assert (language->la_struct_too_deep_ellipsis != NULL);
+	      fputs_filtered (language->la_struct_too_deep_ellipsis, stream);
+	    }
+	  else
+	    {
+	      /* Attempt to run an extension language pretty-printer on the
+		 baseclass if possible.  */
+	      if (!options->raw)
+		result
+		  = apply_ext_lang_val_pretty_printer (baseclass, boffset,
+						       value_address (base_val),
+						       stream, recurse,
+						       base_val, options,
+						       current_language);
+
+	      if (!result)
+		cp_print_value_fields (value_primitive_field (val, 0, i, type),
+				       stream, recurse, options,
+				       ((struct type **)
+					obstack_base (&dont_print_vb_obstack)),
+				       0);
+	    }
+	}
+      fputs_filtered (", ", stream);
+
+    flush_it:
+      ;
+    }
+
+  if (dont_print_vb == 0)
+    {
+      /* Free the space used to deal with the printing
+         of this type from top level.  */
+      obstack_free (&dont_print_vb_obstack, last_dont_print);
+      /* Reset watermark so that we can continue protecting
+         ourselves from whatever we were protecting ourselves.  */
+      dont_print_vb_obstack = tmp_obstack;
+    }
+}
+
 /* Print value of a static member.  To avoid infinite recursion when
    printing a class that contains a static instance of the class, we
    keep the addresses of all printed static member classes in an
-- 
2.17.2

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

* [PATCH 37/55] Simplify generic_val_print_float
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (49 preceding siblings ...)
  2019-12-08 18:52 ` [PATCH 45/55] Introduce cp_print_value Tom Tromey
@ 2019-12-08 18:52 ` Tom Tromey
  2019-12-08 18:54 ` [PATCH 36/55] Introduce generic_value_print_char Tom Tromey
                   ` (4 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes generic_val_print_float not to call
val_print_scalar_formatted.  This lets generic_value_print then use
value_print_scalar_formatted instead.

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

	* valprint.c (generic_val_print_float): Don't call
	val_print_scalar_formatted.
	(generic_val_print, generic_value_print): Update.

Change-Id: I00b73411232adf768c11d0d5271218644a6e390f
---
 gdb/ChangeLog  |  6 ++++++
 gdb/valprint.c | 29 +++++++++++++++--------------
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 4e65115cf97..630b6567cd0 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -898,17 +898,11 @@ generic_val_print_float (struct type *type,
   struct gdbarch *gdbarch = get_type_arch (type);
   int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
 
-  if (options->format)
-    {
-      val_print_scalar_formatted (type, embedded_offset,
-				  original_value, options, 0, stream);
-    }
-  else
-    {
-      const gdb_byte *valaddr = value_contents_for_printing (original_value);
+  gdb_assert (!options->format);
 
-      print_floating (valaddr + embedded_offset * unit_size, type, stream);
-    }
+  const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
+  print_floating (valaddr + embedded_offset * unit_size, type, stream);
 }
 
 /* generic_val_print helper for TYPE_CODE_COMPLEX.  */
@@ -1047,8 +1041,12 @@ generic_val_print (struct type *type,
 
     case TYPE_CODE_FLT:
     case TYPE_CODE_DECFLOAT:
-      generic_val_print_float (type, embedded_offset, stream,
-			       original_value, options);
+      if (options->format)
+	val_print_scalar_formatted (type, embedded_offset,
+				    original_value, options, 0, stream);
+      else
+	generic_val_print_float (type, embedded_offset, stream,
+				 original_value, options);
       break;
 
     case TYPE_CODE_VOID:
@@ -1159,8 +1157,11 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
 
     case TYPE_CODE_FLT:
     case TYPE_CODE_DECFLOAT:
-      generic_val_print_float (type, 0, stream,
-			       val, options);
+      if (options->format)
+	value_print_scalar_formatted (val, options, 0, stream);
+      else
+	generic_val_print_float (type, 0, stream,
+				 val, options);
       break;
 
     case TYPE_CODE_VOID:
-- 
2.17.2

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

* [PATCH 49/55] Introduce ada_value_print_num
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (53 preceding siblings ...)
  2019-12-08 18:54 ` [PATCH 47/55] Introduce ada_value_print_ptr Tom Tromey
@ 2019-12-08 18:54 ` Tom Tromey
  2020-01-15  0:37 ` [PATCH 00/55] Remove val_print Tom Tromey
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:54 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds ada_value_print_num, a value-based analogue of
ada_val_print_num.

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

	* ada-valprint.c (ada_value_print_num): New function.
	(ada_value_print_1): Use it.

Change-Id: I45be06938ef8712d30541942f4682ec7244ae407
---
 gdb/ChangeLog      |  5 +++
 gdb/ada-valprint.c | 86 ++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 88 insertions(+), 3 deletions(-)

diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 0286ced7c30..b5d113e1713 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -936,6 +936,88 @@ ada_val_print_num (struct type *type, const gdb_byte *valaddr,
     }
 }
 
+/* Implement Ada val_print'ing for the case where TYPE is
+   a TYPE_CODE_INT or TYPE_CODE_RANGE.  */
+
+static void
+ada_value_print_num (struct value *val, struct ui_file *stream, int recurse,
+		     const struct value_print_options *options)
+{
+  struct type *type = ada_check_typedef (value_type (val));
+  const gdb_byte *valaddr = value_contents_for_printing (val);
+
+  if (ada_is_fixed_point_type (type))
+    {
+      struct value *scale = ada_scaling_factor (type);
+      val = value_cast (value_type (scale), val);
+      val = value_binop (val, scale, BINOP_MUL);
+
+      const char *fmt = TYPE_LENGTH (type) < 4 ? "%.11g" : "%.17g";
+      std::string str
+	= target_float_to_string (value_contents (val), value_type (val), fmt);
+      fputs_filtered (str.c_str (), stream);
+      return;
+    }
+  else if (TYPE_CODE (type) == TYPE_CODE_RANGE
+	   && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ENUM
+	       || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_BOOL
+	       || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CHAR))
+    {
+      /* For enum-valued ranges, we want to recurse, because we'll end
+	 up printing the constant's name rather than its numeric
+	 value.  Character and fixed-point types are also printed
+	 differently, so recuse for those as well.  */
+      struct type *target_type = TYPE_TARGET_TYPE (type);
+      val = value_cast (target_type, val);
+      common_val_print (val, stream, recurse + 1, options,
+			language_def (language_ada));
+      return;
+    }
+  else
+    {
+      int format = (options->format ? options->format
+		    : options->output_format);
+
+      if (format)
+	{
+	  struct value_print_options opts = *options;
+
+	  opts.format = format;
+	  value_print_scalar_formatted (val, &opts, 0, stream);
+	}
+      else if (ada_is_system_address_type (type))
+	{
+	  /* FIXME: We want to print System.Address variables using
+	     the same format as for any access type.  But for some
+	     reason GNAT encodes the System.Address type as an int,
+	     so we have to work-around this deficiency by handling
+	     System.Address values as a special case.  */
+
+	  struct gdbarch *gdbarch = get_type_arch (type);
+	  struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+	  CORE_ADDR addr = extract_typed_address (valaddr, ptr_type);
+
+	  fprintf_filtered (stream, "(");
+	  type_print (type, "", stream, -1);
+	  fprintf_filtered (stream, ") ");
+	  fputs_filtered (paddress (gdbarch, addr), stream);
+	}
+      else
+	{
+	  value_print_scalar_formatted (val, options, 0, stream);
+	  if (ada_is_character_type (type))
+	    {
+	      LONGEST c;
+
+	      fputs_filtered (" ", stream);
+	      c = unpack_long (type, valaddr);
+	      ada_printchar (c, type, stream);
+	    }
+	}
+      return;
+    }
+}
+
 /* Implement Ada val_print'ing for the case where TYPE is
    a TYPE_CODE_ENUM.  */
 
@@ -1279,9 +1361,7 @@ ada_value_print_1 (struct value *val, struct ui_file *stream, int recurse,
 
     case TYPE_CODE_INT:
     case TYPE_CODE_RANGE:
-      ada_val_print_num (type, valaddr, 0, 0,
-			 address, stream, recurse, val,
-			 options);
+      ada_value_print_num (val, stream, recurse, options);
       break;
 
     case TYPE_CODE_ENUM:
-- 
2.17.2

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

* [PATCH 36/55] Introduce generic_value_print_char
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (50 preceding siblings ...)
  2019-12-08 18:52 ` [PATCH 37/55] Simplify generic_val_print_float Tom Tromey
@ 2019-12-08 18:54 ` Tom Tromey
  2019-12-08 18:54 ` [PATCH 31/55] Fix generic_val_print_enum for value-based printing Tom Tromey
                   ` (3 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:54 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds generic_value_print_char, a value-based analogue of
generic_val_print_char.

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

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

Change-Id: I7baf1cb6cebc78388010c9cce68b3d865fdb50e0
---
 gdb/ChangeLog  |  5 +++++
 gdb/valprint.c | 34 +++++++++++++++++++++++++++++++---
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 44ae99783b6..4e65115cf97 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -857,6 +857,36 @@ generic_val_print_char (struct type *type, struct type *unresolved_type,
     }
 }
 
+/* generic_value_print helper for TYPE_CODE_CHAR.  */
+
+static void
+generic_value_print_char (struct value *value, struct ui_file *stream,
+			  const struct value_print_options *options)
+{
+  if (options->format || options->output_format)
+    {
+      struct value_print_options opts = *options;
+
+      opts.format = (options->format ? options->format
+		     : options->output_format);
+      value_print_scalar_formatted (value, &opts, 0, stream);
+    }
+  else
+    {
+      struct type *unresolved_type = value_type (value);
+      struct type *type = check_typedef (unresolved_type);
+      const gdb_byte *valaddr = value_contents_for_printing (value);
+
+      LONGEST val = unpack_long (type, valaddr);
+      if (TYPE_UNSIGNED (type))
+	fprintf_filtered (stream, "%u", (unsigned int) val);
+      else
+	fprintf_filtered (stream, "%d", (int) val);
+      fputs_filtered (" ", stream);
+      LA_PRINT_CHAR (val, unresolved_type, stream);
+    }
+}
+
 /* generic_val_print helper for TYPE_CODE_FLT and TYPE_CODE_DECFLOAT.  */
 
 static void
@@ -1058,7 +1088,6 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
 		     const struct generic_val_print_decorations *decorations)
 {
   struct type *type = value_type (val);
-  struct type *unresolved_type = type;
 
   type = check_typedef (type);
   switch (TYPE_CODE (type))
@@ -1125,8 +1154,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_CHAR:
-      generic_val_print_char (type, unresolved_type, 0,
-			      stream, val, options);
+      generic_value_print_char (val, stream, options);
       break;
 
     case TYPE_CODE_FLT:
-- 
2.17.2

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

* [PATCH 47/55] Introduce ada_value_print_ptr
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (52 preceding siblings ...)
  2019-12-08 18:54 ` [PATCH 31/55] Fix generic_val_print_enum for value-based printing Tom Tromey
@ 2019-12-08 18:54 ` Tom Tromey
  2019-12-08 18:54 ` [PATCH 49/55] Introduce ada_value_print_num Tom Tromey
  2020-01-15  0:37 ` [PATCH 00/55] Remove val_print Tom Tromey
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:54 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This adds ada_value_print_ptr, a value-based analogue of
ada_val_print_ptr.

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

	* ada-valprint.c (ada_value_print_ptr): New function.
	(ada_value_print_1): Use it.

Change-Id: I6c70599ebf91c0b0a55b040b0e838cb047d502a3
---
 gdb/ChangeLog      |  5 +++++
 gdb/ada-valprint.c | 24 +++++++++++++++++++++---
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 83033d9ee8c..b3fb9512f57 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -813,6 +813,26 @@ ada_val_print_ptr (struct type *type, const gdb_byte *valaddr,
     }
 }
 
+/* Implement Ada value_print'ing for the case where TYPE is a
+   TYPE_CODE_PTR.  */
+
+static void
+ada_value_print_ptr (struct value *val,
+		     struct ui_file *stream, int recurse,
+		     const struct value_print_options *options)
+{
+  common_val_print (val, stream, recurse, options, language_def (language_c));
+
+  struct type *type = ada_check_typedef (value_type (val));
+  if (ada_is_tag_type (type))
+    {
+      const char *name = ada_tag_name (val);
+
+      if (name != NULL)
+	fprintf_filtered (stream, " (%s)", name);
+    }
+}
+
 /* Implement Ada val_print'ing for the case where TYPE is
    a TYPE_CODE_INT or TYPE_CODE_RANGE.  */
 
@@ -1254,9 +1274,7 @@ ada_value_print_1 (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_PTR:
-      ada_val_print_ptr (type, valaddr, 0, 0,
-			 address, stream, recurse, val,
-			 options);
+      ada_value_print_ptr (val, stream, recurse, options);
       break;
 
     case TYPE_CODE_INT:
-- 
2.17.2

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

* [PATCH 31/55] Fix generic_val_print_enum for value-based printing
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (51 preceding siblings ...)
  2019-12-08 18:54 ` [PATCH 36/55] Introduce generic_value_print_char Tom Tromey
@ 2019-12-08 18:54 ` Tom Tromey
  2019-12-08 18:54 ` [PATCH 47/55] Introduce ada_value_print_ptr Tom Tromey
                   ` (2 subsequent siblings)
  55 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-08 18:54 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This removes a call to val_print_scalar_formatted from
generic_val_print_enum, preferring to do the work in the callers.
This lets generic_value_print use the value-based API.

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

	* valprint.c (generic_val_print): Update.
	(generic_value_print): Update.
	* valprint.c (generic_val_print_enum): Don't call
	val_print_scalar_formatted.

Change-Id: I8a949daf9de4527482ff3b8e7038b58e97de1464
---
 gdb/ChangeLog  |  7 +++++++
 gdb/valprint.c | 30 +++++++++++++++---------------
 2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 980dd3b024e..fe7ffa78abc 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -695,19 +695,13 @@ generic_val_print_enum (struct type *type,
   struct gdbarch *gdbarch = get_type_arch (type);
   int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
 
-  if (options->format)
-    {
-      val_print_scalar_formatted (type, embedded_offset,
-				  original_value, options, 0, stream);
-    }
-  else
-    {
-      const gdb_byte *valaddr = value_contents_for_printing (original_value);
+  gdb_assert (!options->format);
 
-      val = unpack_long (type, valaddr + embedded_offset * unit_size);
+  const gdb_byte *valaddr = value_contents_for_printing (original_value);
 
-      generic_val_print_enum_1 (type, val, stream);
-    }
+  val = unpack_long (type, valaddr + embedded_offset * unit_size);
+
+  generic_val_print_enum_1 (type, val, stream);
 }
 
 /* generic_val_print helper for TYPE_CODE_FLAGS.  */
@@ -951,8 +945,12 @@ generic_val_print (struct type *type,
       break;
 
     case TYPE_CODE_ENUM:
-      generic_val_print_enum (type, embedded_offset, stream,
-			      original_value, options);
+      if (options->format)
+	val_print_scalar_formatted (type, embedded_offset,
+				    original_value, options, 0, stream);
+      else
+	generic_val_print_enum (type, embedded_offset, stream,
+				original_value, options);
       break;
 
     case TYPE_CODE_FLAGS:
@@ -1060,8 +1058,10 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_ENUM:
-      generic_val_print_enum (type, 0, stream,
-			      val, options);
+      if (options->format)
+	value_print_scalar_formatted (val, options, 0, stream);
+      else
+	generic_val_print_enum (type, 0, stream, val, options);
       break;
 
     case TYPE_CODE_FLAGS:
-- 
2.17.2

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

* Re: [PATCH 11/55] Introduce generic_value_print
  2019-12-08 18:30 ` [PATCH 11/55] Introduce generic_value_print Tom Tromey
@ 2019-12-09  4:05   ` Christian Biesinger via gdb-patches
  2019-12-09 23:40     ` Tom Tromey
  0 siblings, 1 reply; 76+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-12-09  4:05 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Sun, Dec 8, 2019 at 1:33 PM Tom Tromey <tom@tromey.com> wrote:
>
> This introduces generic_value_print, which is a value-based analogue
> to generic_val_print.  For now this is unused and simply calls
> generic_val_print, but subsequent patches will both change this
> function to work using the value API directly, and convert callers of
> generic_val_print to call this instead.

I'm really not familiar with this code at all, but since this is new,
should this be a member function on struct value?

Christian

> gdb/ChangeLog
> 2019-12-08  Tom Tromey  <tom@tromey.com>
>
>         * valprint.h (generic_value_print): Declare.
>         * valprint.c (generic_value_print): New function.
>
> Change-Id: I00b9ef91c1f3bf351b0e13e9873b849e80dfd944
> ---
>  gdb/ChangeLog  |  5 +++++
>  gdb/valprint.c | 12 ++++++++++++
>  gdb/valprint.h | 11 +++++++++++
>  3 files changed, 28 insertions(+)
>
> diff --git a/gdb/valprint.c b/gdb/valprint.c
> index d595a1d54e6..0e13e2b2d62 100644
> --- a/gdb/valprint.c
> +++ b/gdb/valprint.c
> @@ -1007,6 +1007,18 @@ generic_val_print (struct type *type,
>      }
>  }
>
> +/* See valprint.h.  */
> +
> +void
> +generic_value_print (struct value *val, struct ui_file *stream, int recurse,
> +                    const struct value_print_options *options,
> +                    const struct generic_val_print_decorations *decorations)
> +{
> +  generic_val_print (value_type (val), value_embedded_offset (val),
> +                    value_address (val), stream, recurse, val, options,
> +                    decorations);
> +}
> +
>  /* Helper function for val_print and common_val_print that does the
>     work.  Arguments are as to val_print, but FULL_VALUE, if given, is
>     the value to be printed.  */
> diff --git a/gdb/valprint.h b/gdb/valprint.h
> index c63ac8de19b..e4b90404fa2 100644
> --- a/gdb/valprint.h
> +++ b/gdb/valprint.h
> @@ -211,6 +211,17 @@ extern void generic_val_print (struct type *type,
>                                const struct value_print_options *options,
>                                const struct generic_val_print_decorations *);
>
> +/* Print a value in a generic way.  VAL is the value, STREAM is where
> +   to print it, RECURSE is the recursion depth, OPTIONS describe how
> +   the printing should be done, and D is the language-specific
> +   decorations object.  Note that structs and unions cannot be printed
> +   by this function.  */
> +
> +extern void generic_value_print (struct value *val, struct ui_file *stream,
> +                                int recurse,
> +                                const struct value_print_options *options,
> +                                const struct generic_val_print_decorations *d);
> +
>  extern void generic_emit_char (int c, struct type *type, struct ui_file *stream,
>                                int quoter, const char *encoding);
>
> --
> 2.17.2
>

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

* Re: [PATCH 03/55] Introduce common_val_print_checked
  2019-12-08 18:31 ` [PATCH 03/55] Introduce common_val_print_checked Tom Tromey
@ 2019-12-09  4:06   ` Christian Biesinger via gdb-patches
  2019-12-09 23:37     ` Tom Tromey
  0 siblings, 1 reply; 76+ messages in thread
From: Christian Biesinger via gdb-patches @ 2019-12-09  4:06 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Sun, Dec 8, 2019 at 1:33 PM Tom Tromey <tom@tromey.com> wrote:
> However, doing this will also break dw2-op-out-param.exp.  Making the
> change causes "bt" to print:

Did you forget to paste something here...?

> However, the test wants to see:
>
> ... operand2=<optimized out>
>
> That is, a wholly-optimized out structure should not print its fields.
>
> So, this patch introduces a new common_val_print_checked, which calls
> value_check_printable first, and then arranges to use it in the one
> spot that affects the test suite.
>
> I was not completely sure if it would be preferable to change the
> test.  However, I reasoned that, assuming this output was intentional
> in the first place, in a backtrace space is at a premium and so this
> is a reasonable approach.  In other spots calling common_val_print,
> this behavior is probably unintended, or at least a "don't care".
>
> gdb/ChangeLog
> 2019-12-08  Tom Tromey  <tom@tromey.com>
>
>         * valprint.h (common_val_print_checked): Declare.
>         * valprint.c (common_val_print_checked): New function.
>         * stack.c (print_frame_arg): Use common_val_print_checked.
>
> Change-Id: I6802b6bf9b4aa30b399bb133e5c848b24ad16d7a
> ---
>  gdb/ChangeLog  |  6 ++++++
>  gdb/stack.c    |  2 +-
>  gdb/valprint.c | 13 +++++++++++++
>  gdb/valprint.h |  8 ++++++++
>  4 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/stack.c b/gdb/stack.c
> index cc7b7e5bbe0..26229983f8b 100644
> --- a/gdb/stack.c
> +++ b/gdb/stack.c
> @@ -486,7 +486,7 @@ print_frame_arg (const frame_print_options &fp_opts,
>               vp_opts.summary
>                 = fp_opts.print_frame_arguments == print_frame_arguments_scalars;
>
> -             common_val_print (arg->val, &stb, 2, &vp_opts, language);
> +             common_val_print_checked (arg->val, &stb, 2, &vp_opts, language);
>             }
>           catch (const gdb_exception_error &except)
>             {
> diff --git a/gdb/valprint.c b/gdb/valprint.c
> index 62c78b95ad2..20763338aff 100644
> --- a/gdb/valprint.c
> +++ b/gdb/valprint.c
> @@ -1210,6 +1210,19 @@ common_val_print (struct value *val, struct ui_file *stream, int recurse,
>                 val, options, language);
>  }
>
> +/* See valprint.h.  */
> +
> +void
> +common_val_print_checked (struct value *val, struct ui_file *stream,
> +                         int recurse,
> +                         const struct value_print_options *options,
> +                         const struct language_defn *language)
> +{
> +  if (!value_check_printable (val, stream, options))
> +    return;
> +  common_val_print (val, stream, recurse, options, language);
> +}
> +
>  /* Print on stream STREAM the value VAL according to OPTIONS.  The value
>     is printed using the current_language syntax.  */
>
> diff --git a/gdb/valprint.h b/gdb/valprint.h
> index 24b731ab357..c63ac8de19b 100644
> --- a/gdb/valprint.h
> +++ b/gdb/valprint.h
> @@ -282,4 +282,12 @@ extern bool val_print_check_max_depth (struct ui_file *stream, int recurse,
>                                        const struct value_print_options *opts,
>                                        const struct language_defn *language);
>
> +/* Like common_val_print, but call value_check_printable first.  */
> +
> +extern void common_val_print_checked
> +  (struct value *val,
> +   struct ui_file *stream, int recurse,
> +   const struct value_print_options *options,
> +   const struct language_defn *language);
> +
>  #endif
> --
> 2.17.2
>

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

* Re: [PATCH 03/55] Introduce common_val_print_checked
  2019-12-09  4:06   ` Christian Biesinger via gdb-patches
@ 2019-12-09 23:37     ` Tom Tromey
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-09 23:37 UTC (permalink / raw)
  To: Christian Biesinger; +Cc: Tom Tromey, gdb-patches

Christian> Did you forget to paste something here...?

I'll dig it up again later but I think it started with a "#" and I
forgot that this makes it a comment to "git commit".

Tom

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

* Re: [PATCH 11/55] Introduce generic_value_print
  2019-12-09  4:05   ` Christian Biesinger via gdb-patches
@ 2019-12-09 23:40     ` Tom Tromey
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2019-12-09 23:40 UTC (permalink / raw)
  To: Christian Biesinger; +Cc: Tom Tromey, gdb-patches

Christian> I'm really not familiar with this code at all, but since this is new,
Christian> should this be a member function on struct value?

Possibly, but there aren't really methods there now (it's opaque
currently), and anyway for this series I wanted to try to keep each
patch reasonably close to the existing code, to make the transition more
clear.

FWIW once I had some scripts to try to convert struct value to be more
like a class.  This is difficult to do in its entirety though.  There
are many potential methods.

Tom

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

* Re: [PATCH 00/55] Remove val_print
  2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
                   ` (54 preceding siblings ...)
  2019-12-08 18:54 ` [PATCH 49/55] Introduce ada_value_print_num Tom Tromey
@ 2020-01-15  0:37 ` Tom Tromey
  2020-01-15 11:52   ` Simon Marchi
  55 siblings, 1 reply; 76+ messages in thread
From: Tom Tromey @ 2020-01-15  0:37 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> I've long wanted to remove the val_print API.  It is used for the
Tom> lowest level of value printing, and works by passing around an
Tom> "exploded" value -- the type, offset, content, and address are passed
Tom> as separate parameters.  However, at some point we also had to start
Tom> passing around the original outer-most value as well (to check content
Tom> validity), which made the entire exercise a bit of a travesty.

[...]

Tom> Regression tested by the buildbot.  I don't propose checking this in
Tom> until after the 9.1 branch has been made.

I'd like to move forward with this sometime soon, so if you have
comments or concerns, it would be good to send them.

thanks,
Tom

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

* Re: [PATCH 09/55] Use common_val_print in c-valprint.c
  2019-12-08 18:30 ` [PATCH 09/55] Use common_val_print in c-valprint.c Tom Tromey
@ 2020-01-15  5:09   ` Simon Marchi
  2020-01-24  1:03     ` Tom Tromey
  0 siblings, 1 reply; 76+ messages in thread
From: Simon Marchi @ 2020-01-15  5:09 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2019-12-08 1:29 p.m., Tom Tromey wrote:
> @@ -593,12 +589,12 @@ c_value_print (struct value *val, struct ui_file *stream,
>           type is indicated by the quoted string anyway.
>           (Don't use c_textual_element_type here; quoted strings
>           are always exactly (char *), (wchar_t *), or the like.  */
> -      if (TYPE_CODE (val_type) == TYPE_CODE_PTR
> -	  && TYPE_NAME (val_type) == NULL
> -	  && TYPE_NAME (TYPE_TARGET_TYPE (val_type)) != NULL
> -	  && (strcmp (TYPE_NAME (TYPE_TARGET_TYPE (val_type)),
> +      if (TYPE_CODE (type) == TYPE_CODE_PTR
> +	  && TYPE_NAME (type) == NULL
> +	  && TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL
> +	  && (strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)),
>  		      "char") == 0
> -	      || textual_name (TYPE_NAME (TYPE_TARGET_TYPE (val_type)))))
> +	      || textual_name (TYPE_NAME (TYPE_TARGET_TYPE (type)))))
>  	{
>  	  /* Print nothing.  */
>  	}

This introduces a behavior change.  It's not dramatic, but I don't think it was
intended, otherwise you would have mentioned it.

Considering this program:

---
typedef char *charptr;

charptr hello = "hello";

int main()
{
  return 0;
}
---

Before:

(gdb) p hello
$1 = (charptr) 0x400574 "hello"

After:

(gdb) p hello
$1 = 0x400574 "hello"

To restore the original behavior, the checks above should use the
value's original type (like they do today).

> @@ -667,36 +659,27 @@ c_value_print (struct value *val, struct ui_file *stream,
>  	  /* We have RTTI information, so use it.  */
>  	  val = value_full_object (val, real_type, 
>  				   full, top, using_enc);
> +	  /* In a destructor we might see a real type that is a
> +	     superclass of the object's type.  In this case it is
> +	     better to leave the object as-is.  */
> +	  if (!(full
> +		&& (TYPE_LENGTH (real_type)
> +		    < TYPE_LENGTH (value_enclosing_type (val)))))
> +	    val = value_cast (real_type, val);
>  	  fprintf_filtered (stream, "(%s%s) ",
>  			    TYPE_NAME (real_type),
>  			    full ? "" : _(" [incomplete object]"));
>  	  /* Print out object: enclosing type is same as real_type if
>  	     full.  */

This comment was most likely attached to the val_print call, it's a
bit odd to leave it there.

Simon

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

* Re: [PATCH 12/55] Introduce value_print_scalar_formatted
  2019-12-08 18:32 ` [PATCH 12/55] Introduce value_print_scalar_formatted Tom Tromey
@ 2020-01-15  5:15   ` Simon Marchi
  2020-01-23 23:37     ` Tom Tromey
  0 siblings, 1 reply; 76+ messages in thread
From: Simon Marchi @ 2020-01-15  5:15 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2019-12-08 1:29 p.m., Tom Tromey wrote:
> diff --git a/gdb/valprint.h b/gdb/valprint.h
> index e4b90404fa2..f1c93aa26b6 100644
> --- a/gdb/valprint.h
> +++ b/gdb/valprint.h
> @@ -141,6 +141,16 @@ extern void val_print_scalar_formatted (struct type *,
>  					int,
>  					struct ui_file *);
>  
> +/* Print a scalar according to OPTIONS and SIZE on STREAM.  Format i
> +   is not supported at this level.

There seems to be a typo above, "Format i".

> +
> +   This is how the elements of an array or structure are printed
> +   with a format.  */
> +
> +extern void value_print_scalar_formatted (struct value *,
> +					  const struct value_print_options *,
> +					  int, struct ui_file *);
> +

I think you should add the parameter names here, especially since the comment
refers to them.

Simon

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

* Re: [PATCH 14/55] Introduce value_print_array_elements
  2019-12-08 18:31 ` [PATCH 14/55] Introduce value_print_array_elements Tom Tromey
@ 2020-01-15  5:47   ` Simon Marchi
  2020-01-23 23:39     ` Tom Tromey
  0 siblings, 1 reply; 76+ messages in thread
From: Simon Marchi @ 2020-01-15  5:47 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2019-12-08 1:29 p.m., Tom Tromey wrote:
> This introduces value_print_array_elements, which is an analogue of
> val_print_array_elements that uses the value API.
> 
> gdb/ChangeLog
> 2019-12-08  Tom Tromey  <tom@tromey.com>
> 
> 	* valprint.c (value_print_array_elements): New function.
> 	* valprint.h (value_print_array_elements): Declare.
> 
> Change-Id: I82d7666ce30b8cae3689fbf392177b08ef861a3b
> ---
>  gdb/ChangeLog  |   5 ++
>  gdb/valprint.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++++
>  gdb/valprint.h |   6 +++
>  3 files changed, 137 insertions(+)
> 
> diff --git a/gdb/valprint.c b/gdb/valprint.c
> index d09a42926e2..b2506dc6fc4 100644
> --- a/gdb/valprint.c
> +++ b/gdb/valprint.c
> @@ -2184,6 +2184,132 @@ val_print_array_elements (struct type *type,
>      }
>  }
>  
> +/* See valprint.h.  */
> +
> +void
> +value_print_array_elements (struct value *val, struct ui_file *stream,
> +			    int recurse,
> +			    const struct value_print_options *options,
> +			    unsigned int i)
> +{
> +  unsigned int things_printed = 0;
> +  unsigned len;
> +  struct type *elttype, *index_type, *base_index_type;
> +  unsigned eltlen;
> +  /* Position of the array element we are examining to see
> +     whether it is repeated.  */
> +  unsigned int rep1;
> +  /* Number of repetitions we have detected so far.  */
> +  unsigned int reps;
> +  LONGEST low_bound, high_bound;
> +  LONGEST low_pos, high_pos;
> +
> +  struct type *type = check_typedef (value_type (val));
> +
> +  elttype = TYPE_TARGET_TYPE (type);
> +  eltlen = type_length_units (check_typedef (elttype));
> +  index_type = TYPE_INDEX_TYPE (type);
> +
> +  if (get_array_bounds (type, &low_bound, &high_bound))
> +    {
> +      if (TYPE_CODE (index_type) == TYPE_CODE_RANGE)
> +	base_index_type = TYPE_TARGET_TYPE (index_type);
> +      else
> +	base_index_type = index_type;
> +
> +      /* Non-contiguous enumerations types can by used as index types
> +	 in some languages (e.g. Ada).  In this case, the array length
> +	 shall be computed from the positions of the first and last
> +	 literal in the enumeration type, and not from the values
> +	 of these literals.  */
> +      if (!discrete_position (base_index_type, low_bound, &low_pos)
> +	  || !discrete_position (base_index_type, high_bound, &high_pos))
> +	{
> +	  warning (_("unable to get positions in array, use bounds instead"));
> +	  low_pos = low_bound;
> +	  high_pos = high_bound;
> +	}
> +
> +      /* The array length should normally be HIGH_POS - LOW_POS + 1.
> +         But we have to be a little extra careful, because some languages
> +	 such as Ada allow LOW_POS to be greater than HIGH_POS for
> +	 empty arrays.  In that situation, the array length is just zero,
> +	 not negative!  */
> +      if (low_pos > high_pos)
> +	len = 0;
> +      else
> +	len = high_pos - low_pos + 1;
> +    }
> +  else
> +    {
> +      warning (_("unable to get bounds of array, assuming null array"));
> +      low_bound = 0;
> +      len = 0;
> +    }
> +
> +  annotate_array_section_begin (i, elttype);
> +
> +  for (; i < len && things_printed < options->print_max; i++)
> +    {
> +      scoped_value_mark free_values;
> +
> +      if (i != 0)
> +	{
> +	  if (options->prettyformat_arrays)
> +	    {
> +	      fprintf_filtered (stream, ",\n");
> +	      print_spaces_filtered (2 + 2 * recurse, stream);
> +	    }
> +	  else
> +	    {
> +	      fprintf_filtered (stream, ", ");
> +	    }

You could remove these extra braces.

Simon

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

* Re: [PATCH 28/55] Convert Pascal to value-based API
  2019-12-08 18:32 ` [PATCH 28/55] Convert Pascal to value-based API Tom Tromey
@ 2020-01-15  5:57   ` Simon Marchi
  2020-01-23 23:41     ` Tom Tromey
  0 siblings, 1 reply; 76+ messages in thread
From: Simon Marchi @ 2020-01-15  5:57 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2019-12-08 1:29 p.m., Tom Tromey wrote:
> @@ -1056,6 +1065,182 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
>    fprintf_filtered (stream, "}");
>  }
>  
> +/* Mutually recursive subroutines of pascal_object_print_value and
> +   c_val_print to print out a structure's fields:
> +   pascal_object_print_val_fields and pascal_object_print_value.
> +
> +   TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the
> +   same meanings as in pascal_object_print_value and c_val_print.
> +
> +   DONT_PRINT is an array of baseclass types that we
> +   should not print, or zero if called from top level.  */

The comment above needs to be updated.

Simon

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

* Re: [PATCH 40/55] Introduce c_value_print_ptr
  2019-12-08 18:32 ` [PATCH 40/55] Introduce c_value_print_ptr Tom Tromey
@ 2020-01-15  6:01   ` Simon Marchi
  2020-01-23 23:47     ` Tom Tromey
  0 siblings, 1 reply; 76+ messages in thread
From: Simon Marchi @ 2020-01-15  6:01 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2019-12-08 1:29 p.m., Tom Tromey wrote:
> This adds c_value_print_ptr, a value-based analogue of
> c_val_print_ptr.
> 
> gdb/ChangeLog
> 2019-12-08  Tom Tromey  <tom@tromey.com>
> 
> 	* c-valprint.c (c_value_print_ptr): New function.
> 	(c_value_print_inner): Use it.
> 
> Change-Id: Iba7917a57d5d67c51a76014c4bcb82c0353f6453
> ---
>  gdb/ChangeLog    |  5 +++++
>  gdb/c-valprint.c | 40 ++++++++++++++++++++++++++++++++++++++--
>  2 files changed, 43 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
> index af7a386fb78..f50c49abbfd 100644
> --- a/gdb/c-valprint.c
> +++ b/gdb/c-valprint.c
> @@ -375,6 +375,43 @@ c_val_print_ptr (struct type *type, const gdb_byte *valaddr,
>      }
>  }
>  
> +/* c_val_print helper for TYPE_CODE_PTR.  */
> +
> +static void
> +c_value_print_ptr (struct value*val, struct ui_file *stream, int recurse,

Missing a space.

Simon

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

* Re: [PATCH 44/55] Introduce cp_print_value_fields and c_value_print_struct
  2019-12-08 18:32 ` [PATCH 44/55] Introduce cp_print_value_fields and c_value_print_struct Tom Tromey
@ 2020-01-15  6:15   ` Simon Marchi
  2020-01-24  0:54     ` Tom Tromey
  0 siblings, 1 reply; 76+ messages in thread
From: Simon Marchi @ 2020-01-15  6:15 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2019-12-08 1:29 p.m., Tom Tromey wrote:
> @@ -385,6 +386,280 @@ cp_print_value_fields (struct type *type, struct type *real_type,
>    fprintf_filtered (stream, "}");
>  }
>  
> +/* Mutually recursive subroutines of cp_print_value and c_val_print to
> +   print out a structure's fields: cp_print_value_fields and
> +   cp_print_value.
> +
> +   TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the same
> +   meanings as in cp_print_value and c_val_print.
> +
> +   2nd argument REAL_TYPE is used to carry over the type of the
> +   derived class across the recursion to base classes.
> +
> +   DONT_PRINT is an array of baseclass types that we should not print,
> +   or zero if called from top level.  */

This comment needs to be updated.

Simon

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

* Re: [PATCH 00/55] Remove val_print
  2020-01-15  0:37 ` [PATCH 00/55] Remove val_print Tom Tromey
@ 2020-01-15 11:52   ` Simon Marchi
  2020-03-14  0:02     ` Tom Tromey
  0 siblings, 1 reply; 76+ messages in thread
From: Simon Marchi @ 2020-01-15 11:52 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 2020-01-14 7:36 p.m., Tom Tromey wrote:
>>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
> 
> Tom> I've long wanted to remove the val_print API.  It is used for the
> Tom> lowest level of value printing, and works by passing around an
> Tom> "exploded" value -- the type, offset, content, and address are passed
> Tom> as separate parameters.  However, at some point we also had to start
> Tom> passing around the original outer-most value as well (to check content
> Tom> validity), which made the entire exercise a bit of a travesty.
> 
> [...]
> 
> Tom> Regression tested by the buildbot.  I don't propose checking this in
> Tom> until after the 9.1 branch has been made.
> 
> I'd like to move forward with this sometime soon, so if you have
> comments or concerns, it would be good to send them.
> 
> thanks,
> Tom
> 

Hi Tom,

That looks very nice.  I remember struggling with the embedded offset concept,
I think passing down values everywhere makes it much easier to understand.

I left some small comments, but overall this LGTM.

Simon

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

* Re: [PATCH 12/55] Introduce value_print_scalar_formatted
  2020-01-15  5:15   ` Simon Marchi
@ 2020-01-23 23:37     ` Tom Tromey
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2020-01-23 23:37 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> On 2019-12-08 1:29 p.m., Tom Tromey wrote:
>> diff --git a/gdb/valprint.h b/gdb/valprint.h
>> index e4b90404fa2..f1c93aa26b6 100644
>> --- a/gdb/valprint.h
>> +++ b/gdb/valprint.h
>> @@ -141,6 +141,16 @@ extern void val_print_scalar_formatted (struct type *,
>> int,
>> struct ui_file *);
>> 
>> +/* Print a scalar according to OPTIONS and SIZE on STREAM.  Format i
>> +   is not supported at this level.

Simon> There seems to be a typo above, "Format i".

It's copied from val_print_scalar_formatted.  I think it refers to the
literal format 'i', so I changed it to read "Format 'i' is not..."

>> +
>> +   This is how the elements of an array or structure are printed
>> +   with a format.  */
>> +
>> +extern void value_print_scalar_formatted (struct value *,
>> +					  const struct value_print_options *,
>> +					  int, struct ui_file *);
>> +

Simon> I think you should add the parameter names here, especially since the comment
Simon> refers to them.

I've done this.

Tom

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

* Re: [PATCH 14/55] Introduce value_print_array_elements
  2020-01-15  5:47   ` Simon Marchi
@ 2020-01-23 23:39     ` Tom Tromey
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2020-01-23 23:39 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

>> +	  else
>> +	    {
>> +	      fprintf_filtered (stream, ", ");
>> +	    }

Simon> You could remove these extra braces.

Done.

Tom

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

* Re: [PATCH 28/55] Convert Pascal to value-based API
  2020-01-15  5:57   ` Simon Marchi
@ 2020-01-23 23:41     ` Tom Tromey
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2020-01-23 23:41 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> The comment above needs to be updated.

Done.

Tom

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

* Re: [PATCH 40/55] Introduce c_value_print_ptr
  2020-01-15  6:01   ` Simon Marchi
@ 2020-01-23 23:47     ` Tom Tromey
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2020-01-23 23:47 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

>> +static void
>> +c_value_print_ptr (struct value*val, struct ui_file *stream, int recurse,

Simon> Missing a space.

Thanks, I fixed this.

Tom

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

* Re: [PATCH 44/55] Introduce cp_print_value_fields and c_value_print_struct
  2020-01-15  6:15   ` Simon Marchi
@ 2020-01-24  0:54     ` Tom Tromey
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2020-01-24  0:54 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> On 2019-12-08 1:29 p.m., Tom Tromey wrote:
>> @@ -385,6 +386,280 @@ cp_print_value_fields (struct type *type, struct type *real_type,
>> fprintf_filtered (stream, "}");
>> }
>> 
>> +/* Mutually recursive subroutines of cp_print_value and c_val_print to
>> +   print out a structure's fields: cp_print_value_fields and
>> +   cp_print_value.
>> +
>> +   TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the same
>> +   meanings as in cp_print_value and c_val_print.
>> +
>> +   2nd argument REAL_TYPE is used to carry over the type of the
>> +   derived class across the recursion to base classes.
>> +
>> +   DONT_PRINT is an array of baseclass types that we should not print,
>> +   or zero if called from top level.  */

Simon> This comment needs to be updated.

I did this.

Tom

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

* Re: [PATCH 09/55] Use common_val_print in c-valprint.c
  2020-01-15  5:09   ` Simon Marchi
@ 2020-01-24  1:03     ` Tom Tromey
  2020-03-14  9:18       ` [committted][gdb/testsuite] Fix FAIL in gdb.base/printcmds.exp Tom de Vries
  0 siblings, 1 reply; 76+ messages in thread
From: Tom Tromey @ 2020-01-24  1:03 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

>> +      if (TYPE_CODE (type) == TYPE_CODE_PTR
>> +	  && TYPE_NAME (type) == NULL
>> +	  && TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL
>> +	  && (strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)),
>> "char") == 0
>> -	      || textual_name (TYPE_NAME (TYPE_TARGET_TYPE (val_type)))))
>> +	      || textual_name (TYPE_NAME (TYPE_TARGET_TYPE (type)))))
>> {
>> /* Print nothing.  */
>> }

Simon> This introduces a behavior change.  It's not dramatic, but I don't think it was
Simon> intended, otherwise you would have mentioned it.

Wow, nice catch.  And thank you.

I've added a test case for this to the patch, and I've fixed it.

Tom

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

* Re: [PATCH 00/55] Remove val_print
  2020-01-15 11:52   ` Simon Marchi
@ 2020-03-14  0:02     ` Tom Tromey
  0 siblings, 0 replies; 76+ messages in thread
From: Tom Tromey @ 2020-03-14  0:02 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

[ removing val_print ]

Simon> I left some small comments, but overall this LGTM.

I've been rebasing this all along, and I re-regression tested it and
fixed one regression I found.  So, I'm going to check this in now.

Tom

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

* [committted][gdb/testsuite] Fix FAIL in gdb.base/printcmds.exp
  2020-01-24  1:03     ` Tom Tromey
@ 2020-03-14  9:18       ` Tom de Vries
  0 siblings, 0 replies; 76+ messages in thread
From: Tom de Vries @ 2020-03-14  9:18 UTC (permalink / raw)
  To: Tom Tromey, Simon Marchi; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 245 bytes --]

[ was: Re: [PATCH 09/55] Use common_val_print in c-valprint.c ]

On 24-01-2020 01:54, Tom Tromey wrote:
> I've added a test case for this to the patch, and I've fixed it.

That one failed for me, so I've committed attached patch.

Thanks,
- Tom

[-- Attachment #2: 0001-gdb-testsuite-Fix-FAIL-in-gdb.base-printcmds.exp.patch --]
[-- Type: text/x-patch, Size: 1192 bytes --]

[gdb/testsuite] Fix FAIL in gdb.base/printcmds.exp

With test-case gdb.base/printcmds.exp, I run into:
...
(gdb) print teststring2^M
$563 = (charptr) "more contents"^M
(gdb) FAIL: gdb.base/printcmds.exp: print teststring2
...

The corresponding test is:
...
     gdb_test "print teststring2" " = (charptr) \"more contents\""
...

Fix the FAIL by adding the missing quoting for the parentheses around charptr.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-03-14  Tom de Vries  <tdevries@suse.de>

	* gdb.base/printcmds.exp: Add missing quoting for "print
	teststring2".

---
 gdb/testsuite/gdb.base/printcmds.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index 2c8baad5aa..066e7fce87 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -520,7 +520,7 @@ proc test_print_strings {} {
 	" = (.unsigned char .. )?\"teststring contents\"" "p teststring with elements set to 20"
 
     gdb_test "print teststring2" \
-	" = (charptr) \"more contents\""
+	" = \\(charptr\\) \"more contents\""
 
     gdb_test_no_output "set print elements 8"
 

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

end of thread, other threads:[~2020-03-14  9:18 UTC | newest]

Thread overview: 76+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-08 18:30 [PATCH 00/55] Remove val_print Tom Tromey
2019-12-08 18:30 ` [PATCH 06/55] Use common_val_print in riscv-tdep.c Tom Tromey
2019-12-08 18:30 ` [PATCH 04/55] Use common_val_print in infcmd.c Tom Tromey
2019-12-08 18:30 ` [PATCH 16/55] Make pascal_object_print_value_fields static Tom Tromey
2019-12-08 18:30 ` [PATCH 48/55] Rewrite ada_value_print_1 floating point case Tom Tromey
2019-12-08 18:30 ` [PATCH 32/55] Remove generic_val_print_flags Tom Tromey
2019-12-08 18:30 ` [PATCH 20/55] Introduce f_value_print_innner Tom Tromey
2019-12-08 18:30 ` [PATCH 22/55] Convert Rust printing to value-based API Tom Tromey
2019-12-08 18:30 ` [PATCH 13/55] Two simple uses of value_print_scalar_formatted Tom Tromey
2019-12-08 18:30 ` [PATCH 30/55] Introduce generic_value_print_ptr Tom Tromey
2019-12-08 18:30 ` [PATCH 41/55] Introduce c_value_print_int Tom Tromey
2019-12-08 18:30 ` [PATCH 11/55] Introduce generic_value_print Tom Tromey
2019-12-09  4:05   ` Christian Biesinger via gdb-patches
2019-12-09 23:40     ` Tom Tromey
2019-12-08 18:30 ` [PATCH 09/55] Use common_val_print in c-valprint.c Tom Tromey
2020-01-15  5:09   ` Simon Marchi
2020-01-24  1:03     ` Tom Tromey
2020-03-14  9:18       ` [committted][gdb/testsuite] Fix FAIL in gdb.base/printcmds.exp Tom de Vries
2019-12-08 18:30 ` [PATCH 19/55] Introduce pascal_value_print_inner Tom Tromey
2019-12-08 18:30 ` [PATCH 24/55] Convert D printing to value-based API Tom Tromey
2019-12-08 18:30 ` [PATCH 07/55] Use common_val_print in f-valprint.c Tom Tromey
2019-12-08 18:30 ` [PATCH 35/55] Introduce generic_value_print_int Tom Tromey
2019-12-08 18:30 ` [PATCH 10/55] Introduce la_value_print_inner Tom Tromey
2019-12-08 18:30 ` [PATCH 25/55] Convert Modula-2 printing to value-based API Tom Tromey
2019-12-08 18:31 ` [PATCH 29/55] Initial rewrite of generic_value_print Tom Tromey
2019-12-08 18:31 ` [PATCH 46/55] Rewrite ada_value_print_inner Tom Tromey
2019-12-08 18:31 ` [PATCH 03/55] Introduce common_val_print_checked Tom Tromey
2019-12-09  4:06   ` Christian Biesinger via gdb-patches
2019-12-09 23:37     ` Tom Tromey
2019-12-08 18:31 ` [PATCH 34/55] Introduce generic_value_print_bool Tom Tromey
2019-12-08 18:31 ` [PATCH 38/55] Introduce generic_value_print_complex Tom Tromey
2019-12-08 18:31 ` [PATCH 14/55] Introduce value_print_array_elements Tom Tromey
2020-01-15  5:47   ` Simon Marchi
2020-01-23 23:39     ` Tom Tromey
2019-12-08 18:31 ` [PATCH 18/55] Introduce m2_value_print_inner Tom Tromey
2019-12-08 18:31 ` [PATCH 05/55] Use common_val_print in mi-main.c Tom Tromey
2019-12-08 18:31 ` [PATCH 42/55] Introduce c_value_print_memberptr Tom Tromey
2019-12-08 18:31 ` [PATCH 26/55] Convert Fortran printing to value-based API Tom Tromey
2019-12-08 18:31 ` [PATCH 02/55] Refactor val_print and common_val_print Tom Tromey
2019-12-08 18:31 ` [PATCH 33/55] Simplify generic_val_print_func Tom Tromey
2019-12-08 18:32 ` [PATCH 28/55] Convert Pascal to value-based API Tom Tromey
2020-01-15  5:57   ` Simon Marchi
2020-01-23 23:41     ` Tom Tromey
2019-12-08 18:32 ` [PATCH 52/55] Introduce ada_value_print_array Tom Tromey
2019-12-08 18:32 ` [PATCH 43/55] Introduce c_value_print_array Tom Tromey
2019-12-08 18:32 ` [PATCH 12/55] Introduce value_print_scalar_formatted Tom Tromey
2020-01-15  5:15   ` Simon Marchi
2020-01-23 23:37     ` Tom Tromey
2019-12-08 18:32 ` [PATCH 23/55] Convert Go printing to value-based API Tom Tromey
2019-12-08 18:32 ` [PATCH 27/55] Rewrite pascal_value_print_inner Tom Tromey
2019-12-08 18:32 ` [PATCH 44/55] Introduce cp_print_value_fields and c_value_print_struct Tom Tromey
2020-01-15  6:15   ` Simon Marchi
2020-01-24  0:54     ` Tom Tromey
2019-12-08 18:32 ` [PATCH 08/55] Use common_val_print in cp-valprint.c Tom Tromey
2019-12-08 18:32 ` [PATCH 40/55] Introduce c_value_print_ptr Tom Tromey
2020-01-15  6:01   ` Simon Marchi
2020-01-23 23:47     ` Tom Tromey
2019-12-08 18:32 ` [PATCH 01/55] Use scoped_value_mark in value_print Tom Tromey
2019-12-08 18:32 ` [PATCH 15/55] Simplify c_val_print_array Tom Tromey
2019-12-08 18:32 ` [PATCH 39/55] Rewrite c_value_print_inner Tom Tromey
2019-12-08 18:32 ` [PATCH 54/55] Change extension language pretty-printers to use value API Tom Tromey
2019-12-08 18:32 ` [PATCH 51/55] Convert ada_value_print to value-based API Tom Tromey
2019-12-08 18:50 ` [PATCH 55/55] Remove val_print Tom Tromey
2019-12-08 18:51 ` [PATCH 53/55] Change print_field_values to use value-based API Tom Tromey
2019-12-08 18:51 ` [PATCH 21/55] Introduce ada_value_print_inner Tom Tromey
2019-12-08 18:51 ` [PATCH 17/55] Introduce c_value_print_inner Tom Tromey
2019-12-08 18:51 ` [PATCH 50/55] Convert ada_val_print_ref to value-based API Tom Tromey
2019-12-08 18:52 ` [PATCH 45/55] Introduce cp_print_value Tom Tromey
2019-12-08 18:52 ` [PATCH 37/55] Simplify generic_val_print_float Tom Tromey
2019-12-08 18:54 ` [PATCH 36/55] Introduce generic_value_print_char Tom Tromey
2019-12-08 18:54 ` [PATCH 31/55] Fix generic_val_print_enum for value-based printing Tom Tromey
2019-12-08 18:54 ` [PATCH 47/55] Introduce ada_value_print_ptr Tom Tromey
2019-12-08 18:54 ` [PATCH 49/55] Introduce ada_value_print_num Tom Tromey
2020-01-15  0:37 ` [PATCH 00/55] Remove val_print Tom Tromey
2020-01-15 11:52   ` Simon Marchi
2020-03-14  0:02     ` 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).