summaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorSiva Chandra <sivachandra@chromium.org>2015-04-25 07:04:40 -0700
committerSiva Chandra <sivachandra@chromium.org>2015-05-09 17:30:35 -0700
commit4c082a81dfebcca45e4ee8cb90490ab733b8e017 (patch)
tree824873fd9d879d57492bde01f990cc36f0f454dd /gdb/testsuite
parent10a52f094ebbbed3f9d1b28a2ded94e43d500133 (diff)
downloadbinutils-gdb-4c082a81dfebcca45e4ee8cb90490ab733b8e017.tar.gz
[Python] Add methods reference_value and const_value to gdb.Value.
gdb/ChangeLog: * NEWS (Python Scripting): Mention the new gdb.Value methods. * python/py-value.c (valpy_reference_value): New function. (valpy_const_value): Likewise. (value_object_methods): Add new methods. * value.c (make_cv_value): New function. * value.h (make_cv_value): Declare. gdb/doc/ChangeLog: * python.texi (Values From Inferior): Add descriptions of new methods gdb.Value.reference_value and gdb.Value.const_value. gdb/testsuite/ChangeLog: * gdb.python/py-xmethods.cc: Enhance test case. * gdb.python/py-xmethods.exp: New tests. * gdb.python/py-xmethods.py (A_indexoper): New xmethod worker function. (B_indexoper): Likewise. (global_dm_list) : Add new xmethod worker functions.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog9
-rw-r--r--gdb/testsuite/gdb.python/py-xmethods.cc2
-rw-r--r--gdb/testsuite/gdb.python/py-xmethods.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-xmethods.py16
4 files changed, 28 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index f4ee04a48be..52140bd9536 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2015-05-09 Siva Chandra Reddy <sivachandra@google.com>
+
+ * gdb.python/py-xmethods.cc: Enhance test case.
+ * gdb.python/py-xmethods.exp: New tests.
+ * gdb.python/py-xmethods.py (A_indexoper): New xmethod worker
+ function.
+ (B_indexoper): Likewise.
+ (global_dm_list) : Add new xmethod worker functions.
+
2015-05-08 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.base/coredump-filter.exp: Correctly unset
diff --git a/gdb/testsuite/gdb.python/py-xmethods.cc b/gdb/testsuite/gdb.python/py-xmethods.cc
index aedd1de1043..98bdb728aa0 100644
--- a/gdb/testsuite/gdb.python/py-xmethods.cc
+++ b/gdb/testsuite/gdb.python/py-xmethods.cc
@@ -173,7 +173,7 @@ int main(void)
for (int i = 0; i < 10; i++)
{
- a1.array[i] = a2.array[i] = i;
+ a1.array[i] = a2.array[i] = b1.array[i] = i;
}
return 0; /* Break here. */
diff --git a/gdb/testsuite/gdb.python/py-xmethods.exp b/gdb/testsuite/gdb.python/py-xmethods.exp
index 712f271be22..274b06e5124 100644
--- a/gdb/testsuite/gdb.python/py-xmethods.exp
+++ b/gdb/testsuite/gdb.python/py-xmethods.exp
@@ -100,6 +100,8 @@ gdb_test "p a1.geta()" "From Python <A_geta>.*5" "After: a1.geta()"
gdb_test "p ++a1" "From Python <plus_plus_A>.*6" "After: ++a1"
gdb_test "p a1.getarrayind(5)" "From Python <A_getarrayind>.*5" \
"After: a1.getarrayind(5)"
+gdb_test "P a1\[6\]" ".*int &.*6" "After a1\[\]"
+gdb_test "P b1\[7\]" ".*const int &.*7" "After b1\[\]"
# Note the following test. Xmethods on dynamc types are not looked up
# currently. Hence, even though a_ptr points to a B object, the xmethod
# defined for A objects is invoked.
diff --git a/gdb/testsuite/gdb.python/py-xmethods.py b/gdb/testsuite/gdb.python/py-xmethods.py
index 3a2f100f3b5..a32781acd9d 100644
--- a/gdb/testsuite/gdb.python/py-xmethods.py
+++ b/gdb/testsuite/gdb.python/py-xmethods.py
@@ -43,6 +43,12 @@ def A_getarrayind(obj, index):
print('From Python <A_getarrayind>:')
return obj['array'][index]
+def A_indexoper(obj, index):
+ return obj['array'][index].reference_value()
+
+def B_indexoper(obj, index):
+ return obj['array'][index].const_value().reference_value()
+
type_A = gdb.parse_and_eval('(dop::A *) 0').type.target()
type_B = gdb.parse_and_eval('(dop::B *) 0').type.target()
@@ -213,6 +219,16 @@ global_dm_list = [
'^getarrayind$',
A_getarrayind,
type_int),
+ SimpleXMethodMatcher('A_indexoper',
+ '^dop::A$',
+ 'operator\\[\\]',
+ A_indexoper,
+ type_int),
+ SimpleXMethodMatcher('B_indexoper',
+ '^dop::B$',
+ 'operator\\[\\]',
+ B_indexoper,
+ type_int)
]
for matcher in global_dm_list: