From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 5/9] Return value_print_options from varobj_formatted_print_options
Date: Sat, 04 Jul 2026 16:05:19 -0600 [thread overview]
Message-ID: <20260704-print-opts-cleanup-v1-5-fb54a5112a8d@tromey.com> (raw)
In-Reply-To: <20260704-print-opts-cleanup-v1-0-fb54a5112a8d@tromey.com>
This changes varobj_formatted_print_options to return the
value_print_options object.
---
gdb/ada-varobj.c | 5 +----
gdb/varobj.c | 19 +++++++++----------
gdb/varobj.h | 4 ++--
3 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c
index d526d4c1857..6d4cf166b87 100644
--- a/gdb/ada-varobj.c
+++ b/gdb/ada-varobj.c
@@ -922,10 +922,7 @@ static std::string
ada_value_of_variable (const struct varobj *var,
enum varobj_display_formats format)
{
- struct value_print_options opts;
-
- varobj_formatted_print_options (&opts, format);
-
+ value_print_options opts = varobj_formatted_print_options (format);
return ada_varobj_get_value_of_variable (var->value.get (), var->type,
&opts);
}
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 92a1f5ae578..14eae8d920f 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -642,8 +642,7 @@ varobj_get_iterator (struct varobj *var)
#if HAVE_PYTHON
if (var->dynamic->pretty_printer)
{
- value_print_options opts;
- varobj_formatted_print_options (&opts, var->format);
+ value_print_options opts = varobj_formatted_print_options (var->format);
return py_varobj_get_iterator (var, var->dynamic->pretty_printer, &opts);
}
#endif
@@ -2100,13 +2099,14 @@ my_value_of_variable (struct varobj *var, enum varobj_display_formats format)
return std::string ();
}
-void
-varobj_formatted_print_options (struct value_print_options *opts,
- enum varobj_display_formats format)
+value_print_options
+varobj_formatted_print_options (enum varobj_display_formats format)
{
- *opts = get_formatted_print_options (format_code[(int) format]);
- opts->deref_ref = false;
- opts->raw = !pretty_printing;
+ value_print_options opts
+ = get_formatted_print_options (format_code[(int) format]);
+ opts.deref_ref = false;
+ opts.raw = !pretty_printing;
+ return opts;
}
std::string
@@ -2114,7 +2114,6 @@ varobj_value_get_print_value (struct value *value,
enum varobj_display_formats format,
const struct varobj *var)
{
- struct value_print_options opts;
struct type *type = NULL;
long len = 0;
gdb::unique_xmalloc_ptr<char> encoding;
@@ -2128,7 +2127,7 @@ varobj_value_get_print_value (struct value *value,
string_file stb;
std::string thevalue;
- varobj_formatted_print_options (&opts, format);
+ value_print_options opts = varobj_formatted_print_options (format);
#if HAVE_PYTHON
if (gdb_python_initialized)
diff --git a/gdb/varobj.h b/gdb/varobj.h
index 1fab22d1c9e..57161a31c66 100644
--- a/gdb/varobj.h
+++ b/gdb/varobj.h
@@ -347,8 +347,8 @@ extern std::string
enum varobj_display_formats format,
const struct varobj *var);
-extern void varobj_formatted_print_options (struct value_print_options *opts,
- enum varobj_display_formats format);
+extern value_print_options
+ varobj_formatted_print_options (enum varobj_display_formats format);
extern void varobj_restrict_range (const std::vector<varobj *> &children,
int *from, int *to);
--
2.49.0
next prev 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 ` Tom Tromey [this message]
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-5-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