diff options
author | Siva Chandra <sivachandra@chromium.org> | 2013-12-02 06:45:09 -0800 |
---|---|---|
committer | Siva Chandra <sivachandra@chromium.org> | 2014-02-19 15:47:45 -0800 |
commit | f7bd0f7854f2fd0dfeddafd073b007d91bea79e8 (patch) | |
tree | 38d3ca9d46e619b3f4a371a0b50158563a3af60d /gdb/doc | |
parent | 649ebbcaef0f8e58146e62be0d3f22da5f82446c (diff) | |
download | gdb-f7bd0f7854f2fd0dfeddafd073b007d91bea79e8.zip gdb-f7bd0f7854f2fd0dfeddafd073b007d91bea79e8.tar.gz gdb-f7bd0f7854f2fd0dfeddafd073b007d91bea79e8.tar.bz2 |
Call overloaded operators to perform operations on gdb.Value objects.
* NEWS: Add entry for the new feature
* python/py-value.c (valpy_binop): Call value_x_binop for struct
and class values.
testsuite/
* gdb.python/py-value-cc.cc: Improve test case to enable testing
operations on gdb.Value objects.
* gdb.python/py-value-cc.exp: Add new test to test operations on
gdb.Value objects.
doc/
* python.texi (Values From Inferior): Add description about the
new feature.
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/doc/python.texi | 21 |
2 files changed, 25 insertions, 1 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 23823ee..9619907 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2014-02-19 Siva Chandra Reddy <sivachandra@google.com> + + * python.texi (Values From Inferior): Add description about the + new feature. + 2014-02-17 Doug Evans <xdje42@gmail.com> * Makefile.in (GDB_DOC_FILES): Add python.texi. diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index 62636a4..90b7074 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -528,7 +528,26 @@ bar = some_val + 2 @noindent As result of this, @code{bar} will also be a @code{gdb.Value} object -whose values are of the same type as those of @code{some_val}. +whose values are of the same type as those of @code{some_val}. Valid +Python operations can also be performed on @code{gdb.Value} objects +representing a @code{struct} or @code{class} object. For such cases, +the overloaded operator (if present), is used to perform the operation. +For example, if @code{val1} and @code{val2} are @code{gdb.Value} objects +representing instances of a @code{class} which overloads the @code{+} +operator, then one can use the @code{+} operator in their Python script +as follows: + +@smallexample +val3 = val1 + val2 +@end smallexample + +@noindent +The result of the operation @code{val3} is also a @code{gdb.Value} +object corresponding to the value returned by the overloaded @code{+} +operator. In general, overloaded operators are invoked for the +following operations: @code{+} (binary addition), @code{-} (binary +subtraction), @code{*} (multiplication), @code{/}, @code{%}, @code{<<}, +@code{>>}, @code{|}, @code{&}, @code{^}. Inferior values that are structures or instances of some class can be accessed using the Python @dfn{dictionary syntax}. For example, if |