aboutsummaryrefslogtreecommitdiff
path: root/gdb/varobj.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-06-06 09:54:45 -0600
committerTom Tromey <tromey@adacore.com>2022-07-15 09:25:33 -0600
commitc4a3dbaf1132105586586617a59d0e7566eefd41 (patch)
tree60fdbcc109b1a55a76ce8070f6b4b7c81dc6c38f /gdb/varobj.c
parentaa63b0a77e193b5181390f19465f33c314d0490e (diff)
downloadfsf-binutils-gdb-c4a3dbaf1132105586586617a59d0e7566eefd41.zip
fsf-binutils-gdb-c4a3dbaf1132105586586617a59d0e7566eefd41.tar.gz
fsf-binutils-gdb-c4a3dbaf1132105586586617a59d0e7566eefd41.tar.bz2
Expose current 'print' settings to Python
PR python/17291 asks for access to the current print options. While I think this need is largely satisfied by the existence of Value.format_string, it seemed to me that a bit more could be done. First, while Value.format_string uses the user's settings, it does not react to temporary settings such as "print/x". This patch changes this. Second, there is no good way to examine the current settings (in particular the temporary ones in effect for just a single "print"). This patch adds this as well. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17291
Diffstat (limited to 'gdb/varobj.c')
-rw-r--r--gdb/varobj.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 1aca015..9a6d579 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -658,7 +658,11 @@ varobj_get_iterator (struct varobj *var)
{
#if HAVE_PYTHON
if (var->dynamic->pretty_printer)
- return py_varobj_get_iterator (var, var->dynamic->pretty_printer);
+ {
+ value_print_options opts;
+ varobj_formatted_print_options (&opts, var->format);
+ return py_varobj_get_iterator (var, var->dynamic->pretty_printer, &opts);
+ }
#endif
gdb_assert_not_reached ("requested an iterator from a non-dynamic varobj");
@@ -2146,6 +2150,8 @@ varobj_value_get_print_value (struct value *value,
string_file stb;
std::string thevalue;
+ varobj_formatted_print_options (&opts, format);
+
#if HAVE_PYTHON
if (gdb_python_initialized)
{
@@ -2166,7 +2172,8 @@ varobj_value_get_print_value (struct value *value,
gdbpy_ref<> output = apply_varobj_pretty_printer (value_formatter,
&replacement,
- &stb);
+ &stb,
+ &opts);
/* If we have string like output ... */
if (output != NULL)
@@ -2225,8 +2232,6 @@ varobj_value_get_print_value (struct value *value,
}
#endif
- varobj_formatted_print_options (&opts, format);
-
/* If the THEVALUE has contents, it is a regular string. */
if (!thevalue.empty ())
current_language->printstr (&stb, type, (gdb_byte *) thevalue.c_str (),