Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 9/9] Use references for value_print_options
Date: Sat, 04 Jul 2026 16:05:23 -0600	[thread overview]
Message-ID: <20260704-print-opts-cleanup-v1-9-fb54a5112a8d@tromey.com> (raw)
In-Reply-To: <20260704-print-opts-cleanup-v1-0-fb54a5112a8d@tromey.com>

Nearly all code using value_print_options will not work with a NULL
pointer.  This patch changes such code to use a reference instead.
Only a small number of uses of "value_print_options *" remain, all
seemingly necessary.
---
 gdb/ada-lang.c               |   8 +-
 gdb/ada-lang.h               |   4 +-
 gdb/ada-valprint.c           |  82 ++++++++++-----------
 gdb/ada-varobj.c             |  10 +--
 gdb/auxv.c                   |   2 +-
 gdb/breakpoint.c             |   2 +-
 gdb/c-lang.c                 |   2 +-
 gdb/c-lang.h                 |   6 +-
 gdb/c-valprint.c             |  58 +++++++--------
 gdb/char-print.c             |  14 ++--
 gdb/char-print.h             |   4 +-
 gdb/cli/cli-cmds.c           |   2 +-
 gdb/compile/compile.c        |   6 +-
 gdb/cp-valprint.c            |  45 ++++++-----
 gdb/d-lang.c                 |   2 +-
 gdb/d-lang.h                 |   2 +-
 gdb/d-valprint.c             |   4 +-
 gdb/dwarf2/read.c            |   2 +-
 gdb/extension-priv.h         |   2 +-
 gdb/extension.c              |   2 +-
 gdb/extension.h              |   2 +-
 gdb/f-lang.c                 |   2 +-
 gdb/f-lang.h                 |   6 +-
 gdb/f-valprint.c             |  44 +++++------
 gdb/gdbtypes.h               |   2 +-
 gdb/gnu-v3-abi.c             |   6 +-
 gdb/go-lang.h                |   2 +-
 gdb/go-valprint.c            |   8 +-
 gdb/guile/guile-internal.h   |   4 +-
 gdb/guile/scm-lazy-string.c  |   2 +-
 gdb/guile/scm-pretty-print.c |  34 ++++-----
 gdb/guile/scm-value.c        |   4 +-
 gdb/infcmd.c                 |   8 +-
 gdb/language.c               |  12 +--
 gdb/language.h               |   8 +-
 gdb/linux-thread-db.c        |   2 +-
 gdb/m2-lang.c                |   2 +-
 gdb/m2-lang.h                |   4 +-
 gdb/m2-valprint.c            |  28 +++----
 gdb/mi/mi-cmd-stack.c        |   2 +-
 gdb/mi/mi-main.c             |  10 +--
 gdb/mips-tdep.c              |   6 +-
 gdb/p-lang.c                 |   2 +-
 gdb/p-lang.h                 |   6 +-
 gdb/p-valprint.c             |  66 ++++++++---------
 gdb/printcmd.c               |  90 +++++++++++-----------
 gdb/python/py-framefilter.c  |  14 ++--
 gdb/python/py-lazy-string.c  |   2 +-
 gdb/python/py-prettyprint.c  |  40 +++++-----
 gdb/python/py-unwind.c       |   2 +-
 gdb/python/py-value.c        |   4 +-
 gdb/python/py-varobj.c       |  10 +--
 gdb/python/python-internal.h |   6 +-
 gdb/record-full.c            |   4 +-
 gdb/riscv-tdep.c             |   6 +-
 gdb/rust-lang.c              |  42 +++++------
 gdb/rust-lang.h              |  12 +--
 gdb/stack.c                  |   2 +-
 gdb/tracepoint.c             |   2 +-
 gdb/valprint.c               | 172 +++++++++++++++++++++----------------------
 gdb/valprint.h               |  26 +++----
 gdb/value.c                  |   4 +-
 gdb/value.h                  |   8 +-
 gdb/varobj.c                 |  10 +--
 64 files changed, 493 insertions(+), 494 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 2bb6cf7f9ff..0e7db2704a3 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13504,7 +13504,7 @@ class ada_language : public language_defn
   void print_array_index (struct type *index_type,
 			  LONGEST index,
 			  struct ui_file *stream,
-			  const value_print_options *options) const override
+			  const value_print_options &options) const override
   {
     struct value *index_value = val_atr (index_type, index);
 
@@ -13810,7 +13810,7 @@ class ada_language : public language_defn
   /* See language.h.  */
 
   void value_print (struct value *val, struct ui_file *stream,
-		    const value_print_options *options) const override
+		    const value_print_options &options) const override
   {
     return ada_value_print (val, stream, options);
   }
@@ -13819,7 +13819,7 @@ class ada_language : public language_defn
 
   void value_print_inner
 	(struct value *val, struct ui_file *stream, int recurse,
-	 const value_print_options *options) const override
+	 const value_print_options &options) const override
   {
     return ada_value_print_inner (val, stream, recurse, options);
   }
@@ -13890,7 +13890,7 @@ class ada_language : public language_defn
   void printstr (struct ui_file *stream, struct type *elttype,
 		 const gdb_byte *string, unsigned int length,
 		 const char *encoding, int force_ellipses,
-		 const value_print_options *options) const override
+		 const value_print_options &options) const override
   {
     /* ada_printstr doesn't handle UTF-8 too well, but we want this
        for lazy-string printing.  Defer this case to the generic
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 882963baea4..5382fe894cf 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -165,10 +165,10 @@ extern void ada_print_typedef (struct type *type, struct symbol *new_symbol,
 /* Implement la_value_print_inner for Ada.  */
 
 extern void ada_value_print_inner (struct value *, struct ui_file *, int,
-				   const value_print_options *);
+				   const value_print_options &);
 
 extern void ada_value_print (struct value *, struct ui_file *,
-			     const value_print_options *);
+			     const value_print_options &);
 
 				/* Defined in ada-lang.c */
 
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 8eeccf1d589..d66f9f84d52 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -32,7 +32,7 @@
 
 static bool print_field_values (struct value *, struct value *,
 				struct ui_file *, int,
-				const value_print_options *,
+				const value_print_options &,
 				bool, const struct language_defn *);
 
 \f
