diff options
author | Tom Tromey <tromey@redhat.com> | 2010-02-02 16:45:17 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2010-02-02 16:45:17 +0000 |
commit | edf3d5f3f8c5adff55934e57da9cd8c874dc2a55 (patch) | |
tree | b4c0a67139f68773c88d955a0a8267a8c6759bba /gdb/testsuite | |
parent | 4339cae0bb39a38117d51fc52066e659dccaee29 (diff) | |
download | gdb-edf3d5f3f8c5adff55934e57da9cd8c874dc2a55.zip gdb-edf3d5f3f8c5adff55934e57da9cd8c874dc2a55.tar.gz gdb-edf3d5f3f8c5adff55934e57da9cd8c874dc2a55.tar.bz2 |
gdb
PR c++/11226, PR c++/9629, PR c++/9688, PR c++/8890:
* valops.c (search_struct_field): Compute nbases after calling
CHECK_TYPEDEF.
(check_field): Call CHECK_TYPEDEF.
* cp-valprint.c (cp_print_value): Pass correct address to
baseclass_offset. Fix check for virtual base past the end of the
object. Don't offset address passed to cp_print_value_fields or
apply_val_pretty_printer.
(cp_print_value_fields): Fix call to val_print.
(cp_print_value_fields_rtti): New function.
* c-valprint.c (c_val_print): Use cp_print_value_fields_rtti.
* p-valprint.c (pascal_object_print_value_fields): Fix call to
val_print.
* python/py-prettyprint.c (apply_val_pretty_printer): Add embedded
offset to address.
* language.h (struct language_defn) <la_val_print>: Document.
* c-lang.h (cp_print_value_fields_rtti): Declare.
gdb/testsuite
PR c++/11226, PR c++/9629, PR c++/9688, PR c++/8890:
* gdb.cp/virtbase.cc: New file.
* gdb.cp/virtbase.exp: New file.
* gdb.cp/userdef.exp: Allow 'struct' or 'class'.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/userdef.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/virtbase.cc | 57 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/virtbase.exp | 57 |
4 files changed, 122 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 0be26e6..d55d31a 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2010-02-02 Tom Tromey <tromey@redhat.com> + + PR c++/11226, PR c++/9629, PR c++/9688, PR c++/8890: + * gdb.cp/virtbase.cc: New file. + * gdb.cp/virtbase.exp: New file. + * gdb.cp/userdef.exp: Allow 'struct' or 'class'. + 2010-02-01 Jan Kratochvil <jan.kratochvil@redhat.com> PR libc/11214: diff --git a/gdb/testsuite/gdb.cp/userdef.exp b/gdb/testsuite/gdb.cp/userdef.exp index bd54c78..2bbf95e 100644 --- a/gdb/testsuite/gdb.cp/userdef.exp +++ b/gdb/testsuite/gdb.cp/userdef.exp @@ -153,7 +153,7 @@ gdb_test "break A2::'operator +'" ".*Breakpoint $decimal at.*" gdb_test "print c" "\\\$\[0-9\]* = {m = {z = .*}}" gdb_test "print *c" "\\\$\[0-9\]* = \\(Member &\\) @$hex: {z = .*}" gdb_test "print &*c" "\\\$\[0-9\]* = \\(Member \\*\\) $hex" -gdb_test "ptype &*c" "type = struct Member {\[\r\n \]+int z;\[\r\n\]+} &\\*" +gdb_test "ptype &*c" "type = (struct|class) Member {(\[\r\n \]+public:)?\[\r\n \]+int z;\[\r\n\]+} &\\*" gdb_exit return 0 diff --git a/gdb/testsuite/gdb.cp/virtbase.cc b/gdb/testsuite/gdb.cp/virtbase.cc new file mode 100644 index 0000000..ae0a2c7 --- /dev/null +++ b/gdb/testsuite/gdb.cp/virtbase.cc @@ -0,0 +1,57 @@ +// This first batch of classes are for PR 11226. +namespace mc { + class Base { + protected: + int x; + + public: + Base(void) { x = 2; }; + }; +} + +namespace ph { + class Middle: public virtual mc::Base { + protected: + int y; + + public: + Middle(void): mc::Base() { y = 3; }; + + int get_y(void) + { + return y; // breakpoint 1 + }; + }; + + class Derived: public virtual Middle { + protected: + int z; + + public: + Derived(void): Middle() { z = 4; }; + + int get_z(void) + { + return z; // breakpoint 2 + }; + }; +} + +// These classes are for PR 9629. +struct A {}; +struct B : virtual A {}; + +struct C {int v; C() {v=11;};}; +struct D:virtual C{}; + +class E:B,D{}; + +int main() { + ph::Derived tst; + tst.get_y(); + tst.get_z(); + + E *e = new E; + + return 0; // breakpoint 3 +} diff --git a/gdb/testsuite/gdb.cp/virtbase.exp b/gdb/testsuite/gdb.cp/virtbase.exp new file mode 100644 index 0000000..6a37626 --- /dev/null +++ b/gdb/testsuite/gdb.cp/virtbase.exp @@ -0,0 +1,57 @@ +# Copyright 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# This file is part of the gdb testsuite. + +if { [skip_cplus_tests] } { continue } + +set testfile "virtbase" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested virtbase.exp + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if {![runto_main]} then { + perror "couldn't run to breakpoint" + continue +} + +gdb_breakpoint [gdb_get_line_number "breakpoint 1"] +gdb_continue_to_breakpoint "first breakpoint" + +# In PR 11226, we failed to print x correctly in the "print *this" +# case. +gdb_test "print *this" " = {<mc::Base> = {x = 2}, _vptr.Middle = $hex, y = 3}" +gdb_test "print x" " = 2" + +gdb_breakpoint [gdb_get_line_number "breakpoint 2"] +gdb_continue_to_breakpoint "second breakpoint" + +# In PR 11226, we could not find x here. +gdb_test "print x" " = 2" + +gdb_breakpoint [gdb_get_line_number "breakpoint 3"] +gdb_continue_to_breakpoint "third breakpoint" + +# In PR 9629, we failed to print v correctly here. +gdb_test "print *(D *) e" " = {<C> = {v = 11}, _vptr.D = $hex}" |