aboutsummaryrefslogtreecommitdiff
path: root/gdb/doc
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-04-22 15:13:09 -0600
committerTom Tromey <tom@tromey.com>2018-05-31 15:00:40 -0600
commit7729052b5377bfbf1c5ec5eaab59dd5071d4c5b1 (patch)
tree750e865b7e765e41e28c93214bcbdd1f98f8ce75 /gdb/doc
parent8a60efe714e636c9f958058a8dfb12de81bdcbfa (diff)
downloadgdb-7729052b5377bfbf1c5ec5eaab59dd5071d4c5b1.zip
gdb-7729052b5377bfbf1c5ec5eaab59dd5071d4c5b1.tar.gz
gdb-7729052b5377bfbf1c5ec5eaab59dd5071d4c5b1.tar.bz2
Add basic Python API for convenience variables
This adds a basic Python API for accessing convenience variables. With this, convenience variables can be read and set from Python. Although gdb supports convenience variables whose value changes at each call, this is not exposed to Python; it could be, but I think it's just as good to write a convenience function in this situation. This is PR python/23080. Tested on x86-64 Fedora 26. 2018-04-22 Tom Tromey <tom@tromey.com> PR python/23080: * NEWS: Update for new functions. * python/py-value.c (gdbpy_set_convenience_variable) (gdbpy_convenience_variable): New functions. * python/python-internal.h (gdbpy_convenience_variable) (gdbpy_set_convenience_variable): Declare. * python/python.c (python_GdbMethods): Add convenience_variable, set_convenience_variable. doc/ChangeLog 2018-04-22 Tom Tromey <tom@tromey.com> PR python/23080: * python.texi (Basic Python): Document gdb.convenience_variable, gdb.set_convenience_variable. testsuite/ChangeLog 2018-04-22 Tom Tromey <tom@tromey.com> PR python/23080: * gdb.python/python.exp: Add convenience variable tests.
Diffstat (limited to 'gdb/doc')
-rw-r--r--gdb/doc/python.texi23
1 files changed, 21 insertions, 2 deletions
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 4182b60..60e016a 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -288,6 +288,26 @@ If no exception is raised, the return value is always an instance of
@code{gdb.Value} (@pxref{Values From Inferior}).
@end defun
+@findex gdb.convenience_variable
+@defun gdb.convenience_variable (name)
+Return the value of the convenience variable (@pxref{Convenience
+Vars}) named @var{name}. @var{name} must be a string. The name
+should not include the @samp{$} that is used to mark a convenience
+variable in an expression. If the convenience variable does not
+exist, then @code{None} is returned.
+@end defun
+
+@findex gdb.set_convenience_variable
+@defun gdb.set_convenience_variable (name, value)
+Set the value of the convenience variable (@pxref{Convenience Vars})
+named @var{name}. @var{name} must be a string. The name should not
+include the @samp{$} that is used to mark a convenience variable in an
+expression. If @var{value} is @code{None}, then the convenience
+variable is removed. Otherwise, if @var{value} is not a
+@code{gdb.Value} (@pxref{Values From Inferior}), it is is converted
+using the @code{gdb.Value} constructor.
+@end defun
+
@findex gdb.parse_and_eval
@defun gdb.parse_and_eval (expression)
Parse @var{expression}, which must be a string, as an expression in
@@ -297,8 +317,7 @@ the current language, evaluate it, and return the result as a
This function can be useful when implementing a new command
(@pxref{Commands In Python}), as it provides a way to parse the
command's argument as an expression. It is also useful simply to
-compute values, for example, it is the only way to get the value of a
-convenience variable (@pxref{Convenience Vars}) as a @code{gdb.Value}.
+compute values.
@end defun
@findex gdb.find_pc_line