diff options
author | Tom Tromey <tromey@redhat.com> | 2012-09-27 16:04:18 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2012-09-27 16:04:18 +0000 |
commit | a34b9538378eebb04c4ee8d200c5af9c54446fff (patch) | |
tree | 1c36a68b2707392f8ee4df9d18707edcebbeb090 /gdb/testsuite/gdb.cp | |
parent | 3afaed66d498d3f6acf5ec93a8f420f78c9b4032 (diff) | |
download | gdb-a34b9538378eebb04c4ee8d200c5af9c54446fff.tar.gz |
Fix https://bugzilla.redhat.com/show_bug.cgi?id=849357
* cp-valprint.c (cp_print_value_fields): Use get_vptr_fieldno.
gdb/testsuite
* gdb.cp/derivation.exp: Add regression test.
* gdb.cp/derivation.cc (class V_base, class V_inter, class
V_derived): New.
(vderived): New global.
Diffstat (limited to 'gdb/testsuite/gdb.cp')
-rw-r--r-- | gdb/testsuite/gdb.cp/derivation.cc | 29 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/derivation.exp | 8 |
2 files changed, 37 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.cp/derivation.cc b/gdb/testsuite/gdb.cp/derivation.cc index 942fcd26b65..fcd57ce22ba 100644 --- a/gdb/testsuite/gdb.cp/derivation.cc +++ b/gdb/testsuite/gdb.cp/derivation.cc @@ -118,8 +118,37 @@ public: }; +class V_base +{ +public: + virtual void m(); + int base; +}; + +void +V_base::m() +{ +} + +class V_inter : public virtual V_base +{ +public: + virtual void f(); + int inter; +}; + +void +V_inter::f() +{ +} +class V_derived : public V_inter +{ +public: + double x; +}; +V_derived vderived; int A::afoo() { return 1; diff --git a/gdb/testsuite/gdb.cp/derivation.exp b/gdb/testsuite/gdb.cp/derivation.exp index b752b526e48..a4210d9d422 100644 --- a/gdb/testsuite/gdb.cp/derivation.exp +++ b/gdb/testsuite/gdb.cp/derivation.exp @@ -176,3 +176,11 @@ gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" { gdb_test "print g_instance.bfoo()" "\\$\[0-9\]+ = 2" "print value of g_instance.bfoo()" gdb_test "print g_instance.cfoo()" "\\$\[0-9\]+ = 3" "print value of g_instance.cfoo()" + +# This is a regression test for a bug that caused a crash when trying +# to print the vtbl pointer. We don't care about the output so much +# here (it is tested elsewhere), just that gdb doesn't crash. We test +# "ptype" first because, before the gdb fix, that was the only code +# path calling get_vptr_fieldno. +gdb_test "ptype vderived" "type = .*" +gdb_test "print vderived" " = {.* inter = 0.*x = 0}" |