aboutsummaryrefslogtreecommitdiff
path: root/gdb/doc
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/doc
parentaa63b0a77e193b5181390f19465f33c314d0490e (diff)
downloadgdb-c4a3dbaf1132105586586617a59d0e7566eefd41.zip
gdb-c4a3dbaf1132105586586617a59d0e7566eefd41.tar.gz
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/doc')
-rw-r--r--gdb/doc/python.texi18
1 files changed, 18 insertions, 0 deletions
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 19ae330..4573ba67 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -1742,6 +1742,24 @@ pretty-printer for this value exists, then it is returned. If no such
printer exists, then this returns @code{None}.
@end defun
+Normally, a pretty-printer can respect the user's print settings
+(including temporarily applied settings, such as @samp{/x}) simply by
+calling @code{Value.format_string} (@pxref{Values From Inferior}).
+However, these settings can also be queried directly:
+
+@findex gdb.print_options
+@defun gdb.print_options ()
+Return a dictionary whose keys are the valid keywords that can be
+given to @code{Value.format_string}, and whose values are the user's
+settings. During a @code{print} or other operation, the values will
+reflect any flags that are temporarily in effect.
+
+@smallexample
+(gdb) python print (gdb.print_options ()['max_elements'])
+200
+@end smallexample
+@end defun
+
@node Selecting Pretty-Printers
@subsubsection Selecting Pretty-Printers
@cindex selecting python pretty-printers