summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2010-08-23 20:29:19 +0000
committerTom Tromey <tromey@redhat.com>2010-08-23 20:29:19 +0000
commitf9ffd4bb11c401df4c0c5733e946c48d6b295c5e (patch)
treee703cf5f4d37e888044a224d8b4a2ce06118e5da /gdb/testsuite/gdb.python
parent9919d93bc70b0ed9bb5991bcf46e4c3ffaa0a3ce (diff)
downloadbinutils-gdb-f9ffd4bb11c401df4c0c5733e946c48d6b295c5e.tar.gz
gdb
PR python/11145: * python/py-value.c: Include expression.h. (valpy_do_cast): New function. (valpy_cast): Use it. (valpy_dynamic_cast): New function. (valpy_reinterpret_cast): Likewise. (value_object_methods): Add dynamic_cast, reinterpret_cast. gdb/doc PR python/11145: * gdb.texinfo (Values From Inferior): Document dynamic_cast and reinterpret_cast methods. gdb/testsuite PR python/11145: * gdb.python/py-value.c (Base, Derived): New types. (base): New global. * gdb.python/py-value.exp (test_subscript_regression): Add dynamic_cast test.
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r--gdb/testsuite/gdb.python/py-value.c10
-rw-r--r--gdb/testsuite/gdb.python/py-value.exp5
2 files changed, 15 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-value.c b/gdb/testsuite/gdb.python/py-value.c
index 7481bd52810..5ac7d761e40 100644
--- a/gdb/testsuite/gdb.python/py-value.c
+++ b/gdb/testsuite/gdb.python/py-value.c
@@ -40,6 +40,16 @@ typedef struct s *PTR;
enum e evalue = TWO;
#ifdef __cplusplus
+
+struct Base {
+ virtual int x() { return 5; }
+};
+
+struct Derived : public Base {
+};
+
+Base *base = new Derived ();
+
void ptr_ref(int*& rptr_int)
{
return; /* break to inspect pointer by reference. */
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index eaed9c7a6b4..13bce9a05ef 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -374,6 +374,11 @@ proc test_subscript_regression {lang} {
gdb_py_test_silent_cmd "python rptr = gdb.history(0)" \
"Obtains value from GDB" 1
gdb_test "python print rptr\[0\]" "2" "Check pointer passed as reference"
+
+ # Just the most basic test of dynamic_cast -- it is checked in
+ # the C++ tests.
+ gdb_test "python print bool(gdb.parse_and_eval('base').dynamic_cast(gdb.lookup_type('Derived').pointer()))" \
+ True
}
gdb_breakpoint [gdb_get_line_number "break to inspect struct and union"]