@@ -43,13 +43,13 @@ static bool print_field_values (struct value *, struct value *,
 
 static void
 print_optional_low_bound (struct ui_file *stream, struct type *type,
-			  const value_print_options *options)
+			  const value_print_options &options)
 {
   struct type *index_type;
   LONGEST low_bound;
   LONGEST high_bound;
 
-  if (options->print_array_indexes)
+  if (options.print_array_indexes)
     return;
 
   if (!get_array_bounds (type, &low_bound, &high_bound))
@@ -109,7 +109,7 @@ static void
 val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 				 int offset, struct ui_file *stream,
 				 int recurse,
-				 const value_print_options *options)
+				 const value_print_options &options)
 {
   unsigned int i;
   unsigned int things_printed = 0;
@@ -146,7 +146,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
   i = 0;
   annotate_array_section_begin (i, elttype);
 
-  while (i < len && things_printed < options->print_max)
+  while (i < len && things_printed < options.print_max)
     {
       /* Both this outer loop and the inner loop that checks for
 	 duplicates may allocate many values.  To avoid using too much
@@ -158,7 +158,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 
       if (i != 0)
 	{
-	  if (options->prettyformat_arrays)
+	  if (options.prettyformat_arrays)
 	    {
 	      gdb_printf (stream, ",\n");
 	      print_spaces (2 + 2 * recurse, stream);
@@ -168,7 +168,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	      gdb_printf (stream, ", ");
 	    }
 	}
-      else if (options->prettyformat_arrays)
+      else if (options.prettyformat_arrays)
 	{
 	  gdb_printf (stream, "\n");
 	  print_spaces (2 + 2 * recurse, stream);
@@ -202,12 +202,12 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	    break;
 	}
 
-      if (i - i0 > options->repeat_count_threshold)
+      if (i - i0 > options.repeat_count_threshold)
 	{
-	  value_print_options opts = *options;
+	  value_print_options opts = options;
 
 	  opts.deref_ref = false;
-	  common_val_print (v0, stream, recurse + 1, &opts, current_language);
+	  common_val_print (v0, stream, recurse + 1, opts, current_language);
 	  annotate_elt_rep (i - i0);
 	  gdb_printf (stream, _(" %p[<repeats %u times>%p]"),
 		      metadata_style.style ().ptr (), i - i0, nullptr);
@@ -217,14 +217,14 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
       else
 	{
 	  int j;
-	  value_print_options opts = *options;
+	  value_print_options opts = options;
 
 	  opts.deref_ref = false;
 	  for (j = i0; j < i; j += 1)
 	    {
 	      if (j > i0)
 		{
-		  if (options->prettyformat_arrays)
+		  if (options.prettyformat_arrays)
 		    {
 		      gdb_printf (stream, ",\n");
 		      print_spaces (2 + 2 * recurse, stream);
@@ -237,7 +237,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 		  maybe_print_array_index (index_type, j + low,
 					   stream, options);
 		}
-	      common_val_print (v0, stream, recurse + 1, &opts,
+	      common_val_print (v0, stream, recurse + 1, opts,
 				current_language);
 	      annotate_elt ();
 	    }
@@ -398,7 +398,7 @@ static bool
 print_variant_part (struct value *value, int field_num,
 		    struct value *outer_value,
 		    struct ui_file *stream, int recurse,
-		    const value_print_options *options,
+		    const value_print_options &options,
 		    bool comma_needed,
 		    const struct language_defn *language)
 {
@@ -432,7 +432,7 @@ print_variant_part (struct value *value, int field_num,
 static bool
 print_field_values (struct value *value, struct value *outer_value,
 		    struct ui_file *stream, int recurse,
-		    const value_print_options *options,
+		    const value_print_options &options,
 		    bool comma_needed,
 		    const struct language_defn *language)
 {
@@ -468,7 +468,7 @@ print_field_values (struct value *value, struct value *outer_value,
 	gdb_printf (stream, ", ");
       comma_needed = true;
 
-      if (options->prettyformat)
+      if (options.prettyformat)
 	{
 	  gdb_printf (stream, "\n");
 	  print_spaces (2 + 2 * recurse, stream);
@@ -507,19 +507,19 @@ print_field_values (struct value *value, struct value *outer_value,
 		     bit_pos / HOST_CHAR_BIT,
 		     bit_pos % HOST_CHAR_BIT,
 		     bit_size, type->field (i).type ());
-	      opts = *options;
+	      opts = options;
 	      opts.deref_ref = false;
-	      common_val_print (v, stream, recurse + 1, &opts, language);
+	      common_val_print (v, stream, recurse + 1, opts, language);
 	    }
 	}
       else
 	{
-	  value_print_options opts = *options;
+	  value_print_options opts = options;
 
 	  opts.deref_ref = false;
 
 	  struct value *v = value->field (i);
-	  common_val_print (v, stream, recurse + 1, &opts, language);
+	  common_val_print (v, stream, recurse + 1, opts, language);
 	}
       annotate_field_end ();
     }
@@ -534,7 +534,7 @@ static void
 ada_val_print_string (struct type *type, const gdb_byte *valaddr,
 		      int offset_aligned,
 		      struct ui_file *stream, int recurse,
-		      const value_print_options *options)
+		      const value_print_options &options)
 {
   enum bfd_endian byte_order = type_byte_order (type);
   struct type *elttype = type->target_type ();
@@ -553,7 +553,7 @@ ada_val_print_string (struct type *type, const gdb_byte *valaddr,
 
   /* If requested, look for the first null char and only print
      elements up to it.  */
-  if (options->stop_print_at_null)
+  if (options.stop_print_at_null)
     {
       unsigned int print_max_chars = get_print_max_chars (options);
       int temp_len;
@@ -578,9 +578,9 @@ ada_val_print_string (struct type *type, const gdb_byte *valaddr,
 static void
 ada_value_print_ptr (struct value *val,
 		     struct ui_file *stream, int recurse,
-		     const value_print_options *options)
+		     const value_print_options &options)
 {
-  if (!options->format
+  if (!options.format
       && val->type ()->target_type ()->code () == TYPE_CODE_INT
       && val->type ()->target_type ()->length () == 0)
     {
@@ -605,7 +605,7 @@ ada_value_print_ptr (struct value *val,
 
 static void
 ada_value_print_num (struct value *val, struct ui_file *stream, int recurse,
-		     const value_print_options *options)
+		     const value_print_options &options)
 {
   struct type *type = ada_check_typedef (val->type ());
   const gdb_byte *valaddr = val->contents_for_printing ().data ();
@@ -627,15 +627,15 @@ ada_value_print_num (struct value *val, struct ui_file *stream, int recurse,
     }
   else
     {
-      int format = (options->format ? options->format
-		    : options->output_format);
+      int format = (options.format ? options.format
+		    : options.output_format);
 
       if (format)
 	{
-	  value_print_options opts = *options;
+	  value_print_options opts = options;
 
 	  opts.format = format;
-	  value_print_scalar_formatted (val, &opts, 0, stream);
+	  value_print_scalar_formatted (val, opts, 0, stream);
 	}
       else if (ada_is_system_address_type (type))
 	{
@@ -676,11 +676,11 @@ ada_value_print_num (struct value *val, struct ui_file *stream, int recurse,
 
 static void
 ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse,
-		    const value_print_options *options)
+		    const value_print_options &options)
 {
   LONGEST val;
 
-  if (options->format)
+  if (options.format)
     {
       value_print_scalar_formatted (value, options, 0, stream);
       return;
@@ -714,13 +714,13 @@ static void
 ada_val_print_struct_union (struct value *value,
 			    struct ui_file *stream,
 			    int recurse,
-			    const value_print_options *options)
+			    const value_print_options &options)
 {
   gdb_printf (stream, "(");
 
   if (print_field_values (value, value, stream, recurse, options,
 			  false, language_def (language_ada))
-      && options->prettyformat)
+      && options.prettyformat)
     {
       gdb_printf (stream, "\n");
       print_spaces (2 * recurse, stream);
@@ -734,13 +734,13 @@ ada_val_print_struct_union (struct value *value,
 
 static void
 ada_value_print_array (struct value *val, struct ui_file *stream, int recurse,
-		       const value_print_options *options)
+		       const value_print_options &options)
 {
   struct type *type = ada_check_typedef (val->type ());
 
   /* For an array of characters, print with string syntax.  */
   if (ada_is_string_type (type)
-      && (options->format == 0 || options->format == 's'))
+      && (options.format == 0 || options.format == 's'))
     {
       const gdb_byte *valaddr = val->contents_for_printing ().data ();
       int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr;
@@ -775,7 +775,7 @@ ada_val_print_ref (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 value_print_options *options)
+		   const value_print_options &options)
 {
   /* For references, the debugger is expected to print the value as
      an address if DEREF_REF is null.  But printing an address in place
@@ -830,7 +830,7 @@ ada_val_print_ref (struct type *type, const gdb_byte *valaddr,
 
 void
 ada_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
-		       const value_print_options *options)
+		       const value_print_options &options)
 {
   struct type *type = ada_check_typedef (val->type ());
 
@@ -891,7 +891,7 @@ ada_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_FLT:
-      if (options->format)
+      if (options.format)
 	{
 	  common_val_print (val, stream, recurse, options,
 			    language_def (language_c));
@@ -920,7 +920,7 @@ ada_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
 
 void
 ada_value_print (struct value *val0, struct ui_file *stream,
-		 const value_print_options *options)
+		 const value_print_options &options)
 {
   struct value *val = ada_to_fixed_value (val0);
   struct type *type = ada_check_typedef (val->type ());
@@ -956,7 +956,7 @@ ada_value_print (struct value *val0, struct ui_file *stream,
 	}
     }
 
-  opts = *options;
+  opts = options;
   opts.deref_ref = true;
-  common_val_print (val, stream, 0, &opts, current_language);
+  common_val_print (val, stream, 0, opts, current_language);
 }
diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c
index 623df0f01ed..4291a56da53 100644
--- a/gdb/ada-varobj.c
+++ b/gdb/ada-varobj.c
@@ -807,7 +807,7 @@ ada_varobj_get_type_of_child (struct value *parent_value,
 
 static std::string
 ada_varobj_get_value_image (struct value *value,
-			    const value_print_options *opts)
+			    const value_print_options &opts)
 {
   string_file buffer;
 
@@ -826,7 +826,7 @@ ada_varobj_get_value_image (struct value *value,
 static std::string
 ada_varobj_get_value_of_array_variable (struct value *value,
 					struct type *type,
-					const value_print_options *opts)
+					const value_print_options &opts)
 {
   const int numchild = ada_varobj_get_array_number_of_children (value, type);
 
@@ -836,7 +836,7 @@ ada_varobj_get_value_of_array_variable (struct value *value,
      which is not very convenient...  */
   if (value
       && ada_is_string_type (type)
-      && (opts->format == 0 || opts->format == 's'))
+      && (opts.format == 0 || opts.format == 's'))
     {
       std::string str = ada_varobj_get_value_image (value, opts);
       return string_printf ("[%d] %s", numchild, str.c_str ());
@@ -851,7 +851,7 @@ ada_varobj_get_value_of_array_variable (struct value *value,
 static std::string
 ada_varobj_get_value_of_variable (struct value *value,
 				  struct type *type,
-				  const value_print_options *opts)
+				  const value_print_options &opts)
 {
   ada_varobj_decode_var (&value, &type);
 
@@ -924,7 +924,7 @@ ada_value_of_variable (const struct varobj *var,
 {
   value_print_options opts = varobj_formatted_print_options (format);
   return ada_varobj_get_value_of_variable (var->value.get (), var->type,
-					   &opts);
+					   opts);
 }
 
 /* Implement the "value_is_changeable_p" routine for Ada.  */
diff --git a/gdb/auxv.c b/gdb/auxv.c
index 206406f8175..d2cfe99a995 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -446,7 +446,7 @@ fprint_auxv_entry (struct ui_file *file, const char *name,
 	if (opts.addressprint)
 	  gdb_printf (file, ("%s "), paddress (arch, val));
 	val_print_string (builtin_type (arch)->builtin_char,
-			  NULL, val, -1, file, &opts);
+			  NULL, val, -1, file, opts);
 	gdb_printf (file, ("\n"));
       }
       break;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 68811ed57da..1bba5f0f8ac 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5039,7 +5039,7 @@ watchpoint_value_print (struct value *val, struct ui_file *stream)
   else
     {
       const value_print_options &opts = get_user_print_options ();
-      value_print (val, stream, &opts);
+      value_print (val, stream, opts);
     }
 }
 
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index fe7edd53366..6bc0782846b 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -174,7 +174,7 @@ void
 language_defn::printstr (struct ui_file *stream, struct type *type,
 			 const gdb_byte *string, unsigned int length,
 			 const char *user_encoding, int force_ellipses,
-			 const value_print_options *options) const
+			 const value_print_options &options) const
 {
   c_string_type str_type;
   const char *type_encoding;
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 14a74b30af8..dd1fbaefe8e 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -84,10 +84,10 @@ extern void c_print_typedef (struct type *,
 /* Implement la_value_print_inner for the C family of languages.  */
 
 extern void c_value_print_inner (struct value *, struct ui_file *, int,
-				 const value_print_options *);
+				 const value_print_options &);
 
 extern void c_value_print (struct value *, struct ui_file *,
-			   const value_print_options *);
+			   const value_print_options &);
 
 /* These are in c-lang.c: */
 
@@ -107,7 +107,7 @@ extern void cp_print_class_memberptr (struct value *, struct ui_file *);
 
 extern void cp_print_value_fields (struct value *,
 				   struct ui_file *, int,
-				   const value_print_options *,
+				   const value_print_options &,
 				   struct type **, int);
 
 /* gcc-2.6 or later (when using -fvtable-thunks)
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 48087d2d7f7..9d9708e5be0 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -142,7 +142,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
 			struct type *unresolved_elttype,
 			const gdb_byte *valaddr, int embedded_offset,
 			CORE_ADDR address, struct ui_file *stream, int recurse,
-			const value_print_options *options)
+			const value_print_options &options)
 {
   int want_space = 0;
   struct gdbarch *gdbarch = type->arch ();
@@ -154,10 +154,10 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
       return;
     }
 
-  if (options->symbol_print)
+  if (options.symbol_print)
     want_space = print_address_demangle (options, gdbarch, address, stream,
 					 demangle);
-  else if (options->addressprint)
+  else if (options.addressprint)
     {
       fputs_styled (paddress (gdbarch, address), address_style.style (),
 		    stream);
@@ -167,7 +167,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
   /* For a pointer to a textual type, also print the string
      pointed to, unless pointer is null.  */
 
-  if (c_textual_element_type (unresolved_elttype, options->format)
+  if (c_textual_element_type (unresolved_elttype, options.format)
       && address != 0)
     {
       if (want_space)
@@ -181,7 +181,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
       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
+      if (!options.symbol_print
 	  && (msymbol.minsym != NULL)
 	  && (vt_address == msymbol.value_address ()))
 	{
@@ -193,7 +193,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
 	  want_space = 1;
 	}
 
-      if (vt_address && options->vtblprint)
+      if (vt_address && options.vtblprint)
 	{
 	  struct value *vt_val;
 	  struct symbol *wsym = NULL;
@@ -220,7 +220,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
 	  vt_val = value_at (wtype, vt_address);
 	  common_val_print (vt_val, stream, recurse + 1, options,
 			    current_language);
-	  if (options->prettyformat)
+	  if (options.prettyformat)
 	    {
 	      gdb_printf (stream, "\n");
 	      print_spaces (2 + 2 * recurse, stream);
@@ -234,7 +234,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
 static void
 c_value_print_array (struct value *val,
 		     struct ui_file *stream, int recurse,
-		     const value_print_options *options)
+		     const value_print_options &options)
 {
   struct type *type = check_typedef (val->type ());
   CORE_ADDR address = val->address ();
@@ -257,7 +257,7 @@ c_value_print_array (struct value *val,
       /* 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)
+				  options.format)
 	  && val->bytes_available (0, type->length ())
 	  && !val->bits_any_optimized_out (0,
 					   TARGET_CHAR_BIT * type->length ()))
@@ -266,7 +266,7 @@ c_value_print_array (struct value *val,
 
 	  /* If requested, look for the first null char and only
 	     print elements up to it.  */
-	  if (options->stop_print_at_null)
+	  if (options.stop_print_at_null)
 	    {
 	      unsigned int print_max_chars = get_print_max_chars (options);
 	      unsigned int temp_len;
@@ -326,9 +326,9 @@ c_value_print_array (struct value *val,
 
 static void
 c_value_print_ptr (struct value *val, struct ui_file *stream, int recurse,
-		   const value_print_options *options)
+		   const value_print_options &options)
 {
-  if (options->format && options->format != 's')
+  if (options.format && options.format != 's')
     {
       value_print_scalar_formatted (val, options, 0, stream);
       return;
@@ -337,7 +337,7 @@ c_value_print_ptr (struct value *val, struct ui_file *stream, int recurse,
   struct type *type = check_typedef (val->type ());
   const gdb_byte *valaddr = val->contents_for_printing ().data ();
 
-  if (options->vtblprint && cp_is_vtbl_ptr_type (type))
+  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
@@ -362,13 +362,13 @@ c_value_print_ptr (struct value *val, struct ui_file *stream, int recurse,
 
 static void
 c_value_print_struct (struct value *val, struct ui_file *stream, int recurse,
-		      const value_print_options *options)
+		      const value_print_options &options)
 {
   struct type *type = check_typedef (val->type ());
 
-  if (type->code () == TYPE_CODE_UNION && recurse && !options->unionprint)
+  if (type->code () == TYPE_CODE_UNION && recurse && !options.unionprint)
     gdb_printf (stream, "{...}");
-  else if (options->vtblprint && cp_is_vtbl_ptr_type (type))
+  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
@@ -389,15 +389,15 @@ c_value_print_struct (struct value *val, struct ui_file *stream, int recurse,
 
 static void
 c_value_print_int (struct value *val, struct ui_file *stream,
-		   const value_print_options *options)
+		   const value_print_options &options)
 {
-  if (options->format || options->output_format)
+  if (options.format || options.output_format)
     {
-      value_print_options opts = *options;
+      value_print_options opts = options;
 
-      opts.format = (options->format ? options->format
-		     : options->output_format);
-      value_print_scalar_formatted (val, &opts, 0, stream);
+      opts.format = (options.format ? options.format
+		     : options.output_format);
+      value_print_scalar_formatted (val, opts, 0, stream);
     }
   else
     {
@@ -408,7 +408,7 @@ c_value_print_int (struct value *val, struct ui_file *stream,
 	 the character equivalent as well.  */
       struct type *type = val->type ();
       const gdb_byte *valaddr = val->contents_for_printing ().data ();
-      if (c_textual_element_type (type, options->format))
+      if (c_textual_element_type (type, options.format))
 	{
 	  gdb_puts (" ", stream);
 	  current_language->printchar (unpack_long (type, valaddr), type,
@@ -421,7 +421,7 @@ c_value_print_int (struct value *val, struct ui_file *stream,
 
 void
 c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
-		     const value_print_options *options)
+		     const value_print_options &options)
 {
   struct type *type = val->type ();
 
@@ -471,12 +471,12 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
 \f
 void
 c_value_print (struct value *val, struct ui_file *stream,
-	       const value_print_options *options)
+	       const value_print_options &options)
 {
   struct type *type, *real_type;
   int full, using_enc;
   LONGEST top;
-  value_print_options opts = *options;
+  value_print_options opts = options;
 
   opts.deref_ref = true;
 
@@ -505,7 +505,7 @@ c_value_print (struct value *val, struct ui_file *stream,
 	{
 	  /* Print nothing.  */
 	}
-      else if (options->objectprint
+      else if (options.objectprint
 	       && (type->target_type ()->code () == TYPE_CODE_STRUCT))
 	{
 	  int is_ref = TYPE_IS_REFERENCE (type);
@@ -557,7 +557,7 @@ c_value_print (struct value *val, struct ui_file *stream,
   if (!val->initialized ())
     gdb_printf (stream, " [uninitialized] ");
 
-  if (options->objectprint && (type->code () == TYPE_CODE_STRUCT))
+  if (options.objectprint && (type->code () == TYPE_CODE_STRUCT))
     {
       /* Attempt to determine real type of object.  */
       real_type = value_rtti_type (val, &full, &top, &using_enc);
@@ -586,5 +586,5 @@ c_value_print (struct value *val, struct ui_file *stream,
 	}
     }
 
-  common_val_print (val, stream, 0, &opts, current_language);
+  common_val_print (val, stream, 0, opts, current_language);
 }
diff --git a/gdb/char-print.c b/gdb/char-print.c
index 8eba856c5bb..f3425ac2cbc 100644
--- a/gdb/char-print.c
+++ b/gdb/char-print.c
@@ -323,15 +323,15 @@ wchar_printer::count_next_character (wchar_iterator *iter,
 void
 wchar_printer::print_converted_chars_to_obstack
      (const std::vector<converted_character> &chars,
-      const value_print_options *options,
+      const value_print_options &options,
       int *finished)
 {
   unsigned int idx, num_elements;
   const converted_character *elem;
   enum {START, SINGLE, REPEAT, INCOMPLETE, FINISH} state, last;
   gdb_wchar_t wide_quote_char = gdb_btowc (m_quoter);
-  const int print_max = options->print_max_chars > 0
-      ? options->print_max_chars : options->print_max;
+  const int print_max = options.print_max_chars > 0
+      ? options.print_max_chars : options.print_max;
 
   /* Set the start state.  */
   idx = num_elements = 0;
@@ -351,7 +351,7 @@ wchar_printer::print_converted_chars_to_obstack
 	    int j;
 
 	    /* We are outputting a single character
-	       (< options->repeat_count_threshold).  */
+	       (< options.repeat_count_threshold).  */
 
 	    if (last != SINGLE)
 	      {
@@ -385,7 +385,7 @@ wchar_printer::print_converted_chars_to_obstack
 	    int j;
 
 	    /* We are outputting a character with a repeat count
-	       greater than options->repeat_count_threshold.  */
+	       greater than options.repeat_count_threshold.  */
 
 	    if (last == SINGLE)
 	      {
@@ -455,7 +455,7 @@ wchar_printer::print_converted_chars_to_obstack
 	    {
 	    case wchar_iterate_ok:
 	    case wchar_iterate_invalid:
-	      if (elem->repeat_count > options->repeat_count_threshold)
+	      if (elem->repeat_count > options.repeat_count_threshold)
 		state = REPEAT;
 	      else
 		state = SINGLE;
@@ -479,7 +479,7 @@ void
 wchar_printer::print (struct ui_file *stream, const gdb_byte *string,
 		      unsigned int length, int force_ellipses,
 		      int c_style_terminator,
-		      const value_print_options *options)
+		      const value_print_options &options)
 {
   unsigned int i;
   int finished = 0;
diff --git a/gdb/char-print.h b/gdb/char-print.h
index 44181a07de9..61b90a94ba2 100644
--- a/gdb/char-print.h
+++ b/gdb/char-print.h
@@ -106,7 +106,7 @@ class wchar_printer
   void print (struct ui_file *stream, const gdb_byte *string,
 	      unsigned int length, int force_ellipses,
 	      int c_style_terminator,
-	      const value_print_options *options);
+	      const value_print_options &options);
 
 protected:
 
@@ -165,7 +165,7 @@ class wchar_printer
      elements in CHARS.  */
   void print_converted_chars_to_obstack
        (const std::vector<converted_character> &chars,
-	const value_print_options *options,
+	const value_print_options &options,
 	int *finished);
 
 private:
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 3aa5f0038a9..8a89358f16b 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -2705,7 +2705,7 @@ shell_internal_fn (struct gdbarch *gdbarch,
   value_print_options opts = get_no_prettyformat_print_options ();
 
   string_file stream;
-  value_print (val, &stream, &opts);
+  value_print (val, &stream, opts);
 
   /* We should always have two quote chars, which we'll strip.  */
   gdb_assert (stream.size () >= 2);
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 7a60bd33a64..d91ce18ea2c 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -257,9 +257,9 @@ compile_code_command_completer (struct cmd_list_element *ignore,
 void
 compile_print_value (struct value *val, void *data_voidp)
 {
-  const value_print_options *print_opts = (value_print_options *) data_voidp;
+  const value_print_options &print_opts = * (value_print_options *) data_voidp;
 
-  print_value (val, *print_opts);
+  print_value (val, print_opts);
 }
 
 /* Handle the input from the 'compile print' command.  The "compile
@@ -280,7 +280,7 @@ compile_print_command (const char *arg, int from_tty)
   gdb::option::process_options
     (&arg, gdb::option::PROCESS_OPTIONS_REQUIRE_DELIMITER, group);
 
-  print_command_parse_format (&arg, "compile print", &print_opts);
+  print_command_parse_format (&arg, "compile print", print_opts);
 
   /* Passing &PRINT_OPTS as SCOPE_DATA is safe as do_module_cleanup
      will not touch the stale pointer if compile_object_run has
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 83719b9dd6c..ca2f16b04ac 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -48,10 +48,10 @@ static struct obstack dont_print_stat_array_obstack;
 
 static void cp_print_static_field (struct type *, struct value *,
 				   struct ui_file *, int,
-				   const value_print_options *);
+				   const value_print_options &);
 
 static void cp_print_value (struct value *, struct ui_file *,
-			    int, const value_print_options *,
+			    int, const value_print_options &,
 			    struct type **);
 
 
@@ -122,7 +122,7 @@ cp_is_vtbl_member (struct type *type)
 
 void
 cp_print_value_fields (struct value *val, struct ui_file *stream,
-		       int recurse, const value_print_options *options,
+		       int recurse, const value_print_options &options,
 		       struct type **dont_print_vb,
 		       int dont_print_statmem)
 {
@@ -193,19 +193,19 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 	  const gdb_byte *valaddr = val->contents_for_printing ().data ();
 
 	  /* If requested, skip printing of static fields.  */
-	  if (!options->static_field_print
+	  if (!options.static_field_print
 	      && type->field (i).is_static ())
 	    continue;
 
 	  if (fields_seen)
 	    {
 	      gdb_puts (",", stream);
-	      if (!options->prettyformat)
+	      if (!options.prettyformat)
 		gdb_puts (" ", stream);
 	    }
 	  else if (n_baseclasses > 0)
 	    {
-	      if (options->prettyformat)
+	      if (options.prettyformat)
 		{
 		  gdb_printf (stream, "\n");
 		  print_spaces (2 + 2 * recurse, stream);
@@ -216,7 +216,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 	    }
 	  fields_seen = 1;
 
-	  if (options->prettyformat)
+	  if (options.prettyformat)
 	    {
 	      gdb_printf (stream, "\n");
 	      print_spaces (2 + 2 * recurse, stream);
@@ -242,8 +242,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 	  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;
+	  value_print_options opts = options;
 
 	  /* Do not print leading '=' in case of anonymous
 	     unions.  */
@@ -254,8 +253,8 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 	      /* 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;
+	      if (opts.max_depth != -1 && opts.max_depth < INT_MAX)
+		++opts.max_depth;
 	    }
 	  annotate_field_value ();
 
@@ -280,7 +279,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 		}
 	      else
 		{
-		  opts->deref_ref = false;
+		  opts.deref_ref = false;
 
 		  v = value_field_bitfield (type, i, valaddr,
 					    val->embedded_offset (), val);
@@ -332,7 +331,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 	      else
 		{
 		  struct value *v = val->primitive_field (0, i, type);
-		  opts->deref_ref = false;
+		  opts.deref_ref = false;
 		  common_val_print (v, stream, recurse + 1, opts,
 				    current_language);
 		}
@@ -372,7 +371,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 	    }
 	}
 
-      if (options->prettyformat)
+      if (options.prettyformat)
 	{
 	  gdb_printf (stream, "\n");
 	  print_spaces (2 * recurse, stream);
@@ -389,7 +388,7 @@ static void
 cp_print_value_fields_pp (struct value *val,
 			  struct ui_file *stream,
 			  int recurse,
-			  const value_print_options *options,
+			  const value_print_options &options,
 			  struct type **dont_print_vb,
 			  int dont_print_statmem)
 {
@@ -397,7 +396,7 @@ cp_print_value_fields_pp (struct value *val,
 
   /* Attempt to run an extension language pretty-printer if
      possible.  */
-  if (!options->raw)
+  if (!options.raw)
     result
       = apply_ext_lang_val_pretty_printer (val, stream,
 					   recurse, options,
@@ -413,7 +412,7 @@ cp_print_value_fields_pp (struct value *val,
 
 static void
 cp_print_value (struct value *val, struct ui_file *stream,
-		int recurse, const value_print_options *options,
+		int recurse, const value_print_options &options,
 		struct type **dont_print_vb)
 {
   struct type *type = check_typedef (val->type ());
@@ -503,7 +502,7 @@ cp_print_value (struct value *val, struct ui_file *stream,
 	}
 
       /* Now do the printing.  */
-      if (options->prettyformat)
+      if (options.prettyformat)
 	{
 	  gdb_printf (stream, "\n");
 	  print_spaces (2 * recurse, stream);
@@ -562,7 +561,7 @@ cp_print_static_field (struct type *type,
 		       struct value *val,
 		       struct ui_file *stream,
 		       int recurse,
-		       const value_print_options *options)
+		       const value_print_options &options)
 {
   value_print_options opts;
 
@@ -628,9 +627,9 @@ cp_print_static_field (struct type *type,
 		    sizeof (struct type *));
     }
 
-  opts = *options;
+  opts = options;
   opts.deref_ref = false;
-  common_val_print (val, stream, recurse, &opts, current_language);
+  common_val_print (val, stream, recurse, opts, current_language);
 }
 
 /* Find the field in *SELF, or its non-virtual base classes, with
@@ -780,12 +779,12 @@ test_print_fields (gdbarch *arch)
 
   string_file out;
   value_print_options opts = get_no_prettyformat_print_options ();
-  cp_print_value_fields(val, &out, 0, &opts, NULL, 0);
+  cp_print_value_fields (val, &out, 0, opts, NULL, 0);
   SELF_CHECK (out.string () == "{A = false, B = 5, C = true}");
 
   out.clear();
   opts.format = 'x';
-  cp_print_value_fields(val, &out, 0, &opts, NULL, 0);
+  cp_print_value_fields (val, &out, 0, opts, NULL, 0);
   SELF_CHECK (out.string () == "{A = 0x0, B = 0x5, C = 0x1}");
 }
 
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index f6ebf49fc19..437b397a3a4 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -160,7 +160,7 @@ class d_language : public language_defn
 
   void value_print_inner
 	(struct value *val, struct ui_file *stream, int recurse,
-	 const value_print_options *options) const override
+	 const value_print_options &options) const override
   {
     return d_value_print_inner (val, stream, recurse, options);
   }
diff --git a/gdb/d-lang.h b/gdb/d-lang.h
index 57a4d5bfbac..7921d3ac804 100644
--- a/gdb/d-lang.h
+++ b/gdb/d-lang.h
@@ -82,6 +82,6 @@ extern struct block_symbol d_lookup_nested_symbol (struct type *, const char *,
 
 extern void d_value_print_inner (struct value *val,
 				 struct ui_file *stream, int recurse,
-				 const value_print_options *options);
+				 const value_print_options &options);
 
 #endif /* GDB_D_LANG_H */
diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c
index 493c043a7e2..4713a923db8 100644
--- a/gdb/d-valprint.c
+++ b/gdb/d-valprint.c
@@ -31,7 +31,7 @@ dynamic_array_type (struct type *type,
 		    LONGEST embedded_offset, CORE_ADDR address,
 		    struct ui_file *stream, int recurse,
 		    struct value *val,
-		    const value_print_options *options)
+		    const value_print_options &options)
 {
   if (type->num_fields () == 2
       && type->field (0).type ()->code () == TYPE_CODE_INT
@@ -71,7 +71,7 @@ dynamic_array_type (struct type *type,
 
 void
 d_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
-		     const value_print_options *options)
+		     const value_print_options &options)
 {
   int ret;
 
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 6f34f187d47..4b1844a1f14 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -5138,7 +5138,7 @@ dwarf2_compute_name (const char *name,
 		      value_print_options opts
 			= get_formatted_print_options ('d');
 		      opts.raw = true;
-		      value_print (v, &buf, &opts);
+		      value_print (v, &buf, opts);
 		      release_value (v);
 		    }
 		}
diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h
index 24f9e79a9e5..bb6acdf8290 100644
--- a/gdb/extension-priv.h
+++ b/gdb/extension-priv.h
@@ -165,7 +165,7 @@ struct extension_language_ops
   enum ext_lang_rc (*apply_val_pretty_printer)
     (const struct extension_language_defn *,
      struct value *val, struct ui_file *stream, int recurse,
-     const value_print_options *options,
+     const 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 d82efa88a50..de3b3eb69a5 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -468,7 +468,7 @@ ext_lang_type_printers::~ext_lang_type_printers ()
 int
 apply_ext_lang_val_pretty_printer (struct value *val,
 				   struct ui_file *stream, int recurse,
-				   const value_print_options *options,
+				   const value_print_options &options,
 				   const struct language_defn *language)
 {
   for (const struct extension_language_defn *extlang : extension_languages)
diff --git a/gdb/extension.h b/gdb/extension.h
index ab5c7b2d167..e500e52f19f 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -296,7 +296,7 @@ extern gdb::unique_xmalloc_ptr<char> apply_ext_lang_type_printers
 
 extern int apply_ext_lang_val_pretty_printer
   (struct value *value, struct ui_file *stream, int recurse,
-   const value_print_options *options,
+   const value_print_options &options,
    const struct language_defn *language);
 
 extern enum ext_lang_bt_status apply_ext_lang_frame_filter
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 90062734b0e..5a40995f310 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -1635,7 +1635,7 @@ fortran_structop_operation::evaluate (struct type *expect_type,
 void
 f_language::print_array_index (struct type *index_type, LONGEST index,
 			       struct ui_file *stream,
-			       const value_print_options *options) const
+			       const value_print_options &options) const
 {
   struct value *index_value = value_from_longest (index_type, index);
 
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index cb48eb3fde0..b660ddf371e 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -64,7 +64,7 @@ class f_language : public language_defn
   void print_array_index (struct type *index_type,
 			  LONGEST index,
 			  struct ui_file *stream,
-			  const value_print_options *options) const override;
+			  const value_print_options &options) const override;
 
   /* See language.h.  */
   void language_arch_info (struct gdbarch *gdbarch,
@@ -137,7 +137,7 @@ class f_language : public language_defn
 
   void value_print_inner
 	(struct value *val, struct ui_file *stream, int recurse,
-	 const value_print_options *options) const override;
+	 const value_print_options &options) const override;
 
   /* See language.h.  */
 
@@ -170,7 +170,7 @@ class f_language : public language_defn
   void printstr (struct ui_file *stream, struct type *elttype,
 		 const gdb_byte *string, unsigned int length,
 		 const char *encoding, int force_ellipses,
-		 const value_print_options *options) const override
+		 const value_print_options &options) const override
   {
     if (elttype->length () == 4)
       gdb_puts ("4_", stream);
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index bff2acf6056..e1b9b8eebc0 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -121,7 +121,7 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
 				       struct value *val,
 				       struct ui_file *stream,
 				       int recurse,
-				       const value_print_options *options)
+				       const value_print_options &options)
     : m_elts (0),
       m_val (val),
       m_stream (stream),
@@ -139,7 +139,7 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
      cases, return true.  */
   bool continue_walking (bool should_continue)
   {
-    bool cont = should_continue && (m_elts < m_options->print_max);
+    bool cont = should_continue && (m_elts < m_options.print_max);
     if (!cont && should_continue)
       gdb_puts ("...", m_stream);
     return cont;
@@ -191,11 +191,11 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
     size_t dim_indx = m_dimension - 1;
     struct type *elt_type_prev = m_elt_type_prev;
     LONGEST elt_off_prev = m_elt_off_prev;
-    bool repeated = (m_options->repeat_count_threshold < UINT_MAX
+    bool repeated = (m_options.repeat_count_threshold < UINT_MAX
 		     && elt_type_prev != nullptr
 		     && (m_elts + ((m_nrepeats + 1)
 				   * m_stats[dim_indx + 1].nelts)
-			 <= m_options->print_max)
+			 <= m_options.print_max)
 		     && dimension_contents_eq (m_val, elt_type,
 					       elt_off_prev, elt_off));
 
@@ -206,7 +206,7 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
 	LONGEST nrepeats = m_nrepeats;
 
 	m_nrepeats = 0;
-	if (nrepeats >= m_options->repeat_count_threshold)
+	if (nrepeats >= m_options.repeat_count_threshold)
 	  {
 	    annotate_elt_rep (nrepeats + 1);
 	    gdb_printf (m_stream, "%p[<repeats %s times>%p]",
@@ -234,7 +234,7 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
 	       And we need to print `...' by hand if the skipped element
 	       would be the last one processed, because the subsequent call
 	       to `continue_walking' from our caller won't do that.  */
-	    if (m_elts < m_options->print_max)
+	    if (m_elts < m_options.print_max)
 	      {
 		maybe_print_array_index (m_stats[dim_indx].index_type, index,
 					 m_stream, m_options);
@@ -262,7 +262,7 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
     LONGEST elt_off_prev = m_elt_off_prev;
     bool repeated = false;
 
-    if (m_options->repeat_count_threshold < UINT_MAX
+    if (m_options.repeat_count_threshold < UINT_MAX
 	&& elt_type_prev != nullptr)
       {
 	/* When printing large arrays this spot is called frequently, so clean
@@ -281,7 +281,7 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
 
     if (repeated)
       m_nrepeats++;
-    if (!repeated || last_p || m_elts + 1 == m_options->print_max)
+    if (!repeated || last_p || m_elts + 1 == m_options.print_max)
       {
 	LONGEST nrepeats = m_nrepeats;
 	bool printed = false;
@@ -289,7 +289,7 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
 	if (nrepeats != 0)
 	  {
 	    m_nrepeats = 0;
-	    if (nrepeats >= m_options->repeat_count_threshold)
+	    if (nrepeats >= m_options.repeat_count_threshold)
 	      {
 		annotate_elt_rep (nrepeats + 1);
 		gdb_printf (m_stream, "%p[<repeats %s times>%p]",
@@ -401,7 +401,7 @@ class fortran_array_printer_impl : public fortran_array_walker_base_impl
 
   /* The print control options.  Gives us the maximum number of elements to
      print, and is passed through to each element that we print.  */
-  const value_print_options *m_options = nullptr;
+  const value_print_options &m_options;
 
   /* The number of the current dimension being handled.  */
   LONGEST m_dimension;
@@ -424,7 +424,7 @@ static void
 fortran_print_array (struct type *type, CORE_ADDR address,
 		     struct ui_file *stream, int recurse,
 		     const struct value *val,
-		     const value_print_options *options)
+		     const value_print_options &options)
 {
   fortran_array_walker<fortran_array_printer_impl> p
     (type, address, (struct value *) val, stream, recurse, options);
@@ -451,7 +451,7 @@ static const struct generic_val_print_decorations f_decorations =
 void
 f_language::value_print_inner (struct value *val, struct ui_file *stream,
 			       int recurse,
-			       const value_print_options *options) const
+			       const value_print_options &options) const
 {
   struct type *type = check_typedef (val->type ());
   struct gdbarch *gdbarch = type->arch ();
@@ -485,7 +485,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
       break;
 
     case TYPE_CODE_PTR:
-      if (options->format && options->format != 's')
+      if (options.format && options.format != 's')
 	{
 	  value_print_scalar_formatted (val, options, 0, stream);
 	  break;
@@ -504,10 +504,10 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
 	      return;
 	    }
 
-	  if (options->symbol_print)
+	  if (options.symbol_print)
 	    want_space = print_address_demangle (options, gdbarch, addr,
 						 stream, demangle);
-	  else if (options->addressprint && options->format != 's')
+	  else if (options.addressprint && options.format != 's')
 	    {
 	      fputs_styled (paddress (gdbarch, addr), address_style.style (),
 			    stream);
@@ -518,7 +518,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
 	     pointed to, unless pointer is null.  */
 	  if (elttype->length () == 1
 	      && elttype->code () == TYPE_CODE_INT
-	      && (options->format == 0 || options->format == 's')
+	      && (options.format == 0 || options.format == 's')
 	      && addr != 0)
 	    {
 	      if (want_space)
@@ -581,12 +581,12 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
       break;
 
     case TYPE_CODE_BOOL:
-      if (options->format || options->output_format)
+      if (options.format || options.output_format)
 	{
-	  value_print_options opts = *options;
-	  opts.format = (options->format ? options->format
-			 : options->output_format);
-	  value_print_scalar_formatted (val, &opts, 0, stream);
+	  value_print_options opts = options;
+	  opts.format = (options.format ? options.format
+			 : options.output_format);
+	  value_print_scalar_formatted (val, opts, 0, stream);
 	}
       else
 	{
@@ -657,7 +657,7 @@ info_common_command_for_block (const struct block *block, const char *comname,
 	    try
 	      {
 		val = value_of_variable (common->contents[index], block);
-		value_print (val, gdb_stdout, &opts);
+		value_print (val, gdb_stdout, opts);
 	      }
 
 	    catch (const gdb_exception_error &except)
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 7186362e026..8fdfdad9676 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2793,7 +2793,7 @@ extern void recursive_dump_type (struct type *, int);
 /* printcmd.c */
 
 extern void print_scalar_formatted (const gdb_byte *, struct type *,
-				    const value_print_options *,
+				    const value_print_options &,
 				    int, struct ui_file *);
 
 extern int can_dereference (struct type *);
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 2ca29ef77d3..834f9b24bf6 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -684,7 +684,7 @@ gnuv3_print_method_ptr (const gdb_byte *contents,
   else
     {
       const value_print_options &opts = get_user_print_options ();
-      print_address_demangle (&opts, gdbarch, ptr_value, stream, demangle);
+      print_address_demangle (opts, gdbarch, ptr_value, stream, demangle);
     }
 
   if (adjustment)
@@ -870,7 +870,7 @@ compute_vtable_size (vtable_hash_t &offset_hash, struct value *value)
 static void
 print_one_vtable (struct gdbarch *gdbarch, struct value *value,
 		  int max_voffset,
-		  const value_print_options *opts)
+		  const value_print_options &opts)
 {
   int i;
   struct type *type = check_typedef (value->type ());
@@ -975,7 +975,7 @@ gnuv3_print_vtable (struct value *value)
 	{
 	  if (count > 0)
 	    gdb_printf ("\n");
-	  print_one_vtable (gdbarch, item.first, item.second, &opts);
+	  print_one_vtable (gdbarch, item.first, item.second, opts);
 	  ++count;
 	}
     }
diff --git a/gdb/go-lang.h b/gdb/go-lang.h
index c2be398df52..67f624dc21a 100644
--- a/gdb/go-lang.h
+++ b/gdb/go-lang.h
@@ -123,7 +123,7 @@ class go_language : public language_defn
 
   void value_print_inner
 	(struct value *val, struct ui_file *stream, int recurse,
-	 const value_print_options *options) const override;
+	 const value_print_options &options) const override;
 
   /* See language.h.  */
 
diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c
index 0ee6571bc75..c99e034369b 100644
--- a/gdb/go-valprint.c
+++ b/gdb/go-valprint.c
@@ -40,7 +40,7 @@ print_go_string (struct type *type,
 		 LONGEST embedded_offset, CORE_ADDR address,
 		 struct ui_file *stream, int recurse,
 		 struct value *val,
-		 const value_print_options *options)
+		 const value_print_options &options)
 {
   struct gdbarch *gdbarch = type->arch ();
   struct type *elt_ptr_type = type->field (0).type ();
@@ -63,7 +63,7 @@ print_go_string (struct type *type,
     error (_("Unable to read string length"));
 
   /* TODO(dje): Print address of struct or actual string?  */
-  if (options->addressprint)
+  if (options.addressprint)
     {
       fputs_styled (paddress (gdbarch, addr), address_style.style (), stream);
       gdb_puts (" ", stream);
@@ -88,7 +88,7 @@ print_go_string (struct type *type,
 void
 go_language::value_print_inner (struct value *val, struct ui_file *stream,
 				int recurse,
-				const value_print_options *options) const
+				const value_print_options &options) const
 {
   struct type *type = check_typedef (val->type ());
 
@@ -101,7 +101,7 @@ go_language::value_print_inner (struct value *val, struct ui_file *stream,
 	  switch (go_type)
 	    {
 	    case GO_TYPE_STRING:
-	      if (! options->raw)
+	      if (! options.raw)
 		{
 		  print_go_string (type, val->embedded_offset (),
 				   val->address (),
diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h
index 7d406890e62..cb46d7497ea 100644
--- a/gdb/guile/guile-internal.h
+++ b/gdb/guile/guile-internal.h
@@ -500,7 +500,7 @@ extern struct value *lsscm_safe_lazy_string_to_value (SCM string,
 
 extern void lsscm_val_print_lazy_string
   (SCM string, struct ui_file *stream,
-   const value_print_options *options);
+   const value_print_options &options);
 
 /* scm-objfile.c */
 
@@ -612,7 +612,7 @@ extern enum ext_lang_rc gdbscm_apply_val_pretty_printer
   (const struct extension_language_defn *,
    struct value *val,
    struct ui_file *stream, int recurse,
-   const value_print_options *options,
+   const value_print_options &options,
    const struct language_defn *language);
 
 extern int gdbscm_breakpoint_has_cond (const struct extension_language_defn *,
diff --git a/gdb/guile/scm-lazy-string.c b/gdb/guile/scm-lazy-string.c
index 53324172617..1011256c3c8 100644
--- a/gdb/guile/scm-lazy-string.c
+++ b/gdb/guile/scm-lazy-string.c
@@ -349,7 +349,7 @@ lsscm_safe_lazy_string_to_value (SCM string, int arg_pos,
 
 void
 lsscm_val_print_lazy_string (SCM string, struct ui_file *stream,
-			     const value_print_options *options)
+			     const value_print_options &options)
 {
   lazy_string_smob *ls_smob;
   struct type *elt_type;
diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index 3bf994a7bdf..5545a9070d7 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -645,7 +645,7 @@ ppscm_print_exception_unless_memory_error (SCM exception,
 static enum guile_string_repr_result
 ppscm_print_string_repr (SCM printer, enum display_hint hint,
 			 struct ui_file *stream, int recurse,
-			 const value_print_options *options,
+			 const value_print_options &options,
 			 struct gdbarch *gdbarch,
 			 const struct language_defn *language)
 {
@@ -661,11 +661,11 @@ ppscm_print_string_repr (SCM printer, enum display_hint hint,
     }
   else if (scm_is_eq (str_scm, SCM_BOOL_T))
     {
-      value_print_options opts = *options;
+      value_print_options opts = options;
 
       gdb_assert (replacement != NULL);
       opts.addressprint = false;
-      common_val_print (replacement, stream, recurse, &opts, language);
+      common_val_print (replacement, stream, recurse, opts, language);
       result = STRING_REPR_OK;
     }
   else if (scm_is_string (str_scm))
@@ -700,10 +700,10 @@ ppscm_print_string_repr (SCM printer, enum display_hint hint,
     }
   else if (lsscm_is_lazy_string (str_scm))
     {
-      value_print_options local_opts = *options;
+      value_print_options local_opts = options;
 
       local_opts.addressprint = false;
-      lsscm_val_print_lazy_string (str_scm, stream, &local_opts);
+      lsscm_val_print_lazy_string (str_scm, stream, local_opts);
       result = STRING_REPR_OK;
     }
   else
@@ -725,7 +725,7 @@ ppscm_print_string_repr (SCM printer, enum display_hint hint,
 static void
 ppscm_print_children (SCM printer, enum display_hint hint,
 		      struct ui_file *stream, int recurse,
-		      const value_print_options *options,
+		      const value_print_options &options,
 		      struct gdbarch *gdbarch,
 		      const struct language_defn *language,
 		      int printed_nothing)
@@ -774,17 +774,17 @@ ppscm_print_children (SCM printer, enum display_hint hint,
   /* Use the prettyformat_arrays option if we are printing an array,
      and the pretty option otherwise.  */
   if (is_array)
-    pretty = options->prettyformat_arrays;
+    pretty = options.prettyformat_arrays;
   else
     {
-      if (options->prettyformat == Val_prettyformat)
+      if (options.prettyformat == Val_prettyformat)
 	pretty = 1;
       else
-	pretty = options->prettyformat_structs;
+	pretty = options.prettyformat_structs;
     }
 
   done_flag = 0;
-  for (i = 0; i < options->print_max; ++i)
+  for (i = 0; i < options.print_max; ++i)
     {
       SCM scm_name, v_scm;
       SCM item = itscm_safe_call_next_x (iter, gdbscm_memory_error_p);
@@ -847,7 +847,7 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 
       /* In summary mode, we just want to print "= {...}" if there is
 	 a value.  */
-      if (options->summary)
+      if (options.summary)
 	{
 	  /* This increment tricks the post-loop logic to print what
 	     we want.  */
@@ -874,7 +874,7 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 	{
 	  /* We print the index, not whatever the child method
 	     returned as the name.  */
-	  if (options->print_array_indexes)
+	  if (options.print_array_indexes)
 	    gdb_printf (stream, "[%d] = ", i);
 	}
       else if (! is_map)
@@ -885,10 +885,10 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 
       if (lsscm_is_lazy_string (v_scm))
 	{
-	  value_print_options local_opts = *options;
+	  value_print_options local_opts = options;
 
 	  local_opts.addressprint = false;
-	  lsscm_val_print_lazy_string (v_scm, stream, &local_opts);
+	  lsscm_val_print_lazy_string (v_scm, stream, local_opts);
 	}
       else if (scm_is_string (v_scm))
 	{
@@ -914,12 +914,12 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 	      /* When printing the key of a map we allow one additional
 		 level of depth.  This means the key will print before the
 		 value does.  */
-	      value_print_options opt = *options;
+	      value_print_options opt = options;
 	      if (is_map && i % 2 == 0
 		  && opt.max_depth != -1
 		  && opt.max_depth < INT_MAX)
 		++opt.max_depth;
-	      common_val_print (value, stream, recurse + 1, &opt, language);
+	      common_val_print (value, stream, recurse + 1, opt, language);
 	    }
 	}
 
@@ -957,7 +957,7 @@ enum ext_lang_rc
 gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang,
 				 struct value *value,
 				 struct ui_file *stream, int recurse,
-				 const value_print_options *options,
+				 const value_print_options &options,
 				 const struct language_defn *language)
 {
   struct type *type = value->type ();
diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c
index fb739c370ef..27719568809 100644
--- a/gdb/guile/scm-value.c
+++ b/gdb/guile/scm-value.c
@@ -161,7 +161,7 @@ vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate)
     {
       string_file stb;
 
-      common_val_print (v_smob->value, &stb, 0, &opts, current_language);
+      common_val_print (v_smob->value, &stb, 0, opts, current_language);
       scm_puts (stb.c_str (), port);
     }
   catch (const gdb_exception &except)
@@ -1274,7 +1274,7 @@ gdbscm_value_print (SCM self)
   gdbscm_gdb_exception exc {};
   try
     {
-      common_val_print (value, &stb, 0, &opts, current_language);
+      common_val_print (value, &stb, 0, opts, current_language);
     }
   catch (const gdb_exception &except)
     {
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 90a49eff8be..4b7cdd0e686 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1652,7 +1652,7 @@ print_return_value_1 (struct ui_out *uiout, struct return_value_info *rv)
 	{
 	  const value_print_options opts = get_user_print_options ();
 	  string_file stb;
-	  value_print (rv->value, &stb, &opts);
+	  value_print (rv->value, &stb, opts);
 	  uiout->field_stream ("return-value", stb);
 	}
       else
@@ -2423,7 +2423,7 @@ default_print_one_register_info (struct ui_file *file,
       value_print_options opts = get_user_print_options ();
       opts.deref_ref = true;
 
-      common_val_print (val, &format_stream, 0, &opts, current_language);
+      common_val_print (val, &format_stream, 0, opts, current_language);
 
       if (print_raw_format)
 	{
@@ -2439,7 +2439,7 @@ default_print_one_register_info (struct ui_file *file,
       /* Print the register in hex.  */
       value_print_options opts = get_formatted_print_options ('x');
       opts.deref_ref = true;
-      common_val_print (val, &format_stream, 0, &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 && regtype->is_vector () == 0)
@@ -2447,7 +2447,7 @@ default_print_one_register_info (struct ui_file *file,
 	  pad_to_column (format_stream, value_column_2);
 	  opts = get_user_print_options ();
 	  opts.deref_ref = true;
-	  common_val_print (val, &format_stream, 0, &opts, current_language);
+	  common_val_print (val, &format_stream, 0, opts, current_language);
 	}
     }
 
diff --git a/gdb/language.c b/gdb/language.c
index 25d57af363b..a83ef441279 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -610,7 +610,7 @@ default_word_break_characters (void)
 void
 language_defn::print_array_index (struct type *index_type, LONGEST index,
 				  struct ui_file *stream,
-				  const value_print_options *options) const
+				  const value_print_options &options) const
 {
   struct value *index_value = value_from_longest (index_type, index);
 
@@ -635,7 +635,7 @@ language_defn::watch_location_expression (struct type *type,
 
 void
 language_defn::value_print (struct value *val, struct ui_file *stream,
-	       const value_print_options *options) const
+	       const value_print_options &options) const
 {
   return c_value_print (val, stream, options);
 }
@@ -653,7 +653,7 @@ language_defn::parser (struct parser_state *ps) const
 void
 language_defn::value_print_inner
 	(struct value *val, struct ui_file *stream, int recurse,
-	 const value_print_options *options) const
+	 const value_print_options &options) const
 {
   return c_value_print_inner (val, stream, recurse, options);
 }
@@ -774,7 +774,7 @@ class unknown_language : public language_defn
   /* See language.h.  */
 
   void value_print (struct value *val, struct ui_file *stream,
-		    const value_print_options *options) const override
+		    const value_print_options &options) const override
   {
     error (_("value printing not implemented for language \"%s\""),
 	   natural_name ());
@@ -784,7 +784,7 @@ class unknown_language : public language_defn
 
   void value_print_inner
 	(struct value *val, struct ui_file *stream, int recurse,
-	 const value_print_options *options) const override
+	 const value_print_options &options) const override
   {
     error (_("inner value printing not implemented for language \"%s\""),
 	   natural_name ());
@@ -812,7 +812,7 @@ class unknown_language : public language_defn
   void printstr (struct ui_file *stream, struct type *elttype,
 		 const gdb_byte *string, unsigned int length,
 		 const char *encoding, int force_ellipses,
-		 const value_print_options *options) const override
+		 const value_print_options &options) const override
   {
     error (_("print string not implemented for language \"%s\""),
 	   natural_name ());
diff --git a/gdb/language.h b/gdb/language.h
index 3330151ed36..9afe5e960c3 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -305,7 +305,7 @@ struct language_defn
   virtual void print_array_index (struct type *index_type,
 				  LONGEST index_value,
 				  struct ui_file *stream,
-				  const value_print_options *options) const;
+				  const value_print_options &options) const;
 
   /* Given a symbol VAR, the corresponding block VAR_BLOCK (if any) and a
      stack frame id FRAME, read the value of the variable and return (pointer
@@ -499,13 +499,13 @@ struct language_defn
 
   /* Print a top-level value using syntax appropriate for this language.  */
   virtual void value_print (struct value *val, struct ui_file *stream,
-			    const value_print_options *options) const;
+			    const value_print_options &options) const;
 
   /* Print a value using syntax appropriate for this language.  RECURSE is
      the recursion depth.  It is zero-based.  */
   virtual void value_print_inner
 	(struct value *val, struct ui_file *stream, int recurse,
-	 const value_print_options *options) const;
+	 const value_print_options &options) const;
 
   /* Parser function.  */
 
@@ -522,7 +522,7 @@ struct language_defn
   virtual void printstr (struct ui_file *stream, struct type *elttype,
 			 const gdb_byte *string, unsigned int length,
 			 const char *encoding, int force_ellipses,
-			 const value_print_options *options) const;
+			 const value_print_options &options) const;
 
 
   /* Print a typedef using syntax appropriate for this language.
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index bbeed776f70..4a5d2124926 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -700,7 +700,7 @@ check_thread_db_callback (const td_thrhandle_t *th, void *arg)
 	{
 	  const value_print_options &opts = get_user_print_options ();
 	  LOG (" = ");
-	  value_print (val, gdb_stdlog, &opts);
+	  value_print (val, gdb_stdlog, opts);
 	}
     }
 
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 0fc84e5d4db..7bee1f36dc8 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -179,7 +179,7 @@ void
 m2_language::printstr (struct ui_file *stream, struct type *elttype,
 			const gdb_byte *string, unsigned int length,
 			const char *encoding, int force_ellipses,
-			const value_print_options *options) const
+			const value_print_options &options) const
 {
   m2_wchar_printer printer (elttype, '"', encoding);
   printer.print (stream, string, length, force_ellipses, 0, options);
diff --git a/gdb/m2-lang.h b/gdb/m2-lang.h
index cf082a07e9b..f1640e0301b 100644
--- a/gdb/m2-lang.h
+++ b/gdb/m2-lang.h
@@ -84,7 +84,7 @@ class m2_language : public language_defn
 
   void value_print_inner (struct value *val, struct ui_file *stream,
 			  int recurse,
-			  const value_print_options *options) const override;
+			  const value_print_options &options) const override;
 
   /* See language.h.  */
 
@@ -100,7 +100,7 @@ class m2_language : public language_defn
   void printstr (struct ui_file *stream, struct type *elttype,
 		 const gdb_byte *string, unsigned int length,
 		 const char *encoding, int force_ellipses,
-		 const value_print_options *options) const override;
+		 const value_print_options &options) const override;
 
   /* See language.h.  */
 
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index 6bad4c95c08..85266999a54 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -31,12 +31,12 @@
 
 static int print_unpacked_pointer (struct type *type,
 				   CORE_ADDR address, CORE_ADDR addr,
-				   const value_print_options *options,
+				   const value_print_options &options,
 				   struct ui_file *stream);
 static void
 m2_print_array_contents (struct value *val,
 			 struct ui_file *stream, int recurse,
-			 const value_print_options *options,
+			 const value_print_options &options,
 			 int len);
 
 
@@ -157,7 +157,7 @@ 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 value_print_options *options)
+			  const value_print_options &options)
 {
   CORE_ADDR addr;
   LONGEST len;
@@ -182,7 +182,7 @@ m2_print_unbounded_array (struct value *value,
 static int
 print_unpacked_pointer (struct type *type,
 			CORE_ADDR address, CORE_ADDR addr,
-			const value_print_options *options,
+			const value_print_options &options,
 			struct ui_file *stream)
 {
   struct gdbarch *gdbarch = type->arch ();
@@ -197,7 +197,7 @@ print_unpacked_pointer (struct type *type,
       return 0;
     }
 
-  if (options->addressprint && options->format != 's')
+  if (options.addressprint && options.format != 's')
     {
       fputs_styled (paddress (gdbarch, address), address_style.style (),
 		    stream);
@@ -209,7 +209,7 @@ print_unpacked_pointer (struct type *type,
 
   if (elttype->length () == 1
       && elttype->code () == TYPE_CODE_INT
-      && (options->format == 0 || options->format == 's')
+      && (options.format == 0 || options.format == 's')
       && addr != 0)
     {
       if (want_space)
@@ -226,7 +226,7 @@ print_variable_at_address (struct type *type,
 			   const gdb_byte *valaddr,
 			   struct ui_file *stream,
 			   int recurse,
-			   const value_print_options *options)
+			   const value_print_options &options)
 {
   struct gdbarch *gdbarch = type->arch ();
   CORE_ADDR addr = unpack_pointer (type, valaddr);
@@ -257,7 +257,7 @@ print_variable_at_address (struct type *type,
 static void
 m2_print_array_contents (struct value *val,
 			 struct ui_file *stream, int recurse,
-			 const value_print_options *options,
+			 const value_print_options &options,
 			 int len)
 {
   struct type *type = check_typedef (val->type ());
@@ -269,7 +269,7 @@ m2_print_array_contents (struct value *val,
 	  ((type->code () == TYPE_CODE_INT)
 	   || ((current_language->la_language == language_m2)
 	       && (type->code () == TYPE_CODE_CHAR)))
-	  && (options->format == 0 || options->format == 's'))
+	  && (options.format == 0 || options.format == 's'))
 	val_print_string (type, NULL, val->address (), len+1, stream,
 			  options);
       else
@@ -300,7 +300,7 @@ static const struct generic_val_print_decorations m2_decorations =
 void
 m2_language::value_print_inner (struct value *val, struct ui_file *stream,
 				int recurse,
-				const value_print_options *options) const
+				const value_print_options &options) const
 {
   unsigned len;
   struct type *elttype;
@@ -321,11 +321,11 @@ m2_language::value_print_inner (struct value *val, struct ui_file *stream,
 	      ((elttype->code () == TYPE_CODE_INT)
 	       || ((current_language->la_language == language_m2)
 		   && (elttype->code () == TYPE_CODE_CHAR)))
-	      && (options->format == 0 || options->format == 's'))
+	      && (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)
+	      if (options.stop_print_at_null)
 		{
 		  unsigned int print_max_chars = get_print_max_chars (options);
 		  unsigned int temp_len;
@@ -358,7 +358,7 @@ m2_language::value_print_inner (struct value *val, struct ui_file *stream,
     case TYPE_CODE_PTR:
       if (TYPE_CONST (type))
 	print_variable_at_address (type, valaddr, stream, recurse, options);
-      else if (options->format && options->format != 's')
+      else if (options.format && options.format != 's')
 	value_print_scalar_formatted (val, options, 0, stream);
       else
 	{
@@ -368,7 +368,7 @@ m2_language::value_print_inner (struct value *val, struct ui_file *stream,
       break;
 
     case TYPE_CODE_UNION:
-      if (recurse && !options->unionprint)
+      if (recurse && !options.unionprint)
 	{
 	  gdb_printf (stream, "{...}");
 	  break;
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index ce58ab15e7f..87ed3d9dcb4 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -547,7 +547,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
 	      opts.deref_ref = true;
 	      if (arg->sym->is_argument ())
 		opts.raw = fp_opts.print_raw_frame_arguments;
-	      common_val_print (arg->val, &stb, 0, &opts,
+	      common_val_print (arg->val, &stb, 0, opts,
 				language_def (arg->sym->language ()));
 	    }
 	  catch (const gdb_exception_error &except)
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 5e5244619af..750f22a8e46 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1076,7 +1076,7 @@ output_register (const frame_info_ptr &frame, int regnum, int format,
 
   value_print_options opts = get_formatted_print_options (format);
   opts.deref_ref = true;
-  common_val_print (val, &stb, 0, &opts, current_language);
+  common_val_print (val, &stb, 0, opts, current_language);
   uiout->field_stream ("value", stb);
 }
 
@@ -1160,7 +1160,7 @@ mi_cmd_data_evaluate_expression (const char *command, const char *const *argv,
   /* Print the result of the expression evaluation.  */
   value_print_options opts = get_user_print_options ();
   opts.deref_ref = false;
-  common_val_print (val, &stb, 0, &opts, current_language);
+  common_val_print (val, &stb, 0, opts, current_language);
 
   uiout->field_stream ("value", stb);
 }
@@ -1334,7 +1334,7 @@ mi_cmd_data_read_memory (const char *command, const char *const *argv,
 		{
 		  stream.clear ();
 		  print_scalar_formatted (&mbuf[col_byte], word_type,
-					  &print_opts, word_asize, &stream);
+					  print_opts, word_asize, &stream);
 		  uiout->field_stream (NULL, stream);
 		}
 	    }
@@ -2492,7 +2492,7 @@ print_variable_or_computed (const char *expression, enum print_values values)
 	{
 	  value_print_options opts = get_no_prettyformat_print_options ();
 	  opts.deref_ref = true;
-	  common_val_print (val, &stb, 0, &opts, current_language);
+	  common_val_print (val, &stb, 0, opts, current_language);
 	  uiout->field_stream ("value", stb);
 	}
       break;
@@ -2500,7 +2500,7 @@ print_variable_or_computed (const char *expression, enum print_values values)
       {
 	value_print_options opts = get_no_prettyformat_print_options ();
 	opts.deref_ref = true;
-	common_val_print (val, &stb, 0, &opts, current_language);
+	common_val_print (val, &stb, 0, opts, current_language);
 	uiout->field_stream ("value", stb);
       }
       break;
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 6532884f69b..3026f2c1e92 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -6349,7 +6349,7 @@ mips_print_fp_register (struct ui_file *file, const frame_info_ptr &frame,
       value_print_options opts = get_formatted_print_options ('x');
       print_scalar_formatted (raw_buffer.data (),
 			      builtin_type (gdbarch)->builtin_uint32,
-			      &opts, 'w', file);
+			      opts, 'w', file);
 
       gdb_printf (file, " flt: %s", flt_str.c_str ());
 
@@ -6376,7 +6376,7 @@ mips_print_fp_register (struct ui_file *file, const frame_info_ptr &frame,
       value_print_options opts = get_formatted_print_options ('x');
       print_scalar_formatted (raw_buffer.data (),
 			      builtin_type (gdbarch)->builtin_uint64,
-			      &opts, 'g', file);
+			      opts, 'g', file);
 
       gdb_printf (file, " flt: %s", flt_str.c_str ());
       gdb_printf (file, " dbl: %s", dbl_str.c_str ());
@@ -6410,7 +6410,7 @@ mips_print_register (struct ui_file *file, const frame_info_ptr &frame,
     gdb_printf (file, ": ");
 
   value_print_options opts = get_formatted_print_options ('x');
-  value_print_scalar_formatted (val, &opts, 0, file);
+  value_print_scalar_formatted (val, opts, 0, file);
 }
 
 /* Print IEEE exception condition bits in FLAGS.  */
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index b727255ea12..457642e00eb 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -212,7 +212,7 @@ void
 pascal_language::printstr (struct ui_file *stream, struct type *elttype,
 			   const gdb_byte *string, unsigned int length,
 			   const char *encoding, int force_ellipses,
-			   const value_print_options *options) const
+			   const value_print_options &options) const
 {
   pascal_wchar_printer printer (elttype, '\'', encoding);
   printer.print (stream, string, length, force_ellipses, 0, options);
diff --git a/gdb/p-lang.h b/gdb/p-lang.h
index 4c80e1b21c4..89c59e27450 100644
--- a/gdb/p-lang.h
+++ b/gdb/p-lang.h
@@ -95,13 +95,13 @@ class pascal_language : public language_defn
   /* See language.h.  */
 
   void value_print (struct value *val, struct ui_file *stream,
-		    const value_print_options *options) const override;
+		    const value_print_options &options) const override;
 
   /* See language.h.  */
 
   void value_print_inner
 	(struct value *val, struct ui_file *stream, int recurse,
-	 const value_print_options *options) const override;
+	 const value_print_options &options) const override;
 
   /* See language.h.  */
 
@@ -117,7 +117,7 @@ class pascal_language : public language_defn
   void printstr (struct ui_file *stream, struct type *elttype,
 		 const gdb_byte *string, unsigned int length,
 		 const char *encoding, int force_ellipses,
-		 const value_print_options *options) const override;
+		 const value_print_options &options) const override;
 
   /* See language.h.  */
 
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 4f94189b6e6..d647090fcd0 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -44,7 +44,7 @@
 
 static void pascal_object_print_value_fields (struct value *, struct ui_file *,
 					      int,
-					      const value_print_options *,
+					      const value_print_options &,
 					      struct type **, int);
 
 /* Decorations for Pascal.  */
@@ -66,7 +66,7 @@ static const struct generic_val_print_decorations p_decorations =
 void
 pascal_language::value_print_inner (struct value *val,
 				    struct ui_file *stream, int recurse,
-				    const value_print_options *options) const
+				    const value_print_options &options) const
 
 {
   struct type *type = check_typedef (val->type ());
@@ -96,14 +96,14 @@ pascal_language::value_print_inner (struct value *val,
 	    /* 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'
+	    if (options.format == 's'
 		|| ((eltlen == 1 || eltlen == 2 || eltlen == 4)
 		    && elttype->code () == TYPE_CODE_CHAR
-		    && options->format == 0))
+		    && options.format == 0))
 	      {
 		/* If requested, look for the first null char and only print
 		   elements up to it.  */
-		if (options->stop_print_at_null)
+		if (options.stop_print_at_null)
 		  {
 		    unsigned int print_max_chars
 		      = get_print_max_chars (options);
@@ -148,12 +148,12 @@ pascal_language::value_print_inner (struct value *val,
       goto print_unpacked_pointer;
 
     case TYPE_CODE_PTR:
-      if (options->format && options->format != 's')
+      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))
+      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
@@ -177,7 +177,7 @@ pascal_language::value_print_inner (struct value *val,
 	  return;
 	}
 
-      if (options->addressprint && options->format != 's')
+      if (options.addressprint && options.format != 's')
 	{
 	  fputs_styled (paddress (gdbarch, addr), address_style.style (),
 			stream);
@@ -191,7 +191,7 @@ pascal_language::value_print_inner (struct value *val,
 	       || elttype->code () == TYPE_CODE_CHAR))
 	   || ((elttype->length () == 2 || elttype->length () == 4)
 	       && elttype->code () == TYPE_CODE_CHAR))
-	  && (options->format == 0 || options->format == 's')
+	  && (options.format == 0 || options.format == 's')
 	  && addr != 0)
 	{
 	  if (want_space)
@@ -230,7 +230,7 @@ pascal_language::value_print_inner (struct value *val,
 	    = lookup_minimal_symbol_by_pc (vt_address);
 
 	  /* If 'symbol_print' is set, we did the work above.  */
-	  if (!options->symbol_print
+	  if (!options.symbol_print
 	      && (msymbol.minsym != NULL)
 	      && (vt_address == msymbol.value_address ()))
 	    {
@@ -241,7 +241,7 @@ pascal_language::value_print_inner (struct value *val,
 	      gdb_puts (">", stream);
 	      want_space = 1;
 	    }
-	  if (vt_address && options->vtblprint)
+	  if (vt_address && options.vtblprint)
 	    {
 	      struct value *vt_val;
 	      struct symbol *wsym = NULL;
@@ -268,7 +268,7 @@ pascal_language::value_print_inner (struct value *val,
 	      vt_val = value_at (wtype, vt_address);
 	      common_val_print (vt_val, stream, recurse + 1, options,
 				current_language);
-	      if (options->prettyformat)
+	      if (options.prettyformat)
 		{
 		  gdb_printf (stream, "\n");
 		  print_spaces (2 + 2 * recurse, stream);
@@ -294,14 +294,14 @@ pascal_language::value_print_inner (struct value *val,
       break;
 
     case TYPE_CODE_UNION:
-      if (recurse && !options->unionprint)
+      if (recurse && !options.unionprint)
 	{
 	  gdb_printf (stream, "{...}");
 	  break;
 	}
       [[fallthrough]];
     case TYPE_CODE_STRUCT:
-      if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
+      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
@@ -407,10 +407,10 @@ pascal_language::value_print_inner (struct value *val,
 \f
 void
 pascal_language::value_print (struct value *val, struct ui_file *stream,
-			      const value_print_options *options) const
+			      const value_print_options &options) const
 {
   struct type *type = val->type ();
-  value_print_options opts = *options;
+  value_print_options opts = options;
 
   opts.deref_ref = true;
 
@@ -439,7 +439,7 @@ pascal_language::value_print (struct value *val, struct ui_file *stream,
 	  gdb_printf (stream, ") ");
 	}
     }
-  common_val_print (val, stream, 0, &opts, current_language);
+  common_val_print (val, stream, 0, opts, current_language);
 }
 
 
@@ -456,10 +456,10 @@ static struct obstack dont_print_statmem_obstack;
 
 static void pascal_object_print_static_field (struct value *,
 					      struct ui_file *, int,
-					      const value_print_options *);
+					      const value_print_options &);
 
 static void pascal_object_print_value (struct value *, struct ui_file *, int,
-				       const value_print_options *,
+				       const value_print_options &,
 				       struct type **);
 
 /* It was changed to this after 2.4.5.  */
@@ -513,7 +513,7 @@ pascal_object_is_vtbl_member (struct type *type)
 static void
 pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 				  int recurse,
-				  const value_print_options *options,
+				  const value_print_options &options,
 				  struct type **dont_print_vb,
 				  int dont_print_statmem)
 {
@@ -552,14 +552,14 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
       for (i = n_baseclasses; i < len; i++)
 	{
 	  /* If requested, skip printing of static fields.  */
-	  if (!options->pascal_static_field_print
+	  if (!options.pascal_static_field_print
 	      && type->field (i).is_static ())
 	    continue;
 	  if (fields_seen)
 	    gdb_printf (stream, ", ");
 	  else if (n_baseclasses > 0)
 	    {
-	      if (options->prettyformat)
+	      if (options.prettyformat)
 		{
 		  gdb_printf (stream, "\n");
 		  print_spaces (2 + 2 * recurse, stream);
@@ -570,7 +570,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 	    }
 	  fields_seen = 1;
 
-	  if (options->prettyformat)
+	  if (options.prettyformat)
 	    {
 	      gdb_printf (stream, "\n");
 	      print_spaces (2 + 2 * recurse, stream);
@@ -618,12 +618,12 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 		}
 	      else
 		{
-		  value_print_options opts = *options;
+		  value_print_options opts = options;
 
 		  v = value_field_bitfield (type, i, valaddr, 0, val);
 
 		  opts.deref_ref = false;
-		  common_val_print (v, stream, recurse + 1, &opts,
+		  common_val_print (v, stream, recurse + 1, opts,
 				    current_language);
 		}
 	    }
@@ -650,13 +650,13 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 		}
 	      else
 		{
-		  value_print_options opts = *options;
+		  value_print_options opts = options;
 
 		  opts.deref_ref = false;
 
 		  struct value *v = val->primitive_field (0, i,
 							  val->type ());
-		  common_val_print (v, stream, recurse + 1, &opts,
+		  common_val_print (v, stream, recurse + 1, opts,
 				    current_language);
 		}
 	    }
@@ -671,7 +671,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 	  dont_print_statmem_obstack = tmp_obstack;
 	}
 
-      if (options->prettyformat)
+      if (options.prettyformat)
 	{
 	  gdb_printf (stream, "\n");
 	  print_spaces (2 * recurse, stream);
@@ -686,7 +686,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 static void
 pascal_object_print_value (struct value *val, struct ui_file *stream,
 			   int recurse,
-			   const value_print_options *options,
+			   const value_print_options &options,
 			   struct type **dont_print_vb)
 {
   struct type **last_dont_print
@@ -762,7 +762,7 @@ pascal_object_print_value (struct value *val, struct ui_file *stream,
 	    }
 	}
 
-      if (options->prettyformat)
+      if (options.prettyformat)
 	{
 	  gdb_printf (stream, "\n");
 	  print_spaces (2 * recurse, stream);
@@ -813,7 +813,7 @@ static void
 pascal_object_print_static_field (struct value *val,
 				  struct ui_file *stream,
 				  int recurse,
-				  const value_print_options *options)
+				  const value_print_options &options)
 {
   struct type *type = val->type ();
   value_print_options opts;
@@ -855,9 +855,9 @@ pascal_object_print_static_field (struct value *val,
       return;
     }
 
-  opts = *options;
+  opts = options;
   opts.deref_ref = false;
-  common_val_print (val, stream, recurse, &opts, current_language);
+  common_val_print (val, stream, recurse, opts, current_language);
 }
 
 INIT_GDB_FILE (pascal_valprint)
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 64df1030bb0..e103602bde1 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -287,7 +287,7 @@ decode_format (const char **string_ptr, int oformat, int osize)
 
 static void
 print_formatted (struct value *val, int size,
-		 const value_print_options *options,
+		 const value_print_options &options,
 		 struct ui_file *stream)
 {
   struct type *type = check_typedef (val->type ());
@@ -298,7 +298,7 @@ print_formatted (struct value *val, int size,
 
   if (size)
     {
-      switch (options->format)
+      switch (options.format)
 	{
 	case 's':
 	  {
@@ -322,7 +322,7 @@ print_formatted (struct value *val, int size,
 	}
     }
 
-  if (options->format == 0 || options->format == 's'
+  if (options.format == 0 || options.format == 's'
       || type->code () == TYPE_CODE_VOID
       || type->code () == TYPE_CODE_REF
       || type->code () == TYPE_CODE_ARRAY
@@ -363,7 +363,7 @@ float_type_from_length (struct type *type)
 
 void
 print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
-			const value_print_options *options,
+			const value_print_options &options,
 			int size, struct ui_file *stream)
 {
   struct gdbarch *gdbarch = type->arch ();
@@ -371,7 +371,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
   enum bfd_endian byte_order = type_byte_order (type);
 
   /* String printing should go through val_print_scalar_formatted.  */
-  gdb_assert (options->format != 's');
+  gdb_assert (options.format != 's');
 
   /* If the value is a pointer, and pointers and addresses are not the
      same, then at this point, the value's length (in target bytes) is
@@ -382,8 +382,8 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
   /* If we are printing it as unsigned, truncate it in case it is actually
      a negative signed value (e.g. "print/u (short)-1" should print 65535
      (if shorts are 16 bits) instead of 4294967295).  */
-  if (options->format != 'c'
-      && (options->format != 'd' || type->is_unsigned ()))
+  if (options.format != 'c'
+      && (options.format != 'd' || type->is_unsigned ()))
     {
       if (len < type->length () && byte_order == BFD_ENDIAN_BIG)
 	valaddr += type->length () - len;
@@ -398,7 +398,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
       valaddr = &zero;
     }
 
-  if (size != 0 && (options->format == 'x' || options->format == 't'))
+  if (size != 0 && (options.format == 'x' || options.format == 't'))
     {
       /* Truncate to fit.  */
       unsigned newlen;
@@ -432,12 +432,12 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
      here for possible use later.  */
   std::optional<LONGEST> val_long;
   if ((is_fixed_point_type (type)
-       && (options->format == 'o'
-	   || options->format == 'x'
-	   || options->format == 't'
-	   || options->format == 'z'
-	   || options->format == 'd'
-	   || options->format == 'u'))
+       && (options.format == 'o'
+	   || options.format == 'x'
+	   || options.format == 't'
+	   || options.format == 'z'
+	   || options.format == 'd'
+	   || options.format == 'u'))
       || (type->code () == TYPE_CODE_RANGE && type->bounds ()->bias != 0)
       || type->bit_size_differs_p ())
     {
@@ -451,7 +451,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
   /* Printing a non-float type as 'f' will interpret the data as if it were
      of a floating-point type of the same length, if that exists.  Otherwise,
      the data is printed as integer.  */
-  char format = options->format;
+  char format = options.format;
   if (format == 'f' && type->code () != TYPE_CODE_FLT)
     {
       type = float_type_from_length (type);
@@ -493,7 +493,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
       break;
     case 'c':
       {
-	value_print_options opts = *options;
+	value_print_options opts = options;
 
 	if (!val_long.has_value ())
 	  val_long.emplace (unpack_long (type, valaddr));
@@ -504,7 +504,7 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
 	else
 	  type = builtin_type (gdbarch)->builtin_true_char;
 
-	value_print (value_from_longest (type, *val_long), stream, &opts);
+	value_print (value_from_longest (type, *val_long), stream, opts);
       }
       break;
 
@@ -762,11 +762,11 @@ pc_prefix (CORE_ADDR addr)
    Return non-zero if anything was printed; zero otherwise.  */
 
 int
-print_address_demangle (const value_print_options *opts,
+print_address_demangle (const value_print_options &opts,
 			struct gdbarch *gdbarch, CORE_ADDR addr,
 			struct ui_file *stream, int do_demangle)
 {
-  if (opts->addressprint)
+  if (opts.addressprint)
     {
       fputs_styled (paddress (gdbarch, addr), address_style.style (), stream);
       print_address_symbolic (gdbarch, addr, stream, do_demangle, " ");
@@ -926,14 +926,14 @@ integer_is_zero (const gdb_byte *x, int len)
 
 /* Find the start address of a string in which ADDR is included.
    Basically we search for '\0' and return the next address,
-   but if OPTIONS->PRINT_MAX is smaller than the length of a string,
+   but if OPTIONS.PRINT_MAX is smaller than the length of a string,
    we stop searching and return the address to print characters as many as
    PRINT_MAX from the string.  */
 
 static CORE_ADDR
 find_string_backward (struct gdbarch *gdbarch,
 		      CORE_ADDR addr, int count, int char_size,
-		      const value_print_options *options,
+		      const value_print_options &options,
 		      int *strings_counted)
 {
   const int chunk_size = 0x20;
@@ -1124,7 +1124,7 @@ do_examine_next_address (struct format_data fmt)
 	{
 	  next_address = find_string_backward (gdbarch, next_address,
 					       count, val_type->length (),
-					       &opts, &count);
+					       opts, &count);
 	}
       else
 	{
@@ -1209,7 +1209,7 @@ do_examine_next_address (struct format_data fmt)
 	  last_examine_value
 	    = release_value (value_at_lazy (val_type, next_address));
 
-	  print_formatted (last_examine_value.get (), size, &opts, gdb_stdout);
+	  print_formatted (last_examine_value.get (), size, opts, gdb_stdout);
 
 	  /* Display any branch delay slots following the final insn.  */
 	  if (format == 'i' && count == 1)
@@ -1246,13 +1246,13 @@ validate_format (struct format_data fmt, const char *cmdname)
 
 void
 print_command_parse_format (const char **expp, const char *cmdname,
-			    value_print_options *opts)
+			    value_print_options &opts)
 {
   const char *exp = *expp;
 
-  /* opts->raw value might already have been set by 'set print raw-values'
+  /* opts.raw value might already have been set by 'set print raw-values'
      or by using 'print -raw-values'.
-     So, do not set opts->raw to 0, only set it to 1 if /r is given.  */
+     So, do not set opts.raw to 0, only set it to 1 if /r is given.  */
   if (exp && *exp == '/')
     {
       format_data fmt;
@@ -1262,12 +1262,12 @@ print_command_parse_format (const char **expp, const char *cmdname,
       validate_format (fmt, cmdname);
       last_format = fmt.format;
 
-      opts->format = fmt.format;
-      opts->raw = opts->raw || fmt.raw;
+      opts.format = fmt.format;
+      opts.raw = opts.raw || fmt.raw;
     }
   else
     {
-      opts->format = 0;
+      opts.format = 0;
     }
 
   *expp = exp;
@@ -1293,7 +1293,7 @@ print_value (value *val, const value_print_options &opts)
 
   annotate_value_history_value ();
 
-  print_formatted (val, 0, &opts, gdb_stdout);
+  print_formatted (val, 0, opts, gdb_stdout);
   gdb_printf ("\n");
 
   annotate_value_history_end ();
@@ -1331,12 +1331,12 @@ should_validate_memtags (gdbarch *gdbarch, struct value *value)
 /* Helper for parsing arguments for print_command_1.  */
 
 static struct value *
-process_print_command_args (const char *args, value_print_options *print_opts,
+process_print_command_args (const char *args, value_print_options &print_opts,
 			    bool voidprint)
 {
-  *print_opts = get_user_print_options ();
+  print_opts = get_user_print_options ();
   /* Override global settings with explicit options, if any.  */
-  auto group = make_value_print_options_def_group (print_opts);
+  auto group = make_value_print_options_def_group (&print_opts);
   gdb::option::process_options
     (&args, gdb::option::PROCESS_OPTIONS_REQUIRE_DELIMITER, group);
 
@@ -1349,7 +1349,7 @@ process_print_command_args (const char *args, value_print_options *print_opts,
       /* This setting allows large arrays to be printed by limiting the
 	 number of elements that are loaded into GDB's memory; we only
 	 need to load as many array elements as we plan to print.  */
-      scoped_array_length_limiting limit_large_arrays (print_opts->print_max);
+      scoped_array_length_limiting limit_large_arrays (print_opts.print_max);
 
       /* VOIDPRINT is true to indicate that we do want to print a void
 	 value, so invert it for parse_expression.  */
@@ -1372,7 +1372,7 @@ print_command_1 (const char *args, int voidprint)
 {
   value_print_options print_opts;
 
-  struct value *val = process_print_command_args (args, &print_opts, voidprint);
+  struct value *val = process_print_command_args (args, print_opts, voidprint);
 
   if (voidprint || (val && val->type () &&
 		    val->type ()->code () != TYPE_CODE_VOID))
@@ -1483,7 +1483,7 @@ output_command (const char *exp, int from_tty)
      need to load as many array elements as we plan to print.  */
   scoped_array_length_limiting limit_large_arrays (opts.print_max);
 
-  print_formatted (val, fmt.size, &opts, gdb_stdout);
+  print_formatted (val, fmt.size, opts, gdb_stdout);
 
   annotate_value_end ();
 
@@ -2212,7 +2212,7 @@ do_one_display (struct display *d)
 	  struct value *val;
 
 	  val = d->exp->evaluate ();
-	  print_formatted (val, d->format.size, &opts, gdb_stdout);
+	  print_formatted (val, d->format.size, opts, gdb_stdout);
 	}
       catch (const gdb_exception_error &ex)
 	{
@@ -2386,7 +2386,7 @@ print_variable_value (symbol *var, const frame_info_ptr &frame,
       val = read_var_value (var, NULL, frame);
       value_print_options opts = get_user_print_options ();
       opts.deref_ref = true;
-      common_val_print_checked (val, stream, indent, &opts, language);
+      common_val_print_checked (val, stream, indent, opts, language);
     }
   catch (const gdb_exception_error &except)
     {
@@ -2909,7 +2909,7 @@ ui_printf (const char *arg, struct ui_file *stream)
 			     args_ptr);
 		}
 
-	      print_formatted (val_args[i], 0, &print_opts, stream);
+	      print_formatted (val_args[i], 0, print_opts, stream);
 	    }
 	    break;
 	  case literal_piece:
@@ -2991,7 +2991,7 @@ memory_tag_print_tag_command (const char *args, enum memtag_type tag_type)
      then fetch the logical or allocation tag.  */
   value_print_options print_opts;
 
-  struct value *val = process_print_command_args (args, &print_opts, true);
+  struct value *val = process_print_command_args (args, print_opts, true);
   gdbarch *arch = current_inferior ()->arch ();
 
   /* If the address is not in a region memory mapped with a memory tagging
@@ -3012,7 +3012,7 @@ memory_tag_print_tag_command (const char *args, enum memtag_type tag_type)
 		== memtag_type::logical? "Logical" : "Allocation");
 
   struct value *v_tag = process_print_command_args (tag.c_str (),
-						    &print_opts,
+						    print_opts,
 						    true);
   print_opts.output_format = 'x';
   print_value (v_tag, print_opts);
@@ -3046,7 +3046,7 @@ memory_tag_print_allocation_tag_command (const char *args, int from_tty)
 static void
 parse_with_logical_tag_input (const char *args, struct value **val,
 			      gdb::byte_vector &tags,
-			      value_print_options *print_opts)
+			      value_print_options &print_opts)
 {
   /* Fetch the address.  */
   std::string address_string = extract_string_maybe_quoted (&args);
@@ -3085,7 +3085,7 @@ memory_tag_with_logical_tag_command (const char *args, int from_tty)
   gdbarch *arch = current_inferior ()->arch ();
 
   /* Parse the input.  */
-  parse_with_logical_tag_input (args, &val, tags, &print_opts);
+  parse_with_logical_tag_input (args, &val, tags, print_opts);
 
   /* Setting the logical tag is just a local operation that does not touch
      any memory from the target.  Given an input value, we modify the value
@@ -3125,7 +3125,7 @@ parse_set_allocation_tag_input (const char *args, struct value **val,
 
   /* Parse the address into a value.  */
   value_print_options print_opts;
-  *val = process_print_command_args (address_string.c_str (), &print_opts,
+  *val = process_print_command_args (address_string.c_str (), print_opts,
 				     true);
 
   /* Fetch the length.  */
@@ -3203,7 +3203,7 @@ memory_tag_check_command (const char *args, int from_tty)
      pointer, then check its logical tag against the allocation tag.  */
   value_print_options print_opts;
 
-  struct value *val = process_print_command_args (args, &print_opts, true);
+  struct value *val = process_print_command_args (args, print_opts, true);
   gdbarch *arch = current_inferior ()->arch ();
 
   CORE_ADDR addr = value_as_address (val);
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index d095a9779db..2777b944097 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -221,7 +221,7 @@ py_print_type (struct ui_out *out, struct value *val)
 
 static void
 py_print_value (struct ui_out *out, struct value *val,
-		const value_print_options *opts,
+		const value_print_options &opts,
 		int indent,
 		enum ext_lang_frame_args args_type,
 		const struct language_defn *language)
@@ -304,7 +304,7 @@ py_print_single_arg (struct ui_out *out,
 		     const char *sym_name,
 		     struct frame_arg *fa,
 		     struct value *fv,
-		     const value_print_options *opts,
+		     const value_print_options &opts,
 		     enum ext_lang_frame_args args_type,
 		     int print_args_field,
 		     const struct language_defn *language)
@@ -485,7 +485,7 @@ enumerate_args (PyObject *iter,
 	  if (arg.entry_kind != print_entry_values_only)
 	    {
 	      py_print_single_arg (out, NULL, &arg,
-				   NULL, &opts,
+				   NULL, opts,
 				   args_type,
 				   print_args_field,
 				   NULL);
@@ -499,7 +499,7 @@ enumerate_args (PyObject *iter,
 		  out->wrap_hint (4);
 		}
 
-	      py_print_single_arg (out, NULL, &entryarg, NULL, &opts,
+	      py_print_single_arg (out, NULL, &entryarg, NULL, opts,
 				   args_type, print_args_field, NULL);
 	    }
 	}
@@ -507,7 +507,7 @@ enumerate_args (PyObject *iter,
 	{
 	  /* If the object has provided a value, we just print that.  */
 	  if (val != NULL)
-	    py_print_single_arg (out, sym_name.get (), NULL, val, &opts,
+	    py_print_single_arg (out, sym_name.get (), NULL, val, opts,
 				 args_type, print_args_field,
 				 language);
 	}
@@ -605,13 +605,13 @@ enumerate_locals (PyObject *iter,
 	{
 	  int val_indent = (indent + 1) * 4;
 
-	  py_print_value (out, val, &opts, val_indent, args_type,
+	  py_print_value (out, val, opts, val_indent, args_type,
 			  language);
 	}
       else
 	{
 	  if (args_type != NO_VALUES)
-	    py_print_value (out, val, &opts, 0, args_type,
+	    py_print_value (out, val, opts, 0, args_type,
 			    language);
 	}
 
diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c
index e095bc3fb69..e155e1ee2ef 100644
--- a/gdb/python/py-lazy-string.c
+++ b/gdb/python/py-lazy-string.c
@@ -313,7 +313,7 @@ stpy_str (PyObject *self)
     {
       struct type *type = stpy_lazy_string_elt_type (str);
       val_print_string (type, str->encoding, str->address, str->length,
-			&stream, &opts);
+			&stream, opts);
     }
   catch (const gdb_exception &exc)
     {
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 057d6b35aaf..ce6ed699f3e 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -281,7 +281,7 @@ print_stack_unless_memory_error (struct ui_file *stream)
 static enum gdbpy_string_repr_result
 print_string_repr (PyObject *printer, const char *hint,
 		   struct ui_file *stream, int recurse,
-		   const value_print_options *options,
+		   const value_print_options &options,
 		   const struct language_defn *language,
 		   struct gdbarch *gdbarch)
 {
@@ -299,14 +299,14 @@ print_string_repr (PyObject *printer, const char *hint,
 	  long length;
 	  struct type *type;
 	  gdb::unique_xmalloc_ptr<char> encoding;
-	  value_print_options local_opts = *options;
+	  value_print_options local_opts = options;
 
 	  gdbpy_extract_lazy_string (py_str.get (), &addr, &type,
 				     &length, &encoding);
 
 	  local_opts.addressprint = false;
 	  val_print_string (type, encoding.get (), addr, (int) length,
-			    stream, &local_opts);
+			    stream, local_opts);
 	}
       else
 	{
@@ -338,10 +338,10 @@ print_string_repr (PyObject *printer, const char *hint,
     }
   else if (replacement)
     {
-      value_print_options opts = *options;
+      value_print_options opts = options;
 
       opts.addressprint = false;
-      common_val_print (replacement, stream, recurse, &opts, language);
+      common_val_print (replacement, stream, recurse, opts, language);
     }
   else
     {
@@ -358,7 +358,7 @@ print_string_repr (PyObject *printer, const char *hint,
 static void
 print_children (PyObject *printer, const char *hint,
 		struct ui_file *stream, int recurse,
-		const value_print_options *options,
+		const value_print_options &options,
 		const struct language_defn *language,
 		int is_py_none)
 {
@@ -391,17 +391,17 @@ print_children (PyObject *printer, const char *hint,
   /* Use the prettyformat_arrays option if we are printing an array,
      and the pretty option otherwise.  */
   if (is_array)
-    pretty = options->prettyformat_arrays;
+    pretty = options.prettyformat_arrays;
   else
     {
-      if (options->prettyformat == Val_prettyformat)
+      if (options.prettyformat == Val_prettyformat)
 	pretty = 1;
       else
-	pretty = options->prettyformat_structs;
+	pretty = options.prettyformat_structs;
     }
 
   done_flag = 0;
-  for (i = 0; i < options->print_max; ++i)
+  for (i = 0; i < options.print_max; ++i)
     {
       PyObject *py_v;
       const char *name;
@@ -462,7 +462,7 @@ print_children (PyObject *printer, const char *hint,
 
       /* In summary mode, we just want to print "= {...}" if there is
 	 a value.  */
-      if (options->summary)
+      if (options.summary)
 	{
 	  /* This increment tricks the post-loop logic to print what
 	     we want.  */
@@ -489,7 +489,7 @@ print_children (PyObject *printer, const char *hint,
 	{
 	  /* We print the index, not whatever the child method
 	     returned as the name.  */
-	  if (options->print_array_indexes)
+	  if (options.print_array_indexes)
 	    gdb_printf (stream, "[%d] = ", i);
 	}
       else if (! is_map)
@@ -504,13 +504,13 @@ print_children (PyObject *printer, const char *hint,
 	  struct type *type;
 	  long length;
 	  gdb::unique_xmalloc_ptr<char> encoding;
-	  value_print_options local_opts = *options;
+	  value_print_options local_opts = options;
 
 	  gdbpy_extract_lazy_string (py_v, &addr, &type, &length, &encoding);
 
 	  local_opts.addressprint = false;
 	  val_print_string (type, encoding.get (), addr, (int) length, stream,
-			    &local_opts);
+			    local_opts);
 	}
       else if (gdbpy_is_string (py_v))
 	{
@@ -536,12 +536,12 @@ print_children (PyObject *printer, const char *hint,
 	      /* When printing the key of a map we allow one additional
 		 level of depth.  This means the key will print before the
 		 value does.  */
-	      value_print_options opt = *options;
+	      value_print_options opt = options;
 	      if (is_map && i % 2 == 0
 		  && opt.max_depth != -1
 		  && opt.max_depth < INT_MAX)
 		++opt.max_depth;
-	      common_val_print (value, stream, recurse + 1, &opt, language);
+	      common_val_print (value, stream, recurse + 1, opt, language);
 	    }
 	}
 
@@ -573,7 +573,7 @@ enum ext_lang_rc
 gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
 				struct value *value,
 				struct ui_file *stream, int recurse,
-				const value_print_options *options,
+				const value_print_options &options,
 				const struct language_defn *language)
 {
   struct type *type = value->type ();
@@ -611,7 +611,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
     return EXT_LANG_RC_NOP;
 
   scoped_restore set_options = make_scoped_restore (&gdbpy_current_print_options,
-						    options);
+						    &options);
 
   /* If we are printing a map, we want some special formatting.  */
   gdb::unique_xmalloc_ptr<char> hint (gdbpy_get_display_hint (printer.get ()));
@@ -642,10 +642,10 @@ gdbpy_ref<>
 apply_varobj_pretty_printer (PyObject *printer_obj,
 			     struct value **replacement,
 			     struct ui_file *stream,
-			     const value_print_options *opts)
+			     const value_print_options &opts)
 {
   scoped_restore set_options = make_scoped_restore (&gdbpy_current_print_options,
-						    opts);
+						    &opts);
 
   *replacement = NULL;
   gdbpy_ref<> py_str = pretty_print_one_value (printer_obj, replacement);
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index ec682c34ebc..022526b85f4 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -222,7 +222,7 @@ unwind_infopy_str (PyObject *self)
 	  {
 	    try
 	      {
-		value_print (value, &stb, &opts);
+		value_print (value, &stb, opts);
 		stb.puts (")");
 	      }
 	    catch (const gdb_exception &except)
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index a63af395e2c..9d5986d3767 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -789,7 +789,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
   try
     {
       common_val_print (((value_object *) self)->value, &stb, 0,
-			&opts, current_language);
+			opts, current_language);
     }
   catch (const gdb_exception &except)
     {
@@ -1255,7 +1255,7 @@ valpy_str (PyObject *self)
   try
     {
       common_val_print (((value_object *) self)->value, &stb, 0,
-			&opts, current_language);
+			opts, current_language);
     }
   catch (const gdb_exception &except)
     {
diff --git a/gdb/python/py-varobj.c b/gdb/python/py-varobj.c
index b307dd1eb7e..e133c1c252b 100644
--- a/gdb/python/py-varobj.c
+++ b/gdb/python/py-varobj.c
@@ -24,7 +24,7 @@
 struct py_varobj_iter : public varobj_iter
 {
   py_varobj_iter (struct varobj *var, gdbpy_ref<> &&pyiter,
-		  const value_print_options *opts);
+		  const value_print_options &opts);
   ~py_varobj_iter () override;
 
   std::unique_ptr<varobj_item> next () override;
@@ -132,10 +132,10 @@ py_varobj_iter::next ()
    python iterator actually responsible for the iteration.  */
 
 py_varobj_iter::py_varobj_iter (struct varobj *var, gdbpy_ref<> &&pyiter,
-				const value_print_options *opts)
+				const value_print_options &opts)
   : m_var (var),
     m_iter (pyiter.release ()),
-    m_opts (*opts)
+    m_opts (opts)
 {
 }
 
@@ -144,7 +144,7 @@ py_varobj_iter::py_varobj_iter (struct varobj *var, gdbpy_ref<> &&pyiter,
 
 std::unique_ptr<varobj_iter>
 py_varobj_get_iterator (struct varobj *var, PyObject *printer,
-			const value_print_options *opts)
+			const value_print_options &opts)
 {
   gdbpy_enter_varobj enter_py (var);
 
@@ -152,7 +152,7 @@ py_varobj_get_iterator (struct varobj *var, PyObject *printer,
     return NULL;
 
   scoped_restore set_options = make_scoped_restore (&gdbpy_current_print_options,
-						    opts);
+						    &opts);
 
   gdbpy_ref<> children (PyObject_CallMethodObjArgs (printer, gdbpy_children_cst,
 						    NULL));
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index d7acd873f0f..3f9ccaa3132 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -435,7 +435,7 @@ extern enum ext_lang_rc gdbpy_apply_val_pretty_printer
   (const struct extension_language_defn *,
    struct value *value,
    struct ui_file *stream, int recurse,
-   const value_print_options *options,
+   const value_print_options &options,
    const struct language_defn *language);
 extern void gdbpy_load_ptwrite_filter
   (const struct extension_language_defn *extlang,
@@ -968,7 +968,7 @@ int gdbpy_is_value_object (PyObject *obj);
 gdbpy_ref<> apply_varobj_pretty_printer (PyObject *print_obj,
 					 struct value **replacement,
 					 struct ui_file *stream,
-					 const value_print_options *opts);
+					 const value_print_options &opts);
 gdbpy_ref<> gdbpy_get_varobj_pretty_printer (struct value *value);
 gdb::unique_xmalloc_ptr<char> gdbpy_get_display_hint (PyObject *printer);
 PyObject *gdbpy_default_visualizer (PyObject *self, PyObject *args);
@@ -1034,7 +1034,7 @@ struct varobj;
 std::unique_ptr<varobj_iter> py_varobj_get_iterator
      (struct varobj *var,
       PyObject *printer,
-      const value_print_options *opts);
+      const value_print_options &opts);
 
 /* Deleter for Py_buffer unique_ptr specialization.  */
 
diff --git a/gdb/record-full.c b/gdb/record-full.c
index c843236e5fe..63de543b87d 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -2821,7 +2821,7 @@ maintenance_print_record_instruction (const char *args, int from_tty)
 					 entry.get_loc ());
 	      gdb_printf ("Register %s changed: ",
 			  gdbarch_register_name (arch, entry.reg ().num));
-	      value_print (val, gdb_stdout, &opts);
+	      value_print (val, gdb_stdout, opts);
 	      gdb_printf ("\n");
 	      break;
 	    }
@@ -2843,7 +2843,7 @@ maintenance_print_record_instruction (const char *args, int from_tty)
   value *val = value_from_contents (regtype, to_print->pc.get_loc ());
   gdb_printf ("Register %s changed: ",
 	      gdbarch_register_name (arch, to_print->pc.num));
-  value_print (val, gdb_stdout, &opts);
+  value_print (val, gdb_stdout, opts);
   gdb_printf ("\n");
 }
 
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index d98d3f33fed..100a44cddf3 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -1186,7 +1186,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch,
       value_print_options opts = get_user_print_options ();
       opts.deref_ref = true;
 
-      common_val_print (val, file, 0, &opts, current_language);
+      common_val_print (val, file, 0, opts, current_language);
 
       if (print_raw_format)
 	{
@@ -1203,7 +1203,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch,
       /* Print the register in hex.  */
       value_print_options opts = get_formatted_print_options ('x');
       opts.deref_ref = true;
-      common_val_print (val, file, 0, &opts, current_language);
+      common_val_print (val, file, 0, opts, current_language);
 
       if (print_raw_format)
 	{
@@ -1339,7 +1339,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch,
 		  opts = get_user_print_options ();
 		  opts.deref_ref = true;
 		  gdb_printf (file, "\t");
-		  common_val_print (val, file, 0, &opts, current_language);
+		  common_val_print (val, file, 0, opts, current_language);
 		}
 	    }
 	}
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index a4614e9874a..2d453bf22a9 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -461,7 +461,7 @@ void
 rust_language::printstr (struct ui_file *stream, struct type *type,
 			 const gdb_byte *string, unsigned int length,
 			 const char *user_encoding, int force_ellipses,
-			 const value_print_options *options) const
+			 const value_print_options &options) const
 {
   /* Rust always uses UTF-8, but let the caller override this if need
      be.  */
@@ -518,7 +518,7 @@ rust_slice_to_array (struct value *val)
 void
 rust_language::val_print_slice
      (struct value *val, struct ui_file *stream, int recurse,
-      const value_print_options *options) const
+      const value_print_options &options) const
 {
   struct type *orig_type = check_typedef (val->type ());
 
@@ -558,7 +558,7 @@ rust_language::val_print_slice
 void
 rust_language::val_print_struct
 	(struct value *val, struct ui_file *stream, int recurse,
-	 const value_print_options *options) const
+	 const value_print_options &options) const
 {
   int first_field;
   struct type *type = check_typedef (val->type ());
@@ -590,7 +590,7 @@ rust_language::val_print_struct
   else
     gdb_puts ("{", stream);
 
-  opts = *options;
+  opts = options;
   opts.deref_ref = false;
 
   first_field = 1;
@@ -602,7 +602,7 @@ rust_language::val_print_struct
       if (!first_field)
 	gdb_puts (",", stream);
 
-      if (options->prettyformat)
+      if (options.prettyformat)
 	{
 	  gdb_puts ("\n", stream);
 	  print_spaces (2 + 2 * recurse, stream);
@@ -619,11 +619,11 @@ rust_language::val_print_struct
 	  gdb_puts (": ", stream);
 	}
 
-      common_val_print (val->field (i), stream, recurse + 1, &opts,
+      common_val_print (val->field (i), stream, recurse + 1, opts,
 			this);
     }
 
-  if (options->prettyformat)
+  if (options.prettyformat)
     {
       gdb_puts ("\n", stream);
       print_spaces (2 * recurse, stream);
@@ -640,9 +640,9 @@ rust_language::val_print_struct
 void
 rust_language::print_enum (struct value *val, struct ui_file *stream,
 			   int recurse,
-			   const value_print_options *options) const
+			   const value_print_options &options) const
 {
-  value_print_options opts = *options;
+  value_print_options opts = options;
   struct type *type = check_typedef (val->type ());
 
   opts.deref_ref = false;
@@ -699,7 +699,7 @@ rust_language::print_enum (struct value *val, struct ui_file *stream,
 		    styled_string (variable_name_style.style (),
 				   variant_type->field (j).name ()));
 
-      common_val_print (val->field (j), stream, recurse + 1, &opts,
+      common_val_print (val->field (j), stream, recurse + 1, opts,
 			this);
     }
 
@@ -714,9 +714,9 @@ rust_language::print_enum (struct value *val, struct ui_file *stream,
 void
 rust_language::value_print_inner
 	(struct value *val, struct ui_file *stream, int recurse,
-	 const value_print_options *options) const
+	 const value_print_options &options) const
 {
-  value_print_options opts = *options;
+  value_print_options opts = options;
   opts.deref_ref = true;
 
   if (opts.prettyformat == Val_prettyformat_default)
@@ -751,7 +751,7 @@ rust_language::value_print_inner
 	    gdb_puts ("b", stream);
 	    val_print_string (elttype->target_type (), "ASCII", addr,
 			      high_bound - low_bound + 1, stream,
-			      &opts);
+			      opts);
 	    break;
 	  }
       }
@@ -782,7 +782,7 @@ rust_language::value_print_inner
 	gdb_puts ("b", stream);
 	printstr (stream, type->target_type (),
 		  val->contents_for_printing ().data (),
-		  high_bound - low_bound + 1, "ASCII", 0, &opts);
+		  high_bound - low_bound + 1, "ASCII", 0, opts);
       }
       break;
 
@@ -804,20 +804,20 @@ rust_language::value_print_inner
 	 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 (val, stream, recurse, &opts);
+      val_print_struct (val, stream, recurse, opts);
       break;
 
     case TYPE_CODE_STRUCT:
       if (rust_enum_p (type))
-	print_enum (val, stream, recurse, &opts);
+	print_enum (val, stream, recurse, opts);
       else
-	val_print_struct (val, stream, recurse, &opts);
+	val_print_struct (val, stream, recurse, opts);
       break;
 
     default:
     generic_print:
       /* Nothing special yet.  */
-      generic_value_print (val, stream, recurse, &opts, &rust_decorations);
+      generic_value_print (val, stream, recurse, opts, &rust_decorations);
     }
 }
 
@@ -826,9 +826,9 @@ rust_language::value_print_inner
 void
 rust_language::value_print
 	(struct value *val, struct ui_file *stream,
-	 const value_print_options *options) const
+	 const value_print_options &options) const
 {
-  value_print_options opts = *options;
+  value_print_options opts = options;
   opts.deref_ref = true;
 
   struct type *type = check_typedef (val->type ());
@@ -839,7 +839,7 @@ rust_language::value_print
       gdb_printf (stream, ") ");
     }
 
-  return common_val_print (val, stream, 0, &opts, this);
+  return common_val_print (val, stream, 0, opts, this);
 }
 
 \f
diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h
index 8e20d352394..ad8214710ff 100644
--- a/gdb/rust-lang.h
+++ b/gdb/rust-lang.h
@@ -137,12 +137,12 @@ class rust_language : public language_defn
 
   void value_print_inner
 	(struct value *val, struct ui_file *stream, int recurse,
-	 const value_print_options *options) const override;
+	 const value_print_options &options) const override;
 
   /* See language.h.  */
 
   void value_print (struct value *val, struct ui_file *stream,
-		    const value_print_options *options) const override;
+		    const value_print_options &options) const override;
 
   /* See language.h.  */
 
@@ -164,7 +164,7 @@ class rust_language : public language_defn
   void printstr (struct ui_file *stream, struct type *elttype,
 		 const gdb_byte *string, unsigned int length,
 		 const char *encoding, int force_ellipses,
-		 const value_print_options *options) const override;
+		 const value_print_options &options) const override;
 
   /* See language.h.  */
 
@@ -202,20 +202,20 @@ class rust_language : public language_defn
 
   void val_print_slice (struct value *val, struct ui_file *stream,
 			int recurse,
-			const value_print_options *options) const;
+			const value_print_options &options) const;
 
   /* Helper for value_print_inner, arguments are as for that function.
      Prints structs and untagged unions.  */
 
   void val_print_struct (struct value *val, struct ui_file *stream,
 			 int recurse,
-			 const value_print_options *options) const;
+			 const value_print_options &options) const;
 
   /* Helper for value_print_inner, arguments are as for that function.
      Prints discriminated unions (Rust enums).  */
 
   void print_enum (struct value *val, struct ui_file *stream, int recurse,
-		   const value_print_options *options) const;
+		   const value_print_options &options) const;
 };
 
 #endif /* GDB_RUST_LANG_H */
diff --git a/gdb/stack.c b/gdb/stack.c
index 4ebecfc36c3..06494281fdd 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -480,7 +480,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_checked (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/tracepoint.c b/gdb/tracepoint.c
index 18b678afd52..377191e2591 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -540,7 +540,7 @@ decode_agent_options (const char *exp, int *trace_string)
 	  /* Allow an optional decimal number giving an explicit maximum
 	     string length, defaulting it to the "print characters" value;
 	     so "collect/s80 mystr" gets at most 80 bytes of string.  */
-	  *trace_string = get_print_max_chars (&opts);
+	  *trace_string = get_print_max_chars (opts);
 	  exp++;
 	  if (*exp >= '0' && *exp <= '9')
 	    *trace_string = atoi (exp);
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 1873b5d58b3..f7c8f517890 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -409,7 +409,7 @@ val_print_invalid_address (struct ui_file *stream)
 static void
 print_unpacked_pointer (struct type *type, struct type *elttype,
 			CORE_ADDR address, struct ui_file *stream,
-			const value_print_options *options)
+			const value_print_options &options)
 {
   struct gdbarch *gdbarch = type->arch ();
 
@@ -420,9 +420,9 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
       return;
     }
 
-  if (options->symbol_print)
+  if (options.symbol_print)
     print_address_demangle (options, gdbarch, address, stream, demangle);
-  else if (options->addressprint)
+  else if (options.addressprint)
     fputs_styled (paddress (gdbarch, address), address_style.style (),
 		  stream);
 }
@@ -432,7 +432,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
 static void
 generic_val_print_array (struct value *val,
 			 struct ui_file *stream, int recurse,
-			 const value_print_options *options,
+			 const value_print_options &options,
 			 const struct
 			     generic_val_print_decorations *decorations)
 {
@@ -465,7 +465,7 @@ generic_val_print_array (struct value *val,
 static void
 generic_val_print_string (struct value *val,
 			  struct ui_file *stream, int recurse,
-			  const value_print_options *options,
+			  const value_print_options &options,
 			  const struct generic_val_print_decorations
 			    *decorations)
 {
@@ -490,7 +490,7 @@ generic_val_print_string (struct value *val,
 
       /* If requested, look for the first null char and only
 	 print elements up to it.  */
-      if (options->stop_print_at_null)
+      if (options.stop_print_at_null)
 	{
 	  unsigned int print_max_chars = get_print_max_chars (options);
 	  unsigned int temp_len;
@@ -534,10 +534,10 @@ generic_val_print_string (struct value *val,
 
 static void
 generic_value_print_ptr (struct value *val, struct ui_file *stream,
-			 const value_print_options *options)
+			 const value_print_options &options)
 {
 
-  if (options->format && options->format != 's')
+  if (options.format && options.format != 's')
     value_print_scalar_formatted (val, options, 0, stream);
   else
     {
@@ -593,15 +593,15 @@ static void
 generic_val_print_ref (struct type *type,
 		       struct ui_file *stream, int recurse,
 		       struct value *original_value,
-		       const value_print_options *options)
+		       const value_print_options &options)
 {
   struct type *elttype = check_typedef (type->target_type ());
   struct value *deref_val = NULL;
   const bool value_is_synthetic
     = original_value->bits_synthetic_pointer (0, (TARGET_CHAR_BIT
 						  * type->length ()));
-  const bool must_coerce_ref = ((options->addressprint && value_is_synthetic)
-				|| options->deref_ref);
+  const bool must_coerce_ref = ((options.addressprint && value_is_synthetic)
+				|| options.deref_ref);
   const bool type_is_defined = elttype->code () != TYPE_CODE_UNDEF;
   const gdb_byte *valaddr = original_value->contents_for_printing ().data ();
 
@@ -619,13 +619,13 @@ generic_val_print_ref (struct type *type,
      Notice that for references to TYPE_CODE_STRUCT, 'set print object on' will
      cause original_value to be a not_lval instead of an lval_computed,
      which will make value_bits_synthetic_pointer return false.
-     This happens because if options->objectprint is true, c_value_print will
+     This happens because if options.objectprint is true, c_value_print will
      overwrite original_value's contents with the result of coercing
      the reference through value_addr, and then set its type back to
      TYPE_CODE_REF.  In that case we don't have to coerce the reference again;
      we can simply treat it as non-synthetic and move on.  */
 
-  if (options->addressprint)
+  if (options.addressprint)
     {
       const gdb_byte *address = (value_is_synthetic && type_is_defined
 				 ? get_value_addr_contents (deref_val)
@@ -633,11 +633,11 @@ generic_val_print_ref (struct type *type,
 
       print_ref_address (type, address, stream);
 
-      if (options->deref_ref)
+      if (options.deref_ref)
 	gdb_puts (": ", stream);
     }
 
-  if (options->deref_ref)
+  if (options.deref_ref)
     {
       if (type_is_defined)
 	common_val_print (deref_val, stream, recurse, options,
@@ -737,9 +737,9 @@ generic_val_print_enum_1 (struct type *type, LONGEST val,
 static void
 generic_val_print_enum (struct type *type, struct ui_file *stream,
 			struct value *original_value,
-			const value_print_options *options)
+			const value_print_options &options)
 {
-  gdb_assert (!options->format);
+  gdb_assert (!options.format);
 
   const gdb_byte *valaddr = original_value->contents_for_printing ().data ();
 
@@ -754,11 +754,11 @@ static void
 generic_val_print_func (struct type *type, CORE_ADDR address,
 			struct ui_file *stream,
 			struct value *original_value,
-			const value_print_options *options)
+			const value_print_options &options)
 {
   struct gdbarch *gdbarch = type->arch ();
 
-  gdb_assert (!options->format);
+  gdb_assert (!options.format);
 
   /* FIXME, we should consider, at least for ANSI C language,
      eliminating the distinction made between FUNCs and POINTERs to
@@ -775,15 +775,15 @@ generic_val_print_func (struct type *type, CORE_ADDR address,
 static void
 generic_value_print_bool
   (struct value *value, struct ui_file *stream,
-   const value_print_options *options,
+   const value_print_options &options,
    const struct generic_val_print_decorations *decorations)
 {
-  if (options->format || options->output_format)
+  if (options.format || options.output_format)
     {
-      value_print_options opts = *options;
-      opts.format = (options->format ? options->format
-		     : options->output_format);
-      value_print_scalar_formatted (value, &opts, 0, stream);
+      value_print_options opts = options;
+      opts.format = (options.format ? options.format
+		     : options.output_format);
+      value_print_scalar_formatted (value, opts, 0, stream);
     }
   else
     {
@@ -803,28 +803,28 @@ generic_value_print_bool
 
 static void
 generic_value_print_int (struct value *val, struct ui_file *stream,
-			 const value_print_options *options)
+			 const value_print_options &options)
 {
-  value_print_options opts = *options;
+  value_print_options opts = options;
 
-  opts.format = (options->format ? options->format
-		 : options->output_format);
-  value_print_scalar_formatted (val, &opts, 0, stream);
+  opts.format = (options.format ? options.format
+		 : options.output_format);
+  value_print_scalar_formatted (val, opts, 0, stream);
 }
 
 /* generic_value_print helper for TYPE_CODE_CHAR.  */
 
 static void
 generic_value_print_char (struct value *value, struct ui_file *stream,
-			  const value_print_options *options)
+			  const value_print_options &options)
 {
-  if (options->format || options->output_format)
+  if (options.format || options.output_format)
     {
-      value_print_options opts = *options;
+      value_print_options opts = options;
 
-      opts.format = (options->format ? options->format
-		     : options->output_format);
-      value_print_scalar_formatted (value, &opts, 0, stream);
+      opts.format = (options.format ? options.format
+		     : options.output_format);
+      value_print_scalar_formatted (value, opts, 0, stream);
     }
   else
     {
@@ -847,9 +847,9 @@ generic_value_print_char (struct value *value, struct ui_file *stream,
 static void
 generic_val_print_float (struct type *type, struct ui_file *stream,
 			 struct value *original_value,
-			 const value_print_options *options)
+			 const value_print_options &options)
 {
-  gdb_assert (!options->format);
+  gdb_assert (!options.format);
 
   const gdb_byte *valaddr = original_value->contents_for_printing ().data ();
 
@@ -860,9 +860,9 @@ generic_val_print_float (struct type *type, struct ui_file *stream,
 
 static void
 generic_val_print_fixed_point (struct value *val, struct ui_file *stream,
-			       const value_print_options *options)
+			       const value_print_options &options)
 {
-  if (options->format)
+  if (options.format)
     value_print_scalar_formatted (val, options, 0, stream);
   else
     {
@@ -885,7 +885,7 @@ generic_val_print_fixed_point (struct value *val, struct ui_file *stream,
 
 static void
 generic_value_print_complex (struct value *val, struct ui_file *stream,
-			     const value_print_options *options,
+			     const value_print_options &options,
 			     const struct generic_val_print_decorations
 			       *decorations)
 {
@@ -906,10 +906,10 @@ static void
 generic_value_print_memberptr
   (struct value *val, struct ui_file *stream,
    int recurse,
-   const value_print_options *options,
+   const value_print_options &options,
    const struct generic_val_print_decorations *decorations)
 {
-  if (!options->format)
+  if (!options.format)
     {
       /* Member pointers are essentially specific to C++, and so if we
 	 encounter one, we should print it according to C++ rules.  */
@@ -923,7 +923,7 @@ generic_value_print_memberptr
 
 void
 generic_value_print (struct value *val, struct ui_file *stream, int recurse,
-		     const value_print_options *options,
+		     const value_print_options &options,
 		     const struct generic_val_print_decorations *decorations)
 {
   struct type *type = val->type ();
@@ -967,14 +967,14 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
       break;
 
     case TYPE_CODE_ENUM:
-      if (options->format)
+      if (options.format)
 	value_print_scalar_formatted (val, options, 0, stream);
       else
 	generic_val_print_enum (type, stream, val, options);
       break;
 
     case TYPE_CODE_FLAGS:
-      if (options->format)
+      if (options.format)
 	value_print_scalar_formatted (val, options, 0, stream);
       else
 	val_print_type_code_flags (type, val, stream);
@@ -982,7 +982,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
 
     case TYPE_CODE_FUNC:
     case TYPE_CODE_METHOD:
-      if (options->format)
+      if (options.format)
 	value_print_scalar_formatted (val, options, 0, stream);
       else
 	generic_val_print_func (type, val->address (), stream,
@@ -1003,7 +1003,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
 
     case TYPE_CODE_FLT:
     case TYPE_CODE_DECFLOAT:
-      if (options->format)
+      if (options.format)
 	value_print_scalar_formatted (val, options, 0, stream);
       else
 	generic_val_print_float (type, stream, val, options);
@@ -1053,7 +1053,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
 
 void
 common_val_print (struct value *value, struct ui_file *stream, int recurse,
-		  const value_print_options *options,
+		  const value_print_options &options,
 		  const struct language_defn *language)
 {
   if (language->la_language == language_ada)
@@ -1066,7 +1066,7 @@ common_val_print (struct value *value, struct ui_file *stream, int recurse,
   if (value->lazy ())
     value->fetch_lazy ();
 
-  value_print_options local_opts = *options;
+  value_print_options local_opts = options;
   struct type *type = value->type ();
   struct type *real_type = check_typedef (type);
 
@@ -1079,7 +1079,7 @@ common_val_print (struct value *value, struct ui_file *stream, int recurse,
   if (!valprint_check_validity (stream, real_type, 0, value))
     return;
 
-  if (!options->raw)
+  if (!options.raw)
     {
       if (apply_ext_lang_val_pretty_printer (value, stream, recurse, options,
 					     language))
@@ -1098,7 +1098,7 @@ common_val_print (struct value *value, struct ui_file *stream, int recurse,
 
   /* Handle summary mode.  If the value is a scalar, print it;
      otherwise, print an ellipsis.  */
-  if (options->summary && !val_print_scalar_type_p (type))
+  if (options.summary && !val_print_scalar_type_p (type))
     {
       gdb_printf (stream, "...");
       return;
@@ -1111,7 +1111,7 @@ common_val_print (struct value *value, struct ui_file *stream, int recurse,
 
   try
     {
-      language->value_print_inner (value, stream, recurse, &local_opts);
+      language->value_print_inner (value, stream, recurse, local_opts);
     }
   catch (const gdb_exception_error &except)
     {
@@ -1124,10 +1124,10 @@ common_val_print (struct value *value, struct ui_file *stream, int recurse,
 
 bool
 val_print_check_max_depth (struct ui_file *stream, int recurse,
-			   const value_print_options *options,
+			   const value_print_options &options,
 			   const struct language_defn *language)
 {
-  if (options->max_depth > -1 && recurse >= options->max_depth)
+  if (options.max_depth > -1 && recurse >= options.max_depth)
     {
       gdb_assert (language->struct_too_deep_ellipsis () != NULL);
       gdb_puts (language->struct_too_deep_ellipsis (), stream);
@@ -1143,7 +1143,7 @@ val_print_check_max_depth (struct ui_file *stream, int recurse,
 
 static bool
 value_check_printable (struct value *val, struct ui_file *stream,
-		       const value_print_options *options)
+		       const value_print_options &options)
 {
   if (val == 0)
     {
@@ -1154,7 +1154,7 @@ value_check_printable (struct value *val, struct ui_file *stream,
 
   if (val->entirely_optimized_out ())
     {
-      if (options->summary && !val_print_scalar_type_p (val->type ()))
+      if (options.summary && !val_print_scalar_type_p (val->type ()))
 	gdb_printf (stream, "...");
       else
 	val_print_optimized_out (val, stream);
@@ -1163,7 +1163,7 @@ value_check_printable (struct value *val, struct ui_file *stream,
 
   if (val->entirely_unavailable ())
     {
-      if (options->summary && !val_print_scalar_type_p (val->type ()))
+      if (options.summary && !val_print_scalar_type_p (val->type ()))
 	gdb_printf (stream, "...");
       else
 	val_print_unavailable (stream);
@@ -1192,7 +1192,7 @@ value_check_printable (struct value *val, struct ui_file *stream,
 void
 common_val_print_checked (struct value *val, struct ui_file *stream,
 			  int recurse,
-			  const value_print_options *options,
+			  const value_print_options &options,
 			  const struct language_defn *language)
 {
   if (!value_check_printable (val, stream, options))
@@ -1205,14 +1205,14 @@ common_val_print_checked (struct value *val, struct ui_file *stream,
 
 void
 value_print (struct value *val, struct ui_file *stream,
-	     const value_print_options *options)
+	     const value_print_options &options)
 {
   scoped_value_mark free_values;
 
   if (!value_check_printable (val, stream, options))
     return;
 
-  if (!options->raw)
+  if (!options.raw)
     {
       int r
 	= apply_ext_lang_val_pretty_printer (val, stream, 0, options,
@@ -1233,7 +1233,7 @@ extern void ATTRIBUTE_UNUSED debug_val (struct value *val);
 void ATTRIBUTE_UNUSED
 debug_val (struct value *val)
 {
-  value_print (val, gdb_stdlog, &user_print_options);
+  value_print (val, gdb_stdlog, user_print_options);
   gdb_flush (gdb_stdlog);
 }
 
@@ -1291,7 +1291,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
 
 void
 value_print_scalar_formatted (struct value *val,
-			      const value_print_options *options,
+			      const value_print_options &options,
 			      int size,
 			      struct ui_file *stream)
 {
@@ -1302,12 +1302,12 @@ value_print_scalar_formatted (struct value *val,
   /* 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')
+  if (options.format == 's')
     {
-      value_print_options opts = *options;
+      value_print_options opts = options;
       opts.format = 0;
       opts.deref_ref = false;
-      common_val_print (val, stream, 0, &opts, current_language);
+      common_val_print (val, stream, 0, opts, current_language);
       return;
     }
 
@@ -1414,7 +1414,7 @@ print_floating (const gdb_byte *valaddr, struct type *type,
 void
 print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
 		    unsigned len, enum bfd_endian byte_order, bool zero_pad,
-		    const value_print_options *options)
+		    const value_print_options &options)
 {
   const gdb_byte *p;
   unsigned int i;
@@ -1427,7 +1427,7 @@ print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
 
   const int mask = 0x080;
 
-  if (options->nibblesprint)
+  if (options.nibblesprint)
     digit_separator = current_language->get_digit_separator();
 
   if (byte_order == BFD_ENDIAN_BIG)
@@ -1441,7 +1441,7 @@ print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
 
 	  for (i = 0; i < (HOST_CHAR_BIT * sizeof (*p)); i++)
 	    {
-	      if (options->nibblesprint && seen_a_one && i % 4 == 0)
+	      if (options.nibblesprint && seen_a_one && i % 4 == 0)
 		gdb_putc (*digit_separator, stream);
 
 	      if (*p & (mask >> i))
@@ -1451,7 +1451,7 @@ print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
 
 	      if (zero_pad || seen_a_one || b == '1')
 		gdb_putc (b, stream);
-	      else if (options->nibblesprint)
+	      else if (options.nibblesprint)
 		{
 		  if ((0xf0 & (mask >> i) && (*p & 0xf0))
 		      || (0x0f & (mask >> i) && (*p & 0x0f)))
@@ -1471,7 +1471,7 @@ print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
 	{
 	  for (i = 0; i < (HOST_CHAR_BIT * sizeof (*p)); i++)
 	    {
-	      if (options->nibblesprint && seen_a_one && i % 4 == 0)
+	      if (options.nibblesprint && seen_a_one && i % 4 == 0)
 		gdb_putc (*digit_separator, stream);
 
 	      if (*p & (mask >> i))
@@ -1481,7 +1481,7 @@ print_binary_chars (struct ui_file *stream, const gdb_byte *valaddr,
 
 	      if (zero_pad || seen_a_one || b == '1')
 		gdb_putc (b, stream);
-	      else if (options->nibblesprint)
+	      else if (options.nibblesprint)
 		{
 		  if ((0xf0 & (mask >> i) && (*p & 0xf0))
 		      || (0x0f & (mask >> i) && (*p & 0x0f)))
@@ -1916,7 +1916,7 @@ print_hex_chars (struct ui_file *stream, const gdb_byte *valaddr,
    stream STREAM.  */
 
 void
-print_function_pointer_address (const value_print_options *options,
+print_function_pointer_address (const value_print_options &options,
 				struct gdbarch *gdbarch,
 				CORE_ADDR address,
 				struct ui_file *stream)
@@ -1926,7 +1926,7 @@ print_function_pointer_address (const value_print_options *options,
 
   /* If the function pointer is represented by a description, print
      the address of the description.  */
-  if (options->addressprint && func_addr != address)
+  if (options.addressprint && func_addr != address)
     {
       gdb_puts ("@", stream);
       fputs_styled (paddress (gdbarch, address), address_style.style (),
@@ -1943,9 +1943,9 @@ print_function_pointer_address (const value_print_options *options,
 void
 maybe_print_array_index (struct type *index_type, LONGEST index,
 			 struct ui_file *stream,
-			 const value_print_options *options)
+			 const value_print_options &options)
 {
-  if (!options->print_array_indexes)
+  if (!options.print_array_indexes)
     return;
 
   current_language->print_array_index (index_type, index, stream, options);
@@ -1956,7 +1956,7 @@ maybe_print_array_index (struct type *index_type, LONGEST index,
 void
 value_print_array_elements (struct value *val, struct ui_file *stream,
 			    int recurse,
-			    const value_print_options *options,
+			    const value_print_options &options,
 			    unsigned int i)
 {
   unsigned int things_printed = 0;
@@ -2000,13 +2000,13 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
 
   annotate_array_section_begin (i, elttype);
 
-  for (; i < len && things_printed < options->print_max; i++)
+  for (; i < len && things_printed < options.print_max; i++)
     {
       scoped_value_mark free_values;
 
       if (i != 0)
 	{
-	  if (options->prettyformat_arrays)
+	  if (options.prettyformat_arrays)
 	    {
 	      gdb_printf (stream, ",\n");
 	      print_spaces (2 + 2 * recurse, stream);
@@ -2014,7 +2014,7 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
 	  else
 	    gdb_printf (stream, ", ");
 	}
-      else if (options->prettyformat_arrays)
+      else if (options.prettyformat_arrays)
 	{
 	  gdb_printf (stream, "\n");
 	  print_spaces (2 + 2 * recurse, stream);
@@ -2030,7 +2030,7 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
       reps = 1;
       /* Only check for reps if repeat_count_threshold is not set to
 	 UINT_MAX (unlimited).  */
-      if (options->repeat_count_threshold < UINT_MAX)
+      if (options.repeat_count_threshold < UINT_MAX)
 	{
 	  bool unavailable = element->entirely_unavailable ();
 	  bool available = element->entirely_available ();
@@ -2060,7 +2060,7 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
       common_val_print (element, stream, recurse + 1, options,
 			current_language);
 
-      if (reps > options->repeat_count_threshold)
+      if (reps > options.repeat_count_threshold)
 	{
 	  annotate_elt_rep (reps);
 	  gdb_printf (stream, " %p[<repeats %u times>%p]",
@@ -2068,7 +2068,7 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
 	  annotate_elt_rep_end ();
 
 	  i = rep1 - 1;
-	  things_printed += options->repeat_count_threshold;
+	  things_printed += options.repeat_count_threshold;
 	}
       else
 	{
@@ -2079,7 +2079,7 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
   annotate_array_section_end ();
   if (i < len)
     gdb_printf (stream, "...");
-  if (options->prettyformat_arrays)
+  if (options.prettyformat_arrays)
     {
       gdb_printf (stream, "\n");
       print_spaces (2 * recurse, stream);
@@ -2112,7 +2112,7 @@ generic_printstr (struct ui_file *stream, struct type *type,
 		  const gdb_byte *string, unsigned int length,
 		  const char *encoding, int force_ellipses,
 		  int quote_char, int c_style_terminator,
-		  const value_print_options *options)
+		  const value_print_options &options)
 {
   wchar_printer printer (type, quote_char, encoding);
   printer.print (stream, string, length, force_ellipses,
@@ -2131,7 +2131,7 @@ int
 val_print_string (struct type *elttype, const char *encoding,
 		  CORE_ADDR addr, int len,
 		  struct ui_file *stream,
-		  const value_print_options *options)
+		  const value_print_options &options)
 {
   int force_ellipsis = 0;	/* Force ellipsis to be printed if nonzero.  */
   int err;			/* Non-zero if we got a bad read.  */
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 8c4c601b16d..13bfcf98add 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -128,10 +128,10 @@ struct value_print_options
 /* Return the character count limit for printing strings.  */
 
 static inline unsigned int
-get_print_max_chars (const value_print_options *options)
+get_print_max_chars (const value_print_options &options)
 {
-  return (options->print_max_chars != PRINT_MAX_CHARS_ELEMENTS
-	  ? options->print_max_chars : options->print_max);
+  return (options.print_max_chars != PRINT_MAX_CHARS_ELEMENTS
+	  ? options.print_max_chars : options.print_max);
 }
 
 /* Create an option_def_group for the value_print options, with OPTS
@@ -163,13 +163,13 @@ extern value_print_options get_formatted_print_options (char format);
 
 extern void maybe_print_array_index (struct type *index_type, LONGEST index,
 				     struct ui_file *stream,
-				     const value_print_options *);
+				     const value_print_options &);
 
 
 /* Print elements of an array.  */
 
 extern void value_print_array_elements (struct value *, struct ui_file *, int,
-					const value_print_options *,
+					const value_print_options &,
 					unsigned int);
 
 /* Print a scalar according to OPTIONS and SIZE on STREAM.  Format 'i'
@@ -179,12 +179,12 @@ extern void value_print_array_elements (struct value *, struct ui_file *, int,
    with a format.  */
 
 extern void value_print_scalar_formatted
-  (struct value *val, const value_print_options *options,
+  (struct value *val, const value_print_options &options,
    int size, struct ui_file *stream);
 
 extern void print_binary_chars (struct ui_file *, const gdb_byte *,
 				unsigned int, enum bfd_endian, bool,
-				const value_print_options *options);
+				const value_print_options &options);
 
 extern void print_octal_chars (struct ui_file *, const gdb_byte *,
 			       unsigned int, enum bfd_endian);
@@ -195,7 +195,7 @@ extern void print_decimal_chars (struct ui_file *, const gdb_byte *,
 extern void print_hex_chars (struct ui_file *, const gdb_byte *,
 			     unsigned int, enum bfd_endian, bool);
 
-extern void print_function_pointer_address (const value_print_options *options,
+extern void print_function_pointer_address (const value_print_options &options,
 					    struct gdbarch *gdbarch,
 					    CORE_ADDR address,
 					    struct ui_file *stream);
@@ -259,7 +259,7 @@ struct generic_val_print_decorations
 
 extern void generic_value_print (struct value *val, struct ui_file *stream,
 				 int recurse,
-				 const value_print_options *options,
+				 const 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,
@@ -269,7 +269,7 @@ extern void generic_printstr (struct ui_file *stream, struct type *type,
 			      const gdb_byte *string, unsigned int length,
 			      const char *encoding, int force_ellipses,
 			      int quote_char, int c_style_terminator,
-			      const value_print_options *options);
+			      const value_print_options &options);
 
 /* Run the "output" command.  ARGS and FROM_TTY are the usual
    arguments passed to all command implementations, except ARGS is
@@ -296,7 +296,7 @@ struct format_data
   };
 
 extern void print_command_parse_format (const char **expp, const char *cmdname,
-					value_print_options *opts);
+					value_print_options &opts);
 
 /* Print VAL to console according to OPTS, including recording it to
    the history.  */
@@ -335,7 +335,7 @@ extern int build_address_symbolic (struct gdbarch *,
    LANGUAGE determines what type of ellipsis expression is printed.  */
 
 extern bool val_print_check_max_depth (struct ui_file *stream, int recurse,
-				       const value_print_options *opts,
+				       const value_print_options &opts,
 				       const struct language_defn *language);
 
 /* Like common_val_print, but call value_check_printable first.  */
@@ -343,7 +343,7 @@ extern bool val_print_check_max_depth (struct ui_file *stream, int recurse,
 extern void common_val_print_checked
   (struct value *val,
    struct ui_file *stream, int recurse,
-   const value_print_options *options,
+   const value_print_options &options,
    const struct language_defn *language);
 
 #endif /* GDB_VALPRINT_H */
diff --git a/gdb/value.c b/gdb/value.c
index e9c22cbc9da..34207cb1956 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1787,7 +1787,7 @@ show_values (const char *num_exp, int from_tty)
       val = access_value_history (i);
       gdb_printf (("$%d = "), i);
       const value_print_options &opts = get_user_print_options ();
-      value_print (val, gdb_stdout, &opts);
+      value_print (val, gdb_stdout, opts);
       gdb_printf (("\n"));
     }
 
@@ -2577,7 +2577,7 @@ show_convenience (const char *ignore, int from_tty)
 	  struct value *val;
 
 	  val = value_of_internalvar (gdbarch, &var);
-	  value_print (val, gdb_stdout, &opts);
+	  value_print (val, gdb_stdout, opts);
 	}
       catch (const gdb_exception_error &ex)
 	{
diff --git a/gdb/value.h b/gdb/value.h
index 3651a089fd2..d4746449e70 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -1051,7 +1051,7 @@ struct value *value_vector_widen (struct value *scalar_value,
 class frame_info_ptr;
 struct fn_field;
 
-extern int print_address_demangle (const value_print_options *,
+extern int print_address_demangle (const value_print_options &,
 				   struct gdbarch *, CORE_ADDR,
 				   struct ui_file *, int);
 
@@ -1557,7 +1557,7 @@ extern void print_floating (const gdb_byte *valaddr, struct type *type,
 			    struct ui_file *stream);
 
 extern void value_print (struct value *val, struct ui_file *stream,
-			 const value_print_options *options);
+			 const value_print_options &options);
 
 /* Release values from the value chain and return them.  Values
    created after MARK are released.  If MARK is nullptr, or if MARK is
@@ -1570,13 +1570,13 @@ extern std::vector<value_ref_ptr> value_release_to_mark
 
 extern void common_val_print (struct value *val,
 			      struct ui_file *stream, int recurse,
-			      const value_print_options *options,
+			      const value_print_options &options,
 			      const struct language_defn *language);
 
 extern int val_print_string (struct type *elttype, const char *encoding,
 			     CORE_ADDR addr, int len,
 			     struct ui_file *stream,
-			     const value_print_options *options);
+			     const value_print_options &options);
 
 /* Print the value in stack frame FRAME of a variable specified by a
    struct symbol.  STREAM is the ui_file on which to print the value.
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 14eae8d920f..389e96c4735 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -643,7 +643,7 @@ varobj_get_iterator (struct varobj *var)
   if (var->dynamic->pretty_printer)
     {
       value_print_options opts = varobj_formatted_print_options (var->format);
-      return py_varobj_get_iterator (var, var->dynamic->pretty_printer, &opts);
+      return py_varobj_get_iterator (var, var->dynamic->pretty_printer, opts);
     }
 #endif
 
@@ -2145,7 +2145,7 @@ varobj_value_get_print_value (struct value *value,
 	      gdbpy_ref<> output = apply_varobj_pretty_printer (value_formatter,
 								&replacement,
 								&stb,
-								&opts);
+								opts);
 
 	      /* If we have string like output ...  */
 	      if (output != nullptr && output != Py_None)
@@ -2220,14 +2220,14 @@ varobj_value_get_print_value (struct value *value,
   /* If the THEVALUE has contents, it is a regular string.  */
   if (!thevalue.empty ())
     current_language->printstr (&stb, type, (gdb_byte *) thevalue.c_str (),
-				len, encoding.get (), 0, &opts);
+				len, encoding.get (), 0, opts);
   else if (string_print)
     /* Otherwise, if string_print is set, and it is not a regular
        string, it is a lazy string.  */
-    val_print_string (type, encoding.get (), str_addr, len, &stb, &opts);
+    val_print_string (type, encoding.get (), str_addr, len, &stb, opts);
   else
     /* All other cases.  */
-    common_val_print (value, &stb, 0, &opts, current_language);
+    common_val_print (value, &stb, 0, opts, current_language);
 
   return stb.release ();
 }

-- 
2.49.0


      parent reply	other threads:[~2026-07-04 22:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-04 22:05 [PATCH 0/9] Some cleanups and C++-ification of value_print_options Tom Tromey
2026-07-04 22:05 ` [PATCH 1/9] Return value_print_options from get_formatted_print_options Tom Tromey
2026-07-04 22:05 ` [PATCH 2/9] Return value_print_options from get_no_prettyformat_print_options Tom Tromey
2026-07-04 22:05 ` [PATCH 3/9] Convert get_user_print_options Tom Tromey
2026-07-04 22:05 ` [PATCH 4/9] Return a const reference from gdbpy_get_print_options Tom Tromey
2026-07-04 22:05 ` [PATCH 5/9] Return value_print_options from varobj_formatted_print_options Tom Tromey
2026-07-04 22:05 ` [PATCH 6/9] Use 'const' with some value_print_options Tom Tromey
2026-07-04 22:05 ` [PATCH 7/9] Don't use 'struct' keyword with value_print_options Tom Tromey
2026-07-04 22:05 ` [PATCH 8/9] Use std::forward in fortran_array_walker Tom Tromey
2026-07-04 22:05 ` Tom Tromey [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260704-print-opts-cleanup-v1-9-fb54a5112a8d@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox