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 2/9] Return value_print_options from get_no_prettyformat_print_options
Date: Sat, 04 Jul 2026 16:05:16 -0600	[thread overview]
Message-ID: <20260704-print-opts-cleanup-v1-2-fb54a5112a8d@tromey.com> (raw)
In-Reply-To: <20260704-print-opts-cleanup-v1-0-fb54a5112a8d@tromey.com>

This changes get_no_prettyformat_print_options to return the
value_print_options object.
---
 gdb/cli/cli-cmds.c    |  3 +--
 gdb/cp-valprint.c     |  3 +--
 gdb/mi/mi-cmd-stack.c |  4 +---
 gdb/mi/mi-main.c      |  8 ++------
 gdb/stack.c           |  4 ++--
 gdb/valprint.c        | 13 +++++++------
 gdb/valprint.h        |  6 +++---
 7 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index f5c85dfc352..3aa5f0038a9 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -2702,8 +2702,7 @@ shell_internal_fn (struct gdbarch *gdbarch,
   if (!language->is_string_type_p (type))
     error (_("Argument must be a string."));
 
-  value_print_options opts;
-  get_no_prettyformat_print_options (&opts);
+  value_print_options opts = get_no_prettyformat_print_options ();
 
   string_file stream;
   value_print (val, &stream, &opts);
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 349a0d6bf9e..0558cad87c0 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -779,8 +779,7 @@ test_print_fields (gdbarch *arch)
 			  gdbarch_byte_order (arch), 0xe9);
 
   string_file out;
-  struct value_print_options opts;
-  get_no_prettyformat_print_options (&opts);
+  value_print_options opts = get_no_prettyformat_print_options ();
   cp_print_value_fields(val, &out, 0, &opts, NULL, 0);
   SELF_CHECK (out.string () == "{A = false, B = 5, C = true}");
 
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 280a08d121e..ce58ab15e7f 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -543,9 +543,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
 	{
 	  try
 	    {
-	      struct value_print_options opts;
-
-	      get_no_prettyformat_print_options (&opts);
+	      value_print_options opts = get_no_prettyformat_print_options ();
 	      opts.deref_ref = true;
 	      if (arg->sym->is_argument ())
 		opts.raw = fp_opts.print_raw_frame_arguments;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 200d29309ba..b1c42ddfd24 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2491,9 +2491,7 @@ print_variable_or_computed (const char *expression, enum print_values values)
       uiout->field_stream ("type", stb);
       if (mi_simple_type_p (val->type ()))
 	{
-	  struct value_print_options opts;
-
-	  get_no_prettyformat_print_options (&opts);
+	  value_print_options opts = get_no_prettyformat_print_options ();
 	  opts.deref_ref = true;
 	  common_val_print (val, &stb, 0, &opts, current_language);
 	  uiout->field_stream ("value", stb);
@@ -2501,9 +2499,7 @@ print_variable_or_computed (const char *expression, enum print_values values)
       break;
     case PRINT_ALL_VALUES:
       {
-	struct value_print_options opts;
-
-	get_no_prettyformat_print_options (&opts);
+	value_print_options opts = get_no_prettyformat_print_options ();
 	opts.deref_ref = true;
 	common_val_print (val, &stb, 0, &opts, current_language);
 	uiout->field_stream ("value", stb);
diff --git a/gdb/stack.c b/gdb/stack.c
index e084976eabf..5d725803c1e 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -455,7 +455,6 @@ print_frame_arg (const frame_print_options &fp_opts,
 	  try
 	    {
 	      const struct language_defn *language;
-	      struct value_print_options vp_opts;
 
 	      /* Avoid value_print because it will deref ref parameters.  We
 		 just want to print their addresses.  Print ??? for args whose
@@ -472,7 +471,8 @@ print_frame_arg (const frame_print_options &fp_opts,
 	      else
 		language = current_language;
 
-	      get_no_prettyformat_print_options (&vp_opts);
+	      value_print_options vp_opts
+		= get_no_prettyformat_print_options ();
 	      vp_opts.deref_ref = true;
 	      vp_opts.raw = fp_opts.print_raw_frame_arguments;
 
diff --git a/gdb/valprint.c b/gdb/valprint.c
index cf2bc8e135c..0c385f6ad52 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -104,13 +104,14 @@ get_user_print_options (struct value_print_options *opts)
   *opts = user_print_options;
 }
 
-/* Initialize *OPTS to be a copy of the user print options, but with
-   pretty-formatting disabled.  */
-void
-get_no_prettyformat_print_options (struct value_print_options *opts)
+/* See valprint.h.  */
+
+value_print_options
+get_no_prettyformat_print_options ()
 {
-  *opts = user_print_options;
-  opts->prettyformat = Val_no_prettyformat;
+  value_print_options opts = user_print_options;
+  opts.prettyformat = Val_no_prettyformat;
+  return opts;
 }
 
 /* See valprint.h.  */
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 775ff333646..b38af46f344 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -147,9 +147,9 @@ extern struct value_print_options user_print_options;
 /* Initialize *OPTS to be a copy of the user print options.  */
 extern void get_user_print_options (struct value_print_options *opts);
 
-/* Initialize *OPTS to be a copy of the user print options, but with
-   pretty-formatting disabled.  */
-extern void get_no_prettyformat_print_options (struct value_print_options *);
+/* Return a copy of the user print options, but with pretty-formatting
+   disabled.  */
+extern value_print_options get_no_prettyformat_print_options ();
 
 /* Return a copy of the user print options, but using FORMAT as the
    formatting option.  */

-- 
2.49.0


  parent reply	other threads:[~2026-07-04 22:06 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 ` Tom Tromey [this message]
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 ` [PATCH 9/9] Use references for value_print_options Tom Tromey

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-2-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