diff options
Diffstat (limited to 'gdb/testsuite/gdb.cp')
41 files changed, 1107 insertions, 897 deletions
diff --git a/gdb/testsuite/gdb.cp/ambiguous.exp b/gdb/testsuite/gdb.cp/ambiguous.exp index 6385dcb..f54e964 100644 --- a/gdb/testsuite/gdb.cp/ambiguous.exp +++ b/gdb/testsuite/gdb.cp/ambiguous.exp @@ -1,4 +1,4 @@ -# Copyright 1998, 1999, 2003 Free Software Foundation, Inc. +# Copyright 1998, 1999, 2003, 2004 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 @@ -14,9 +14,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file is part of the gdb testsuite # tests relating to ambiguous class members diff --git a/gdb/testsuite/gdb.cp/annota2.exp b/gdb/testsuite/gdb.cp/annota2.exp index f4f2433..7710cc4 100644 --- a/gdb/testsuite/gdb.cp/annota2.exp +++ b/gdb/testsuite/gdb.cp/annota2.exp @@ -1,4 +1,4 @@ -# Copyright 1999, 2000, 2001, 2002, 2003 +# Copyright 1999, 2000, 2001, 2002, 2003, 2004 # Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file was written by Elena Zannoni (ezannoni@cygnus.com) if $tracelevel then { diff --git a/gdb/testsuite/gdb.cp/annota3.exp b/gdb/testsuite/gdb.cp/annota3.exp index c75a289..37be48d 100644 --- a/gdb/testsuite/gdb.cp/annota3.exp +++ b/gdb/testsuite/gdb.cp/annota3.exp @@ -1,4 +1,4 @@ -# Copyright 2003 Free Software Foundation, Inc. +# Copyright 2003, 2004 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 @@ -14,9 +14,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file was written by Elena Zannoni (ezannoni@cygnus.com) if $tracelevel then { diff --git a/gdb/testsuite/gdb.cp/anon-union.exp b/gdb/testsuite/gdb.cp/anon-union.exp index 0d5c777..4c34dcf 100644 --- a/gdb/testsuite/gdb.cp/anon-union.exp +++ b/gdb/testsuite/gdb.cp/anon-union.exp @@ -1,5 +1,5 @@ # Tests for anonymous union support. -# Copyright 1998, 1999, 2003 Free Software Foundation, Inc. +# Copyright 1998, 1999, 2003, 2004 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 @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # Written by Satish Pai <pai@apollo.hp.com> 1997-08-19 # This file is part of the gdb testsuite diff --git a/gdb/testsuite/gdb.cp/breakpoint.cc b/gdb/testsuite/gdb.cp/breakpoint.cc new file mode 100644 index 0000000..266007c --- /dev/null +++ b/gdb/testsuite/gdb.cp/breakpoint.cc @@ -0,0 +1,41 @@ +/* Code to go along with tests in breakpoint.exp. + + Copyright 2004 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +class C1 { +public: + class Nested { + public: + int + foo () + { + return 1; + } + }; +}; + +int main () +{ + C1::Nested c1; + + c1.foo(); + + return 0; +} diff --git a/gdb/testsuite/gdb.cp/breakpoint.exp b/gdb/testsuite/gdb.cp/breakpoint.exp new file mode 100644 index 0000000..c85f805 --- /dev/null +++ b/gdb/testsuite/gdb.cp/breakpoint.exp @@ -0,0 +1,65 @@ +# Copyright 2004 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This file is part of the gdb testsuite. + +# This contains tests for breakpoints in C++. + +if $tracelevel then { + strace $tracelevel + } + +if { [skip_cplus_tests] } { continue } + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +set testfile "breakpoint" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +proc test_breakpoint {name} { + # Restart the program every time, so that a single failure doesn't + # lead to a cascade. + if ![runto_main] then { + perror "couldn't run to main when testing ${name}" + continue + } else { + gdb_breakpoint "${name}" + gdb_test "continue" "Continuing.\r\n\r\nBreakpoint \[0-9\]*, ${name}.*" "continue to ${name}" + } +} + +test_breakpoint "C1::Nested::foo" + +gdb_exit +return 0 diff --git a/gdb/testsuite/gdb.cp/bs15503.cc b/gdb/testsuite/gdb.cp/bs15503.cc index aec5a0b..5581ec5 100644 --- a/gdb/testsuite/gdb.cp/bs15503.cc +++ b/gdb/testsuite/gdb.cp/bs15503.cc @@ -15,9 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Please email any bugs, comments, and/or additions to this file to: - bug-gdb@prep.ai.mit.edu */ + */ #include <string> #include <iostream> diff --git a/gdb/testsuite/gdb.cp/casts.exp b/gdb/testsuite/gdb.cp/casts.exp index 5b6cabe..3aaf37c 100644 --- a/gdb/testsuite/gdb.cp/casts.exp +++ b/gdb/testsuite/gdb.cp/casts.exp @@ -1,4 +1,4 @@ -# Copyright 2002, 2003 Free Software Foundation, Inc. +# Copyright 2002, 2003, 2004 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 @@ -14,9 +14,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file is part of the gdb testsuite # Test casting, especially between class types or pointer-to-class diff --git a/gdb/testsuite/gdb.cp/class2.cc b/gdb/testsuite/gdb.cp/class2.cc index 16cf988..34263c8 100644 --- a/gdb/testsuite/gdb.cp/class2.cc +++ b/gdb/testsuite/gdb.cp/class2.cc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 2003 Free Software Foundation, Inc. + Copyright 2003, 2004 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 @@ -15,9 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Please email any bugs, comments, and/or additions to this file to: - bug-gdb@prep.ai.mit.edu */ + */ struct A { diff --git a/gdb/testsuite/gdb.cp/classes.exp b/gdb/testsuite/gdb.cp/classes.exp index 16a4c3b..12428be 100644 --- a/gdb/testsuite/gdb.cp/classes.exp +++ b/gdb/testsuite/gdb.cp/classes.exp @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file was written by Fred Fish. (fnf@cygnus.com) # And rewritten by Michael Chastain <mec.gnu@mindspring.com>. diff --git a/gdb/testsuite/gdb.cp/cplusfuncs.exp b/gdb/testsuite/gdb.cp/cplusfuncs.exp index 0a5e1b3..a509afb 100644 --- a/gdb/testsuite/gdb.cp/cplusfuncs.exp +++ b/gdb/testsuite/gdb.cp/cplusfuncs.exp @@ -1,4 +1,5 @@ -# Copyright 1992, 1997, 1999, 2001, 2002, 2003 Free Software Foundation, Inc. +# Copyright 1992, 1997, 1999, 2001, 2002, 2003, 2004 +# 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 @@ -14,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file was written by Fred Fish. (fnf@cygnus.com) # Adapted for g++ 3.0 ABI by Michael Chastain. (chastain@redhat.com) diff --git a/gdb/testsuite/gdb.cp/ctti.exp b/gdb/testsuite/gdb.cp/ctti.exp index a5e75d8..7c23b49 100644 --- a/gdb/testsuite/gdb.cp/ctti.exp +++ b/gdb/testsuite/gdb.cp/ctti.exp @@ -14,9 +14,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file is part of the gdb testsuite # file written by Elena Zannoni (ezannoni@cygnus.com) # rewritten by Michael Chastain (mec.gnu@mindspring.com) diff --git a/gdb/testsuite/gdb.cp/cttiadd.cc b/gdb/testsuite/gdb.cp/cttiadd.cc index 1958605..ffba405 100644 --- a/gdb/testsuite/gdb.cp/cttiadd.cc +++ b/gdb/testsuite/gdb.cp/cttiadd.cc @@ -15,9 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Please email any bugs, comments, and/or additions to this file to: - bug-gdb@prep.ai.mit.edu */ + */ template<class T> T add(T v1, T v2) { diff --git a/gdb/testsuite/gdb.cp/cttiadd1.cc b/gdb/testsuite/gdb.cp/cttiadd1.cc index 3ef318a..9b149b3 100644 --- a/gdb/testsuite/gdb.cp/cttiadd1.cc +++ b/gdb/testsuite/gdb.cp/cttiadd1.cc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1998, 1999 Free Software Foundation, Inc. + Copyright 1998, 1999, 2004 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 @@ -15,9 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Please email any bugs, comments, and/or additions to this file to: - bug-gdb@prep.ai.mit.edu */ + */ template<class T> T add(T v1, T v2); diff --git a/gdb/testsuite/gdb.cp/cttiadd2.cc b/gdb/testsuite/gdb.cp/cttiadd2.cc index a2f04b5..3538661 100644 --- a/gdb/testsuite/gdb.cp/cttiadd2.cc +++ b/gdb/testsuite/gdb.cp/cttiadd2.cc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1998, 1999 Free Software Foundation, Inc. + Copyright 1998, 1999, 2004 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 @@ -15,9 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Please email any bugs, comments, and/or additions to this file to: - bug-gdb@prep.ai.mit.edu */ + */ template<class T> T add2(T v1, T v2) { diff --git a/gdb/testsuite/gdb.cp/cttiadd3.cc b/gdb/testsuite/gdb.cp/cttiadd3.cc index 60fb61a..2bea7bb 100644 --- a/gdb/testsuite/gdb.cp/cttiadd3.cc +++ b/gdb/testsuite/gdb.cp/cttiadd3.cc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1998, 1999 Free Software Foundation, Inc. + Copyright 1998, 1999, 2004 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 @@ -15,9 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Please email any bugs, comments, and/or additions to this file to: - bug-gdb@prep.ai.mit.edu */ + */ template<class T> T add3(T v1, T v2) { diff --git a/gdb/testsuite/gdb.cp/demangle.exp b/gdb/testsuite/gdb.cp/demangle.exp index 7bd9fc5..848f66f 100644 --- a/gdb/testsuite/gdb.cp/demangle.exp +++ b/gdb/testsuite/gdb.cp/demangle.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1992, 1997, 1999, 2003 Free Software Foundation, Inc. +# Copyright (C) 1992, 1997, 1999, 2003, 2004 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 @@ -14,9 +14,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file was written by Fred Fish. (fnf@cygnus.com) if $tracelevel then { diff --git a/gdb/testsuite/gdb.cp/derivation.exp b/gdb/testsuite/gdb.cp/derivation.exp index 6ef6dbe..d82ab1f 100644 --- a/gdb/testsuite/gdb.cp/derivation.exp +++ b/gdb/testsuite/gdb.cp/derivation.exp @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file was written by Elena Zannoni (ezannoni@cygnus.com) # And rewritten by Michael Chastain <mec.gnu@mindspring.com> diff --git a/gdb/testsuite/gdb.cp/exception.cc b/gdb/testsuite/gdb.cp/exception.cc index 4134fbc..cd124e5 100644 --- a/gdb/testsuite/gdb.cp/exception.cc +++ b/gdb/testsuite/gdb.cp/exception.cc @@ -15,9 +15,9 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + - Please email any bugs, comments, and/or additions to this file to: - bug-gdb@prep.ai.mit.edu */ // Test file for exception handling support. diff --git a/gdb/testsuite/gdb.cp/exception.exp b/gdb/testsuite/gdb.cp/exception.exp index d921ead..3193091 100644 --- a/gdb/testsuite/gdb.cp/exception.exp +++ b/gdb/testsuite/gdb.cp/exception.exp @@ -14,9 +14,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file is part of the gdb testsuite. # tests for exception-handling support # Written by Satish Pai <pai@apollo.hp.com> 1997-07-23 diff --git a/gdb/testsuite/gdb.cp/hang.exp b/gdb/testsuite/gdb.cp/hang.exp index 4c117a1..2308874 100644 --- a/gdb/testsuite/gdb.cp/hang.exp +++ b/gdb/testsuite/gdb.cp/hang.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2002 Free Software Foundation, Inc. +# Copyright 2002, 2004 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 @@ -14,9 +14,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - if $tracelevel then { strace $tracelevel } diff --git a/gdb/testsuite/gdb.cp/inherit.exp b/gdb/testsuite/gdb.cp/inherit.exp index 993bfb1..72de1ac 100644 --- a/gdb/testsuite/gdb.cp/inherit.exp +++ b/gdb/testsuite/gdb.cp/inherit.exp @@ -1,5 +1,5 @@ -# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003 -# Free Software Foundation, Inc. +# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003, +# 2004 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 @@ -15,951 +15,1008 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file was written by Fred Fish. (fnf@cygnus.com) +# And rewritten by Michael Chastain. (mec.gnu@mindspring.com) -set ws "\[\r\n\t \]+" -set nl "\[\r\n\]+" - -# The format of a g++ virtual base pointer. -set vbptr "(_vb\[$.\]|__vb_)\[0-9\]?" +set ws "\[\r\n\t \]+" +set nl "\[\r\n\]+" +set vhn "\\$\[0-9\]+" if $tracelevel then { - strace $tracelevel + strace $tracelevel } if { [skip_cplus_tests] } { continue } -# Note - create separate "inherit" executable from misc.cc - set testfile "inherit" set srcfile misc.cc set binfile ${objdir}/${subdir}/${testfile} - -# Create and source the file that provides information about the compiler -# used to compile the test case. - -if [get_compiler_info ${binfile} "c++"] { - return -1 -} - if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -# -# Single inheritance, print individual members. -# - -proc test_print_si_members {} { - # Print all members of g_A using fully qualified form. - - gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a" - - gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x" - - # Print members of g_A using nonambiguous compact form. - - gdb_test "print g_A.a" ".* = 1" "print g_A.a" - - gdb_test "print g_A.x" ".* = 2" "print g_A.x" - - # Print all members of g_B using fully qualified form. - - gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a" - - gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x" - - gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b" - - gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x" - - # Print members of g_B using nonambiguous compact form. - - gdb_test "print g_B.a" ".* = 3" "print g_B.a" - - gdb_test "print g_B.b" ".* = 5" "print g_B.b" - - gdb_test "print g_B.x" ".* = 6" "print g_B.x" - - # Print all members of g_C using fully qualified form. - - gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a" - - gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x" - - gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c" - - gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x" - - # Print members of g_C using nonambiguous compact form. - - gdb_test "print g_C.a" ".* = 7" "print g_C.a" - - gdb_test "print g_C.c" ".* = 9" "print g_C.c" - - gdb_test "print g_C.x" ".* = 10" "print g_C.x" -} - -# # Single inheritance, print type definitions. -# -proc test_ptype_si {} { +proc test_ptype_si { } { global gdb_prompt global ws global nl - global hp_aCC_compiler # Print class A as a type. - send_gdb "ptype A\n" - gdb_expect { - -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" { - pass "ptype A (FIXME)" + set re_class "class A \{${ws}public:" + set re_fields "int a;${ws}int x;" + set re_synth_gcc_23 "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\((void|)\\);" + + set name "ptype A (FIXME)" + gdb_test_multiple "ptype A" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name } - -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" { - setup_xfail "*-*-*" - fail "ptype A (FIXME)" + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name } - -re ".*$gdb_prompt $" { fail "ptype A" } - timeout { fail "ptype A (timeout)" ; return } } # Print class A as an explicit class. - send_gdb "ptype class A\n" - gdb_expect { - -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" { - pass "ptype class A (FIXME)" + set name "ptype class A (FIXME)" + gdb_test_multiple "ptype class A" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name } - -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" { - if {!$hp_aCC_compiler} {setup_xfail "*-*-*"} - fail "ptype class A (FIXME)" + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name } - -re ".*$gdb_prompt $" { fail "ptype class A" } - timeout { fail "ptype class A (timeout)" ; return } } # Print type of an object of type A. - send_gdb "ptype g_A\n" - gdb_expect { - -re "type = class A \{$nl.*\[ \]*int a;$nl\[ \]*int x;$nl.*\[ \]*\}$nl$gdb_prompt $" { - pass "ptype g_A (FIXME)" + set name "ptype g_A (FIXME)" + gdb_test_multiple "ptype g_A" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name } - -re "type = struct A \{$nl\[ \]*int a;$nl\[ \]*int x;$nl\[ \]*\}$nl$gdb_prompt $" { - if {!$hp_aCC_compiler} {setup_xfail "*-*-*"} - fail "ptype g_A (FIXME)" + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name } - -re ".*$gdb_prompt $" { fail "ptype g_A" } - timeout { fail "ptype g_A (timeout)" ; return } } # Print class B as a type. - gdb_test "ptype B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype B" + set re_class "class B : public A \{${ws}public:" + set re_fields "int b;${ws}int x;" + set re_synth_gcc_23 "B & operator=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\((void|)\\);" + + set name "ptype B" + gdb_test_multiple "ptype B" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name + } + } # Print class B as an explicit class. - gdb_test "ptype class B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype class B" + set name "ptype class B" + gdb_test_multiple "ptype class B" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name + } + } # Print type of an object of type B. - gdb_test "ptype g_B" "type = class B : public A \{$nl\[ \]*public:$nl\[ \]*int b;$nl\[ \]*int x;$nl.*\}" "ptype g_B" + set name "ptype g_B" + gdb_test_multiple "ptype g_B" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name + } + } # Print class C as a type. - gdb_test "ptype C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype C" + set re_class "class C : public A \{${ws}public:" + set re_fields "int c;${ws}int x;" + set re_synth_gcc_23 "C & operator=\\(C const ?&\\);${ws}C\\(C const ?&\\);${ws}C\\((void|)\\);" + + set name "ptype C" + gdb_test_multiple "ptype C" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name + } + } # Print class C as an explicit class. - gdb_test "ptype class C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype class C" + set name "ptype class C" + gdb_test_multiple "ptype class C" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name + } + } # Print type of an object of type g_C. - gdb_test "ptype g_C" "type = class C : public A \{$nl\[ \]*public:$nl\[ \]*int c;$nl\[ \]*int x;$nl.*\}" "ptype g_C" - - # gcc cygnus-2.3.3 (Q1) has this bug, but it was fixed as of - # cygnus-2.3.3-930417. PR 2819. - send_gdb "ptype tagless_struct\n" - gdb_expect { - -re "type = class \{${ws}public:${ws}int one;${ws}int two;${ws}tagless_struct & operator=\\(tagless_struct (const ?)?&\\);${ws}tagless_struct\\(tagless_struct (const ?)?&\\);${ws}tagless_struct\\(\\);${ws}\}$nl$gdb_prompt $" { - pass "ptype tagless struct" + set name "ptype g_C" + gdb_test_multiple "ptype g_C" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name } - -re "type = class \{${ws}public:${ws}int one;${ws}int two;;${ws}\}$nl$gdb_prompt $" { - pass "ptype tagless struct" + } + + # Print a structure with no tag. + + set re_tag "tagless_struct" + set XX_tag "\\._1" + set re_class "(class $re_tag \{${ws}public:|class \{${ws}public:|struct $re_tag \{|struct \{)" + set XX_class "(class $XX_tag \{${ws}public:|struct $XX_tag \{)" + set re_fields "int one;${ws}int two;" + set re_synth_gcc_23 "$re_tag & operator=\\($re_tag const ?&\\);${ws}$re_tag\\($re_tag const ?&\\);${ws}$re_tag\\((void|)\\);" + set XX_synth_gcc_23 "($re_tag|$XX_tag) & operator=\\($XX_tag const ?&\\);${ws}$XX_tag\\($XX_tag const ?&\\);${ws}$XX_tag\\((void|)\\);" + + set name "ptype tagless struct" + gdb_test_multiple "ptype tagless_struct" $name { + -re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass "$name (obsolete gcc or gdb)" } - -re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" { - pass "ptype tagless struct (obsolete gcc or gdb)" + -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass "$name (obsolete gcc or gdb)" } - -re ".*$gdb_prompt $" { - fail "ptype tagless struct" + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + pass "$name (obsolete gcc or gdb)" } - timeout { - fail "ptype tagless struct (timeout)" + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name" } } - send_gdb "ptype v_tagless\n" - gdb_expect { - -re "type = class \{${ws}public:${ws}int one;${ws}int two;${ws}tagless_struct & operator=\\(tagless_struct (const ?)?&\\);${ws}tagless_struct\\(tagless_struct (const ?)?&\\);${ws}tagless_struct\\(\\);${ws}\}$nl$gdb_prompt $" { - pass "ptype variable of type tagless struct" + set name "ptype variable of type tagless struct" + gdb_test_multiple "ptype v_tagless" $name { + -re "type = $XX_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass "$name (obsolete gcc or gdb)" } - -re "type = class \{${ws}public:${ws}int one;${ws}int two;;${ws}\}$nl$gdb_prompt $" { - pass "ptype tagless struct" + -re "type = $re_class${ws}$re_fields${ws}$XX_synth_gcc_23$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass "$name (obsolete gcc or gdb)" } - -re "type = (struct|class).*\{.*int one;.*int two;.*\}$nl$gdb_prompt $" { - pass "ptype variable of type tagless struct (obsolete gcc or gdb)" + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + pass "$name (obsolete gcc or gdb)" } - -re ".*$gdb_prompt $" { - fail "ptype variable of type tagless struct" - } - timeout { - fail "ptype variable of type tagless struct (timeout)" + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name" } } } -# -# Single inheritance, print complete classes. -# - -proc test_print_si_classes {} { - # Print all members of g_A. - - gdb_test "print g_A" ".* = \{a = 1, x = 2\}" "print g_A" - - # Print all members of g_B. - - gdb_test "print g_B" ".* = \{\<(class |)A\> = \{a = 3, x = 4\}, b = 5, x = 6\}" "print g_B" - - # Print all members of g_C. - - gdb_test "print g_C" ".* = \{\<(class |)A\> = \{a = 7, x = 8\}, c = 9, x = 10\}" "print g_C" -} - -# -# Single inheritance, print anonymous unions. -# GDB versions prior to 4.14 entered an infinite loop when printing -# the type of a class containing an anonymous union, and they were also -# incapable of printing the member of an anonymous union. -# We test the printing of the member first, and perform the other tests -# only if the test succeeds, to avoid the infinite loop. -# +# Multiple inheritance, print type definitions. -proc test_print_anon_union {} { +proc test_ptype_mi { } { global gdb_prompt global ws global nl - gdb_test "print g_anon_union.a" ".* = 2" "print anonymous union member" - send_gdb "print g_anon_union\n" - gdb_expect { - -re ".* = \{one = 1, ( = |)\{a = 2, b = 2\}\}$nl$gdb_prompt $" { - pass "print variable of type anonymous union" + set re_class "class D : public B, public C \{${ws}public:" + set re_fields "int d;${ws}int x;" + set re_synth_gcc_23 "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);" + + # ptype D: type, class, object. + + set name "ptype D" + gdb_test_multiple "ptype D" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name + } + } + + set name "ptype class D" + gdb_test_multiple "ptype class D" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name } - -re ".* = .*\{one = 1, ( = |)\{a = 2, b = .*\}\}$nl$gdb_prompt $" { - pass "print variable of type anonymous union (obsolete gcc or gdb)" + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name } - -re ".*$nl$gdb_prompt $" { - fail "print variable of type anonymous union" + } + + set name "ptype g_D" + gdb_test_multiple "ptype g_D" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name } - timeout { - fail "print variableof type anonymous union (timeout)" + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name } } - send_gdb "ptype g_anon_union\n" - gdb_expect { - -re "type = class class_with_anon_union \{${ws}public:${ws}int one;${ws}union \{${ws}public:${ws}int a;${ws}long int b;${ws}union \{\.\.\.\} & operator=\\(union \{\.\.\.\} &\\);${ws}\\\$_0 \\(union \{\.\.\.\} &\\);${ws}\\\$_0 \\(\\);${ws}\};${ws}class_with_anon_union & operator=\\(class_with_anon_union const &\\);${ws}class_with_anon_union\\(class_with_anon_union const &\\);${ws}class_with_anon_union\\(void\\);${ws}\}$nl$gdb_prompt $" { - pass "print type of anonymous union" + + set re_class "class E : public D \{${ws}public:" + set re_fields "int e;${ws}int x;" + set re_synth_gcc_23 "E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\((void|)\\);" + + # ptype E: type, class, object. + + set name "ptype E" + gdb_test_multiple "ptype E" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name } - -re "type = class class_with_anon_union \{${ws}public:${ws}int one;${ws}union \{${ws}int a;${ws}long int b;${ws}\};${ws}class_with_anon_union & operator=\\(class_with_anon_union const ?&\\);${ws}class_with_anon_union\\(class_with_anon_union const ?&\\);${ws}class_with_anon_union\\((void|)\\);${ws}\}$nl$gdb_prompt $" { - pass "print type of anonymous union" + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name } - -re "type = class class_with_anon_union \{${ws}public:${ws}int one;${ws}union \{${ws}int a;${ws}long int b;${ws}\};${ws}\}$nl$gdb_prompt $" { - pass "print type of anonymous union" + } + + set name "ptype class E" + gdb_test_multiple "ptype class E" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name } - -re "type = (struct|class).*\{.*int one;.*union \{.*int a;.*(long|long int|int) b;.*\};.*\}$nl$gdb_prompt $" { - pass "print type of anonymous union (obsolete gcc or gdb)" + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name } - -re ".*$nl$gdb_prompt $" { - fail "print type of anonymous union" + } + + set name "ptype g_E" + gdb_test_multiple "ptype g_E" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name } - timeout { - fail "print type of anonymous union (timeout)" + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name } } } -# -# Multiple inheritance, print individual members. -# +# Single virtual inheritance, print type definitions. -proc test_print_mi_members {} { +proc test_ptype_vi { } { global gdb_prompt + global ws global nl - global hp_aCC_compiler - - # Print all members of g_A. - - gdb_test "print g_A.A::a" ".* = 1" "print g_A.A::a" - - gdb_test "print g_A.A::x" ".* = 2" "print g_A.A::x" - # Print all members of g_B. + # ptype vA: type, class, object. - gdb_test "print g_B.A::a" ".* = 3" "print g_B.A::a" + set re_class "class vA \{${ws}public:" + set re_fields "int va;${ws}int vx;" + set re_synth_gcc_23 "vA & operator=\\(vA const ?&\\);${ws}vA\\(vA const ?&\\);${ws}vA\\((void|)\\);" - gdb_test "print g_B.A::x" ".* = 4" "print g_B.A::x" + set name "ptype vA" + gdb_test_multiple "ptype vA" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name + } + } - gdb_test "print g_B.B::b" ".* = 5" "print g_B.B::b" + set name "ptype class vA" + gdb_test_multiple "ptype class vA" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name + } + } - gdb_test "print g_B.B::x" ".* = 6" "print g_B.B::x" + set name "ptype g_vA" + gdb_test_multiple "ptype g_vA" $name { + -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" { + pass $name + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name + } + } - # Print all members of g_C. + # ptype vB: type, class, object. - gdb_test "print g_C.A::a" ".* = 7" "print g_C.A::a" + set re_class "class vB : public virtual vA \{(${ws}private:|)" + set re_vbptr "vA \\*(_vb.2vA|_vb.vA);${ws}" + set re_access "public:" + set re_fields "int vb;${ws}int vx;" + set re_synth_gcc_2 "vB & operator=\\(vB const ?&\\);${ws}vB\\(int, vB const ?&\\);${ws}vB\\(int\\);" + set re_synth_gcc_3 "vB & operator=\\(vB const ?&\\);${ws}vB\\(vB const ?&\\);${ws}vB\\((void|)\\);" - gdb_test "print g_C.A::x" ".* = 8" "print g_C.A::x" + set name "ptype vB" + gdb_test_multiple "ptype vB" $name { + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass $name + } + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + pass "$name (aCC)" + } + -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name (aCC)" + } + } - gdb_test "print g_C.C::c" ".* = 9" "print g_C.C::c" + set name "ptype class vB" + gdb_test_multiple "ptype class vB" $name { + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass $name + } + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + pass "$name (aCC)" + } + -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name (aCC)" + } + } - gdb_test "print g_C.C::x" ".* = 10" "print g_C.C::x" + set name "ptype g_vB" + gdb_test_multiple "ptype g_vB" $name { + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass $name + } + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + pass "$name (aCC)" + } + -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name (aCC)" + } + } - # Print all members of g_D. + # ptype vC: type, class, object. - # The following is ambiguous, and gdb should detect this. - # For now, accept gdb's behavior as an expected failure if it - # simply prints either member correctly. + set re_class "class vC : public virtual vA \{(${ws}private:|)" + set re_vbptr "vA \\*(_vb.2vA|_vb.vA);${ws}" + set re_access "public:" + set re_fields "int vc;${ws}int vx;" + set re_synth_gcc_2 "vC & operator=\\(vC const ?&\\);${ws}vC\\(int, vC const ?&\\);${ws}vC\\(int\\);" + set re_synth_gcc_3 "vC & operator=\\(vC const ?&\\);${ws}vC\\(vC const ?&\\);${ws}vC\\((void|)\\);" - send_gdb "print g_D.A::a\n" - gdb_expect { - -re "warning: A ambiguous; using D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 15$nl$gdb_prompt $" { - pass "print g_D.A::a" + set name "ptype vC" + gdb_test_multiple "ptype vC" $name { + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass $name } - -re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 11$nl$gdb_prompt $" { - pass "print g_D.A::a (using B)" + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass $name } - -re ".* = 15$nl$gdb_prompt $" { - kfail "gdb/68" "print g_D.A::a" + -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + pass "$name (aCC)" } - -re ".* = 11$nl$gdb_prompt $" { - kfail "gdb/68" "print g_D.A::a" + -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name (aCC)" } - -re ".*$gdb_prompt $" { fail "print g_D.A::a" } - timeout { fail "print g_D.A::a (timeout)" ; return } } - # The following is ambiguous, and gdb should detect this. - # For now, accept gdb's behavior as an expected failure if it - # simply prints either member correctly. - - send_gdb "print g_D.A::x\n" - gdb_expect { - -re "warning: A ambiguous; using D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 16$nl$gdb_prompt $" { - pass "print g_D.A::x" + set name "ptype class vC" + gdb_test_multiple "ptype class vC" $name { + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass $name } - -re "warning: A ambiguous; using D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 12$nl$gdb_prompt $" { - pass "print g_D.A::x (using B)" + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass $name } - -re ".* = 16$nl$gdb_prompt $" { - kfail "gdb/68" "print g_D.A::x" + -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + pass "$name (aCC)" } - -re ".* = 12$nl$gdb_prompt $" { - kfail "gdb/68" "print g_D.A::x" + -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name (aCC)" } - -re ".*$gdb_prompt $" { fail "print g_D.A::x" } - timeout { fail "print g_D.A::x (timeout)" ; return } } - gdb_test "print g_D.B::b" ".* = 13" "print g_D.B::b" - - gdb_test "print g_D.B::x" ".* = 14" "print g_D.B::x" - - gdb_test "print g_D.C::c" ".* = 17" "print g_D.C::c" - - gdb_test "print g_D.C::x" ".* = 18" "print g_D.C::x" + set name "ptype g_vC" + gdb_test_multiple "ptype g_vC" $name { + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass $name + } + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + pass "$name (aCC)" + } + -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name (aCC)" + } + } +} - gdb_test "print g_D.D::d" ".* = 19" "print g_D.D::d" +# Multiple virtual inheritance, print type definitions. - gdb_test "print g_D.D::x" ".* = 20" "print g_D.D::x" +proc test_ptype_mvi { } { + global gdb_prompt + global ws + global nl - # Print all members of g_E. + # ptype vD: type, class, object. - # The following is ambiguous, and gdb should detect this. - # For now, accept gdb's behavior as an expected failure if it - # simply prints either member correctly. + set re_class "class vD : public virtual vB, public virtual vC \{(${ws}private:|)" + set re_vbptr "vC \\*(_vb.2vC|_vb.vC);${ws}vB \\*(_vb.2vB|_vb.vB);" + set re_access "public:" + set re_fields "int vd;${ws}int vx;" + set re_synth_gcc_2 "vD & operator=\\(vD const ?&\\);${ws}vD\\(int, vD const ?&\\);${ws}vD\\(int\\);" + set re_synth_gcc_3 "vD & operator=\\(vD const ?&\\);${ws}vD\\(vD const ?&\\);${ws}vD\\((void|)\\);" - send_gdb "print g_E.A::a\n" - gdb_expect { - -re ".* = 21$nl$gdb_prompt $" { - kfail "gdb/68" "print g_E.A::a" + set name "ptype vD" + gdb_test_multiple "ptype vD" $name { + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass $name } - -re ".* = 25$nl$gdb_prompt $" { - kfail "gdb/68" "print g_E.A::a" + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + pass "$name" + } + -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name" } - -re ".*$gdb_prompt $" { fail "print g_E.A::a" } - timeout { fail "print g_E.A::a (timeout)" ; return } } - # The following is ambiguous, and gdb should detect this. - # For now, accept gdb's behavior as an expected failure if it - # simply prints either member correctly. - - send_gdb "print g_E.A::x\n" - gdb_expect { - -re "warning: A ambiguous; using E::D::C::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 26$nl$gdb_prompt $" { - pass "print g_E.A::x" + set name "ptype class vD" + gdb_test_multiple "ptype class vD" $name { + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass $name } - -re "warning: A ambiguous; using E::D::B::A. Use a cast to disambiguate.$nl\\$\[0-9\]* = 22$nl$gdb_prompt $" { - pass "print g_E.A::x (using B)" + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass $name } - -re ".* = 26$nl$gdb_prompt $" { - kfail "gdb/68" "print g_E.A::x" + -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + pass "$name" } - -re ".* = 22$nl$gdb_prompt $" { - kfail "gdb/68" "print g_E.A::x" + -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name" } - -re ".*$gdb_prompt $" { fail "print g_E.A::x" } - timeout { fail "print g_E.A::x (timeout)" ; return } } - gdb_test "print g_E.B::b" ".* = 23" "print g_E.B::b" - - gdb_test "print g_E.B::x" ".* = 24" "print g_E.B::x" - - gdb_test "print g_E.C::c" ".* = 27" "print g_E.C::c" + set name "ptype g_vD" + gdb_test_multiple "ptype g_vD" $name { + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass $name + } + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + pass "$name" + } + -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name" + } + } - gdb_test "print g_E.C::x" ".* = 28" "print g_E.C::x" + # ptype vE: type, class, object. - gdb_test "print g_E.D::d" ".* = 29" "print g_E.D::d" + set re_class "class vE : public virtual vD \{(${ws}private:|)" + set re_vbptr "vD \\*(_vb.2vD|_vb.vD);" + set re_access "public:" + set re_fields "int ve;${ws}int vx;" + set re_synth_gcc_2 "vE & operator=\\(vE const ?&\\);${ws}vE\\(int, vE const ?&\\);${ws}vE\\(int\\);" + set re_synth_gcc_3 "vE & operator=\\(vE const ?&\\);${ws}vE\\(vE const ?&\\);${ws}vE\\((void|)\\);" - gdb_test "print g_E.D::x" ".* = 30" "print g_E.D::x" + set name "ptype vE" + gdb_test_multiple "ptype vE" $name { + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass $name + } + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + pass "$name" + } + -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name" + } + } - gdb_test "print g_E.E::e" ".* = 31" "print g_E.E::e" + set name "ptype class vE" + gdb_test_multiple "ptype class vE" $name { + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass $name + } + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + pass "$name" + } + -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name" + } + } - gdb_test "print g_E.E::x" ".* = 32" "print g_E.E::x" + set name "ptype g_vE" + gdb_test_multiple "ptype g_vE" $name { + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + pass $name + } + -re "type = $re_class${ws}$re_vbptr${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_2$nl\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "type = $re_class${ws}$re_access${ws}$re_fields$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + pass "$name" + } + -re "type = $re_class${ws}$re_access${ws}$re_fields${ws}$re_synth_gcc_3$nl\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name" + } + } } -# -# Multiple inheritance, print type definitions. -# +# Single inheritance, print individual members. -proc test_ptype_mi {} { - global nl +proc test_print_si_members { } { + global vhn - gdb_test "ptype D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype D" + # Print all members of g_A using fully qualified form. + gdb_test "print g_A.A::a" "$vhn = 1" + gdb_test "print g_A.A::x" "$vhn = 2" - gdb_test "ptype class D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype class D" + # Print members of g_A using nonambiguous compact form. + gdb_test "print g_A.a" "$vhn = 1" + gdb_test "print g_A.x" "$vhn = 2" - gdb_test "ptype g_D" "type = class D : public B, public C \{$nl\[ \]*public:$nl\[ \]*int d;$nl\[ \]*int x;$nl.*\}" "ptype g_D" + # Print all members of g_B using fully qualified form. + gdb_test "print g_B.A::a" "$vhn = 3" + gdb_test "print g_B.A::x" "$vhn = 4" + gdb_test "print g_B.B::b" "$vhn = 5" + gdb_test "print g_B.B::x" "$vhn = 6" - gdb_test "ptype E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype E" + # Print members of g_B using nonambiguous compact form. + gdb_test "print g_B.a" "$vhn = 3" + gdb_test "print g_B.b" "$vhn = 5" + gdb_test "print g_B.x" "$vhn = 6" - gdb_test "ptype class E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype class E" + # Print all members of g_C using fully qualified form. + gdb_test "print g_C.A::a" "$vhn = 7" + gdb_test "print g_C.A::x" "$vhn = 8" + gdb_test "print g_C.C::c" "$vhn = 9" + gdb_test "print g_C.C::x" "$vhn = 10" - gdb_test "ptype g_E" "type = class E : public D \{$nl\[ \]*public:$nl\[ \]*int e;$nl\[ \]*int x;$nl.*\}" "ptype g_E" + # Print members of g_C using nonambiguous compact form. + gdb_test "print g_C.a" "$vhn = 7" + gdb_test "print g_C.c" "$vhn = 9" + gdb_test "print g_C.x" "$vhn = 10" } -# -# Multiple inheritance, print complete classes. -# - -proc test_print_mi_classes {} { - # Print all members of g_D. - - gdb_test "print g_D" ".* = \{\<(class |)B\> = \{\<(class |)A\> = \{a = 11, x = 12\}, b = 13, x = 14\}, \<(class |)C\> = \{\<(class |)A\> = \{a = 15, x = 16\}, c = 17, x = 18\}, d = 19, x = 20\}" "print g_D" +# Single inheritance, print complete classes. - # Print all members of g_E. +proc test_print_si_classes { } { + global vhn - gdb_test "print g_E" ".* = \{\<(class |)D\> = \{\<(class |)B\> = \{\<(class |)A\> = \{a = 21, x = 22\}, b = 23, x = 24\}, \<(class |)C\> = \{\<(class |)A\> = \{a = 25, x = 26\}, c = 27, x = 28\}, d = 29, x = 30\}, e = 31, x = 32\}" "print g_E" + # Print all members of g_A, g_B, g_C. + gdb_test "print g_A" "$vhn = \{a = 1, x = 2\}" + gdb_test "print g_B" "$vhn = \{<(class A|A)> = \{a = 3, x = 4\}, b = 5, x = 6\}" + gdb_test "print g_C" "$vhn = \{<(class A|A)> = \{a = 7, x = 8\}, c = 9, x = 10\}" } -# -# Single virtual inheritance, print individual members. -# +# Multiple inheritance, print individual members. -proc test_print_svi_members {} { +proc test_print_mi_members {} { global gdb_prompt - global decimal global nl + global vhn - # Print all members of g_vA. - - gdb_test "print g_vA.vA::va" ".* = 1" "print g_vA.vA::va" - - gdb_test "print g_vA.vA::vx" ".* = 2" "print g_vA.vA::vx" - - # Print members of g_vA using compact form. - - gdb_test "print g_vA.va" ".* = 1" "print g_vA.va" + # Print all members of g_A. + gdb_test "print g_A.A::a" "$vhn = 1" + gdb_test "print g_A.A::x" "$vhn = 2" - gdb_test "print g_vA.vx" ".* = 2" "print g_vA.vx" + # Print all members of g_B. + gdb_test "print g_B.A::a" "$vhn = 3" + gdb_test "print g_B.A::x" "$vhn = 4" + gdb_test "print g_B.B::b" "$vhn = 5" + gdb_test "print g_B.B::x" "$vhn = 6" - # Print all members of g_vB. + # Print all members of g_C. + gdb_test "print g_C.A::a" "$vhn = 7" + gdb_test "print g_C.A::x" "$vhn = 8" + gdb_test "print g_C.C::c" "$vhn = 9" + gdb_test "print g_C.C::x" "$vhn = 10" - send_gdb "print g_vB.vA::va\n" - gdb_expect { - -re ".* = 3$nl$gdb_prompt $" { pass "print g_vB.vA::va" } - -re ".*virtual baseclass botch.*$gdb_prompt $" { - # Does not happen with gcc cygnus-2.4.5-930828 - fail "print g_vB.vA::va (known bug with gcc cygnus-2.4.5-930417)" - # Many of the rest of these tests have the same problem. - return 0 + # Print all members of g_D. + # + # g_D.A::a and g_D.A::x are ambiguous member accesses, and gdb + # should detect these. There are no ways to PASS these tests + # because I don't know what the gdb message will be. -- chastain + # 2004-01-27. + + set name "print g_D.A::a" + gdb_test_multiple "print g_D.A::a" $name { + -re "$vhn = (15|11)$nl$gdb_prompt $" { + kfail "gdb/68" "print g_D.A::a" } - -re ".*$gdb_prompt $" { fail "print g_vB.vA::va" } - timeout { fail "print g_vB.vA::va (timeout)" ; return } } - gdb_test "print g_vB.vA::vx" ".* = 4" "print g_vB.vA::vx" - - gdb_test "print g_vB.vB::vb" ".* = 5" "print g_vB.vB::vb" - - gdb_test "print g_vB.vB::vx" ".* = 6" "print g_vB.vB::vx" - - # Print members of g_vB using compact form. - - gdb_test "print g_vB.va" ".* = 3" "print g_vB.va" - - gdb_test "print g_vB.vb" ".* = 5" "print g_vB.vb" - - gdb_test "print g_vB.vx" ".* = 6" "print g_vB.vx" + set name "print g_D.A::x" + gdb_test_multiple "print g_D.A::x" $name { + -re "$vhn = (16|12)$nl$gdb_prompt $" { + kfail "gdb/68" "print g_D.A::x" + } + } - # Print all members of g_vC. + gdb_test "print g_D.B::b" "$vhn = 13" + gdb_test "print g_D.B::x" "$vhn = 14" + gdb_test "print g_D.C::c" "$vhn = 17" + gdb_test "print g_D.C::x" "$vhn = 18" + gdb_test "print g_D.D::d" "$vhn = 19" + gdb_test "print g_D.D::x" "$vhn = 20" - gdb_test "print g_vC.vA::va" ".* = 7" "print g_vC.vA::va" + # Print all members of g_E. + # g_E.A::a and g_E.A::x are ambiguous. - gdb_test "print g_vC.vA::vx" ".* = 8" "print g_vC.vA::vx" + set name "print g_E.A::a" + gdb_test_multiple "print g_E.A::a" $name { + -re "$vhn = (21|25)$nl$gdb_prompt $" { + kfail "gdb/68" "print g_E.A::a" + } + } - gdb_test "print g_vC.vC::vc" ".* = 9" "print g_vC.vC::vc" + set name "print g_E.A::x" + gdb_test_multiple "print g_E.A::x" $name { + -re "$vhn = (26|22)$nl$gdb_prompt $" { + kfail "gdb/68" "print g_E.A::x" + } + } - gdb_test "print g_vC.vC::vx" ".* = 10" "print g_vC.vC::vx" + gdb_test "print g_E.B::b" "$vhn = 23" + gdb_test "print g_E.B::x" "$vhn = 24" + gdb_test "print g_E.C::c" "$vhn = 27" + gdb_test "print g_E.C::x" "$vhn = 28" + gdb_test "print g_E.D::d" "$vhn = 29" + gdb_test "print g_E.D::x" "$vhn = 30" + gdb_test "print g_E.E::e" "$vhn = 31" + gdb_test "print g_E.E::x" "$vhn = 32" +} - # Print members of g_vC using compact form. +# Multiple inheritance, print complete classes. - gdb_test "print g_vC.va" ".* = 7" "print g_vC.va" +proc test_print_mi_classes { } { + global vhn - gdb_test "print g_vC.vc" ".* = 9" "print g_vC.vc" + # Print all members of g_D. + gdb_test "print g_D" "$vhn = \{\<(class |)B\> = \{\<(class |)A\> = \{a = 11, x = 12\}, b = 13, x = 14\}, \<(class |)C\> = \{\<(class |)A\> = \{a = 15, x = 16\}, c = 17, x = 18\}, d = 19, x = 20\}" - gdb_test "print g_vC.vx" ".* = 10" "print g_vC.vx" + # Print all members of g_E. + gdb_test "print g_E" "$vhn = \{\<(class |)D\> = \{\<(class |)B\> = \{\<(class |)A\> = \{a = 21, x = 22\}, b = 23, x = 24\}, \<(class |)C\> = \{\<(class |)A\> = \{a = 25, x = 26\}, c = 27, x = 28\}, d = 29, x = 30\}, e = 31, x = 32\}" } +# Single inheritance, print anonymous unions. +# GDB versions prior to 4.14 entered an infinite loop when printing +# the type of a class containing an anonymous union, and they were also +# incapable of printing the member of an anonymous union. +# We test the printing of the member first, and perform the other tests +# only if the test succeeds, to avoid the infinite loop. # -# Single virtual inheritance, print type definitions. -# +# GDB HEAD 2004-01-27 with hp aCC A.03.45 crashes on the first test. +# -- chastain 2004-01-27 -proc test_ptype_vi {} { +proc test_print_anon_union {} { global gdb_prompt global ws global nl - global vbptr + global vhn - # This class does not use any C++-specific features, so it's fine for - # it to print as "struct". - send_gdb "ptype vA\n" - gdb_expect { - -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype vA" - } - -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" { - pass "ptype vA" - } - -re ".*$gdb_prompt $" { fail "ptype vA" } - timeout { fail "ptype vA (timeout)" ; return } - } + gdb_test "print g_anon_union.a" "$vhn = 2" "print anonymous union member" - # This class does not use any C++-specific features, so it's fine for - # it to print as "struct". - send_gdb "ptype class vA\n" - gdb_expect { - -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype class vA" - } - -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" { - pass "ptype class vA" + set name "print variable of type anonymous union" + gdb_test_multiple "print g_anon_union" $name { + -re "$vhn = \{one = 1, \{a = 2, b = 2\}\}$nl$gdb_prompt $" { + pass $name } - -re ".*$gdb_prompt $" { fail "ptype class vA" } - timeout { fail "ptype class vA (timeout)" ; return } } - # This class does not use any C++-specific features, so it's fine for - # it to print as "struct". - send_gdb "ptype g_vA\n" - gdb_expect { - -re "type = class vA \{$nl\[ \]*public:$nl\[ \]*int va;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype g_vA" - } - -re "type = struct vA \{$nl\[ \]*int va;$nl\[ \]*int vx;$nl\}$nl$gdb_prompt $" { - pass "ptype g_vA" - } - -re ".*$gdb_prompt $" { fail "ptype g_vA" } - timeout { fail "ptype g_vA (timeout)" ; return } - } + set re_class "class class_with_anon_union \{${ws}public:" + set re_fields "int one;${ws}" + set re_anon_union "union \{${ws}int a;${ws}long int b;${ws}\};" + set re_synth_gcc_23 "class_with_anon_union & operator=\\(class_with_anon_union const ?&\\);${ws}class_with_anon_union\\(class_with_anon_union const ?&\\);${ws}class_with_anon_union\\((void|)\\);" - send_gdb "ptype vB\n" - gdb_expect { - -re "ptype vB${nl}type = class vB : public virtual vA \{$nl private:${ws}vA \\*${vbptr}vA;$nl public:${ws}int vb;${ws}int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype vB" + set name "print type of anonymous union" + gdb_test_multiple "ptype g_anon_union" $name { + -re "type = $re_class${ws}$re_fields${ws}$re_anon_union$nl\}$nl$gdb_prompt $" { + pass $name } - -re "ptype vB${nl}type = class vB : public virtual vA \{$nl public:${ws}int vb;${ws}int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype vB (aCC)" + -re "type = $re_class${ws}$re_fields${ws}$re_anon_union${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" { + pass $name } - -re ".*$gdb_prompt $" { fail "ptype vB" } - timeout { fail "ptype vB (timeout)" } } +} - send_gdb "ptype class vB\n" - gdb_expect { - -re "type = class vB : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype class vB" - } - -re "type = class vB : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype class vB (aCC)" - } - -re ".*$gdb_prompt $" { fail "ptype class vB" } - timeout { fail "ptype class vB (timeout)" } - } - send_gdb "ptype g_vB\n" - gdb_expect { - -re "type = class vB : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype g_vB" - } - -re "type = class vB : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vb;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype g_vB (aCC)" - } - -re ".*$gdb_prompt $" { fail "ptype g_vB" } - timeout { fail "ptype g_vB (timeout)" } - } +# Single virtual inheritance, print individual members. - send_gdb "ptype vC\n" - gdb_expect { - -re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype vC" - } - -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype vC (aCC)" - } - -re ".*$gdb_prompt $" { fail "ptype vC" } - timeout { fail "ptype vC (timeout)" } - } +proc test_print_svi_members { } { + global vhn - send_gdb "ptype class vC\n" - gdb_expect { - -re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype class vC" - } - -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype class vC (aCC)" - } - -re ".*$gdb_prompt $" { fail "ptype class vC" } - timeout { fail "ptype class vC (timeout)" } - } + # Print all members of g_vA. + gdb_test "print g_vA.vA::va" "$vhn = 1" + gdb_test "print g_vA.vA::vx" "$vhn = 2" - send_gdb "ptype g_vC\n" - gdb_expect { - -re "type = class vC : public virtual vA \{$nl\[ \]*private:$nl\[ \]*vA \\*${vbptr}vA;$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype g_vC" - } - -re "type = class vC : public virtual vA \{$nl\[ \]*public:$nl\[ \]*int vc;$nl\[ \]*int vx;$nl.*\}$nl$gdb_prompt $" { - pass "ptype g_vC (aCC)" - } - -re ".*$gdb_prompt $" { fail "ptype g_vC" } - timeout { fail "ptype g_vC (timeout)" } - } + # Print members of g_vA using compact form. + gdb_test "print g_vA.va" "$vhn = 1" + gdb_test "print g_vA.vx" "$vhn = 2" + + # Print all members of g_vB. + gdb_test "print g_vB.vA::va" "$vhn = 3" + gdb_test "print g_vB.vA::vx" "$vhn = 4" + gdb_test "print g_vB.vB::vb" "$vhn = 5" + gdb_test "print g_vB.vB::vx" "$vhn = 6" + + # Print members of g_vB using compact form. + gdb_test "print g_vB.va" "$vhn = 3" + gdb_test "print g_vB.vb" "$vhn = 5" + gdb_test "print g_vB.vx" "$vhn = 6" + + # Print all members of g_vC. + gdb_test "print g_vC.vA::va" "$vhn = 7" + gdb_test "print g_vC.vA::vx" "$vhn = 8" + gdb_test "print g_vC.vC::vc" "$vhn = 9" + gdb_test "print g_vC.vC::vx" "$vhn = 10" + + # Print members of g_vC using compact form. + gdb_test "print g_vC.va" "$vhn = 7" "print g_vC.va" + gdb_test "print g_vC.vc" "$vhn = 9" "print g_vC.vc" + gdb_test "print g_vC.vx" "$vhn = 10" "print g_vC.vx" } -# # Single virtual inheritance, print complete classes. -# -proc test_print_svi_classes {} { +proc test_print_svi_classes { } { global gdb_prompt global hex - global decimal global nl - global vbptr + global vhn # Print all members of g_vA. - - gdb_test "print g_vA" ".* = \{va = 1, vx = 2\}" "print g_vA" + gdb_test "print g_vA" "$vhn = \{va = 1, vx = 2\}" # Print all members of g_vB. - - send_gdb "print g_vB\n" - gdb_expect { - -re ".* = \{\<class vA\> = \{va = 3, vx = 4\}, vb = 5, vx = 6, Virtual table at $hex\}$nl$gdb_prompt $" { - pass "print g_vB (aCC)" - } - -re ".* = \{\<class vA\> = \{va = 3, vx = 4\}, vb = 5, vx = 6, __vfp = $hex\}$nl$gdb_prompt $" { - pass "print g_vB (aCC)" - } - -re ".* = \{\<vA\> = \{va = 3, vx = 4\}, ${vbptr}vA = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" { - pass "print g_vB" + set re_vbptr_2 "(_vb.2vA|_vb.vA)" + set re_vbptr_3 "_vptr.vB" + + set name "print g_vB" + gdb_test_multiple "print g_vB" $name { + -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_2 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name (FIXME v3 vtbl ptr)" + } + -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = $hex <VTT for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + pass $name } - -re ".* = \{\<vA\> = \{va = 3, vx = 4\}, _vptr.vB = $hex, vb = 5, vx = 6\}$nl$gdb_prompt $" { - pass "print g_vB (FIXME v3 vtbl ptr)" - } - -re ".* = \{\<vA\> = \{va = 3, vx = 4\}, _vptr.vB = $hex <VTT for vB>, vb = 5, vx = 6\}$nl$gdb_prompt $" { - # Happens with gcc 3.3 -gstabs+ - # Does not happen with gcc 3.2.3 -gstabs+. - # Does not happen gcc HEAD%20030624 (pre-3.4) -gstabs+. - # -- chastain 2003-06-29 - pass "print g_vB" - } - - -re ".*invalid address 0x0.*$gdb_prompt $" { - # Does not happen with gcc cygnus-2.4.5-930828 - fail "print g_vB (known bug with gcc cygnus-2.4.5-930417)" - # Many of the rest of these tests have the same problem. - return 0 - } - -re ".*$gdb_prompt $" { fail "print g_vB" } - timeout { fail "print g_vB (timeout)" ; return } } # Print all members of g_vC. - - send_gdb "print g_vC\n" - gdb_expect { - -re ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, Virtual table at $hex\}$nl$gdb_prompt $" { - pass "print g_vC (aCC)" - } - -re ".* = \{\<class vA\> = \{va = 7, vx = 8\}, vc = 9, vx = 10, __vfp = $hex\}$nl$gdb_prompt $" { - pass "print g_vC (aCC)" + set re_vbptr_2 "(_vb.2vA|_vb.vA)" + set re_vbptr_3 "_vptr.vC" + + set name "print g_vC" + gdb_test_multiple "print g_vC" $name { + -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_2 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + pass $name + } + -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name (FIXME v3 vtbl ptr)" + } + -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = $hex <VTT for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + pass $name } - -re ".* = \{\<vA\> = \{va = 7, vx = 8\}, ${vbptr}vA = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" { - pass "print g_vC" - } - -re ".* = \{\<vA\> = \{va = 7, vx = 8\}, _vptr.vC = $hex, vc = 9, vx = 10\}$nl$gdb_prompt $" { - pass "print g_vC (FIXME v3 vtbl ptr)" - } - -re ".* = \{\<vA\> = \{va = 7, vx = 8\}, _vptr.vC = $hex <VTT for vC>, vc = 9, vx = 10\}$nl$gdb_prompt $" { - # Happens with gcc 3.3 -gstabs+ - # Does not happen with gcc 3.2.3 -gstabs+. - # Does not happen gcc HEAD%20030624 (pre-3.4) -gstabs+. - # -- chastain 2003-06-29 - pass "print g_vC" - } - -re ".*$gdb_prompt $" { fail "print g_vC" } - timeout { fail "print g_vC (timeout)" } } } -# # Multiple virtual inheritance, print individual members. -# -proc test_print_mvi_members {} { - global gdb_prompt - global decimal - global nl +proc test_print_mvi_members { } { + global vhn # Print all members of g_vD. - - send_gdb "print g_vD.vA::va\n" - gdb_expect { - -re ".* = 19$nl$gdb_prompt $" { pass "print g_vD.vA::va" } - -re ".*virtual baseclass botch.*$gdb_prompt $" { - # Does not happen with gcc cygnus-2.4.5-930828 - fail "print g_vD.vA::va (known bug with gcc cygnus-2.4.5-930417)" - # Many of the rest of these tests have the same problem. - return 0 - } - -re ".*$gdb_prompt $" { fail "print g_vD.vA::va" } - timeout { fail "print g_vD.vA::va (timeout)" ; return } - } - - gdb_test "print g_vD.vA::vx" ".* = 20" "print g_vD.vA::vx" - - gdb_test "print g_vD.vB::vb" ".* = 21" "print g_vD.vB::vb" - - gdb_test "print g_vD.vB::vx" ".* = 22" "print g_vD.vB::vx" - - gdb_test "print g_vD.vC::vc" ".* = 23" "print g_vD.vC::vc" - - gdb_test "print g_vD.vC::vx" ".* = 24" "print g_vD.vC::vx" - - gdb_test "print g_vD.vD::vd" ".* = 25" "print g_vD.vD::vd" - - gdb_test "print g_vD.vD::vx" ".* = 26" "print g_vD.vD::vx" + gdb_test "print g_vD.vA::va" "$vhn = 19" + gdb_test "print g_vD.vA::vx" "$vhn = 20" + gdb_test "print g_vD.vB::vb" "$vhn = 21" + gdb_test "print g_vD.vB::vx" "$vhn = 22" + gdb_test "print g_vD.vC::vc" "$vhn = 23" + gdb_test "print g_vD.vC::vx" "$vhn = 24" + gdb_test "print g_vD.vD::vd" "$vhn = 25" + gdb_test "print g_vD.vD::vx" "$vhn = 26" # Print all members of g_vE. - - gdb_test "print g_vE.vA::va" ".* = 0" "print g_vE.vA::va" - - gdb_test "print g_vE.vA::vx" ".* = 0" "print g_vE.vA::vx" - - gdb_test "print g_vE.vB::vb" ".* = 0" "print g_vE.vB::vb" - - gdb_test "print g_vE.vB::vx" ".* = 0" "print g_vE.vB::vx" - - gdb_test "print g_vE.vC::vc" ".* = 0" "print g_vE.vC::vc" - - gdb_test "print g_vE.vC::vx" ".* = 0" "print g_vE.vC::vx" - - gdb_test "print g_vE.vD::vd" ".* = 0" "print g_vE.vD::vd" - - gdb_test "print g_vE.vD::vx" ".* = 0" "print g_vE.vD::vx" - - gdb_test "print g_vE.vE::ve" ".* = 27" "print g_vE.vE::ve" - - gdb_test "print g_vE.vE::vx" ".* = 28" "print g_vE.vE::vx" + gdb_test "print g_vE.vA::va" "$vhn = 0" + gdb_test "print g_vE.vA::vx" "$vhn = 0" + gdb_test "print g_vE.vB::vb" "$vhn = 0" + gdb_test "print g_vE.vB::vx" "$vhn = 0" + gdb_test "print g_vE.vC::vc" "$vhn = 0" + gdb_test "print g_vE.vC::vx" "$vhn = 0" + gdb_test "print g_vE.vD::vd" "$vhn = 0" + gdb_test "print g_vE.vD::vx" "$vhn = 0" + gdb_test "print g_vE.vE::ve" "$vhn = 27" + gdb_test "print g_vE.vE::vx" "$vhn = 28" } -# -# Multiple virtual inheritance, print type definitions. -# +# Multiple virtual inheritance, print complete classes. -proc test_ptype_mvi {} { +proc test_print_mvi_classes { } { global gdb_prompt + global hex global ws global nl - global vbptr - - send_gdb "ptype vD\n" - gdb_expect { - -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" { - pass "ptype vD" - } - -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" { - pass "ptype vD" - } - -re ".*$gdb_prompt $" { fail "ptype vD" } - timeout { fail "(timeout) ptype vD" } - } - - send_gdb "ptype class vD\n" - gdb_expect { - -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" { - pass "ptype class vD" - } - -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;.*\}.*$gdb_prompt $" { - pass "ptype class vD" - } - -re ".*$gdb_prompt $" { fail "ptype class vD" } - timeout { fail "(timeout) ptype class vD" } - } - - send_gdb "ptype g_vD\n" - gdb_expect { - -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*${vbptr}vC;${ws}vB \\*${vbptr}vB;${ws}public:${ws}int vd;${ws}int vx;$nl.*\}.*$gdb_prompt $" { - pass "ptype g_vD" - } - -re ".*class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;\r\n.*\}.*$gdb_prompt $" { - pass "ptype g_vD" - } - -re ".*$gdb_prompt $" { fail "ptype g_vD" } - timeout { fail "(timeout) ptype g_vD" } - } - - send_gdb "ptype vE\n" - gdb_expect { - -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" { - pass "ptype vE" - } - -re ".*class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" { - pass "ptype vE" - } - -re ".*$gdb_prompt $" { fail "ptype vE" } - timeout { fail "(timeout) ptype vE" } - } + global vhn - send_gdb "ptype class vE\n" - gdb_expect { - -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" { - pass "ptype class vE" - } - -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" { - pass "ptype class vE" - } - -re ".*$gdb_prompt $" { fail "ptype class vE" } - timeout { fail "(timeout) ptype class vE" } - } + # Virtual base pointers for everybody. - send_gdb "ptype g_vE\n" - gdb_expect { - -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;$nl.*\}.*$gdb_prompt $" { - pass "ptype g_vE" - } - -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;\r\n.*\}.*$gdb_prompt $" { - pass "ptype g_vE" - } - -re ".*$gdb_prompt $" { fail "ptype g_vE" } - timeout { fail "(timeout) ptype g_vE" } - } -} - -# -# Multiple virtual inheritance, print complete classes. -# - -proc test_print_mvi_classes {} { - global gdb_prompt - global hex - global decimal - global nl - global vbptr + set re_vbptr_2_vA "(_vb.2vA|_vb.vA)" + set re_vbptr_2_vB "(_vb.2vB|_vb.vB)" + set re_vbptr_2_vC "(_vb.2vC|_vb.vC)" + set re_vbptr_2_vD "(_vb.2vD|_vb.vD)" + set re_vbptr_3_vA "_vptr.vA" + set re_vbptr_3_vB "_vptr.vB" + set re_vbptr_3_vC "_vptr.vC" + set re_vbptr_3_vD "_vptr.vD" + set re_vbptr_3_vE "_vptr.vE" # Print all members of g_vD. - send_gdb "print g_vD\n" - gdb_expect { - -re ".* = \{\<class vB\> = \{\<class vA\> = \{va = 19, vx = 20\}, vb = 21, vx = 22, Virtual table at $hex\}, \<class vC\> = \{vc = 23, vx = 24, Virtual table at $hex\}, vd = 25, vx = 26, Virtual table at $hex\}$nl$gdb_prompt $" { - pass "print g_vD (aCC)" - } - -re ".* = \{\<class vB\> = \{\<class vA\> = \{va = 19, vx = 20\}, vb = 21, vx = 22, __vfp = $hex\}, \<class vC\> = \{vc = 23, vx = 24, __vfp = $hex\}, vd = 25, vx = 26, __vfp = $hex\}$nl$gdb_prompt $" { - pass "print g_vD (aCC)" + set name "print g_vD" + gdb_test_multiple "print g_vD" $name { + -re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_2_vA = $hex, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_2_vA = $hex, vc = 23, vx = 24\}, $re_vbptr_2_vC = $hex, $re_vbptr_2_vB = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + pass $name } - -re ".* = \{\<vB\> = \{\<vA\> = \{va = 19, vx = 20\}, ${vbptr}vA = $hex, vb = 21, vx = 22\}, \<vC\> = \{${vbptr}vA = $hex, vc = 23, vx = 24\}, ${vbptr}vC = $hex, ${vbptr}vB = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { - pass "print g_vD" + -re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_3_vB = $hex, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_3_vC = $hex, vc = 23, vx = 24\}, $re_vbptr_3_vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc HEAD 2004-01-21 -gdwarf-2 + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name (FIXME v3 vtbl ptr)" } - -re ".* = \{\<vB\> = \{\<vA\> = \{va = 19, vx = 20\}, _vptr.vB = $hex, vb = 21, vx = 22\}, \<vC\> = \{_vptr.vC = $hex, vc = 23, vx = 24\}, _vptr.vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { - pass "print g_vD (FIXME v3 vtbl ptr)" + -re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_3_vB = $hex, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_3_vC = $hex <VTT for vD>, vc = 23, vx = 24\}, $re_vbptr_3_vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gstabs+ + pass "$name" } - -re ".* = \{\<vB\> = \{\<vA\> = \{va = 19, vx = 20\}, _vptr.vB = $hex, vb = 21, vx = 22\}, \<vC\> = \{_vptr.vC = $hex <VTT for vD>, vc = 23, vx = 24\}, _vptr.vD = $hex, vd = 25, vx = 26\}$nl$gdb_prompt $" { - # Happens with gcc 3.3 -gstabs+ - # Does not happen with gcc 3.2.3 -gstabs+. - # Does not happen gcc HEAD%20030624 (pre-3.4) -gstabs+. - # -- chastain 2003-06-29 - pass "print g_vD" - } - -re ".*invalid address 0x0.*$gdb_prompt $" { - # Does not happen with gcc cygnus-2.4.5-930828 - fail "print g_vD (known bug with gcc cygnus-2.4.5-930417)" - # Many of the rest of these tests have the same problem. - return 0 - } - -re ".*$gdb_prompt $" { fail "print g_vD" } - timeout { fail "print g_vD (timeout)" ; return } } # Print all members of g_vE. - send_gdb "print g_vE\n" - gdb_expect { - -re ".* = \{\<class vD\> = \{\<class vB\> = \{\<class vA\> = \{va = 0, vx = 0\}, vb = 0, vx = 0, Virtual table at $hex\}, \<class vC\> = \{vc = 0, vx = 0, Virtual table at $hex\}, vd = 0, vx = 0, Virtual table at $hex\}, ve = 27, vx = 28, Virtual table at $hex\}$nl$gdb_prompt $" { - pass "print g_vE (aCC)" - } - -re ".* = \{\<class vD\> = \{\<class vB\> = \{\<class vA\> = \{va = 0, vx = 0\}, vb = 0, vx = 0, __vfp = $hex\}, \<class vC\> = \{vc = 0, vx = 0, __vfp = $hex\}, vd = 0, vx = 0, __vfp = $hex\}, ve = 27, vx = 28, __vfp = $hex\}$nl$gdb_prompt $" { - pass "print g_vE (aCC)" + set name "print g_vE" + gdb_test_multiple "print g_vE" $name { + -re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_2_vA = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_2_vA = $hex, vc = 0, vx = 0\}, $re_vbptr_2_vC = $hex, $re_vbptr_2_vB = $hex, vd = 0, vx = 0\}, $re_vbptr_2_vD = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { + # gcc 2.95.3 -gdwarf-2 + # gcc 2.95.3 -gstabs+ + pass $name } - -re ".* = \{\<vD\> = \{\<vB\> = \{\<vA\> = \{va = 0, vx = 0\}, ${vbptr}vA = $hex, vb = 0, vx = 0\}, \<vC\> = \{${vbptr}vA = $hex, vc = 0, vx = 0\}, ${vbptr}vC = $hex, ${vbptr}vB = $hex, vd = 0, vx = 0\}, ${vbptr}vD = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { - pass "print g_vE" + -re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = $hex, vc = 0, vx = 0\}, $re_vbptr_3_vD = $hex, vd = 0, vx = 0\}, $re_vbptr_3_vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { + # gcc 3.3.2 -gdwarf-2 + # gcc 3.3.2 -gstabs+ + # gcc HEAD 2004-01-21 -gdwarf-2 + # gcc HEAD 2004-01-21 -gstabs+ + pass "$name (FIXME v3 vtbl ptr)" } - -re ".* = \{\<vD\> = \{\<vB\> = \{\<vA\> = \{va = 0, vx = 0\}, _vptr.vB = $hex *(\<VTT for vD\>)?, vb = 0, vx = 0\}, \<vC\> = \{_vptr.vC = $hex *(\<VTT for vD\>)?, vc = 0, vx = 0\}, _vptr.vD = $hex, vd = 0, vx = 0\}, _vptr.vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { - pass "print g_vE (FIXME v3 vtbl ptr)" + -re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = $hex, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = $hex <VTT for vD>, vc = 0, vx = 0\}, $re_vbptr_3_vD = $hex, vd = 0, vx = 0\}, $re_vbptr_3_vE = $hex, ve = 27, vx = 28\}$nl$gdb_prompt $" { + # gcc 3.2.7-rh -gstabs+ + pass "$name (FIXME v3 vtbl ptr)" } - -re ".*$gdb_prompt $" { fail "print g_vE" } - timeout { fail "print g_vE (timeout)" } } } -proc do_tests {} { +proc do_tests { } { global prms_id global bug_id global subdir @@ -980,10 +1037,9 @@ proc do_tests {} { gdb_test "set language c++" "" gdb_test "set width 0" "" - # Get the debug format for the compiled test case. - - if { ![ runto_main] } { - gdb_suppress_tests; + if { ![runto_main] } then { + perror "couldn't run to main" + return } test_ptype_si @@ -991,10 +1047,9 @@ proc do_tests {} { test_ptype_vi test_ptype_mvi - gdb_stop_suppressing_tests; - - if { ![ runto 'inheritance2' ] } { - gdb_suppress_tests; + if { ![runto 'inheritance2'] } then { + perror "couldn't run to inheritance2" + return } test_print_si_members @@ -1003,10 +1058,9 @@ proc do_tests {} { test_print_mi_classes test_print_anon_union - gdb_stop_suppressing_tests; - - if { ![ runto 'inheritance4' ] } { - gdb_suppress_tests; + if { ![runto 'inheritance4'] } { + perror "couldn't run to inheritance4" + return } test_print_svi_members diff --git a/gdb/testsuite/gdb.cp/local.exp b/gdb/testsuite/gdb.cp/local.exp index f4e8d22..5cd2ee9 100644 --- a/gdb/testsuite/gdb.cp/local.exp +++ b/gdb/testsuite/gdb.cp/local.exp @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # tests for local variables # Written by Satish Pai <pai@apollo.hp.com> 1997-07-08 # Cleaned by Michael Chastain <mec@shout.net> 2002-04-08 @@ -73,53 +70,104 @@ if ![runto 'marker1'] then { gdb_test "up" ".*foobar.*" "up from marker1" -# Local classes in g++ get names like "main.1::InnerLocal", just like local -# static variables. Some targets use "___" instead of ".". +set sep "(\[.\]|___)\[0-9\]" -# --- -# Pattern 1: -# PASS -# dwarf-2 -# gcc 2.95.3 +# ptype on a local variable. # -# Pattern 2: -# FAIL -# This has a duplicate "char loc_foo" line. This is a bug. -# Historically this has been an XFAIL. -# dwarf-2 -# gcc 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD +# This test has six arms. The first three arms accept normal output: +# no synthetic methods; synthetic methods before user methods; +# synthetic methods after user methods. # -# Pattern 3: -# PASS -# stabs+ -# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD +# The next two arms accept "foobar__Fi.0::Local" instead of "Local". +# This is a bug. It happens in various places with various versions of +# gcc and gdb and various debugging types. # -# Pattern 4: -# This an old pattern from the hppa aCC version of this file. -# I left it alone. +# The last arm accepts the user methods in duplicate. This bug happens +# with gcc 3.3.2 -gdwarf-2, and has been fixed in gcc HEAD 2004-01-22. # -# chastain 2002-04-08 +# -- chastain 2004-01-24 -# pattern #5 -# PASS -# stabs+ -# gcc HEAD abi-2 -# -# chastain 2004-01-02 +set re_class "((struct|class) Local \{${ws}public:|struct Local \{)" +set re_fields "int loc1;" +set re_methods "char loc_foo\\(char\\);" +set re_synth_gcc_23 "Local & operator=\\(Local const ?&\\);${ws}Local\\(Local const ?&\\);${ws}Local\\((void|)\\);" -set sep "(\[.\]|___)\[0-9\]" +set XX_class "((struct|class) foobar__Fi.0::Local \{${ws}public:|struct foobar__Fi.0:Local \{)" +set XX_synth_gcc_2 "Local & operator=\\(foobar__Fi.0::Local const ?&\\);${ws}Local\\(foobar__Fi.0::Local const ?&\\);${ws}Local\\((void|)\\);" +set YY_methods "$re_methods${ws}$re_methods" -send_gdb "ptype Local\n" -gdb_expect { - -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" } - -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*char loc_foo\\((const *|)char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { - kfail "gdb/483" "ptype Local" - } - -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*Local & operator *=\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((void|)\\);\[\r\n\t \]*char loc_foo\\(char\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" } - -re "type = class Local \{\r\n\[\t \]*public:\r\n\[\t \]*int loc1;\r\n\r\n\[\t \]*char loc_foo\\(char\\);\r\n\[\t \]*\\(Local at.*local\\.cc:\[0-9\]*\\)\r\n\}.*$gdb_prompt $" { xpass "ptype Local (old aCC)" } - -re "type = class Local \{\[\r\n\t \]*public:\[\r\n\t \]*int loc1;\[\r\n\t \]*char loc_foo\\(char\\);\[\r\n\t \]*Local & operator *=\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((foobar__Fi${sep}::|)Local const *&\\);\[\r\n\t \]*Local\\((void|)\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype Local" } - -re ".*$gdb_prompt $" { fail "ptype Local" } - timeout { fail "(timeout) ptype Local" } +set name "ptype l" +gdb_test_multiple "ptype l" $name { + -re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" { + # gdb 6.0, gcc 2.95.3, dwarf-2 + # gdb 6.0, gcc HEAD 2004-01-22, dwarf-2 + # gdb HEAD 2004-01-23, gcc HEAD 2004-01,22, dwarf-2 + pass "$name" + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods$nl\}$nl$gdb_prompt $" { + # gdb 6.0, gcc 3.3.2, stabs+ + # gdb HEAD 2004-01-23, gcc 3.3.2, stabs+ + pass "$name" + } + -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23${ws}$nl\}$nl$gdb_prompt $" { + # gdb 6.0, gcc HEAD 2004-01-22, stabs+ + # gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, stabs+ + pass "$name" + } + -re "type = $XX_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" { + # gdb HEAD 2004-01-23, gcc 2.95.3, dwarf-2 + kfail "gdb/1516" "$name" + } + -re "type = ($re_class|$XX_class)${ws}$re_fields${ws}($re_synth_gcc_23|$XX_synth_gcc_2)${ws}$re_methods$nl\}$nl$gdb_prompt $" { + # gdb 6.0, gcc 2.95.3, stabs+ + # gdb HEAD 2004-01-23, gcc 2.95.3, stabs+ + kfail "gdb/1516" "$name" + } + -re "type = ($re_class|$XX_class)${ws}$re_fields${ws}$YY_methods$nl\}$nl$gdb_prompt $" { + # gdb 6.0, gcc 3.3.2, dwarf-2 + # gdb HEAD 2004-01-23, gcc 3.2.2, dwarf-2 + kfail "gdb/483" "$name" + } +} + +# This is the same test with "ptype Local" (the type name) +# instead of "ptype l" (the variable name). + +set name "ptype Local" +gdb_test_multiple "ptype Local" $name { + -re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" { + # gdb 6.0, gcc 2.95.3, dwarf-2 + # gdb 6.0, gcc HEAD 2004-01-22, dwarf-2 + # gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, dwarf-2 + pass "$name" + } + -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods$nl\}$nl$gdb_prompt $" { + # gdb 6.0, gcc 3.3.2, stabs+ + # gdb HEAD 2004-01-23, gcc 3.3.2, stabs+ + pass "$name" + } + -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23${ws}$nl\}$nl$gdb_prompt $" { + # gdb 6.0, gcc HEAD 2004-01-22, stabs+ + # gdb HEAD 2004-01-23, gcc HEAD 2004-01-22, stabs+ + pass "$name" + } + -re "type = $XX_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" { + kfail "gdb/1516" "$name" + } + -re "type = ($re_class|$XX_class)${ws}$re_fields${ws}($re_synth_gcc_23|$XX_synth_gcc_2)${ws}$re_methods$nl\}$nl$gdb_prompt $" { + # gdb 6.0, gcc 2.95.3, stabs+ + # gdb HEAD 2004-01-23, gcc 2.95.3, stabs+ + kfail "gdb/1516" "$name" + } + -re "type = ($re_class|$XX_class)${ws}$re_fields${ws}$YY_methods$nl\}$nl$gdb_prompt $" { + # gdb 6.0, gcc 3.3.2, dwarf-2 + # gdb HEAD 2004-01-23, gcc 3.2.2, dwarf-2 + kfail "gdb/483" "$name" + } + -re "No symbol \"Local\" in current context.$nl$gdb_prompt $" { + # gdb HEAD 2004-01-23, gcc 2.95.3, dwarf-2 + fail "$name" + } } gdb_test "break marker2" diff --git a/gdb/testsuite/gdb.cp/maint.exp b/gdb/testsuite/gdb.cp/maint.exp index 710e14a..fd93333 100644 --- a/gdb/testsuite/gdb.cp/maint.exp +++ b/gdb/testsuite/gdb.cp/maint.exp @@ -1,4 +1,4 @@ -# Copyright 2003 Free Software Foundation Inc. +# Copyright 2003, 2004 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 @@ -14,9 +14,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file tests C++-specific maintenance commands and help on those. diff --git a/gdb/testsuite/gdb.cp/member-ptr.cc b/gdb/testsuite/gdb.cp/member-ptr.cc index 8851a85..e668c46 100644 --- a/gdb/testsuite/gdb.cp/member-ptr.cc +++ b/gdb/testsuite/gdb.cp/member-ptr.cc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1998, 1999 Free Software Foundation, Inc. + Copyright 1998, 1999, 2004 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 @@ -15,9 +15,9 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + - Please email any bugs, comments, and/or additions to this file to: - bug-gdb@prep.ai.mit.edu */ extern "C" { #include <stdio.h> diff --git a/gdb/testsuite/gdb.cp/member-ptr.exp b/gdb/testsuite/gdb.cp/member-ptr.exp index 83a70a0..f6a9d40 100644 --- a/gdb/testsuite/gdb.cp/member-ptr.exp +++ b/gdb/testsuite/gdb.cp/member-ptr.exp @@ -16,9 +16,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # Tests for pointer-to-member support # Written by Satish Pai <pai@apollo.hp.com> 1997-08-19 # Rewritten by Michael Chastain <mec.gnu@mindspring.com> 2004-01-11 diff --git a/gdb/testsuite/gdb.cp/method.exp b/gdb/testsuite/gdb.cp/method.exp index 0e8e485..87666d8 100644 --- a/gdb/testsuite/gdb.cp/method.exp +++ b/gdb/testsuite/gdb.cp/method.exp @@ -14,9 +14,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # tests for misc. C++ method stuff # Written by Satish Pai <pai@apollo.hp.com> 1997-07-08 diff --git a/gdb/testsuite/gdb.cp/misc.exp b/gdb/testsuite/gdb.cp/misc.exp index a2d122f..2758cd0 100644 --- a/gdb/testsuite/gdb.cp/misc.exp +++ b/gdb/testsuite/gdb.cp/misc.exp @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file was written by Fred Fish. (fnf@cygnus.com) if $tracelevel then { diff --git a/gdb/testsuite/gdb.cp/namespace.cc b/gdb/testsuite/gdb.cp/namespace.cc index 6a68373..ee55168 100644 --- a/gdb/testsuite/gdb.cp/namespace.cc +++ b/gdb/testsuite/gdb.cp/namespace.cc @@ -97,6 +97,13 @@ namespace C }; }; + void ensureRefs () { + // NOTE (2004-04-23, carlton): This function is here only to make + // sure that GCC 3.4 outputs debug info for these classes. + static CClass *c = new CClass(); + static CClass::NestedClass *n = new CClass::NestedClass(); + } + namespace { int cX = 6; diff --git a/gdb/testsuite/gdb.cp/namespace.exp b/gdb/testsuite/gdb.cp/namespace.exp index eb03a3e..4b3f1e2 100644 --- a/gdb/testsuite/gdb.cp/namespace.exp +++ b/gdb/testsuite/gdb.cp/namespace.exp @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # tests for namespaces # Originally written by Satish Pai <pai@apollo.hp.com> 1997-07-23 diff --git a/gdb/testsuite/gdb.cp/namespace1.cc b/gdb/testsuite/gdb.cp/namespace1.cc index 5d66810..c3ad692 100644 --- a/gdb/testsuite/gdb.cp/namespace1.cc +++ b/gdb/testsuite/gdb.cp/namespace1.cc @@ -13,9 +13,9 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + - Please email any bugs, comments, and/or additions to this file to: - bug-gdb@prep.ai.mit.edu */ namespace C { @@ -24,6 +24,12 @@ namespace C int z; }; + void ensureOtherRefs () { + // NOTE (2004-04-23, carlton): This function is here only to make + // sure that GCC 3.4 outputs debug info for this class. + static OtherFileClass *c = new OtherFileClass(); + } + namespace { int cXOtherFile = 29; }; diff --git a/gdb/testsuite/gdb.cp/overload.cc b/gdb/testsuite/gdb.cp/overload.cc index 56afc96..a41e14d 100644 --- a/gdb/testsuite/gdb.cp/overload.cc +++ b/gdb/testsuite/gdb.cp/overload.cc @@ -53,6 +53,31 @@ int intToChar (char c) void marker1() {} +// Now test how overloading and namespaces interact. + +class dummyClass {}; + +dummyClass dummyInstance; + +int overloadNamespace(int i) +{ + return 1; +} + +int overloadNamespace(dummyClass d) +{ + return 2; +} + +namespace XXX { + int overloadNamespace (char c) + { + return 3; + } + + void marker2() {} +} + int main () { char arg2 = 2; @@ -81,7 +106,8 @@ int main () intToChar(1); marker1(); // marker1-returns-here - return 0; // marker1-returns-here + XXX::marker2(); // marker1-returns-here + return 0; } foo::foo (int i) { ifoo = i; ccpfoo = NULL; } diff --git a/gdb/testsuite/gdb.cp/overload.exp b/gdb/testsuite/gdb.cp/overload.exp index 2925b50..b09c58e 100644 --- a/gdb/testsuite/gdb.cp/overload.exp +++ b/gdb/testsuite/gdb.cp/overload.exp @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # written by Elena Zannoni (ezannoni@cygnus.com) # Rewritten by Michael Chastain <mec.gnu@mindspring.com> @@ -296,6 +293,21 @@ gdb_test "list \"foo::overloadfnarg(int, int (*)(int))\"" \ "int foo::overloadfnarg.*\\(int arg, int \\(\\*foo\\) \\(int\\)\\).*" \ "list overloaded function with function ptr args - quotes around argument" +# Now some tests to see how overloading and namespaces interact. + +gdb_test "print overloadNamespace(1)" ".\[0-9\]* = 1" +gdb_test "print overloadNamespace('a')" ".\[0-9\]* = 1" +gdb_test "print overloadNamespace(dummyInstance)" ".\[0-9\]* = 2" + +if ![runto 'XXX::marker2'] then { + perror "couldn't run to XXX::marker2" + continue +} + +gdb_test "print overloadNamespace(1)" ".\[0-9\]* = 3" "print overloadNamespace(1) in XXX" +gdb_test "print overloadNamespace('a')" ".\[0-9\]* = 3" "print overloadNamespace('a') in XXX" +gdb_test "print overloadNamespace(dummyInstance)" ".\[0-9\]* = 2" "print overloadNamespace(dummyInstance) in XXX" + # One last mysterious test. # I wonder what this is for? diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp index 043243d..b6dfa5c 100644 --- a/gdb/testsuite/gdb.cp/ovldbreak.exp +++ b/gdb/testsuite/gdb.cp/ovldbreak.exp @@ -1,4 +1,4 @@ -# Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. +# Copyright (C) 1998, 1999, 2001, 2004 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 @@ -14,9 +14,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # written by Elena Zannoni (ezannoni@cygnus.com) # modified by Michael Chastain (chastain@redhat.com) diff --git a/gdb/testsuite/gdb.cp/psmang.exp b/gdb/testsuite/gdb.cp/psmang.exp index 31dd346..b137379 100644 --- a/gdb/testsuite/gdb.cp/psmang.exp +++ b/gdb/testsuite/gdb.cp/psmang.exp @@ -1,4 +1,4 @@ -# Copyright 2002 Free Software Foundation, Inc. +# Copyright 2002, 2004 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 @@ -14,9 +14,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file is part of the gdb testsuite # Looking up methods by name, in programs with multiple compilation units. diff --git a/gdb/testsuite/gdb.cp/ref-types.exp b/gdb/testsuite/gdb.cp/ref-types.exp index 98dc2d6..764ba8b 100644 --- a/gdb/testsuite/gdb.cp/ref-types.exp +++ b/gdb/testsuite/gdb.cp/ref-types.exp @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # written by Elena Zannoni (ezannoni@cygnus.com) if $tracelevel then { diff --git a/gdb/testsuite/gdb.cp/rtti.exp b/gdb/testsuite/gdb.cp/rtti.exp index 1241665..0a8a2d7 100644 --- a/gdb/testsuite/gdb.cp/rtti.exp +++ b/gdb/testsuite/gdb.cp/rtti.exp @@ -46,8 +46,9 @@ set srcfile2 "${srcdir}/${subdir}/${testfile}2.cc" set objfile2 "${objdir}/${subdir}/${testfile}2.o" set binfile ${objdir}/${subdir}/${testfile} -# gdb_get_line_number needs this to be called srcfile. -set srcfile "${srcfile1}" +# gdb_get_line_number needs this to be called srcfile. Except that it +# gets confused if the directories are included. :-( +set srcfile "${testfile}1.cc" if { [gdb_compile "${srcfile1}" "${objfile1}" object {debug c++}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." @@ -78,8 +79,8 @@ if ![runto_main] then { # First, run to after we've constructed the object: -gdb_breakpoint [gdb_get_line_number "constructs-done"] -gdb_continue_to_breakpoint "end of constructors" +gdb_breakpoint [gdb_get_line_number "main-constructs-done"] +gdb_continue_to_breakpoint "end of constructors in main" gdb_test_multiple "print *e1" "print *e1" { -re "warning: RTTI symbol not found for class 'n1::D1'.*$gdb_prompt $" { @@ -131,5 +132,13 @@ gdb_test_multiple "print *e2" "print *e2" { } } +# Now we test the hack that's been implemented to get around some +# instances of PR gdb/1511. + +gdb_breakpoint [gdb_get_line_number "func-constructs-done"] +gdb_continue_to_breakpoint "end of constructors in func" + +gdb_test "print *obj" "\\$\[0-9\]* = {<n2::Base2> = .*}" + gdb_exit return 0 diff --git a/gdb/testsuite/gdb.cp/rtti1.cc b/gdb/testsuite/gdb.cp/rtti1.cc index 6e9d862..de8e12f 100644 --- a/gdb/testsuite/gdb.cp/rtti1.cc +++ b/gdb/testsuite/gdb.cp/rtti1.cc @@ -1,6 +1,6 @@ /* Code to go along with tests in rtti.exp. - Copyright 2003 Free Software Foundation, Inc. + Copyright 2003, 2004 Free Software Foundation, Inc. Contributed by David Carlton <carlton@bactrian.org> and by Kealia, Inc. @@ -55,6 +55,26 @@ namespace n1 { } // n1 +// NOTE: carlton/2004-01-23: This call exists only to convince GCC to +// keep around a reference to 'obj' in n2::func - GCC 3.4 had been +// optimizing it away. +void refer_to (n2::C2 *obj) +{ + // Do nothing. +} + +namespace n2 +{ + void func () + { + C2 *obj = create2 (); + + refer_to (obj); // func-constructs-done + + return; + } +} + int main() { using namespace n1; @@ -63,5 +83,7 @@ int main() C1 *e1 = create1(); C2 *e2 = create2(); - return 0; // constructs-done + n2::func(); // main-constructs-done + + return 0; } diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp index 0f7a573..8763a93 100644 --- a/gdb/testsuite/gdb.cp/templates.exp +++ b/gdb/testsuite/gdb.cp/templates.exp @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file was written by Fred Fish. (fnf@cygnus.com) set ws "\[\r\n\t \]+" diff --git a/gdb/testsuite/gdb.cp/userdef.exp b/gdb/testsuite/gdb.cp/userdef.exp index 4575249..5c9c933 100644 --- a/gdb/testsuite/gdb.cp/userdef.exp +++ b/gdb/testsuite/gdb.cp/userdef.exp @@ -1,5 +1,5 @@ # Tests of overloaded operators resolution. -# Copyright 1998, 1999, 2002 Free Software Foundation, Inc. +# Copyright 1998, 1999, 2002, 2004 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 @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # written by Elena Zannoni (ezannoni@cygnus.com) # # source file "userdef.cc" diff --git a/gdb/testsuite/gdb.cp/virtfunc.exp b/gdb/testsuite/gdb.cp/virtfunc.exp index 958900a..bd931a6 100644 --- a/gdb/testsuite/gdb.cp/virtfunc.exp +++ b/gdb/testsuite/gdb.cp/virtfunc.exp @@ -15,9 +15,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu - # This file was written by Fred Fish. (fnf@cygnus.com) # And rewritten by Michael Chastain <mec.gnu@mindspring.com>. @@ -176,7 +173,7 @@ proc test_ptype_of_classes {} { "" "int a;" \ "public:" "virtual int f\\((void|)\\);" \ "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \ - "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\(\\);" \ + "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\((void|)\\);" \ "" # class B @@ -187,7 +184,7 @@ proc test_ptype_of_classes {} { "" "int b;" \ "public:" "virtual int f\\((void|)\\);" \ "B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \ - "B & operator=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\(\\);" \ + "B & operator=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\((void|)\\);" \ "" # class C @@ -198,7 +195,7 @@ proc test_ptype_of_classes {} { "public:" "int c;" \ "" "" \ "C & operator=\\(C const ?&\\);${ws}C\\(int, C const ?&\\);${ws}C\\(int\\);" \ - "C & operator=\\(C const ?&\\);${ws}C\\(C const ?&\\);${ws}C\\(\\);" \ + "C & operator=\\(C const ?&\\);${ws}C\\(C const ?&\\);${ws}C\\((void|)\\);" \ "" # class AD @@ -220,7 +217,7 @@ proc test_ptype_of_classes {} { "public:" "int d;" \ "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ - "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\(\\);" \ + "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);" \ "" # class E @@ -232,7 +229,7 @@ proc test_ptype_of_classes {} { "public:" "int e;" \ "" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ "E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \ - "E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\(\\);" \ + "E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\((void|)\\);" \ "" # An instance of D @@ -243,7 +240,7 @@ proc test_ptype_of_classes {} { "public:" "int d;" \ "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ - "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\(\\);" \ + "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);" \ "" # An instance of D * @@ -254,7 +251,7 @@ proc test_ptype_of_classes {} { "public:" "int d;" \ "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ - "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\(\\);" \ + "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);" \ " ?\\*" # An instance of AD * @@ -277,7 +274,7 @@ proc test_ptype_of_classes {} { "" "int a;" \ "public:" "virtual int f\\((void|)\\);" \ "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \ - "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\(\\);" \ + "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\((void|)\\);" \ "" # An instance of B @@ -288,7 +285,7 @@ proc test_ptype_of_classes {} { "" "int b;" \ "public:" "virtual int f\\((void|)\\);" \ "B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \ - "B & operator=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\(\\);" \ + "B & operator=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\((void|)\\);" \ "" # An instance of C @@ -299,7 +296,7 @@ proc test_ptype_of_classes {} { "public:" "int c;" \ "" "" \ "C & operator=\\(C const ?&\\);${ws}C\\(int, C const ?&\\);${ws}C\\(int\\);" \ - "C & operator=\\(C const ?&\\);${ws}C\\(C const ?&\\);${ws}C\\(\\);" \ + "C & operator=\\(C const ?&\\);${ws}C\\(C const ?&\\);${ws}C\\((void|)\\);" \ "" # An instance of D @@ -310,7 +307,7 @@ proc test_ptype_of_classes {} { "public:" "int d;" \ "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ - "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\(\\);" \ + "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);" \ "" # An instance of E @@ -321,7 +318,7 @@ proc test_ptype_of_classes {} { "public:" "int e;" \ "" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ "E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \ - "E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\(\\);" \ + "E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\((void|)\\);" \ "" # An instance of V @@ -354,7 +351,7 @@ proc test_ptype_of_classes {} { "" "int a;" \ "public:" "virtual int f\\((void|)\\);" \ "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \ - "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\(\\);" \ + "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\((void|)\\);" \ " ?\\*" # An instance of A * @@ -365,7 +362,7 @@ proc test_ptype_of_classes {} { "" "int a;" \ "public:" "virtual int f\\((void|)\\);" \ "A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);" \ - "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\(\\);" \ + "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\((void|)\\);" \ " ?\\*" # An instance of B * @@ -376,7 +373,7 @@ proc test_ptype_of_classes {} { "" "int b;" \ "public:" "virtual int f\\((void|)\\);" \ "B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);" \ - "B & operator=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\(\\);" \ + "B & operator=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\((void|)\\);" \ " ?\\*" # An instance of D * @@ -387,7 +384,7 @@ proc test_ptype_of_classes {} { "public:" "int d;" \ "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ - "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\(\\);" \ + "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);" \ " ?\\*" # An instance of D * @@ -398,7 +395,7 @@ proc test_ptype_of_classes {} { "public:" "int d;" \ "" "static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);" \ "D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);" \ - "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\(\\);" \ + "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);" \ " ?\\*" # An instance of V * @@ -464,7 +461,7 @@ proc test_ptype_of_classes {} { "public:" "int e;" \ "" "virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \ "E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);" \ - "E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\(\\);" \ + "E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\((void|)\\);" \ " ?\\*" # An instance of VB * |