summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.cp
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.cp')
-rw-r--r--gdb/testsuite/gdb.cp/ambiguous.exp7
-rw-r--r--gdb/testsuite/gdb.cp/annota2.exp7
-rw-r--r--gdb/testsuite/gdb.cp/annota3.exp7
-rw-r--r--gdb/testsuite/gdb.cp/anon-union.exp5
-rw-r--r--gdb/testsuite/gdb.cp/breakpoint.cc41
-rw-r--r--gdb/testsuite/gdb.cp/breakpoint.exp65
-rw-r--r--gdb/testsuite/gdb.cp/bs15503.cc72
-rw-r--r--gdb/testsuite/gdb.cp/bs15503.exp100
-rw-r--r--gdb/testsuite/gdb.cp/casts.exp5
-rw-r--r--gdb/testsuite/gdb.cp/class2.cc74
-rw-r--r--gdb/testsuite/gdb.cp/class2.exp119
-rw-r--r--gdb/testsuite/gdb.cp/classes.cc608
-rw-r--r--gdb/testsuite/gdb.cp/classes.exp1066
-rw-r--r--gdb/testsuite/gdb.cp/cplusfuncs.exp6
-rw-r--r--gdb/testsuite/gdb.cp/ctti.exp358
-rw-r--r--gdb/testsuite/gdb.cp/cttiadd.cc22
-rw-r--r--gdb/testsuite/gdb.cp/cttiadd1.cc21
-rw-r--r--gdb/testsuite/gdb.cp/cttiadd2.cc21
-rw-r--r--gdb/testsuite/gdb.cp/cttiadd3.cc21
-rw-r--r--gdb/testsuite/gdb.cp/demangle.exp5
-rw-r--r--gdb/testsuite/gdb.cp/derivation.exp397
-rw-r--r--gdb/testsuite/gdb.cp/exception.cc69
-rw-r--r--gdb/testsuite/gdb.cp/exception.exp219
-rw-r--r--gdb/testsuite/gdb.cp/hang.exp5
-rw-r--r--gdb/testsuite/gdb.cp/inherit.exp1488
-rw-r--r--gdb/testsuite/gdb.cp/local.exp202
-rw-r--r--gdb/testsuite/gdb.cp/m-static.exp20
-rw-r--r--gdb/testsuite/gdb.cp/maint.exp5
-rw-r--r--gdb/testsuite/gdb.cp/member-ptr.cc21
-rw-r--r--gdb/testsuite/gdb.cp/member-ptr.exp799
-rw-r--r--gdb/testsuite/gdb.cp/method.exp10
-rw-r--r--gdb/testsuite/gdb.cp/misc.cc20
-rw-r--r--gdb/testsuite/gdb.cp/misc.exp3
-rw-r--r--gdb/testsuite/gdb.cp/namespace.cc35
-rw-r--r--gdb/testsuite/gdb.cp/namespace.exp88
-rw-r--r--gdb/testsuite/gdb.cp/namespace1.cc17
-rw-r--r--gdb/testsuite/gdb.cp/overload.cc28
-rw-r--r--gdb/testsuite/gdb.cp/overload.exp522
-rw-r--r--gdb/testsuite/gdb.cp/ovldbreak.exp5
-rw-r--r--gdb/testsuite/gdb.cp/pr-1553.cc53
-rw-r--r--gdb/testsuite/gdb.cp/pr-1553.exp62
-rw-r--r--gdb/testsuite/gdb.cp/psmang.exp5
-rw-r--r--gdb/testsuite/gdb.cp/ref-types.exp7
-rw-r--r--gdb/testsuite/gdb.cp/rtti.exp54
-rw-r--r--gdb/testsuite/gdb.cp/rtti.h10
-rw-r--r--gdb/testsuite/gdb.cp/rtti1.cc44
-rw-r--r--gdb/testsuite/gdb.cp/rtti2.cc6
-rw-r--r--gdb/testsuite/gdb.cp/templates.exp86
-rw-r--r--gdb/testsuite/gdb.cp/userdef.exp5
-rw-r--r--gdb/testsuite/gdb.cp/virtfunc.exp1332
50 files changed, 4770 insertions, 3477 deletions
diff --git a/gdb/testsuite/gdb.cp/ambiguous.exp b/gdb/testsuite/gdb.cp/ambiguous.exp
index 4224b2d79fd..f54e96458d3 100644
--- a/gdb/testsuite/gdb.cp/ambiguous.exp
+++ b/gdb/testsuite/gdb.cp/ambiguous.exp
@@ -1,4 +1,4 @@
-# Copyright 1998, 1999 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
@@ -45,7 +42,7 @@ if [get_compiler_info ${binfile} "c++"] {
return -1;
}
-if { $gcc_compiled } then { continue }
+if { [test_compiler_info gcc-*] } then { continue }
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."
diff --git a/gdb/testsuite/gdb.cp/annota2.exp b/gdb/testsuite/gdb.cp/annota2.exp
index 0446eb3b63f..7710cc495f5 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 {
@@ -193,7 +190,7 @@ gdb_expect {
#
send_gdb "next\n"
gdb_expect {
- -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032watchpoint 3\r\nWatchpoint 3: a.x\r\n\r\nOld value = 0\r\nNew value = 1\r\n\r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nmain\r\n\032\032frame-args\r\n \\(\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n.*$srcfile\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n$decimal\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$" \
+ -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032watchpoint 3\r\n.*atchpoint 3: a.x\r\n\r\nOld value = 0\r\nNew value = 1\r\n\r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nmain\r\n\032\032frame-args\r\n \\(\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n.*$srcfile\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n$decimal\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n$gdb_prompt$" \
{ pass "watch triggered on a.x" }
-re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032watchpoint 3\r\n\.*atchpoint 3: a.x\r\n\r\nOld value = 0\r\nNew value = 1\r\n\r\n\032\032frame-begin 0 $hex\r\n\r\n\032\032frame-function-name\r\nmain\r\n\032\032frame-args\r\n \\(\\)\r\n\032\032frame-source-begin\r\n at \r\n\032\032frame-source-file\r\n.*$srcfile\r\n\032\032frame-source-file-end\r\n:\r\n\032\032frame-source-line\r\n$decimal\r\n\032\032frame-source-end\r\n\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032frame-end\r\n\r\n\032\032stopped\r\n.*$gdb_prompt$" \
{ pass "watch triggered on a.x" }
diff --git a/gdb/testsuite/gdb.cp/annota3.exp b/gdb/testsuite/gdb.cp/annota3.exp
index 431ed4f07bc..37be48d9b39 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 {
@@ -196,7 +193,7 @@ gdb_expect_list "set watch on a.x" "$gdb_prompt$" {
#
send_gdb "next\n"
gdb_expect {
- -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\(\r\n\032\032frames-invalid\r\n\)+\r\n\032\032watchpoint 3\r\nWatchpoint 3: a.x\r\n\r\nOld value = 0\r\nNew value = 1\r\nmain \\(\\) at .*$srcfile:$decimal\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032stopped\r\n.*$gdb_prompt$" {
+ -re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\(\r\n\032\032frames-invalid\r\n\)+\r\n\032\032watchpoint 3\r\n.*atchpoint 3: a.x\r\n\r\nOld value = 0\r\nNew value = 1\r\nmain \\(\\) at .*$srcfile:$decimal\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032stopped\r\n.*$gdb_prompt$" {
pass "watch triggered on a.x"
}
-re "\r\n\032\032post-prompt\r\n\r\n\032\032starting\r\n\r\n\032\032frames-invalid\r\n\r\n\032\032source .*$srcfile.*beg:$hex\r\n\r\n\032\032stopped\r\n$gdb_prompt$" {
diff --git a/gdb/testsuite/gdb.cp/anon-union.exp b/gdb/testsuite/gdb.cp/anon-union.exp
index 0d5c7777319..4c34dcfcd90 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 00000000000..266007cced0
--- /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 00000000000..c85f80541e1
--- /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
new file mode 100644
index 00000000000..5581ec5b1bf
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/bs15503.cc
@@ -0,0 +1,72 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 1992, 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.
+ */
+
+#include <string>
+#include <iostream>
+using namespace std;
+
+template <class T>
+class StringTest {
+public:
+ virtual void runTest();
+ void testFunction();
+};
+
+template <class T>
+void StringTest<T>:: runTest() {
+ testFunction ();
+}
+
+template <class T>
+void StringTest <T>::testFunction() {
+ // initialize s with string literal
+ cout << "in StringTest" << endl;
+ string s("I am a shot string");
+ cout << s << endl;
+
+ // insert 'r' to fix "shot"
+ s.insert(s.begin()+10,'r' );
+ cout << s << endl;
+
+ // concatenate another string
+ s += "and now a longer string";
+ cout << s << endl;
+
+ // find position where blank needs to be inserted
+ string::size_type spos = s.find("and");
+ s.insert(spos, " ");
+ cout << s << endl;
+
+ // erase the concatenated part
+ s.erase(spos);
+ cout << s << endl;
+}
+
+int main() {
+ StringTest<wchar_t> ts;
+ ts.runTest();
+}
+
+/* output:
+I am a shot string
+I am a short string
+I am a short stringand now a longer string
+I am a short string and now a longer string
+I am a short string
+*/
diff --git a/gdb/testsuite/gdb.cp/bs15503.exp b/gdb/testsuite/gdb.cp/bs15503.exp
new file mode 100644
index 00000000000..9b6095bec1a
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/bs15503.exp
@@ -0,0 +1,100 @@
+# Copyright 1992, 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. */
+
+# Test case for CLLbs15503
+# This file was written by Sue Kimura (sue_kimura@hp.com)
+# Rewritten by Michael Chastain (mec.gnu@mindspring.com)
+
+if $tracelevel {
+ strace $tracelevel
+}
+
+set testfile "bs15503"
+set srcfile ${testfile}.cc
+set binfile ${objdir}/${subdir}/${testfile}
+
+if [get_compiler_info ${binfile}] {
+ return -1
+}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug c++"] != "" } {
+ perror "Couldn't compile ${srcfile}"
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+if ![runto_main] then {
+ perror "couldn't run to breakpoint"
+ continue
+}
+
+# Set breakpoint on template function
+
+gdb_test "break StringTest<wchar_t>::testFunction" \
+ "Breakpoint $decimal at $hex: file .*${srcfile}, line $decimal."
+
+gdb_test "continue" \
+ ".*Breakpoint $decimal, StringTest<wchar_t>::testFunction \\(this=$hex\\).*" \
+ "continue to StringTest<wchar_t>"
+
+# Run to some random point in the middle of the function.
+
+gdb_breakpoint [gdb_get_line_number "find position where blank needs to be inserted"]
+gdb_continue_to_breakpoint "find position where blank needs to be inserted"
+
+# Call some string methods.
+
+gdb_test "print s.length()" "\\$\[0-9\]+ = 42"
+gdb_test "print s\[0\]" "\\$\[0-9\]+ =.* 'I'"
+gdb_test "print s\[s.length()-1\]" "\\$\[0-9\]+ =.* 'g'"
+gdb_test "print (const char *) s" \
+ "\\$\[0-9\]+ = $hex \"I am a short stringand now a longer string\""
+
+# TODO: tests that do not work with gcc 2.95.3
+# -- chastain 2004-01-07
+#
+# gdb_test "print s.compare(s)" "\\$\[0-9\]+ = 0"
+# gdb_test "print s.compare(\"AAA\")" "\\$\[0-9\]+ = 1"
+# gdb_test "print s.compare(\"ZZZ\")" "\\$\[0-9\]+ = -1"
+
+# TODO: tests that do not work with gcc 2.95.3 and gcc 3.3.2.
+# cannot call overloaded non-member operator. -- chastain 2004-01-07
+#
+# gdb_test "print s == s" "\\$\[0-9\]+ = true"
+# gdb_test "print s > "AAA" "\\$\[0-9\]+ = true"
+# gdb_test "print s < "ZZZ" "\\$\[0-9\]+ = true"
+
+# TODO crash gdb! This is going to be a great test!
+# -- chastain 2004-01-07
+#
+# gdb_test "print s == \"I am a short stringand now a longer string\"" \
+# "\\$\[0-9\]+ = "true"
+
+gdb_test "print (const char *) s.substr(0,4)" "\\$\[0-9\]+ = $hex \"I am\""
+gdb_test "print (const char *) (s=s.substr(0,4))" \
+ "\\$\[0-9\]+ = $hex \"I am\""
+
+# TODO: cannot call overloaded non-member operator again.
+# -- chastain 2004-01-07
+#
+# gdb_test "print (const char *) (s + s)" \
+# "\\$\[0-9\]+ = $hex \"I amI am\""
+# gdb_test "print (const char *) (s + \" \" + s)" \
+# "\\$\[0-9\]+ = $hex \"I am I am\""
diff --git a/gdb/testsuite/gdb.cp/casts.exp b/gdb/testsuite/gdb.cp/casts.exp
index 5b6cabe34fa..3aaf37cbff0 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
new file mode 100644
index 00000000000..b4aa20a0df1
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/class2.cc
@@ -0,0 +1,74 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ 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
+ 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.
+ */
+
+struct A
+{
+ virtual ~A ();
+ int a1;
+};
+
+A::~A()
+{
+ a1 = 800;
+}
+
+struct B : public A
+{
+ virtual ~B ();
+ int b1;
+ int b2;
+};
+
+B::~B()
+{
+ a1 = 900;
+ b1 = 901;
+ b2 = 902;
+}
+
+// Stop the compiler from optimizing away data.
+void refer (A *)
+{
+ ;
+}
+
+struct empty {};
+
+// Stop the compiler from optimizing away data.
+void refer (empty *)
+{
+ ;
+}
+
+int main (void)
+{
+ A alpha, *aap, *abp;
+ B beta, *bbp;
+ empty e;
+
+ alpha.a1 = 100;
+ beta.a1 = 200; beta.b1 = 201; beta.b2 = 202;
+
+ aap = &alpha; refer (aap);
+ abp = &beta; refer (abp);
+ bbp = &beta; refer (bbp);
+ refer (&e);
+
+ return 0; // marker return 0
+} // marker close brace
diff --git a/gdb/testsuite/gdb.cp/class2.exp b/gdb/testsuite/gdb.cp/class2.exp
new file mode 100644
index 00000000000..e3f63b08eae
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/class2.exp
@@ -0,0 +1,119 @@
+# 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
+# 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.
+
+if $tracelevel then {
+ strace $tracelevel
+ }
+
+if { [skip_cplus_tests] } { continue }
+
+set prms_id 0
+set bug_id 0
+
+set testfile "class2"
+set srcfile ${testfile}.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."
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+# Start with "set print object off".
+
+gdb_test "set print object off" ""
+
+if ![runto_main] then {
+ perror "couldn't run to main"
+ continue
+}
+
+get_debug_format
+
+gdb_test "break [gdb_get_line_number "marker return 0"]" \
+ "Breakpoint.*at.* file .*" ""
+
+gdb_test "continue" "Breakpoint .* at .*" ""
+
+# Access the "A" object.
+
+gdb_test "print alpha" \
+ "= {.*a1 = 100.*}" \
+ "print alpha at marker return 0"
+
+# Access the "B" object.
+
+gdb_test "print beta" \
+ "= {.*a1 = 200.*b1 = 201.*b2 = 202}" \
+ "print beta at marker return 0"
+
+# Access the "A" object through an "A *" pointer.
+
+gdb_test_multiple "print * aap" "print * aap at marker return 0" {
+ -re "= {.*a1 = 100.*}\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gdwarf-2
+ # gcc 3.3.2 -gstabs+
+ pass "print * aap at marker return 0"
+ }
+ -re "= {.*a1 = .*}\r\n$gdb_prompt $" {
+ if { [test_compiler_info gcc-2-*] && [test_debug_format "DWARF 2"] } {
+ # gcc 2.95.3 -gdwarf-2
+ setup_kfail "gdb/1465" "*-*-*"
+ }
+ fail "print * aap at marker return 0"
+ }
+}
+
+# Access the "B" object through a "B *" pointer.
+
+gdb_test "print * bbp" \
+ "= {.*a1 = 200.*b1 = 201.*b2 = 202}" \
+ "print * bbp at marker return 0"
+
+# Access the "B" object through an "A *" pointer.
+# This should print using the "A" type.
+
+gdb_test_multiple "print * abp" "print * abp at marker return 0, s-p-o off" {
+ -re "= {.*a1 = 200.*b1 = .*b2 = .*}\r\n$gdb_prompt $" {
+ # This would violate the documentation for "set print object off".
+ fail "print * abp at marker return 0, s-p-o off"
+ }
+ -re "= {.*a1 = 200.*}\r\n$gdb_prompt $" {
+ pass "print * abp at marker return 0, s-p-o off"
+ }
+}
+
+# Access the "B" object through a "B *" pointer expression.
+# This should print using the "B" type.
+
+gdb_test "print * (B *) abp" \
+ "= {.*a1 = 200.*b1 = 201.*b2 = 202}" \
+ "print * (B *) abp at marker return 0"
+
+# Printing the value of an object containing no data fields:
+
+gdb_test "p e" "= \{<No data fields>\}" "print object with no data fields"
diff --git a/gdb/testsuite/gdb.cp/classes.cc b/gdb/testsuite/gdb.cp/classes.cc
new file mode 100644
index 00000000000..d09f38fc36d
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/classes.cc
@@ -0,0 +1,608 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 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
+ 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.
+ */
+
+// Test various -*- C++ -*- things.
+
+// ====================== basic C++ types =======================
+bool v_bool;
+bool v_bool_array[2];
+
+typedef struct fleep fleep;
+struct fleep { int a; } s;
+
+// ====================== simple class structures =======================
+
+struct default_public_struct {
+ // defaults to public:
+ int a;
+ int b;
+};
+
+struct explicit_public_struct {
+ public:
+ int a;
+ int b;
+};
+
+struct protected_struct {
+ protected:
+ int a;
+ int b;
+};
+
+struct private_struct {
+ private:
+ int a;
+ int b;
+};
+
+struct mixed_protection_struct {
+ public:
+ int a;
+ int b;
+ private:
+ int c;
+ int d;
+ protected:
+ int e;
+ int f;
+ public:
+ int g;
+ private:
+ int h;
+ protected:
+ int i;
+};
+
+class public_class {
+ public:
+ int a;
+ int b;
+};
+
+class protected_class {
+ protected:
+ int a;
+ int b;
+};
+
+class default_private_class {
+ // defaults to private:
+ int a;
+ int b;
+};
+
+class explicit_private_class {
+ private:
+ int a;
+ int b;
+};
+
+class mixed_protection_class {
+ public:
+ int a;
+ int b;
+ private:
+ int c;
+ int d;
+ protected:
+ int e;
+ int f;
+ public:
+ int g;
+ private:
+ int h;
+ protected:
+ int i;
+};
+
+class const_vol_method_class {
+public:
+ int a;
+ int b;
+ int foo (int &) const;
+ int bar (int &) volatile;
+ int baz (int &) const volatile;
+};
+
+int const_vol_method_class::foo (int & ir) const
+{
+ return ir + 3;
+}
+int const_vol_method_class::bar (int & ir) volatile
+{
+ return ir + 4;
+}
+int const_vol_method_class::baz (int & ir) const volatile
+{
+ return ir + 5;
+}
+
+// ========================= simple inheritance ==========================
+
+class A {
+ public:
+ int a;
+ int x;
+};
+
+A g_A;
+
+class B : public A {
+ public:
+ int b;
+ int x;
+};
+
+B g_B;
+
+class C : public A {
+ public:
+ int c;
+ int x;
+};
+
+C g_C;
+
+class D : public B, public C {
+ public:
+ int d;
+ int x;
+};
+
+D g_D;
+
+class E : public D {
+ public:
+ int e;
+ int x;
+};
+
+E g_E;
+
+class class_with_anon_union
+{
+ public:
+ int one;
+ union
+ {
+ int a;
+ long b;
+ };
+};
+
+class_with_anon_union g_anon_union;
+
+void inheritance2 (void)
+{
+}
+
+void inheritance1 (void)
+{
+ int ival;
+ int *intp;
+
+ // {A::a, A::x}
+
+ g_A.A::a = 1;
+ g_A.A::x = 2;
+
+ // {{A::a,A::x},B::b,B::x}
+
+ g_B.A::a = 3;
+ g_B.A::x = 4;
+ g_B.B::b = 5;
+ g_B.B::x = 6;
+
+ // {{A::a,A::x},C::c,C::x}
+
+ g_C.A::a = 7;
+ g_C.A::x = 8;
+ g_C.C::c = 9;
+ g_C.C::x = 10;
+
+ // {{{A::a,A::x},B::b,B::x},{{A::a,A::x},C::c,C::x},D::d,D::x}
+
+ // The following initialization code is non-portable, but allows us
+ // to initialize all members of g_D until we can fill in the missing
+ // initialization code with legal C++ code.
+
+ for (intp = (int *) &g_D, ival = 11;
+ intp < ((int *) &g_D + sizeof (g_D) / sizeof (int));
+ intp++, ival++)
+ {
+ *intp = ival;
+ }
+
+ // Overlay the nonportable initialization with legal initialization.
+
+ // ????? = 11; (g_D.A::a = 11; is ambiguous)
+ // ????? = 12; (g_D.A::x = 12; is ambiguous)
+/* djb 6-3-2000
+
+ This should take care of it. Rather than try to initialize using an ambiguous
+ construct, use 2 unambiguous ones for each. Since the ambiguous a/x member is
+ coming from C, and B, initialize D's C::a, and B::a, and D's C::x and B::x.
+ */
+ g_D.C::a = 15;
+ g_D.C::x = 12;
+ g_D.B::a = 11;
+ g_D.B::x = 12;
+ g_D.B::b = 13;
+ g_D.B::x = 14;
+ // ????? = 15;
+ // ????? = 16;
+ g_D.C::c = 17;
+ g_D.C::x = 18;
+ g_D.D::d = 19;
+ g_D.D::x = 20;
+
+
+ // {{{{A::a,A::x},B::b,B::x},{{A::a,A::x},C::c,C::x},D::d,D::x}},E::e,E::x}
+
+ // The following initialization code is non-portable, but allows us
+ // to initialize all members of g_D until we can fill in the missing
+ // initialization code with legal C++ code.
+
+ for (intp = (int *) &g_E, ival = 21;
+ intp < ((int *) &g_E + sizeof (g_E) / sizeof (int));
+ intp++, ival++)
+ {
+ *intp = ival;
+ }
+
+ // Overlay the nonportable initialization with legal initialization.
+
+ // ????? = 21; (g_E.A::a = 21; is ambiguous)
+ // ????? = 22; (g_E.A::x = 22; is ambiguous)
+ g_E.B::b = 23;
+ g_E.B::x = 24;
+ // ????? = 25;
+ // ????? = 26;
+ g_E.C::c = 27;
+ g_E.C::x = 28;
+ g_E.D::d = 29;
+ g_E.D::x = 30;
+ g_E.E::e = 31;
+ g_E.E::x = 32;
+
+ g_anon_union.one = 1;
+ g_anon_union.a = 2;
+
+ inheritance2 ();
+}
+
+// ======================== static member functions =====================
+
+class Static {
+public:
+ static void ii(int, int);
+};
+void Static::ii (int, int) { }
+
+// ======================== virtual base classes=========================
+
+class vA {
+ public:
+ int va;
+ int vx;
+};
+
+vA g_vA;
+
+class vB : public virtual vA {
+ public:
+ int vb;
+ int vx;
+};
+
+vB g_vB;
+
+class vC : public virtual vA {
+ public:
+ int vc;
+ int vx;
+};
+
+vC g_vC;
+
+class vD : public virtual vB, public virtual vC {
+ public:
+ int vd;
+ int vx;
+};
+
+vD g_vD;
+
+class vE : public virtual vD {
+ public:
+ int ve;
+ int vx;
+};
+
+vE g_vE;
+
+void inheritance4 (void)
+{
+}
+
+void inheritance3 (void)
+{
+ int ival;
+ int *intp;
+
+ // {vA::va, vA::vx}
+
+ g_vA.vA::va = 1;
+ g_vA.vA::vx = 2;
+
+ // {{vA::va, vA::vx}, vB::vb, vB::vx}
+
+ g_vB.vA::va = 3;
+ g_vB.vA::vx = 4;
+ g_vB.vB::vb = 5;
+ g_vB.vB::vx = 6;
+
+ // {{vA::va, vA::vx}, vC::vc, vC::vx}
+
+ g_vC.vA::va = 7;
+ g_vC.vA::vx = 8;
+ g_vC.vC::vc = 9;
+ g_vC.vC::vx = 10;
+
+ // {{{{vA::va, vA::vx}, vB::vb, vB::vx}, vC::vc, vC::vx}, vD::vd,vD::vx}
+
+ g_vD.vA::va = 11;
+ g_vD.vA::vx = 12;
+ g_vD.vB::vb = 13;
+ g_vD.vB::vx = 14;
+ g_vD.vC::vc = 15;
+ g_vD.vC::vx = 16;
+ g_vD.vD::vd = 17;
+ g_vD.vD::vx = 18;
+
+
+ // {{{{{vA::va,vA::vx},vB::vb,vB::vx},vC::vc,vC::vx},vD::vd,vD::vx},vE::ve,vE::vx}
+
+ g_vD.vA::va = 19;
+ g_vD.vA::vx = 20;
+ g_vD.vB::vb = 21;
+ g_vD.vB::vx = 22;
+ g_vD.vC::vc = 23;
+ g_vD.vC::vx = 24;
+ g_vD.vD::vd = 25;
+ g_vD.vD::vx = 26;
+ g_vE.vE::ve = 27;
+ g_vE.vE::vx = 28;
+
+ inheritance4 ();
+}
+
+// ======================================================================
+
+class Base1 {
+ public:
+ int x;
+ Base1(int i) { x = i; }
+};
+
+class Foo
+{
+ public:
+ int x;
+ int y;
+ static int st;
+ Foo (int i, int j) { x = i; y = j; }
+ int operator! ();
+ operator int ();
+ int times (int y);
+};
+
+class Bar : public Base1, public Foo {
+ public:
+ int z;
+ Bar (int i, int j, int k) : Base1 (10*k), Foo (i, j) { z = k; }
+};
+
+int Foo::operator! () { return !x; }
+
+int Foo::times (int y) { return x * y; }
+
+int Foo::st = 100;
+
+Foo::operator int() { return x; }
+
+Foo foo(10, 11);
+Bar bar(20, 21, 22);
+
+class ClassWithEnum {
+public:
+ enum PrivEnum { red, green, blue, yellow = 42 };
+ PrivEnum priv_enum;
+ int x;
+};
+
+void enums2 (void)
+{
+}
+
+/* classes.exp relies on statement order in this function for testing
+ enumeration fields. */
+
+void enums1 ()
+{
+ ClassWithEnum obj_with_enum;
+ obj_with_enum.priv_enum = ClassWithEnum::red;
+ obj_with_enum.x = 0;
+ enums2 ();
+ obj_with_enum.priv_enum = ClassWithEnum::green;
+ obj_with_enum.x = 1;
+}
+
+class ClassParam {
+public:
+ int Aptr_a (A *a) { return a->a; }
+ int Aptr_x (A *a) { return a->x; }
+ int Aref_a (A &a) { return a.a; }
+ int Aref_x (A &a) { return a.x; }
+ int Aval_a (A a) { return a.a; }
+ int Aval_x (A a) { return a.x; }
+};
+
+ClassParam class_param;
+
+class Contains_static_instance
+{
+ public:
+ int x;
+ int y;
+ Contains_static_instance (int i, int j) { x = i; y = j; }
+ static Contains_static_instance null;
+};
+
+Contains_static_instance Contains_static_instance::null(0,0);
+Contains_static_instance csi(10,20);
+
+class Contains_nested_static_instance
+{
+ public:
+ class Nested
+ {
+ public:
+ Nested(int i) : z(i) {}
+ int z;
+ static Contains_nested_static_instance xx;
+ };
+
+ Contains_nested_static_instance(int i, int j) : x(i), y(j) {}
+
+ int x;
+ int y;
+
+ static Contains_nested_static_instance null;
+ static Nested yy;
+};
+
+Contains_nested_static_instance Contains_nested_static_instance::null(0, 0);
+Contains_nested_static_instance::Nested Contains_nested_static_instance::yy(5);
+Contains_nested_static_instance
+ Contains_nested_static_instance::Nested::xx(1,2);
+Contains_nested_static_instance cnsi(30,40);
+
+typedef struct {
+ int one;
+ int two;
+} tagless_struct;
+tagless_struct v_tagless;
+
+/* Try to get the compiler to allocate a class in a register. */
+class small {
+ public:
+ int x;
+ int method ();
+};
+
+int
+small::method ()
+{
+ return x + 5;
+}
+
+void marker_reg1 () {}
+
+int
+register_class ()
+{
+ /* We don't call any methods for v, so gcc version cygnus-2.3.3-930220
+ might put this variable in a register. This is a lose, though, because
+ it means that GDB can't call any methods for that variable. */
+ register small v;
+
+ int i;
+
+ /* Perform a computation sufficiently complicated that optimizing compilers
+ won't optimized out the variable. If some compiler constant-folds this
+ whole loop, maybe using a parameter to this function here would help. */
+ v.x = 0;
+ for (i = 0; i < 13; ++i)
+ v.x += i;
+ --v.x; /* v.x is now 77 */
+ marker_reg1 ();
+ return v.x + 5;
+}
+
+void dummy()
+{
+ v_bool = true;
+ v_bool_array[0] = false;
+ v_bool_array[1] = v_bool;
+}
+
+void use_methods ()
+{
+ /* Refer to methods so that they don't get optimized away. */
+ int i;
+ i = class_param.Aptr_a (&g_A);
+ i = class_param.Aptr_x (&g_A);
+ i = class_param.Aref_a (g_A);
+ i = class_param.Aref_x (g_A);
+ i = class_param.Aval_a (g_A);
+ i = class_param.Aval_x (g_A);
+}
+
+
+int
+main()
+{
+#ifdef usestubs
+ set_debug_traps();
+ breakpoint();
+#endif
+ dummy();
+ inheritance1 ();
+ inheritance3 ();
+ enums1 ();
+ register_class ();
+
+ /* FIXME: pmi gets optimized out. Need to do some more computation with
+ it or something. (No one notices, because the test is xfail'd anyway,
+ but that probably won't always be true...). */
+ int Foo::* pmi = &Foo::y;
+
+ /* Make sure the AIX linker doesn't remove the variable. */
+ v_tagless.one = 5;
+
+ use_methods ();
+
+ return foo.*pmi;
+}
+
+/* Create an instance for some classes, otherwise they get optimized away. */
+
+default_public_struct default_public_s;
+explicit_public_struct explicit_public_s;
+protected_struct protected_s;
+private_struct private_s;
+mixed_protection_struct mixed_protection_s;
+public_class public_c;
+protected_class protected_c;
+default_private_class default_private_c;
+explicit_private_class explicit_private_c;
+mixed_protection_class mixed_protection_c;
diff --git a/gdb/testsuite/gdb.cp/classes.exp b/gdb/testsuite/gdb.cp/classes.exp
index 60f5ab75dc4..d4e78c11927 100644
--- a/gdb/testsuite/gdb.cp/classes.exp
+++ b/gdb/testsuite/gdb.cp/classes.exp
@@ -1,5 +1,5 @@
# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003 Free Software Foundation, Inc.
+# 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,577 +15,587 @@
# 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\]+"
if $tracelevel then {
- strace $tracelevel
+ strace $tracelevel
}
if { [skip_cplus_tests] } { continue }
-set testfile "misc"
+set testfile "classes"
set srcfile ${testfile}.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."
}
-#
# Test ptype of class objects.
#
+# This code accepts the output of gcc v2 and v3, dwarf-2 and stabs+.
+# It could use some expansion with other compilers such as hp-ux ac++.
+#
+# There are lots of variations in the output:
+#
+# . gcc -stabs+ emits debug info for implicit member functions:
+# operator=, copy ctor, ctor. gcc -gdwarf-2 does not.
+#
+# . gcc with abi version 1 puts the implicit member functions
+# at the beginning of the member function list; with abi version 2,
+# the implicit member functions are at the end of the member function
+# list. This appears as an output difference with -gstabs+.
+# gcc 3.3.X defaults to abi version 1, and gcc 3.4 will default
+# to abi version 2.
+#
+# . gcc v2 shows data members for virtual base pointers.
+# gcc v3 does not.
+#
+# . gdb always prints "class" for both "class" and "struct".
+# In the future, I should accept "struct" in case gdb improves.
proc test_ptype_class_objects {} {
global gdb_prompt
global ws
global nl
- # Note that struct members are public by default, so we don't print
- # "public:" for the public members of structs.
- # Accept it if gdb just fails to distinguish between
- # class and struct, and everything else is OK.
+ # Simple type.
- send_gdb "ptype struct default_public_struct\n"
- gdb_expect {
- -re "type = struct default_public_struct \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
+ gdb_test_multiple "ptype struct default_public_struct" "ptype struct default_public_struct" {
+ -re "type = class default_public_struct \{${ws}public:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype struct default_public_struct"
}
- -re "type = class default_public_struct \{$nl.*int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
+ -re "type = class default_public_struct \{${ws}public:${ws}int a;${ws}int b;${ws}default_public_struct ?& ?operator ?=\\(default_public_struct const ?&\\);${ws}default_public_struct\\(default_public_struct const ?&\\);${ws}default_public_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
pass "ptype struct default_public_struct"
}
- -re ".*$gdb_prompt $" { fail "ptype struct default_public_struct" }
- timeout { fail "ptype struct default_public_struct (timeout)" ; return }
}
- # Note that struct members are public by default, so we don't print
- # "public:" for the public members of structs.
- # Accept it if gdb just fails to distinguish between
- # class and struct, and everything else is OK.
+ # Same test, slightly different type.
- send_gdb "ptype struct explicit_public_struct\n"
- gdb_expect {
- -re "type = struct explicit_public_struct \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
+ gdb_test_multiple "ptype struct explicit_public_struct" "ptype struct explicit_public_struct" {
+ -re "type = class explicit_public_struct \{${ws}public:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype struct explicit_public_struct"
}
- -re "type = class explicit_public_struct \{$nl.*int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
+ -re "type = class explicit_public_struct \{${ws}public:${ws}int a;${ws}int b;${ws}explicit_public_struct ?& ?operator ?=\\(explicit_public_struct const ?&\\);${ws}explicit_public_struct\\(explicit_public_struct const ?&\\);${ws}explicit_public_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
pass "ptype struct explicit_public_struct"
}
- -re ".*$gdb_prompt $" { fail "ptype struct explicit_public_struct" }
- timeout { fail "ptype struct explicit_public_struct (timeout)" ; return }
}
- # Accept it if gdb just fails to distinguish between
- # class and struct, and everything else is OK.
+ # Same test, slightly different type.
- send_gdb "ptype struct protected_struct\n"
- gdb_expect {
- -re "type = struct protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
+ gdb_test_multiple "ptype struct protected_struct" "ptype struct protected_struct" {
+ -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype struct protected_struct"
}
- -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
+ -re "type = class protected_struct \{${ws}protected:${ws}int a;${ws}int b;${ws}public:${ws}protected_struct ?& ?operator ?=\\(protected_struct const ?&\\);${ws}protected_struct\\(protected_struct const ?&\\);${ws}protected_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
pass "ptype struct protected_struct"
}
- -re ".*$gdb_prompt $" { fail "ptype struct protected_struct" }
- timeout { fail "ptype struct protected_struct (timeout)" ; return }
}
- # Accept it if gdb just fails to distinguish between
- # class and struct, and everything else is OK.
+ # Same test, slightly different type.
- send_gdb "ptype struct private_struct\n"
- gdb_expect {
- -re "type = struct private_struct \{${ws}private:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
+ gdb_test_multiple "ptype struct private_struct" "ptype struct private_struct" {
+ -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype struct private_struct"
}
- -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
+ -re "type = class private_struct \{${ws}private:${ws}int a;${ws}int b;${ws}public:${ws}private_struct ?& ?operator ?=\\(private_struct const ?&\\);${ws}private_struct\\(private_struct const ?&\\);${ws}private_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
pass "ptype struct private_struct"
}
- -re ".*$gdb_prompt $" { fail "ptype struct private_struct" }
- timeout { fail "ptype struct private_struct (timeout)" ; return }
}
- # Accept it if gdb just fails to distinguish between
- # class and struct, and everything else is OK.
+ # Similar test, bigger type.
- send_gdb "ptype struct mixed_protection_struct\n"
- gdb_expect {
- -re "type = struct mixed_protection_struct \{${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl\}$nl$gdb_prompt $" {
+ gdb_test_multiple "ptype struct mixed_protection_struct" "ptype struct mixed_protection_struct" {
+ -re "type = class mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype struct mixed_protection_struct"
}
- -re "type = struct mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl.*\}$nl$gdb_prompt $" {
- pass "ptype struct mixed_protection_struct (extra public)"
- }
- -re "type = class mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl.*\}$nl$gdb_prompt $" {
+ -re "type = class mixed_protection_struct \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;${ws}public:${ws}mixed_protection_struct ?& ?operator ?=\\(mixed_protection_struct const ?&\\);${ws}mixed_protection_struct\\(mixed_protection_struct const ?&\\);${ws}mixed_protection_struct\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
pass "ptype struct mixed_protection_struct"
}
- -re ".*$gdb_prompt $" { fail "ptype struct mixed_protection_struct" }
- timeout { fail "ptype struct mixed_protection_struct (timeout)" ; return }
}
- # Accept it if gdb just fails to distinguish between
- # class and struct, and everything else is OK.
+ # All that again with "class" instead of "struct".
+ # gdb does not care about the difference anyways.
- send_gdb "ptype class public_class\n"
- gdb_expect {
- -re "type = class public_class \{${ws}public:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
+ gdb_test_multiple "ptype class public_class" "ptype class public_class" {
+ -re "type = class public_class \{${ws}public:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class public_class"
}
- -re "type = struct public_class \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
+ -re "type = class public_class \{${ws}public:${ws}int a;${ws}int b;${ws}public_class ?& ?operator ?=\\(public_class const ?&\\);${ws}public_class\\(public_class const ?&\\);${ws}public_class\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
pass "ptype class public_class"
}
- -re ".*$gdb_prompt $" { fail "ptype class public_class" }
- timeout { fail "ptype class public_class (timeout)" ; return }
}
- send_gdb "ptype class protected_class\n"
- gdb_expect {
- -re "type = class protected_class \{${ws}protected:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
+ # Same test, slightly different type.
+
+ gdb_test_multiple "ptype class protected_class" "ptype class protected_class" {
+ -re "type = class protected_class \{${ws}protected:${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class protected_class"
}
- -re "type = struct protected_class \{${ws}int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
- fail "ptype class protected_class"
+ -re "type = class protected_class \{${ws}protected:${ws}int a;${ws}int b;${ws}public:${ws}protected_class ?& ?operator ?=\\(protected_class const ?&\\);${ws}protected_class\\(protected_class const ?&\\);${ws}protected_class\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class protected_class"
}
- -re ".*$gdb_prompt $" { fail "ptype class protected_class" }
- timeout { fail "ptype class protected_class (timeout)" ; return }
}
- # Accept it if gdb just emits a superflous "private:"
- # attribute, since classes default to private and for consistency with
- # structs (where we don't print the "public:" attribute) we don't print
- # the "private:" attribute.
+ # Same test, slightly different type.
+ # The 'private' is optional but gdb always prints it.
- send_gdb "ptype class default_private_class\n"
- gdb_expect {
- -re "type = class default_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
+ gdb_test_multiple "ptype class default_private_class" "ptype class default_private_class" {
+ -re "type = class default_private_class \{${ws}(private:${ws}|)int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class default_private_class"
}
- -re "type = class default_private_class \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
+ -re "type = class default_private_class \{${ws}(private:${ws}|)int a;${ws}int b;${ws}public:${ws}default_private_class ?& ?operator ?=\\(default_private_class const ?&\\);${ws}default_private_class\\(default_private_class const ?&\\);${ws}default_private_class\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
pass "ptype class default_private_class"
}
- -re ".*$gdb_prompt $" { fail "ptype class default_private_class" }
- timeout { fail "ptype class default_private_class (timeout)" ; return }
}
- send_gdb "ptype class explicit_private_class\n"
- gdb_expect {
- -re "type = class explicit_private_class \{${ws}private:${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
+ # Same test, slightly different type.
+
+ gdb_test_multiple "ptype class explicit_private_class" "ptype class explicit_private_class" {
+ -re "type = class explicit_private_class \{${ws}(private:${ws}|)int a;${ws}int b;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class explicit_private_class"
}
- -re "type = class explicit_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
- pass "ptype class explicit_private_class"
- }
- -re "type = struct explicit_private_class \{${ws}int a;${ws}int b;$nl.*\}$nl$gdb_prompt $" {
- fail "ptype class explicit_private_class"
+ -re "type = class explicit_private_class \{${ws}(private:${ws}|)int a;${ws}int b;${ws}public:${ws}explicit_private_class ?& ?operator ?=\\(explicit_private_class const ?&\\);${ws}explicit_private_class\\(explicit_private_class const ?&\\);${ws}explicit_private_class\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class explicit_private_class"
}
- -re ".*$gdb_prompt $" { fail "ptype class explicit_private_class" }
- timeout { fail "ptype class explicit_private_class (timeout)" ; return }
}
- send_gdb "ptype class mixed_protection_class\n"
- gdb_expect {
- -re "type = class mixed_protection_class \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl.*\}$nl$gdb_prompt $" {
+ # Similar test, bigger type.
+
+ gdb_test_multiple "ptype class mixed_protection_class" "ptype struct mixed_protection_class" {
+ -re "type = class mixed_protection_class \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class mixed_protection_class"
}
- -re "type = struct mixed_protection_class \{${ws}int a;${ws}int b;${ws}int c;${ws}int d;${ws}int e;${ws}int f;${ws}int g;${ws}int h;${ws}int i;$nl.*\}$nl$gdb_prompt $" {
- fail "ptype class mixed_protection_class"
+ -re "type = class mixed_protection_class \{${ws}public:${ws}int a;${ws}int b;${ws}private:${ws}int c;${ws}int d;${ws}protected:${ws}int e;${ws}int f;${ws}public:${ws}int g;${ws}private:${ws}int h;${ws}protected:${ws}int i;${ws}public:${ws}mixed_protection_class ?& ?operator ?=\\(mixed_protection_class const ?&\\);${ws}mixed_protection_class\\(mixed_protection_class const ?&\\);${ws}mixed_protection_class\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class mixed_protection_class"
}
- -re ".*$gdb_prompt $" { fail "ptype class mixed_protection_class" }
- timeout { fail "ptype class mixed_protection_class (timeout)" ; return }
}
- # This class does not use any C++-specific features, so it's fine for
- # it to print as "struct".
- send_gdb "ptype class A\n"
- gdb_expect {
- -re "type = (class|struct) A \{(${ws}public:|)${ws}int a;${ws}int x;((${ws}A & operator=\\(A const ?&\\);)|(${ws}A\\((A const|const A) ?&\\);)|(${ws}A\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
+ # Here are some classes with inheritance.
+
+ # Base class.
+
+ gdb_test_multiple "ptype class A" "ptype class A" {
+ -re "type = class A \{${ws}public:${ws}int a;${ws}int x;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class A"
}
- -re ".*$gdb_prompt $" {
- fail "ptype class A"
- }
- timeout {
- fail "ptype class A (timeout)"
- return
+ -re "type = class A \{${ws}public:${ws}int a;${ws}int x;${ws}A ?& ?operator ?=\\(A const ?&\\);${ws}A\\(A const ?&\\);${ws}A\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class A"
}
}
- send_gdb "ptype class B\n"
- gdb_expect {
- -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;${ws}B & operator=\\(B const ?&\\);${ws}B\\((B const|const B) ?&\\);${ws}B\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
+ # Derived class.
+
+ gdb_test_multiple "ptype class B" "ptype class B" {
+ -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class B"
}
- -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;((${ws}B & operator=\\(B const ?&\\);)|(${ws}B\\(B const ?&\\);)|(${ws}B\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype class B (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype class B"
- }
- timeout {
- fail "ptype class B (timeout)"
- return
+ -re "type = class B : public A \{${ws}public:${ws}int b;${ws}int x;${ws}B ?& ?operator ?=\\(B const ?&\\);${ws}B\\(B const ?&\\);${ws}B\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class B"
}
}
- send_gdb "ptype class C\n"
- gdb_expect {
- -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;${ws}C & operator=\\(C const ?&\\);${ws}C\\((C const|const C) ?&\\);${ws}C\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
+ # Derived class.
+
+ gdb_test_multiple "ptype class C" "ptype class C" {
+ -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class C"
}
- -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;((${ws}C & operator=\\(C const ?&\\);)|(${ws}C\\(C const ?&\\);)|(${ws}C\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype class C (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype class C"
- }
- timeout {
- fail "ptype class C (timeout)"
- return
+ -re "type = class C : public A \{${ws}public:${ws}int c;${ws}int x;${ws}C ?& ?operator ?=\\(C const ?&\\);${ws}C\\(C const ?&\\);${ws}C\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class C"
}
}
- send_gdb "ptype class D\n"
- gdb_expect {
- -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
+ # Derived class, multiple inheritance.
+
+ gdb_test_multiple "ptype class D" "ptype class D" {
+ -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class D"
}
- -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(D const ?&\\);)|(${ws}D\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype class D (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype class D"
- }
- timeout {
- fail "ptype class D (timeout)"
- return
+ -re "type = class D : public B, public C \{${ws}public:${ws}int d;${ws}int x;${ws}D ?& ?operator ?=\\(D const ?&\\);${ws}D\\(D const ?&\\);${ws}D\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class D"
}
}
- send_gdb "ptype class E\n"
- gdb_expect {
- -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;${ws}E & operator=\\(E const ?&\\);${ws}E\\((E const|const E) ?&\\);${ws}E\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
+ # Derived class.
+
+ gdb_test_multiple "ptype class E" "ptype class E" {
+ -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class E"
}
- -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;((${ws}E & operator=\\(E const ?&\\);)|(${ws}E\\((E const|const E) ?&\\);)|(${ws}E\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
+ -re "type = class E : public D \{${ws}public:${ws}int e;${ws}int x;${ws}E ?& ?operator ?=\\(E const ?&\\);${ws}E\\(E const ?&\\);${ws}E\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
pass "ptype class E"
}
- -re ".*$gdb_prompt $" {
- fail "ptype class E"
- }
- timeout {
- fail "ptype class E (timeout)"
- return
- }
}
- # With g++ 2.x and stabs debug info, we misinterpret static methods
- # whose name matches their argument mangling.
- send_gdb "ptype class Static\n"
- gdb_expect {
- -re "type = (class|struct) Static \{(${ws}public:|)${ws}Static & operator=\\(Static const ?&\\);${ws}Static\\((Static const|const Static) ?&\\);${ws}Static\\((void|)\\);${ws}static void ii\\(int, int\\);${ws}\}$nl$gdb_prompt $" {
+ # This is a break from inheritance tests.
+ #
+ # gcc 2.X with stabs (stabs or stabs+?) used to have a problem with
+ # static methods whose name is the same as their argument mangling.
+
+ gdb_test_multiple "ptype class Static" "ptype class Static" {
+ -re "type = class Static \{${ws}public:${ws}static void ii\\(int, int\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class Static"
}
- -re "type = (class|struct) Static \{(${ws}public:|)${ws}static void ii\\(int, int\\);${ws}\}$nl$gdb_prompt $" {
+ -re "type = class Static \{${ws}public:${ws}Static ?& ?operator ?=\\(Static const ?&\\);${ws}Static\\(Static const ?&\\);${ws}Static\\((void|)\\);${ws}static void ii\\(int, int\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
pass "ptype class Static"
}
- -re ".*$gdb_prompt $" {
- fail "ptype class Static"
- }
- timeout {
- fail "ptype class Static (timeout)"
- return
+ -re "type = class Static \{${ws}public:${ws}static void ii\\(int, int\\);${ws}Static ?& ?operator ?=\\(Static const ?&\\);${ws}Static\\(Static const ?&\\);${ws}Static\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class Static"
}
}
- send_gdb "ptype class vA\n"
- gdb_expect {
- -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;${ws}\}$nl$gdb_prompt $" {
+ # Here are some virtual inheritance tests.
+
+ gdb_test_multiple "ptype class vA" "ptype class vA" {
+ -re "type = class vA \{${ws}public:${ws}int va;${ws}int vx;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class vA"
}
- -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;${ws}vA & operator=\\(vA const ?&\\);${ws}vA\\((vA const|const vA) ?&\\);${ws}vA\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
+ -re "type = class vA \{${ws}public:${ws}int va;${ws}int vx;${ws}vA ?& ?operator ?=\\(vA const ?&\\);${ws}vA\\(vA const ?&\\);${ws}vA\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
pass "ptype class vA"
}
- -re "type = (class|struct) vA \{(${ws}public:|)${ws}int va;${ws}int vx;((${ws}vA & operator=\\(vA const ?&\\);)|(${ws}vA\\(vA const ?&\\);)|(${ws}vA\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype class vA (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype class vA"
- }
- timeout {
- fail "ptype class vA (timeout)"
- return
- }
}
- # Accept the form with embedded GNU style mangled virtual table constructs
- # for now, but with a FIXME. At some future point, gdb should use a
- # portable representation for the virtual table constructs.
+ # With gcc 2, gdb prints the virtual base pointer.
+ # With gcc 3, gdb does not print the virtual base pointer.
+ # drow considers it a gdb bug if gdb prints the vbptr.
- # The format of a g++ virtual base pointer.
- set vbptr "(_vb\[$.\]|__vb_)\[0-9\]?"
-
- send_gdb "ptype class vB\n"
- gdb_expect {
- -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}vB & operator=\\(vB const ?&\\);${ws}vB\\((vB const|const vB) ?&\\);${ws}vB\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
+ gdb_test_multiple "ptype class vB" "ptype class vB" {
+ -re "type = class vB : public virtual vA \{${ws}private:${ws}vA ?\\* ?_vb.2vA;${ws}public:${ws}int vb;${ws}int vx;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # TODO: kfail this
+ fail "ptype class vB"
+ }
+ -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class vB"
}
- -re "type = class vB : public virtual vA \{${ws}private:${ws}vA \\*${vbptr}vA;${ws}public:${ws}int vb;${ws}int vx;${ws}vB & operator=\\(vB const ?&\\);${ws}vB\\(int, vB const ?&\\);${ws}vB\\(int\\);${ws}\}$nl$gdb_prompt $" {
+ -re "type = class vB : public virtual vA \{${ws}private:${ws}vA ?\\* ?_vb.vA;${ws}public:${ws}int vb;${ws}int vx;${ws}vB ?& ?operator ?=\\(vB const ?&\\);${ws}vB\\(int, ?vB const ?&\\);${ws}vB\\(int\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # See the hidden "in-charge" ctor parameter!
+ # TODO: kfail this
setup_xfail "*-*-*"
fail "ptype class vB (FIXME: non-portable virtual table constructs)"
}
- -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}\}$nl$gdb_prompt $" {
- pass "ptype class vB"
- }
- -re "type = class vB : public virtual vA \{${ws}private:${ws}vA \\*_vb.vA;${ws}public:${ws}int vb;${ws}int vx;((${ws}vB & operator=\\(vB const ?&\\);)|(${ws}vB\\(int, vB const ?&\\);)|(${ws}vB\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
- setup_xfail "*-*-*"
- fail "ptype class vB (FIXME) (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype class vB"
- }
- timeout {
- fail "ptype class vB (timeout)"
- return
+ -re "type = class vB : public virtual vA \{${ws}public:${ws}int vb;${ws}int vx;${ws}vB ?& ?operator ?=\\(vB const ?&\\);${ws}vB\\(vB const ?&\\);${ws}vB\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class vB"
}
}
- # Accept the form with embedded GNU style mangled virtual table constructs
- # for now, but with a FIXME. At some future point, gdb should use a
- # portable representation for the virtual table constructs.
+ # Another class with a virtual base.
- send_gdb "ptype class vC\n"
- gdb_expect {
- -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}vC & operator=\\(vC const ?&\\);${ws}vC\\((vC const|const vC) ?&\\);${ws}vC\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
+ gdb_test_multiple "ptype class vC" "ptype class vC" {
+ -re "type = class vC : public virtual vA \{${ws}private:${ws}vA ?\\* ?_vb.2vA;${ws}public:${ws}int vc;${ws}int vx;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # TODO: kfail
+ fail "ptype class vC"
+ }
+ -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class vC"
}
- -re "type = class vC : public virtual vA \{${ws}private:${ws}vA \\*${vbptr}vA;${ws}public:${ws}int vc;${ws}int vx;${ws}vC & operator=\\(vC const ?&\\);${ws}vC\\(int, vC const ?&\\);${ws}vC\\(int\\);${ws}\}$nl$gdb_prompt $" {
+ -re "type = class vC : public virtual vA \{${ws}private:${ws}vA ?\\* ?_vb.vA;${ws}public:${ws}int vc;${ws}int vx;${ws}vC ?& ?operator ?=\\(vC const ?&\\);${ws}vC\\(int, ?vC const ?&\\);${ws}vC\\(int\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # See the hidden "in-charge" ctor parameter!
+ # TODO: kfail
setup_xfail "*-*-*"
fail "ptype class vC (FIXME: non-portable virtual table constructs)"
}
- -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}\}$nl$gdb_prompt $" {
- pass "ptype class vC"
- }
- -re "type = class vC : public virtual vA \{${ws}private:${ws}vA \\*_vb.vA;${ws}public:${ws}int vc;${ws}int vx;((${ws}vC & operator=\\(vC const ?&\\);)|(${ws}vC\\(int, vC const ?&\\);)|(${ws}vC\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
- setup_xfail "*-*-*"
- fail "ptype class vC (FIXME) (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype class vC"
- }
- timeout {
- fail "ptype class vC (timeout)"
- return
+ -re "type = class vC : public virtual vA \{${ws}public:${ws}int vc;${ws}int vx;${ws}vC ?& ?operator ?=\\(vC const ?&\\);${ws}vC\\(vC const ?&\\);${ws}vC\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class vC"
}
}
- # Accept the form with embedded GNU style mangled virtual table constructs
- # for now, but with a FIXME. At some future point, gdb should use a
- # portable representation for the virtual table constructs.
+ # The classic diamond inheritance.
- send_gdb "ptype class vD\n"
- gdb_expect {
- -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;${ws}vD & operator=\\(vD const ?&\\);${ws}vD\\((vD const|const vD) ?&\\);${ws}vD\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
+ gdb_test_multiple "ptype class vD" "ptype class vD" {
+ -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC ?\\* ?_vb.2vC;${ws}vB ?\\* ?_vb.2vB;${ws}public:${ws}int vd;${ws}int vx;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # TODO: kfail
+ fail "ptype class vD"
+ }
+ -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class vD"
}
- -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;${ws}vD & operator=\\(vD const ?&\\);${ws}vD\\(int, vD const ?&\\);${ws}vD\\(int\\);${ws}\}$nl$gdb_prompt $" {
+ -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC ?\\* ?_vb.vC;${ws}vB ?\\* ?_vb.vB;${ws}public:${ws}int vd;${ws}int vx;${ws}vD ?& ?operator ?=\\(vD const ?&\\);${ws}vD\\(int, ?vD const ?&\\);${ws}vD\\(int\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # See the hidden "in-charge" ctor parameter!
+ # TODO: kfail
setup_xfail "*-*-*"
fail "ptype class vD (FIXME: non-portable virtual table constructs)"
}
- -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;${ws}\}$nl$gdb_prompt $" {
- pass "ptype class vD"
- }
- -re "type = class vD : public virtual vB, public virtual vC \{${ws}private:${ws}vC \\*_vb.vC;${ws}vB \\*_vb.vB;${ws}public:${ws}int vd;${ws}int vx;((${ws}vD & operator=\\(vD const ?&\\);)|(${ws}vD\\(int, vD const ?&\\);)|(${ws}vD\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
- setup_xfail "*-*-*"
- fail "ptype class vD (FIXME) (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype class vD"
- }
- timeout {
- fail "ptype class vD (timeout)"
- return
+ -re "type = class vD : public virtual vB, public virtual vC \{${ws}public:${ws}int vd;${ws}int vx;${ws}vD ?& ?operator ?=\\(vD const ?&\\);${ws}vD\\(vD const ?&\\);${ws}vD\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class vD"
}
}
- # Accept the form with embedded GNU style mangled virtual table constructs
- # for now, but with a FIXME. At some future point, gdb should use a
- # portable representation for the virtual table constructs.
+ # One more case of virtual derivation.
- send_gdb "ptype class vE\n"
- gdb_expect {
- -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}vE & operator=\\(vE const ?&\\);${ws}vE\\((vE const|const vE) ?&\\);${ws}vE\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
+ gdb_test_multiple "ptype class vE" "ptype class vE" {
+ -re "type = class vE : public virtual vD \{${ws}private:${ws}vD ?\\* ?_vb.2vD;${ws}public:${ws}int ve;${ws}int vx;$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # TODO: kfail
+ fail "ptype class vE"
+ }
+ -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class vE"
}
- -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*${vbptr}vD;${ws}public:${ws}int ve;${ws}int vx;${ws}vE & operator=\\(vE const ?&\\);${ws}vE\\(int, vE const ?&\\);${ws}vE\\(int\\);${ws}\}$nl$gdb_prompt $" {
+ -re "type = class vE : public virtual vD \{${ws}private:${ws}vD ?\\* ?_vb.vD;${ws}public:${ws}int ve;${ws}int vx;${ws}vE ?& ?operator ?=\\(vE const ?&\\);${ws}vE\\(int, ?vE const ?&\\);${ws}vE\\(int\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # See the hidden "in-charge" ctor parameter!
+ # TODO: kfail
setup_xfail "*-*-*"
fail "ptype class vE (FIXME: non-portable virtual table constructs)"
}
- -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}\}$nl$gdb_prompt $" {
- pass "ptype class vE"
- }
- -re "type = class vE : public virtual vD \{${ws}private:${ws}vD \\*_vb.vD;${ws}public:${ws}int ve;${ws}int vx;((${ws}vE & operator=\\(vE const ?&\\);)|(${ws}vE\\(int, vE const ?&\\);)|(${ws}vE\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
- setup_xfail "*-*-*"
- fail "ptype class vE (FIXME) (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype class vE"
- }
- timeout {
- fail "ptype class vE (timeout)"
- return
+ -re "type = class vE : public virtual vD \{${ws}public:${ws}int ve;${ws}int vx;${ws}vE ?& ?operator ?=\\(vE const ?&\\);${ws}vE\\(vE const ?&\\);${ws}vE\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class vE"
}
}
- send_gdb "ptype class Base1\n"
- gdb_expect {
- -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1 & operator=\\(Base1 const ?&\\);${ws}Base1\\(((Base1 const)|(const Base1)) ?&\\);${ws}Base1\\(int\\);${ws}\}$nl$gdb_prompt $" {
+ # Another inheritance series.
+
+ gdb_test_multiple "ptype class Base1" "ptype class Base1" {
+ -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1\\(int\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class Base1"
}
- -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1\\(int\\);${ws}\}$nl$gdb_prompt $" {
+ -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1 ?& ?operator ?=\\(Base1 const ?&\\);${ws}Base1\\(Base1 const ?&\\);${ws}Base1\\(int\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
pass "ptype class Base1"
}
- -re "type = class Base1 \{${ws}public:${ws}int x;((${ws}Base1 & operator=\\(Base1 const ?&\\);)|(${ws}Base1\\(Base1 const ?&\\);)|(${ws}Base1\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype class Base1 (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype class Base1"
- }
- timeout {
- fail "ptype class Base1 (timeout)"
- return
+ -re "type = class Base1 \{${ws}public:${ws}int x;${ws}Base1\\(int\\);${ws}Base1 ?& ?operator ?=\\(Base1 const ?&\\);${ws}Base1\\(Base1 const ?&\\);$nl\}$nl$gdb_prompt $" {
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class Base1"
}
}
- send_gdb "ptype class Foo\n"
- gdb_expect {
- -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;\r\n${ws}Foo\\(int, int\\);${ws}int operator!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" {
- pass "ptype class Foo"
- }
- -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo & operator=\\(Foo const ?&\\);${ws}Foo\\((Foo const|const Foo) ?&\\);${ws}Foo\\(int, int\\);${ws}int operator!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);${ws}\}$nl$gdb_prompt $" {
+ # The second base class.
+
+ gdb_test_multiple "ptype class Foo" "ptype class Foo" {
+ -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo\\(int, int\\);${ws}int operator ?!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class Foo"
}
- -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;((${ws}Foo & operator=\\(Foo const ?&\\);)|(${ws}Foo\\(Foo const ?&\\);)|(${ws}Foo\\(int, int\\);)|(${ws}int operator!\\((void|)\\);)|(${ws}int operator int\\((void|)\\);)|(${ws}int times\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype class Foo (obsolescent gcc or gdb)"
+ -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo ?& ?operator ?=\\(Foo const ?&\\);${ws}Foo\\(Foo const ?&\\);${ws}Foo\\(int, int\\);${ws}int operator ?!\\((void|)\\);${ws}int operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # TODO: "int operator int()" is a bug
+ # kfail "gdb/1497" "ptype class Foo"
+ pass "ptype class Foo"
}
- -re ".*$gdb_prompt $" {
- fail "ptype class Foo"
+ -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo ?& ?operator ?=\\(Foo const ?&\\);${ws}Foo\\(Foo const ?&\\);${ws}Foo\\(int, int\\);${ws}int operator ?!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gstabs+
+ pass "ptype class Foo"
}
- timeout {
- fail "ptype class Foo (timeout)"
- return
+ -re "type = class Foo \{${ws}public:${ws}int x;${ws}int y;${ws}static int st;${ws}Foo\\(int, int\\);${ws}int operator ?!\\((void|)\\);${ws}operator int\\((void|)\\);${ws}int times\\(int\\);${ws}Foo ?& ?operator ?=\\(Foo const ?&\\);${ws}Foo\\(Foo const ?&\\);$nl\}$nl$gdb_prompt $" {
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class Foo"
}
}
- send_gdb "ptype class Bar\n"
- gdb_expect {
- -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar & operator=\\(Bar const ?&\\);${ws}Bar\\((Bar const|const Bar) ?&\\);${ws}Bar\\(int, int, int\\);${ws}\}$nl$gdb_prompt $" {
+ # A multiple inheritance derived class.
+
+ gdb_test_multiple "ptype class Bar" "ptype class Bar" {
+ -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar\\(int, int, int\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
pass "ptype class Bar"
}
- -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;((${ws}Bar & operator=\\(Bar const ?&\\);)|(${ws}Bar\\(Bar const ?&\\);)|(${ws}Bar\\(int, int, int\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype class Bar (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype class Bar"
+ -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar ?& ?operator ?=\\(Bar const ?&\\);${ws}Bar\\(Bar const ?&\\);${ws}Bar\\(int, int, int\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ pass "ptype class Bar"
}
- timeout {
- fail "ptype class Bar (timeout)"
- return
+ -re "type = class Bar : public Base1, public Foo \{${ws}public:${ws}int z;${ws}Bar\\(int, int, int\\);${ws}Bar ?& ?operator ?=\\(Bar const ?&\\);${ws}Bar\\(Bar const ?&\\);$nl\}$nl$gdb_prompt $" {
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype class Bar"
}
}
}
-#
# Test simple access to class members.
-#
+# TODO: these test names are gross!
+# Just let the test name default.
proc test_non_inherited_member_access {} {
global gdb_prompt
# Print non-inherited members of g_A.
-
gdb_test "print g_A.a" ".* = 1" "g_A.a incorrect"
-
gdb_test "print g_A.x" ".* = 2" "g_A.x incorrect"
# Print non-inherited members of g_B.
-
gdb_test "print g_B.b" ".* = 5" "g_B.b incorrect"
-
gdb_test "print g_B.x" ".* = 6" "g_B.x incorrect"
# Print non-inherited members of g_C.
-
gdb_test "print g_C.c" ".* = 9" "g_C.c incorrect"
-
gdb_test "print g_C.x" ".* = 10" "g_C.x incorrect"
# Print non-inherited members of g_D.
-
gdb_test "print g_D.d" ".* = 19" "g_D.d incorrect"
-
gdb_test "print g_D.x" ".* = 20" "g_D.x incorrect"
# Print non-inherited members of g_E.
-
gdb_test "print g_E.e" ".* = 31" "g_E.e incorrect"
-
gdb_test "print g_E.x" ".* = 32" "g_E.x incorrect"
}
-#
-# Try access to non-members that are members of another class.
-# Should give errors.
-#
+# Test access to members of other classes.
+# gdb should refuse to print them.
+# (I feel old -- I remember when this was legal in C -- chastain).
+# TODO: Again, change the silly test names.
proc test_wrong_class_members {} {
global gdb_prompt
gdb_test "print g_A.b" "There is no member( or method|) named b." "print g_A.b should be error"
-
gdb_test "print g_B.c" "There is no member( or method|) named c." "print g_B.c should be error"
-
gdb_test "print g_B.d" "There is no member( or method|) named d." "print g_B.d should be error"
-
gdb_test "print g_C.b" "There is no member( or method|) named b." "print g_C.b should be error"
-
gdb_test "print g_C.d" "There is no member( or method|) named d." "print g_C.d should be error"
-
gdb_test "print g_D.e" "There is no member( or method|) named e." "print g_D.e should be error"
}
-#
-# Try access to non-members that are not members of any class.
-# Should give errors.
-#
+# Test access to names that are not members of any class.
+# TODO: test names again.
proc test_nonexistent_members {} {
global gdb_prompt
gdb_test "print g_A.y" "There is no member( or method|) named y." "print g_A.y should be error"
-
gdb_test "print g_B.z" "There is no member( or method|) named z." "print g_B.z should be error"
-
gdb_test "print g_C.q" "There is no member( or method|) named q." "print g_C.q should be error"
-
gdb_test "print g_D.p" "There is no member( or method|) named p." "print g_D.p should be error"
}
-#
# Call a method that expects a base class parameter with base, inherited,
# and unrelated class arguments.
-#
proc test_method_param_class {} {
gdb_test "call class_param.Aptr_a (&g_A)" ".* = 1" "base class param->a"
@@ -606,62 +616,65 @@ proc test_method_param_class {} {
gdb_test "call class_param.Aval_a (foo)" "Cannot resolve .*" "unrelated class param"
}
-#
# Examine a class with an enum field.
-#
proc test_enums {} {
global gdb_prompt
- global hp_aCC_compiler
+ global nl
+ global ws
# print the object
- send_gdb "print obj_with_enum\n"
- gdb_expect {
- -re "\\$\[0-9\]* = \\{priv_enum = red, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (1)" }
- -re "$gdb_prompt $" { fail "print obj_with_enum (1)" }
- timeout { fail "(timeout) print obj_with_enum (1)" }
- }
- send_gdb "next\n"
- gdb_expect {
- -re "$gdb_prompt $" { pass "next" }
- timeout { fail "(timeout) next" }
- }
+ gdb_test "print obj_with_enum" \
+ "\\$\[0-9\]+ = \{priv_enum = red, x = 0\}" \
+ "print obj_with_enum (1)"
+
+ # advance one line
+
+ gdb_test "next" ""
# print the object again
- send_gdb "print obj_with_enum\n"
- gdb_expect {
- -re "\\$\[0-9\]* = \\{priv_enum = green, x = 0\\}.*$gdb_prompt $" { pass "print obj_with_enum (2)" }
- -re "$gdb_prompt $" { fail "print obj_with_enum (2)" }
- timeout { fail "(timeout) print obj_with_enum (2)" }
- }
- # print out the enum member
- send_gdb "print obj_with_enum.priv_enum\n"
- gdb_expect {
- -re "\\$\[0-9\]* = green.*$gdb_prompt $" { pass "print obj_with_enum.priv_enum" }
- -re "$gdb_prompt $" { fail "print obj_with_enum.priv_enum" }
- timeout { fail "(timeout) print obj_with_enum.priv_enum" }
- }
+ gdb_test "print obj_with_enum" \
+ "\\$\[0-9\]+ = \{priv_enum = green, x = 0\}" \
+ "print obj_with_enum (2)"
+
+ # print the enum member
+
+ gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = green"
# ptype on the enum member
- # The third success case is a little dubious, but it's not clear what
- # ought to be required of a ptype on a private enum... -sts 19990324
- send_gdb "ptype obj_with_enum.priv_enum\n"
- gdb_expect {
- -re "type = enum ClassWithEnum::PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" }
- -re "type = enum PrivEnum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" }
- -re "type = enum \\{red, green, blue, yellow = 42\\}.*$gdb_prompt $" { pass "ptype obj_with_enum.priv_enum" }
- -re "$gdb_prompt $" { fail "ptype obj_with_enum.priv_enum" }
- timeout { fail "(timeout) ptype obj_with_enum.priv_enum" }
+
+ gdb_test_multiple "ptype obj_with_enum.priv_enum" "ptype obj_with_enum.priv_enum" {
+ -re "type = enum ClassWithEnum::PrivEnum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" {
+ pass "ptype obj_with_enum.priv_enum"
+ }
+ -re "type = enum PrivEnum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ pass "ptype obj_with_enum.priv_enum"
+ }
+ -re "type = enum \{ ?red, green, blue, yellow = 42 ?\}$nl$gdb_prompt $" {
+ # This case case is a little dubious, but it's not clear what
+ # ought to be required of a ptype on a private enum...
+ # -sts 19990324
+ #
+ # It bugs me that this happens with gcc 3.
+ # -- chastain 2003-12-30
+ #
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "ptype obj_with_enum.priv_enum"
+ }
}
# ptype on the object
- send_gdb "ptype obj_with_enum\n"
- gdb_expect {
- -re "type = class ClassWithEnum \\{\r\n\[ \t\]*public:\r\n\[ \t\]*(enum |)ClassWithEnum::PrivEnum priv_enum;\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" { pass "ptype obj_with_enum" }
- -re "type = class ClassWithEnum \\{\r\n\[ \t\]*public:\r\n\[ \t\]*(enum |)PrivEnum priv_enum;\r\n\[ \t\]*int x;.*\\}\r\n$gdb_prompt $"
- {
+ gdb_test_multiple "ptype obj_with_enum" "ptype obj_with_enum" {
+ -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)ClassWithEnum::PrivEnum priv_enum;${ws}int x;$nl\}$nl$gdb_prompt $" {
+ pass "ptype obj_with_enum"
+ }
+ -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)PrivEnum priv_enum;${ws}int x;$nl\}$nl$gdb_prompt $" {
# NOTE: carlton/2003-02-28: One could certainly argue that
# this output is acceptable: PrivEnum is a member of
# ClassWithEnum, so there's no need to explicitly qualify
@@ -670,150 +683,85 @@ proc test_enums {} {
# of ClassWithEnum, so we do that output for a bad reason
# instead of a good reason. Under stabs, we probably
# can't get this right; under DWARF-2, we can.
+ #
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
kfail "gdb/57" "ptype obj_with_enum"
}
- -re "$gdb_prompt $" { fail "ptype obj_with_enum" }
- timeout { fail "(timeout) ptype obj_with_enum" }
+ -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)PrivEnum priv_enum;${ws}int x;${ws}ClassWithEnum ?& ?operator ?=\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ kfail "gdb/57" "ptype obj_with_enum"
+ }
+ -re "type = class ClassWithEnum \{${ws}public:${ws}(enum |)ClassWithEnum::PrivEnum priv_enum;${ws}int x;${ws}ClassWithEnum ?& ?operator ?=\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\(ClassWithEnum const ?&\\);${ws}ClassWithEnum\\((void|)\\);$nl\}$nl$gdb_prompt $" {
+ # I think this is a PASS, but only carlton knows for sure.
+ # -- chastain 2003-12-30
+ #
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ fail "ptype obj_with_enum"
+ }
}
- # We'll do this test twice, because of a parser bug: see
- # PR gdb/826.
+ # I'll do this test two different ways, because of a parser bug.
+ # See PR gdb/1588.
- send_gdb "print (ClassWithEnum::PrivEnum) 42\n"
- gdb_expect {
- -re "\\$\[0-9\]* = yellow.*$gdb_prompt $" { pass "print (ClassWithEnum::PrivEnum) 42" }
- -re "A parse error in expression, near `42'.\r\n$gdb_prompt $" {
- # bison 1.35
- kfail "gdb/826" "print (ClassWithEnum::PrivEnum) 42"
+ gdb_test_multiple "print (ClassWithEnum::PrivEnum) 42" "print (ClassWithEnum::PrivEnum) 42" {
+ -re "\\$\[0-9\]+ = yellow$nl$gdb_prompt $" {
+ pass "print (ClassWithEnum::PrivEnum) 42"
}
- -re "A syntax error in expression, near `42'.\r\n$gdb_prompt $" {
- # bison 1.875
- kfail "gdb/826" "print (ClassWithEnum::PrivEnum) 42"
+ -re "A (parse|syntax) error in expression, near `42'.$nl$gdb_prompt $" {
+ # "parse error" is bison 1.35.
+ # "syntax error" is bison 1.875.
+ kfail "gdb/1588" "print (ClassWithEnum::PrivEnum) 42"
}
- -re "$gdb_prompt $" { fail "print (ClassWithEnum::PrivEnum) 42" }
- timeout { fail "(timeout) print (ClassWithEnum::PrivEnum) 42" }
}
- send_gdb "print ('ClassWithEnum::PrivEnum') 42\n"
- gdb_expect {
- -re "\\$\[0-9\]* = yellow.*$gdb_prompt $" { pass "print ('ClassWithEnum::PrivEnum') 42" }
- -re "No symbol \"ClassWithEnum::PrivEnum\" in current context.\r\n$gdb_prompt $"
- { kfail "gdb/57" "print ('ClassWithEnum::PrivEnum') 42" }
- -re "$gdb_prompt $" { fail "print ('ClassWithEnum::PrivEnum') 42" }
- timeout { fail "(timeout) print ('ClassWithEnum::PrivEnum') 42" }
+ gdb_test_multiple "print ('ClassWithEnum::PrivEnum') 42" "print ('ClassWithEnum::PrivEnum') 42" {
+ -re "\\$\[0-9\]+ = yellow$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "print ('ClassWithEnum::PrivEnum') 42"
+ }
+ -re "No symbol \"ClassWithEnum::PrivEnum\" in current context.$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
+ # gcc 2.95.3 -gstabs+
+ kfail "gdb/57" "print ('ClassWithEnum::PrivEnum') 42"
+ }
}
}
-#
# Pointers to class members
-#
proc test_pointers_to_class_members {} {
global gdb_prompt
- global decimal
- global nl
-
- gdb_test "print Bar::z" ".* = .int\[ \]*\[( \]*Bar::&\[)\]+\[ \]*Bar::z" "print Bar::z"
- gdb_test "print &Foo::x" ".* = .int\[ \]*\[( \]*Foo::\[*)\]+\[ \]*&Foo::x" "print &Foo::x"
-
- gdb_test "print (int)&Foo::x" ".* = 0" "print (int)&Foo::x"
-
- send_gdb "print (int)&Bar::y == 2*sizeof(int)\n"
- gdb_expect {
- -re ".* = true$nl$gdb_prompt $" {
- pass "print (int)&Bar::y == 2*sizeof(int)"
- }
- -re "There is no field named y.*$gdb_prompt $" {
- setup_xfail "*-*-*"
- fail "print (int)&Bar::y == 2*sizeof(int)"
- }
- -re ".*$gdb_prompt $" { fail "print (int)&Bar::y == 2*sizeof(int)" }
- timeout { fail "print (int)&Bar::y == 2*sizeof(int) (timeout)" ; return }
- }
-
- send_gdb "next 2\n"
- setup_xfail "*-*-*"
- gdb_expect {
- -re "$decimal\[ \t\]+inheritance3 \[)(\]+;$nl$gdb_prompt $" {}
- -re ".*$gdb_prompt $" { fail "next to inheritance3" ; return }
- }
- clear_xfail "*-*-*"
-
- gdb_test "print (int)pmi == sizeof(int)" ".* = false" "print (int)pmi == sizeof(int)"
+ gdb_test "print Bar::z" "\\$\[0-9\]+ = \\(int ?\\( ?Bar::& ?\\) ?\\) ?Bar::z"
+ gdb_test "print &Foo::x" "\\$\[0-9\]+ = \\(int ?\\( ?Foo::\\* ?\\) ?\\) ?&Foo::x"
+ gdb_test "print (int)&Foo::x" "\\$\[0-9\]+ = 0"
+ gdb_test "print (int)&Bar::y == 2*sizeof(int)" "\\$\[0-9\]+ = true"
+
+ # TODO: this is a bogus test. It's looking at a variable that
+ # has not even been declared yet, so it's accessing random junk
+ # on the stack and comparing that it's NOT equal to a specific
+ # value. It's been like this since gdb 4.10 in 1993!
+ # -- chastain 2004-01-01
+ gdb_test "print (int)pmi == sizeof(int)" ".* = false"
}
-#
# Test static members.
-#
proc test_static_members {} {
global gdb_prompt
global hex
- global nl
-
- send_gdb "print Foo::st\n"
- gdb_expect {
- -re ".* = 100$nl$gdb_prompt $" {
- pass "print Foo::st"
- }
- -re "There is no field named st.*$gdb_prompt $" {
- setup_xfail "*-*-*"
- fail "print Foo::st"
- }
- -re ".*$gdb_prompt $" { fail "print Foo::st" }
- timeout { fail "print Foo::st (timeout)" ; return }
- }
-
- send_gdb "set foo.st = 200\n"
- gdb_expect {
- -re ".*$gdb_prompt $" {}
- }
-
- send_gdb "print bar.st\n"
- gdb_expect {
- -re ".* = 200$nl$gdb_prompt $" {
- pass "print bar.st"
- }
- -re "There is no member( or method|) named st.*$gdb_prompt $" {
- setup_xfail "*-*-*"
- fail "print bar.st"
- }
- -re ".*$gdb_prompt $" { fail "print bar.st" }
- timeout { fail "print bar.st (timeout)" ; return }
- }
-
- send_gdb "print &foo.st\n"
- gdb_expect {
- -re ".* = .int \[*)\]+ $hex$nl$gdb_prompt $" {
- pass "print &foo.st"
- }
- -re "There is no member( or method|) named st.*$gdb_prompt $" {
- setup_xfail "*-*-*"
- fail "print &foo.st"
- }
- -re ".*$gdb_prompt $" { fail "print &foo.st" }
- timeout { fail "print &foo.st (timeout)" ; return }
- }
-
- set got_bar_st 0
- send_gdb "print &Bar::st\n"
- gdb_expect {
- -re ".* = .int \[*)\]+ $hex$nl$gdb_prompt $" {
- pass "print &Bar::st"
- set got_bar_st 1
- }
- -re "There is no field named st.*$gdb_prompt $" {
- setup_xfail "*-*-*"
- fail "print &Bar::st"
- }
- -re ".*$gdb_prompt $" { fail "print &Bar::st" }
- timeout { fail "print &Bar::st (timeout)" ; return }
- }
- if $got_bar_st then {
- gdb_test "print *\$" ".* = 200" "print *\$"
- }
+ gdb_test "print Foo::st" "\\$\[0-9\]+ = 100"
+ gdb_test "set foo.st = 200" "" ""
+ gdb_test "print bar.st" "\\$\[0-9\]+ = 200"
+ gdb_test "print &foo.st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex"
+ gdb_test "print &Bar::st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex"
+ gdb_test "print *\$" "\\$\[0-9\]+ = 200"
gdb_test "set print static-members off" ""
gdb_test "print csi" \
@@ -840,6 +788,7 @@ proc do_tests {} {
global srcdir
global binfile
global gdb_prompt
+ global nl
set prms_id 0
set bug_id 0
@@ -851,74 +800,71 @@ proc do_tests {} {
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $binfile
- send_gdb "set language c++\n"
- gdb_expect -re "$gdb_prompt $"
- send_gdb "set width 0\n"
- gdb_expect -re "$gdb_prompt $"
-
- runto_main
- test_ptype_class_objects
-
- if [ runto 'inheritance2' ] then {
- test_non_inherited_member_access
- test_wrong_class_members
- test_nonexistent_members
- test_method_param_class
- }
-
- gdb_breakpoint enums2
- if [ gdb_continue "enums2(\\(\\)|)" ]==0 then {
- gdb_test "finish" "" ""
- test_enums
- }
-
- if [istarget "mips-idt-*"] then {
- # Restart because IDT/SIM runs out of file descriptors.
- gdb_exit
- gdb_start
- gdb_reinitialize_dir $srcdir/$subdir
- gdb_load $binfile
- }
-
- if [ runto_main ] then {
- test_pointers_to_class_members
- test_static_members
- }
+ gdb_test "set language c++" "" ""
+ gdb_test "set width 0" "" ""
- if [istarget "mips-idt-*"] then {
- # Restart because IDT/SIM runs out of file descriptors.
- gdb_exit
- gdb_start
- gdb_reinitialize_dir $srcdir/$subdir
- gdb_load $binfile
+ if ![runto_main ] then {
+ perror "couldn't run to breakpoint"
+ return
}
- if [ runto marker_reg1 ] then {
-
- gdb_test "finish" "Run till exit from.*" "finish from marker_reg1"
+ gdb_breakpoint inheritance2
+ gdb_test "continue" ".*Breakpoint .* inheritance2.*" ""
- send_gdb "print v.method ()\n"
- gdb_expect {
- -re "= 82.*$gdb_prompt $" {
- pass "calling method for small class"
- }
- -re "Address requested for identifier .v. which is in register.*$gdb_prompt $" {
- setup_xfail "*-*-*" 2972
- fail "calling method for small class"
- }
- -re ".*$gdb_prompt $" { fail "calling method for small class" }
- timeout { fail "calling method for small class (timeout)" }
- eof { fail "calling method for small class (eof)" }
- }
- }
+ test_ptype_class_objects
+ test_non_inherited_member_access
+ test_wrong_class_members
+ test_nonexistent_members
+ test_method_param_class
+ gdb_breakpoint enums2
+ gdb_test "continue" ".*Breakpoint .* enums2.*" "continue to enums2(\\(\\)|)"
+ gdb_test "finish" "" ""
+ test_enums
+
+ gdb_test "finish" "" ""
+ test_pointers_to_class_members
+ test_static_members
+
+ # Now some random tests that were just thrown in here.
+
+ gdb_breakpoint marker_reg1
+ gdb_test "continue" ".*Breakpoint .* marker_reg1.*" ""
+ gdb_test "finish" "Run till exit from.*" "finish from marker_reg1"
+
+ # This class is so small that an instance of it can fit in a register.
+ # When gdb tries to call a method, it gets embarrassed about taking
+ # the address of a register.
+ #
+ # TODO: I think that message should be a PASS, not an XFAIL.
+ # gdb prints an informative message and declines to do something
+ # impossible.
+ #
+ # The method call actually succeeds if the compiler allocates very
+ # small classes in memory instead of registers. So this test does
+ # not tell us anything interesting if the call succeeds.
+ #
+ # -- chastain 2003-12-31
+ gdb_test_multiple "print v.method ()" "calling method for small class" {
+ -re "\\$\[0-9\]+ = 82$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gdwarf-2
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gdwarf-2
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
+ pass "calling method for small class"
+ }
+ -re "Address requested for identifier \"v\" which is in register .*$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 2.95.3 -gstabs+
+ setup_xfail "*-*-*" 2972
+ fail "calling method for small class"
+ }
+ }
+
+ # This is a random v2 demangling test.
+ # This is redundant with existing tests in demangle.exp.
+ # TODO: Just remove this.
+ gdb_test "maint demangle inheritance1__Fv" "inheritance1\\(void\\)" "demangle"
}
do_tests
-
-send_gdb "maint demangle inheritance1__Fv\n"
-gdb_expect {
- -re "inheritance1\\(void\\).*$gdb_prompt $" { pass "demangle" }
- -re ".*$gdb_prompt $" { fail "demangle" }
- timeout { fail "(timeout) demangle" }
-}
diff --git a/gdb/testsuite/gdb.cp/cplusfuncs.exp b/gdb/testsuite/gdb.cp/cplusfuncs.exp
index 0a5e1b3f0a1..a509afb54e8 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 96e9fcff81a..a2a2e0a3245 100644
--- a/gdb/testsuite/gdb.cp/ctti.exp
+++ b/gdb/testsuite/gdb.cp/ctti.exp
@@ -1,4 +1,4 @@
-# Copyright 1998, 1999, 2001 Free Software Foundation, Inc.
+# Copyright 1998, 1999, 2001, 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,256 +14,194 @@
# 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)
#
# source files cttiadd.cc, cttiadd1.cc, cttiadd2.cc, cttiadd3.cc
-#
+# Call to template instantiations.
if $tracelevel then {
- strace $tracelevel
+ strace $tracelevel
}
if { [skip_cplus_tests] } { continue }
-# Check to see if we have an executable to test. If not, then either we
-# haven't tried to compile one, or the compilation failed for some reason.
-# In either case, just notify the user and skip the tests in this file.
-
set testfile "cttiadd"
-set srcfile ${testfile}.cc
-set srcfile1 ${testfile}1.cc
-set srcfile2 ${testfile}2.cc
-set srcfile3 ${testfile}3.cc
-set binfile ${objdir}/${subdir}/${testfile}
+set srcfile "${srcdir}/${subdir}/${testfile}.cc"
+set srcfile1 "${srcdir}/${subdir}/${testfile}1.cc"
+set srcfile2 "${srcdir}/${subdir}/${testfile}2.cc"
+set srcfile3 "${srcdir}/${subdir}/${testfile}3.cc"
+set objfile "${objdir}/${subdir}/${testfile}.o"
+set objfile1 "${objdir}/${subdir}/${testfile}1.o"
+set objfile2 "${objdir}/${subdir}/${testfile}2.o"
+set objfile3 "${objdir}/${subdir}/${testfile}3.o"
+set binfile "${objdir}/${subdir}/${testfile}"
+
+if { [gdb_compile "${srcfile}" "${objfile}" object {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;
+if { [gdb_compile "${srcfile1}" "${objfile1}" object {debug c++}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
-if { $gcc_compiled } then { continue }
+if { [gdb_compile "${srcfile2}" "${objfile2}" object {debug c++}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
-#if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile1} ${srcdir}/${subdir}/${srcfile2} ${srcdir}/${subdir}/${srcfile3}" "${binfile}" executable {debug c++}] != "" } {
-# gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
-#}
+if { [gdb_compile "${srcfile3}" "${objfile3}" object {debug c++}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
-set cmdline "$CXX_FOR_TARGET ${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile1} ${srcdir}/${subdir}/${srcfile2} ${srcdir}/${subdir}/${srcfile3} -g -o ${binfile}"
+if { [gdb_compile "${objfile} ${objfile1} ${objfile2} ${objfile3}" "${binfile}" executable {debug c++}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
-remote_exec build $cmdline
+if [get_compiler_info ${binfile} "c++"] {
+ return -1;
+}
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
-
-
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
+gdb_breakpoint [gdb_get_line_number "marker add1"]
+gdb_continue_to_breakpoint "marker add1"
-send_gdb "n\n"
-gdb_expect {
- -re "$decimal.*i = 2;.*$gdb_prompt $" {
- pass "next "
- }
- -re ".*$gdb_prompt $" { fail "next " }
- timeout { fail "next " }
- }
-
-
-send_gdb "n\n"
-gdb_expect {
- -re "$decimal.*f = 4.5;.*$gdb_prompt $" {
- pass "next "
- }
- -re ".*$gdb_prompt $" { fail "next " }
- timeout { fail "next " }
- }
-
-send_gdb "n\n"
-gdb_expect {
- -re "$decimal.*c = add\\(c, c\\);.*$gdb_prompt $" {
- pass "next "
- }
- -re ".*$gdb_prompt $" { fail "next " }
- timeout { fail "next " }
- }
-
-send_gdb "n\n"
-gdb_expect {
- -re "$decimal.*i = add\\(i, i\\);.*$gdb_prompt $" {
- pass "next "
- }
- -re ".*$gdb_prompt $" { fail "next " }
- timeout { fail "next " }
- }
-
-send_gdb "n\n"
-gdb_expect {
- -re "$decimal.*f = add\\(f, f\\);.*$gdb_prompt $" {
- pass "next "
- }
- -re ".*$gdb_prompt $" { fail "next " }
- timeout { fail "next " }
- }
-
-send_gdb "n\n"
-gdb_expect {
- -re "$decimal.*add1\\(\\);.*$gdb_prompt $" {
- pass "next "
- }
- -re ".*$gdb_prompt $" { fail "next " }
- timeout { fail "next " }
- }
+gdb_test "print c" "\\$\[0-9\]+ = 194 .*"
+gdb_test "print f" "\\$\[0-9\]+ = 9"
+gdb_test "print i" "\\$\[0-9\]+ = 4"
-send_gdb "print c\n"
-gdb_expect {
- -re ".$decimal = -62.*\r\n$gdb_prompt $" {
- pass "print value of c"
- }
- -re ".*$gdb_prompt $" { fail "print value of c" }
- timeout { fail "(timeout) print value of c" }
- }
+# TODO: this needs more work before actually deploying it.
+# So bail out here.
+if { [ test_compiler_info gcc-*] } then { continue }
-send_gdb "print f\n"
-gdb_expect {
- -re ".$decimal = 9\r\n$gdb_prompt $" {
- pass "print value of f"
- }
- -re ".*$gdb_prompt $" { fail "print value of f" }
- timeout { fail "(timeout) print value of f" }
- }
-
-
-send_gdb "print i\n"
-gdb_expect {
- -re ".$decimal = 4\r\n$gdb_prompt $" {
- pass "print value of i"
- }
- -re ".*$gdb_prompt $" { fail "print value of i" }
- timeout { fail "(timeout) print value of i" }
- }
-
-
-
-send_gdb "print add<int>(2,2)\n"
-gdb_expect {
- -re ".$decimal = 4\r\n$gdb_prompt $" {
- pass "print value of add<int>(2,2)"
- }
- -re ".*$gdb_prompt $" { fail "print value of add<int>(2,2)" }
- timeout { fail "(timeout) print value of add<int>(2,2)" }
- }
-
-send_gdb "print add<float>(2.3,2.3)\n"
-gdb_expect {
- -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" {
- pass "print value of add<float>(2.3,2.3)"
- }
- -re ".*$gdb_prompt $" { fail "print value of add<float>(2.3,2.3)" }
- timeout { fail "(timeout) print value of add<float>(2.3,2.3)" }
- }
-
-send_gdb "print add<char>('A','A')\n"
-gdb_expect {
- -re ".$decimal = -126.*202.\r\n$gdb_prompt $" {
- pass "print value of add<char>('A','A')"
- }
- -re ".*$gdb_prompt $" { fail "print value of add<char>('A','A')" }
- timeout { fail "(timeout) print value of add<char>('A','A')" }
- }
-
+gdb_test_multiple "print add<int>(2,2)" "print add<int>(2,2)" {
+ -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
+ pass "print add<int>(2,2)"
+ }
+ -re "No symbol \"add<int>\" in current context.\r\n$gdb_prompt $" {
+ # TODO: kfail or xfail this
+ fail "print add<int>(2,2)"
+ }
+}
-send_gdb "print add2<int>(2,2)\n"
-gdb_expect {
- -re ".$decimal = 4\r\n$gdb_prompt $" {
- pass "print value of add2<int>(2,2)"
- }
- -re ".*$gdb_prompt $" { fail "print value of add2<int>(2,2)" }
- timeout { fail "(timeout) print value of add2<int>(2,2)" }
- }
+# Note: 2.25 and 4.5 are exactly representable in IEEE-ish formats
+gdb_test_multiple "print add<float>(2.25,2.25)" "print add<float>(2.25,2.25)" {
+ -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
+ pass "print add<float>(2.25,2.25)"
+ }
+ -re "No symbol \"add<float>\" in current context.\r\n$gdb_prompt $" {
+ # TODO: kfail or xfail this
+ fail "print add<float>(2.25,2.25)"
+ }
+}
-send_gdb "print add2<float>(2.3,2.3)\n"
-gdb_expect {
- -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" {
- pass "print value of add2<float>(2.3,2.3)"
- }
- -re ".*$gdb_prompt $" { fail "print value of add2<float>(2.3,2.3)" }
- timeout { fail "(timeout) print value of add2<float>(2.3,2.3)" }
- }
+gdb_test_multiple "print add<unsigned char>('A','A')" "print add<unsigned char>('A','A')" {
+ -re "\\$\[0-9\]+ = -126 .*\r\n$gdb_prompt $" {
+ pass "print add<unsigned char>('A','A')"
+ }
+ -re "No symbol \"add<unsigned char>\" in current context.\r\n$gdb_prompt $" {
+ # TODO: kfail or xfail this
+ fail "print add<unsigned char>('A','A')"
+ }
+}
-send_gdb "print add2<char>('A','A')\n"
-gdb_expect {
- -re ".$decimal = -126.*202.\r\n$gdb_prompt $" {
- pass "print value of add2<char>('A','A')"
- }
- -re ".*$gdb_prompt $" { fail "print value of add2<char>('A','A')" }
- timeout { fail "(timeout) print value of add2<char>('A','A')" }
- }
+gdb_test_multiple "print add2<int>(2,2)" "print add2<int>(2,2)" {
+ -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
+ pass "print add2<int>(2,2)"
+ }
+ -re "No symbol \"add2<int>\" in current context.\r\n$gdb_prompt $" {
+ # TODO: kfail or xfail this
+ fail "print add2<int>(2,2)"
+ }
+}
-send_gdb "print add3<int>(2,2)\n"
-gdb_expect {
- -re ".$decimal = 4\r\n$gdb_prompt $" {
- pass "print value of add3<int>(2,2)"
- }
- -re ".*$gdb_prompt $" { fail "print value of add3<int>(2,2)" }
- timeout { fail "(timeout) print value of add3<int>(2,2)" }
- }
+gdb_test_multiple "print add2<float>(2.25,2.25)" "print add2<float>(2.25,2.25)" {
+ -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
+ pass "print add2<float>(2.25,2.25)"
+ }
+ -re "No symbol \"add2<float>\" in current context.\r\n$gdb_prompt $" {
+ # TODO: kfail or xfail this
+ fail "print add2<float>(2.25,2.25)"
+ }
+}
-send_gdb "print add3<float>(2.3,2.3)\n"
-gdb_expect {
- -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" {
- pass "print value of add3<float>(2.3,2.3)"
- }
- -re ".*$gdb_prompt $" { fail "print value of add3<float>(2.3,2.3)" }
- timeout { fail "(timeout) print value of add3<float>(2.3,2.3)" }
- }
+gdb_test_multiple "print add2<unsigned char>('A','A')" "print add2<unsigned char>('A','A')" {
+ -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" {
+ pass "print add2<unsigned char>('A','A')"
+ }
+ -re "No symbol \"add2<unsigned char>\" in current context.\r\n$gdb_prompt $" {
+ # TODO: kfail or xfail this
+ fail "print add2<unsigned char>('A','A')"
+ }
+}
-send_gdb "print add3<char>('A','A')\n"
-gdb_expect {
- -re ".$decimal = -126.*202.\r\n$gdb_prompt $" {
- pass "print value of add3<char>('A','A')"
- }
- -re ".*$gdb_prompt $" { fail "print value of add3<char>('A','A')" }
- timeout { fail "(timeout) print value of add3<char>('A','A')" }
- }
+gdb_test_multiple "print add3<int>(2,2)" "print add3<int>(2,2)" {
+ -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
+ pass "print add3<int>(2,2)"
+ }
+ -re "No symbol \"add3<int>\" in current context.\r\n$gdb_prompt $" {
+ # TODO: kfail or xfail this
+ fail "print add3<int>(2,2)"
+ }
+}
-send_gdb "print add4<int>(2,2)\n"
-gdb_expect {
- -re ".$decimal = 4\r\n$gdb_prompt $" {
- pass "print value of add4<int>(2,2)"
- }
- -re ".*$gdb_prompt $" { fail "print value of add4<int>(2,2)" }
- timeout { fail "(timeout) print value of add4<int>(2,2)" }
- }
+gdb_test_multiple "print add3<float>(2.25,2.25)" "print add3<float>(2.25,2.25)" {
+ -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
+ pass "print add3<float>(2.25,2.25)"
+ }
+ -re "No symbol \"add3<float>\" in current context.\r\n$gdb_prompt $" {
+ # TODO: kfail or xfail this
+ fail "print add3<float>(2.25,2.25)"
+ }
+}
-send_gdb "print add4<float>(2.3,2.3)\n"
-gdb_expect {
- -re ".$decimal = 4\\.5\[0-9\]+\r\n$gdb_prompt $" {
- pass "print value of add4<float>(2.3,2.3)"
- }
- -re ".*$gdb_prompt $" { fail "print value of add4<float>(2.3,2.3)" }
- timeout { fail "(timeout) print value of add4<float>(2.3,2.3)" }
- }
+gdb_test_multiple "print add3<unsigned char>('A','A')" "print add3<unsigned char>('A','A')" {
+ -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" {
+ pass "print add3<unsigned char>('A','A')"
+ }
+ -re "No symbol \"add3<unsigned char>\" in current context.\r\n$gdb_prompt $" {
+ # TODO: kfail or xfail this
+ fail "print add3<unsigned char>('A','A')"
+ }
+}
-send_gdb "print add4<char>('A','A')\n"
-gdb_expect {
- -re ".$decimal = -126.*202.\r\n$gdb_prompt $" {
- pass "print value of add4<char>('A','A')"
- }
- -re ".*$gdb_prompt $" { fail "print value of add4<char>('A','A')" }
- timeout { fail "(timeout) print value of add4<char>('A','A')" }
- }
+gdb_test_multiple "print add4<int>(2,2)" "print add4<int>(2,2)" {
+ -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
+ pass "print add4<int>(2,2)"
+ }
+ -re "No symbol \"add4<int>\" in current context.\r\n$gdb_prompt $" {
+ # TODO: kfail or xfail this
+ fail "print add4<int>(2,2)"
+ }
+}
+gdb_test_multiple "print add4<float>(2.25,2.25)" "print add4<float>(2.25,2.25)" {
+ -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
+ pass "print add4<float>(2.25,2.25)"
+ }
+ -re "No symbol \"add4<float>\" in current context.\r\n$gdb_prompt $" {
+ # TODO: kfail or xfail this
+ fail "print add4<float>(2.25,2.25)"
+ }
+}
-gdb_exit
-return 0
+gdb_test_multiple "print add4<unsigned char>('A','A')" "print add4<unsigned char>('A','A')" {
+ -re "\\$\[0-9]+ = -126 .*$gdb_prompt $" {
+ pass "print add4<unsigned char>('A','A')"
+ }
+ -re "No symbol \"add4<unsigned char>\" in current context.\r\n$gdb_prompt $" {
+ # TODO: kfail or xfail this
+ fail "print add4<unsigned char>('A','A')"
+ }
+}
diff --git a/gdb/testsuite/gdb.cp/cttiadd.cc b/gdb/testsuite/gdb.cp/cttiadd.cc
index 1f50fae24c1..14ac6d130e5 100644
--- a/gdb/testsuite/gdb.cp/cttiadd.cc
+++ b/gdb/testsuite/gdb.cp/cttiadd.cc
@@ -1,3 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ 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
+ 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.
+ */
+
template<class T> T add(T v1, T v2)
{
T v3;
@@ -8,7 +27,7 @@ template<class T> T add(T v1, T v2)
int main()
{
- char c;
+ unsigned char c;
int i;
float f;
extern void add1();
@@ -23,6 +42,7 @@ int main()
i = add(i, i);
f = add(f, f);
+ // marker add1
add1();
subr2();
subr3();
diff --git a/gdb/testsuite/gdb.cp/cttiadd1.cc b/gdb/testsuite/gdb.cp/cttiadd1.cc
index 7113ecea421..a67babe0a9c 100644
--- a/gdb/testsuite/gdb.cp/cttiadd1.cc
+++ b/gdb/testsuite/gdb.cp/cttiadd1.cc
@@ -1,8 +1,27 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ 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
+ 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.
+ */
+
template<class T> T add(T v1, T v2);
void add1()
{
- char c;
+ unsigned char c;
int i;
float f;
diff --git a/gdb/testsuite/gdb.cp/cttiadd2.cc b/gdb/testsuite/gdb.cp/cttiadd2.cc
index d0d9891fb2f..0d388d7cfb8 100644
--- a/gdb/testsuite/gdb.cp/cttiadd2.cc
+++ b/gdb/testsuite/gdb.cp/cttiadd2.cc
@@ -1,3 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ 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
+ 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.
+ */
+
template<class T> T add2(T v1, T v2)
{
T v3;
@@ -8,7 +27,7 @@ template<class T> T add2(T v1, T v2)
void subr2()
{
- char c;
+ unsigned char c;
int i;
float f;
diff --git a/gdb/testsuite/gdb.cp/cttiadd3.cc b/gdb/testsuite/gdb.cp/cttiadd3.cc
index 7ba1b019f16..1d11dafccd6 100644
--- a/gdb/testsuite/gdb.cp/cttiadd3.cc
+++ b/gdb/testsuite/gdb.cp/cttiadd3.cc
@@ -1,3 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ 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
+ 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.
+ */
+
template<class T> T add3(T v1, T v2)
{
T v3;
@@ -16,7 +35,7 @@ template<class T> T add4(T v1, T v2)
void subr3()
{
- char c;
+ unsigned char c;
int i;
float f;
diff --git a/gdb/testsuite/gdb.cp/demangle.exp b/gdb/testsuite/gdb.cp/demangle.exp
index 7bd9fc54d00..848f66fc7e8 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 38a46a2beaa..d82ab1f6cf9 100644
--- a/gdb/testsuite/gdb.cp/derivation.exp
+++ b/gdb/testsuite/gdb.cp/derivation.exp
@@ -1,4 +1,5 @@
-# Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright 1998, 1999, 2000, 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,28 +15,24 @@
# 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>
# This file is part of the gdb testsuite
-#
-#
-# tests for inheritance, with several derivations types combinations (private,
-# public, protected)
+# tests for inheritance, with several derivations types combinations
+# (private, public, protected)
# classes have simple members and member functions.
-#
+set ws "\[\r\n\t \]+"
+set nl "\[\r\n\]+"
if $tracelevel then {
- strace $tracelevel
- }
+ strace $tracelevel
+}
+
+# Start program.
-#
-# test running programs
-#
set prms_id 0
set bug_id 0
@@ -45,13 +42,6 @@ set testfile "derivation"
set srcfile ${testfile}.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."
}
@@ -61,13 +51,7 @@ gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
-#
-# set it up at a breakpoint so we can play with the variable values
-#
-if ![runto_main] then {
- perror "couldn't run to breakpoint"
- continue
-}
+# Set it up at a breakpoint so we can play with the variable values.
if ![runto 'marker1'] then {
perror "couldn't run to marker1"
@@ -76,236 +60,154 @@ if ![runto 'marker1'] then {
gdb_test "up" ".*main.*" "up from marker1"
+# Print class types and values.
+# See virtfunc.exp for a discussion of ptype.
+# class A
-send_gdb "print a_instance\n"
-gdb_expect {
- -re ".\[0-9\]* = \{a = 1, aa = 2\}\r\n$gdb_prompt $" {
- pass "print value of a_instance"
- }
- -re ".*$gdb_prompt $" { fail "print value of a_instance" }
- timeout { fail "(timeout) print value of a_instance" }
- }
+set re_class "((struct|class) A \{${ws}public:|struct A \{)"
+set re_fields "int a;${ws}int aa;"
+set re_methods "A\\((void|)\\);${ws}int afoo\\((void|)\\);${ws}int foo\\((void|)\\);"
+set re_synth_gcc_23 "A & operator=\\(A const ?&\\);${ws}A\\(A const ?&\\);"
+set re_all_methods "($re_methods|$re_methods${ws}$re_synth_gcc_23|$re_synth_gcc_23${ws}$re_methods)"
+gdb_test "print a_instance" "\\$\[0-9\]+ = \{a = 1, aa = 2\}" "print value of a_instance"
-send_gdb "ptype a_instance\n"
-gdb_expect {
- -re "type = class A \{\r\n\[\t \]*public:\r\n\[\t \]*int a;\r\n\[\t \]*int aa;\[\r\n\t ]+A & operator=\\(A const ?&\\);\[\r\n\t ]+A\\((A const|const A) ?&\\);\[\r\n\t ]+A\\((void|)\\);\r\n\[\t \]*int afoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype a_instance (with synth ops)" }
- -re "type = class A \{\r\n\[\t \]*public:\r\n\[\t \]*int a;\r\n\[\t \]*int aa;\[\r\n\t \]+A\\(void\\);\r\n\[\t \]*int afoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype a_instance (no synth ops)" }
- -re ".*$gdb_prompt $" { fail "ptype a_instance" }
- timeout { fail "(timeout) ptype a_instance" }
+gdb_test_multiple "ptype a_instance" "ptype a_instance" {
+ -re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+ pass "ptype a_instance (no synth ops)"
+ }
+ -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods${ws}$nl\}$nl$gdb_prompt $" {
+ pass "ptype a_instance (with synth ops)"
+ }
+ -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
+ pass "ptype a_instance (with synth ops)"
+ }
}
+# class D
+
+set re_class "class D : private A, public B, protected C \{${ws}public:"
+set XX_class "class D : private A, public B, private C \{${ws}public:"
+set re_fields "int d;${ws}int dd;"
+set re_methods "D\\((void|)\\);${ws}int dfoo\\((void|)\\);${ws}int foo\\((void|)\\);"
+set re_synth_gcc_23 "D & operator=\\(D const ?&\\);${ws}D\\(D const ?&\\);"
+set re_all_methods "($re_methods|$re_methods${ws}$re_synth_gcc_23|$re_synth_gcc_23${ws}$re_methods)"
+
+gdb_test_multiple "print d_instance" "print value of d_instance" {
+ -re "\\$\[0-9\]+ = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, d = 7, dd = 8\}$nl$gdb_prompt $" {
+ pass "print value of d_instance"
+ }
+}
-send_gdb "print d_instance\n"
-gdb_expect {
- -re ".\[0-9\]* = \{<A> = \{a = 1, aa = 2\}, <B> = \{b = 3, bb = 4\}, <C> = \{c = 5, cc = 6\}, d = 7, dd = 8\}\r\n$gdb_prompt $" {
- pass "print value of d_instance"
- }
- -re ".\[0-9\]* = \{<class A> = \{a = 1, aa = 2\}, <class B> = \{b = 3, bb = 4\}, <class C> = \{c = 5, cc = 6\}, d = 7, dd = 8\}\r\n$gdb_prompt $" {
- pass "print value of d_instance"
- }
- -re ".*$gdb_prompt $" { fail "print value of d_instance" }
- timeout { fail "(timeout) print value of d_instance" }
- }
-
- if {$gcc_compiled} then {
- send_gdb "ptype d_instance\n"
- gdb_expect {
- -re "type = class D : private A, public B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int d;\r\n\[\t \]*int dd;\[\r\n\t ]+D & operator=\\(D const ?&\\);\[\r\n\t ]+D\\((D const|const D) ?&\\);\[\r\n\t \]+D\\((void|)\\);\r\n\[\t \]*int dfoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype d_instance" }
- -re "type = class D : private A, public B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int d;\r\n\[\t \]*int dd;\[\r\n\t ]+D & operator=\\(D const ?&\\);\[\r\n\t ]+D\\((D const|const D) ?&\\);\[\r\n\t \]+D\\((void|)\\);\r\n\[\t \]*int dfoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype d_instance" }
- -re "type = class D : private A, public B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int d;\r\n\[\t \]*int dd;\[\r\n\t \]+D\\(void\\);\r\n\[\t \]*int dfoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype d_instance" }
- -re ".*$gdb_prompt $" { fail "ptype d_instance" }
- timeout { fail "(timeout) ptype d_instance" }
- }
- } else {
- send_gdb "ptype d_instance\n"
- gdb_expect {
- -re "type = class D : private A, public B, protected C \{\r\n\[\t \]*public:\r\n\[\t \]*int d;\r\n\[\t \]*int dd;\[\r\n\t \]+D\\(void\\);\r\n\[\t \]*int dfoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype d_instance" }
- -re ".*$gdb_prompt $" { fail "ptype d_instance" }
- timeout { fail "(timeout) ptype d_instance" }
- }
- }
-
-
-send_gdb "print e_instance\n"
-gdb_expect {
- -re ".\[0-9\]* = \{<A> = \{a = 1, aa = 2\}, <B> = \{b = 3, bb = 4\}, <C> = \{c = 5, cc = 6\}, e = 9, ee = 10\}\r\n$gdb_prompt $" {
- pass "print value of e_instance"
- }
- -re ".\[0-9\]* = \{<class A> = \{a = 1, aa = 2\}, <class B> = \{b = 3, bb = 4\}, <class C> = \{c = 5, cc = 6\}, e = 9, ee = 10\}\r\n$gdb_prompt $" {
- pass "print value of e_instance"
- }
- -re ".*$gdb_prompt $" { fail "print value of e_instance" }
- timeout { fail "(timeout) print value of e_instance" }
- }
-
- if {$gcc_compiled} {
- send_gdb "ptype e_instance\n"
- gdb_expect {
- -re "type = class E : public A, private B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int e;\r\n\[\t \]*int ee;\[\r\n\t ]+E & operator=\\(E const ?&\\);\[\r\n\t ]+E\\((E const|const E) ?&\\);\[\r\n\t \]+E\\((void|)\\);\r\n\[\t \]*int efoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype e_instance" }
- -re "type = class E : public A, private B, (protected|private) C \{\r\n\[\t \]*public:\r\n\[\t \]*int e;\r\n\[\t \]*int ee;\[\r\n\t \]+E\\((void|)\\);\r\n\[\t \]*int efoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype e_instance" }
- -re ".*$gdb_prompt $" { fail "ptype e_instance" }
- timeout { fail "(timeout) ptype e_instance" }
- }
- } else {
- send_gdb "ptype e_instance\n"
- gdb_expect {
- -re "type = class E : public A, private B, protected C \{\r\n\[\t \]*public:\r\n\[\t \]*int e;\r\n\[\t \]*int ee;\[\r\n\t \]+E\\((void|)\\);\r\n\[\t \]*int efoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype e_instance" }
- -re ".*$gdb_prompt $" { fail "ptype e_instance" }
- timeout { fail "(timeout) ptype e_instance" }
- }
- }
-
-
-send_gdb "print f_instance\n"
-gdb_expect {
- -re ".\[0-9\]* = \{<A> = \{a = 1, aa = 2\}, <B> = \{b = 3, bb = 4\}, <C> = \{c = 5, cc = 6\}, f = 11, ff = 12\}\r\n$gdb_prompt $" {
- pass "print value of f_instance"
- }
- -re ".\[0-9\]* = \{<class A> = \{a = 1, aa = 2\}, <class B> = \{b = 3, bb = 4\}, <class C> = \{c = 5, cc = 6\}, f = 11, ff = 12\}\r\n$gdb_prompt $" {
- pass "print value of f_instance"
- }
- -re ".*$gdb_prompt $" { fail "print value of f_instance" }
- timeout { fail "(timeout) print value of f_instance" }
- }
-
-send_gdb "ptype f_instance\n"
-gdb_expect {
- -re "type = class F : private A, public B, private C \{\r\n\[\t \]*public:\r\n\[\t \]*int f;\r\n\[\t \]*int ff;\[\r\n\t ]+F & operator=\\(F const ?&\\);\[\r\n\t ]+F\\((F const|const F) ?&\\);\[\r\n\t \]+F\\((void|)\\);\r\n\[\t \]*int ffoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype f_instance" }
- -re "type = class F : private A, public B, private C \{\r\n\[\t \]*public:\r\n\[\t \]*int f;\r\n\[\t \]*int ff;\[\r\n\t \]+F\\((void|)\\);\r\n\[\t \]*int ffoo\\((void|)\\);\r\n\[\t \]*int foo\\((void|)\\);\r\n\}.*$gdb_prompt $" { pass "ptype f_instance" }
- -re ".*$gdb_prompt $" { fail "ptype f_instance" }
- timeout { fail "(timeout) ptype f_instance" }
+gdb_test_multiple "ptype d_instance" "ptype d_instance" {
+ -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
+ pass "ptype d_instance"
+ }
+ -re "type = $re_class${ws}$re_fields${ws}$re_all_methods$nl\}$nl$gdb_prompt $" {
+ pass "ptype d_instance"
+ }
+ -re "type = $XX_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
+ # This is a gcc bug, gcc/13539, gdb/1498.
+ # Fixed in gcc HEAD 2004-01-13
+ setup_xfail "*-*-*" "gcc/13539"
+ fail "ptype d_instance"
+ }
+ -re "type = $XX_class${ws}$re_fields${ws}$re_all_methods$nl\}$nl$gdb_prompt $" {
+ # This is a gcc bug, gcc/13539, gdb/1498.
+ # Fixed in gcc HEAD 2004-01-13
+ setup_xfail "*-*-*" "gcc/13539"
+ fail "ptype d_instance"
+ }
}
+# class E
+set re_class "class E : public A, private B, protected C \{${ws}public:"
+set XX_class "class E : public A, private B, private C \{${ws}public:"
+set re_fields "int e;${ws}int ee;"
+set re_methods "E\\((void|)\\);${ws}int efoo\\((void|)\\);${ws}int foo\\((void|)\\);"
+set re_synth_gcc_23 "E & operator=\\(E const ?&\\);${ws}E\\(E const ?&\\);"
+set re_all_methods "($re_methods|$re_methods${ws}$re_synth_gcc_23|$re_synth_gcc_23${ws}$re_methods)"
-send_gdb "print d_instance.a\n"
-gdb_expect {
- -re ".\[0-9\]* = 1.*$gdb_prompt $" {
- pass "print value of d_instance.a"
- }
- -re ".*$gdb_prompt $" { fail "print value of d_instance.a" }
- timeout { fail "(timeout) print value of d_instance.a" }
- }
-
-send_gdb "print d_instance.aa\n"
-gdb_expect {
- -re ".\[0-9\]* = 2.*$gdb_prompt $" {
- pass "print value of d_instance.aa"
- }
- -re ".*$gdb_prompt $" { fail "print value of d_instance.aa" }
- timeout { fail "(timeout) print value of d_instance.aa" }
- }
-
-send_gdb "print d_instance.b\n"
-gdb_expect {
- -re ".\[0-9\]* = 3.*$gdb_prompt $" {
- pass "print value of d_instance.b"
- }
- -re ".*$gdb_prompt $" { fail "print value of d_instance.b" }
- timeout { fail "(timeout) print value of d_instance.b" }
- }
-
-send_gdb "print d_instance.bb\n"
-gdb_expect {
- -re ".\[0-9\]* = 4.*$gdb_prompt $" {
- pass "print value of d_instance.bb"
- }
- -re ".*$gdb_prompt $" { fail "print value of d_instance.bb" }
- timeout { fail "(timeout) print value of d_instance.bb" }
- }
-
-send_gdb "print d_instance.c\n"
-gdb_expect {
- -re ".\[0-9\]* = 5.*$gdb_prompt $" {
- pass "print value of d_instance.c"
- }
- -re ".*$gdb_prompt $" { fail "print value of d_instance.c" }
- timeout { fail "(timeout) print value of d_instance.c" }
- }
-
-send_gdb "print d_instance.cc\n"
-gdb_expect {
- -re ".\[0-9\]* = 6.*$gdb_prompt $" {
- pass "print value of d_instance.cc"
- }
- -re ".*$gdb_prompt $" { fail "print value of d_instance.cc" }
- timeout { fail "(timeout) print value of d_instance.cc" }
- }
-
-send_gdb "print d_instance.d\n"
-gdb_expect {
- -re ".\[0-9\]* = 7.*$gdb_prompt $" {
- pass "print value of d_instance.d"
- }
- -re ".*$gdb_prompt $" { fail "print value of d_instance.d" }
- timeout { fail "(timeout) print value of d_instance.d" }
- }
-
-send_gdb "print d_instance.dd\n"
-gdb_expect {
- -re ".\[0-9\]* = 8.*$gdb_prompt $" {
- pass "print value of d_instance.dd"
- }
- -re ".*$gdb_prompt $" { fail "print value of d_instance.dd" }
- timeout { fail "(timeout) print value of d_instance.dd" }
- }
-
-send_gdb "print g_instance.a\n"
-gdb_expect {
- -re "warning.*$gdb_prompt $" {
- # The compiler doesn't think this is ambiguous.
- fail "print value of g_instance.a"
+gdb_test_multiple "print e_instance" "print value of e_instance" {
+ -re "\\$\[0-9\]+ = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, e = 9, ee = 10\}$nl$gdb_prompt $" {
+ pass "print value of e_instance"
}
- -re ".\[0-9\]* = 15.*$gdb_prompt $" {
- pass "print value of g_instance.a"
- }
- -re ".*$gdb_prompt $" { fail "print value of g_instance.a" }
- timeout { fail "(timeout) print value of g_instance.a" }
- }
-
-send_gdb "print g_instance.b\n"
-gdb_expect {
- -re "warning.*$gdb_prompt $" {
- # The compiler doesn't think this is ambiguous.
- fail "print value of g_instance.b"
+}
+
+gdb_test_multiple "ptype e_instance" "ptype e_instance" {
+ -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
+ pass "ptype e_instance"
+ }
+ -re "type = $re_class${ws}$re_fields${ws}$re_all_methods$nl\}$nl$gdb_prompt $" {
+ pass "ptype e_instance"
+ }
+ -re "type = $XX_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
+ # This is a gcc bug, gcc/13539, gdb/1498.
+ # Fixed in gcc HEAD 2004-01-13
+ setup_xfail "*-*-*" "gcc/13539"
+ fail "ptype e_instance"
+ }
+ -re "type = $XX_class${ws}$re_fields${ws}$re_all_methods$nl\}$nl$gdb_prompt $" {
+ # This is a gcc bug, gcc/13539, gdb/1498.
+ # Fixed in gcc HEAD 2004-01-13
+ setup_xfail "*-*-*" "gcc/13539"
+ fail "ptype e_instance"
+ }
+}
+
+# class F
+
+set re_class "class F : private A, public B, private C \{${ws}public:"
+set re_fields "int f;${ws}int ff;"
+set re_methods "F\\((void|)\\);${ws}int ffoo\\((void|)\\);${ws}int foo\\((void|)\\);"
+set re_synth_gcc_23 "F & operator=\\(F const ?&\\);${ws}F\\(F const ?&\\);"
+set re_all_methods "($re_methods|$re_methods${ws}$re_synth_gcc_23|$re_synth_gcc_23${ws}$re_methods)"
+
+gdb_test_multiple "print f_instance" "print value of f_instance" {
+ -re "\\$\[0-9\]+ = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, f = 11, ff = 12\}$nl$gdb_prompt $" {
+ pass "print value of f_instance"
+ }
+}
+
+gdb_test_multiple "ptype f_instance" "ptype f_instance" {
+ -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23$nl\}$nl$gdb_prompt $" {
+ pass "ptype f_instance"
}
- -re ".\[0-9\]* = 16.*$gdb_prompt $" {
- pass "print value of g_instance.b"
- }
- -re ".*$gdb_prompt $" { fail "print value of g_instance.b" }
- timeout { fail "(timeout) print value of g_instance.b" }
- }
-
-send_gdb "print g_instance.c\n"
-gdb_expect {
- -re "warning.*$gdb_prompt $" {
- # The compiler doesn't think this is ambiguous.
- fail "print value of g_instance.c"
+ -re "type = $re_class${ws}$re_fields${ws}$re_all_methods$nl\}$nl$gdb_prompt $" {
+ pass "ptype f_instance"
}
- -re ".\[0-9\]* = 17.*$gdb_prompt $" {
- pass "print value of g_instance.c"
- }
- -re ".*$gdb_prompt $" { fail "print value of g_instance.c" }
- timeout { fail "(timeout) print value of g_instance.c" }
- }
-
-send_gdb "print g_instance.afoo()\n"
-gdb_expect {
- -re ".\[0-9\]* = 1.*$gdb_prompt $" {
- pass "print value of g_instance.afoo()"
- }
- -re ".*$gdb_prompt $" { fail "print value of g_instance.afoo()" }
- timeout { fail "(timeout) print value of g_instance.afoo()" }
- }
+}
+
+# Print individual fields.
+
+gdb_test "print d_instance.a" "\\$\[0-9\]+ = 1" "print value of d_instance.a"
+gdb_test "print d_instance.aa" "\\$\[0-9\]+ = 2" "print value of d_instance.aa"
+gdb_test "print d_instance.b" "\\$\[0-9\]+ = 3" "print value of d_instance.b"
+gdb_test "print d_instance.bb" "\\$\[0-9\]+ = 4" "print value of d_instance.bb"
+gdb_test "print d_instance.c" "\\$\[0-9\]+ = 5" "print value of d_instance.c"
+gdb_test "print d_instance.cc" "\\$\[0-9\]+ = 6" "print value of d_instance.cc"
+gdb_test "print d_instance.d" "\\$\[0-9\]+ = 7" "print value of d_instance.d"
+gdb_test "print d_instance.dd" "\\$\[0-9\]+ = 8" "print value of d_instance.dd"
+# Print some fields which are defined in the top of class G
+# and in its base classes. This is not be ambiguous.
+
+gdb_test "print g_instance.a" "\\$\[0-9\]+ = 15" "print value of g_instance.a"
+gdb_test "print g_instance.b" "\\$\[0-9\]+ = 16" "print value of g_instance.b"
+gdb_test "print g_instance.c" "\\$\[0-9\]+ = 17" "print value of g_instance.c"
+
+# Print a function call.
+
+gdb_test "print g_instance.afoo()" "\\$\[0-9\]+ = 1" "print value of g_instance.afoo()"
# If GDB fails to restore the selected frame properly after the
# inferior function call above (see GDB PR 1155 for an explanation of
# why this might happen), all the subsequent tests will fail. We
# should detect report that failure, but let the marker call finish so
# that the rest of the tests can run undisturbed.
+
gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" {
-re "#0 marker1.*$gdb_prompt $" {
setup_kfail "gdb/1155" s390-*-linux-gnu
@@ -317,21 +219,6 @@ gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" {
pass "re-selected 'main' frame after inferior call"
}
}
-
-send_gdb "print g_instance.bfoo()\n"
-gdb_expect {
- -re ".\[0-9\]* = 2.*$gdb_prompt $" {
- pass "print value of g_instance.bfoo()"
- }
- -re ".*$gdb_prompt $" { fail "print value of g_instance.bfoo()" }
- timeout { fail "(timeout) print value of g_instance.bfoo()" }
- }
-
-send_gdb "print g_instance.cfoo()\n"
-gdb_expect {
- -re ".\[0-9\]* = 3.*$gdb_prompt $" {
- pass "print value of g_instance.cfoo()"
- }
- -re ".*$gdb_prompt $" { fail "print value of g_instance.cfoo()" }
- timeout { fail "(timeout) print value of g_instance.cfoo()" }
- }
+
+gdb_test "print g_instance.bfoo()" "\\$\[0-9\]+ = 2" "print value of g_instance.bfoo()"
+gdb_test "print g_instance.cfoo()" "\\$\[0-9\]+ = 3" "print value of g_instance.cfoo()"
diff --git a/gdb/testsuite/gdb.cp/exception.cc b/gdb/testsuite/gdb.cp/exception.cc
new file mode 100644
index 00000000000..cd124e59285
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/exception.cc
@@ -0,0 +1,69 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 1997, 1998, 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.
+ */
+
+
+
+// Test file for exception handling support.
+
+#include <iostream>
+using namespace std;
+
+int foo (int i)
+{
+ if (i < 32)
+ throw (int) 13;
+ else
+ return i * 2;
+}
+
+extern "C" int bar (int k, unsigned long eharg, int flag);
+
+int bar (int k, unsigned long eharg, int flag)
+{
+ cout << "k is " << k << " eharg is " << eharg << " flag is " << flag << endl;
+ return 1;
+}
+
+int main()
+{
+ int j;
+
+ try {
+ j = foo (20);
+ }
+ catch (int x) {
+ cout << "Got an except " << x << endl;
+ }
+
+ try {
+ try {
+ j = foo (20);
+ }
+ catch (int x) {
+ cout << "Got an except " << x << endl;
+ throw;
+ }
+ }
+ catch (int y) {
+ cout << "Got an except (rethrown) " << y << endl;
+ }
+
+ // Not caught
+ foo (20);
+}
diff --git a/gdb/testsuite/gdb.cp/exception.exp b/gdb/testsuite/gdb.cp/exception.exp
new file mode 100644
index 00000000000..31930913a23
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/exception.exp
@@ -0,0 +1,219 @@
+# Copyright 1997, 1998, 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.
+# tests for exception-handling support
+# Written by Satish Pai <pai@apollo.hp.com> 1997-07-23
+# Rewritten by Michael Chastain <mec.gnu@mindspring.com> 2004-01-08
+
+# This file used to have two copies of the tests with different
+# compiler flags for hp-ux. Instead, the user should set CXXOPTS
+# or run runtest with --target_board unix/gdb:debug_flags="..."
+# to choose the compiler flags.
+#
+# The interesting compiler flags are: "aCC +A -Wl,-a,-archive" .
+# Static-linked executables use a different mechanism to get the
+# address of the notification hook in the C++ support library.
+
+# TODO: this file is not ready for production yet. If you are working
+# on C++ exception support for gdb, you can take out the "continue"
+# statement and try your luck. -- chastain 2004-01-09
+
+# TODO: this file has many absolute line numbers.
+# Replace them with gdb_get_line_number.
+
+set ws "\[\r\n\t \]+"
+set nl "\[\r\n\]+"
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+set testfile "exception"
+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."
+}
+
+# Start with a fresh gdb
+
+set prms_id 0
+set bug_id 0
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+if ![runto_main] then {
+ perror "couldn't run to breakpoint"
+ continue
+}
+
+# As I said before, this test script is not ready yet!
+
+continue
+
+# Set a catch catchpoint
+
+gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)"
+
+# Set a throw catchpoint
+
+gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)" \
+ "catch throw (static executable)"
+
+# The catchpoints should be listed in the list of breakpoints.
+
+set re_head "Num${ws}Type${ws}Disp${ws}Enb${ws}Address${ws}What"
+set re_1_main "1${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}in main.*breakpoint already hit.*"
+set re_2_catch "2${ws}catch catch${ws}keep${ws}y${ws}$hex${ws}exception catch"
+set re_3_catch "3${ws}catch throw${ws}keep${ws}y${ws}$hex${ws}exception throw"
+set re_2_bp "2${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}exception catch"
+set re_3_bp "3${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}exception throw"
+
+set name "info breakpoints"
+gdb_test_multiple "info breakpoints" $name {
+ -re "$re_head${ws}$re_1_main${ws}$re_2_catch${ws}$re_3_catch\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "$re_head${ws}$re_1_main${ws}$re_2_bp${ws}$re_3_bp\r\n$gdb_prompt $" {
+ # TODO: gdb HEAD 2004-01-08 does this. Is this okay?
+ unresolved $name
+ }
+}
+
+# Some targets support "info catch".
+# Some do not.
+
+set name "info catch"
+gdb_test_multiple "info catch" $name {
+ -re "Info catch not supported with this target/compiler combination.\r\n$gdb_prompt $" {
+ unsupported $name
+ }
+ -re "No catches.\r\n$gdb_prompt $" {
+ # TODO: gdb HEAD 2004-01-08 does this. Is this okay?
+ unresolved $name
+ }
+}
+
+# Get the first exception thrown
+
+set name "continue to first throw"
+gdb_test_multiple "continue" $name {
+ -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:50\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\)\r\n.*\r\n$gdb_prompt $" {
+ # TODO: gdb HEAD 2004-01-08 does this. Is this okay?
+ unresolved $name
+ }
+}
+
+# Backtrace from the throw point.
+# This should get to user code.
+
+set name "backtrace after first throw"
+gdb_test_multiple "backtrace" $name {
+ -re ".*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:30\r\n#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*${srcfile}:48\r\n$gdb_prompt $" {
+ pass $name
+ }
+}
+
+# Continue to the catch.
+
+set name "continue to first catch"
+gdb_test_multiple "continue" $name {
+ -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\), throw location.*${srcfile}:30, catch location .*${srcfile}:50\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\)\r\n.*\r\n$gdb_prompt $" {
+ # TODO: gdb HEAD 2004-01-08 does this. Is this okay?
+ unresolved $name
+ }
+}
+
+# Backtrace from the catch point.
+# This should get to user code.
+
+set name "backtrace after first catch"
+gdb_test_multiple "backtrace" $name {
+ -re ".*#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*$srcfile:50\r\n$gdb_prompt $" {
+ pass $name
+ }
+}
+
+# Continue to second throw.
+
+set name "continue to second throw"
+gdb_test_multiple "continue" $name {
+ -re "Continuing.${ws}Got an except 13${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "Continuing.${ws}Got an except 13${ws}Catchpoint \[0-9\]+ \\(exception thrown\\)\r\n.*\r\n$gdb_prompt $" {
+ # TODO: gdb HEAD 2004-01-08 does this. Is this okay?
+ unresolved $name
+ }
+}
+
+# Backtrace from the throw point.
+# This should get to user code.
+
+set name "backtrace after second throw"
+gdb_test_multiple "backtrace" $name {
+ -re ".*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:30\r\n#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*${srcfile}:56\r\n$gdb_prompt $" {
+ pass $name
+ }
+}
+
+# Continue to second catch.
+
+set name "continue to second catch"
+gdb_test_multiple "continue" $name {
+ -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\)\r\n.*\r\n$gdb_prompt $" {
+ # TODO: gdb HEAD 2004-01-08 does this. Is this okay?
+ unresolved $name
+ }
+}
+
+# Backtrace from the catch point.
+# This should get to user code.
+
+set name "backtrace after second catch"
+gdb_test_multiple "backtrace" $name {
+ -re ".*#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*$srcfile:58\r\n$gdb_prompt $" {
+ pass $name
+ }
+}
+
+# That is all for now.
+#
+# The original code had:
+#
+# continue to re-throw ; backtrace
+# continue to catch ; backtrace
+# continue to throw out of main
+#
+# The problem is that "re-throw" does not show a throw; only a catch.
+# I do not know if this is because of a bug, or because the generated
+# code is optimized for a throw into the same function.
+#
+# -- chastain 2004-01-09
diff --git a/gdb/testsuite/gdb.cp/hang.exp b/gdb/testsuite/gdb.cp/hang.exp
index 4c117a10744..23088741fb4 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 993bfb159cb..72de1ac33a7 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 21ceb7ae3db..6bae99ff290 100644
--- a/gdb/testsuite/gdb.cp/local.exp
+++ b/gdb/testsuite/gdb.cp/local.exp
@@ -1,4 +1,5 @@
-# Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+# Copyright 1998, 1999, 2000, 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
-
# 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
@@ -24,6 +22,9 @@
# This file is part of the gdb testsuite
+set ws "\[\r\n\t \]+"
+set nl "\[\r\n\]+"
+
if $tracelevel then {
strace $tracelevel
}
@@ -69,45 +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
-set sep "(\[.\]|___)\[0-9\]"
+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|)\\);"
-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 ".*$gdb_prompt $" { fail "ptype Local" }
- timeout { fail "(timeout) ptype Local" }
+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"
+
+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"
@@ -131,6 +191,10 @@ gdb_expect {
# this right.
kfail gdb/825 "Local out of scope"
}
+ -re "ptype Local${eol}type = class Local {${eol} public:${eol} int loc1;${eol} char loc_foo\\(char\\);${eol}.*${eol}}${eol}${gdb_prompt} " {
+ # gcc 3.X abi-2 -gstabs+
+ kfail gdb/825 "Local out of scope"
+ }
-re ".*${gdb_prompt} $" {
fail "Local out of scope"
}
@@ -168,12 +232,20 @@ gdb_expect {
#
# chastain 2002-05-27
+# Pattern 5:
+# PASS
+# stabs+
+# HEAD
+#
+# chastain 2004-01-02
+
send_gdb "ptype InnerLocal\n"
gdb_expect {
-re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*(InnerLocal::|)NestedInnerLocal nest1;\[\r\n\t \]*int il_foo\\((unsigned char const|const unsigned char) *&\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal (pattern 1)" }
-re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*(InnerLocal::|)NestedInnerLocal nest1;\[\r\n\t \]*InnerLocal *& operator *=\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((void|)\\);\[\r\n\t \]*int il_foo\\(unsigned char const *&\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal (pattern 2)" }
-re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*InnerLocal::NestedInnerLocal nest1;\r\n\r\n\[\t \]*.int il_foo\\(unsigned char const &\\);\r\n\[\t \]*\}\[\t \]*\\(Local at.*local\\.cc:36\\).*$gdb_prompt $" { pass "ptype InnerLocal (old HP aCC)" }
-re "type = class InnerLocal \{\r\n\[\t \]*public:\r\n\[\t \]*char ilc;\r\n\[\t \]*int \\*ip;\r\n\[\t \]*class InnerLocal4::NestedInnerLocal nest1;\r\n\r\n\[\t \]*int il_foo\\(unsigned char const &\\);\r\n\[\t \]*\\(Local at.*local\.cc:\[0-9\]+\\)\r\n\}.*$gdb_prompt $" { pass "ptype InnerLocal (old HP aCC)" }
+ -re "type = class InnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*char ilc;\[\r\n\t \]*int \\* *ip;\[\r\n\t \]*(InnerLocal::|)NestedInnerLocal nest1;\[\r\n\t \]* int il_foo\\(unsigned char const *&\\);\[\r\n\t \]*InnerLocal *& operator *=\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((main${sep}::|)InnerLocal const *&\\);\[\r\n\t \]*InnerLocal\\((void|)\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal (pattern 5)" }
-re ".*$gdb_prompt $" { fail "ptype InnerLocal" }
timeout { fail "(timeout) ptype InnerLocal" }
}
@@ -191,38 +263,46 @@ gdb_expect {
#
# chastain 2002-04-08
+# NOTE (2004-02-24, carlton): This test really is invalid -
+# 'NestedInnerLocal' shouldn't be visible, so only the third
+# expression should count as a pass. I'm leaving in the earlier
+# passes, however, given the current problematic state of our local
+# class support, but once we fix PR gdb/482, we should delete this
+# test.
+
send_gdb "ptype NestedInnerLocal\n"
gdb_expect {
-re "type = class NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype NestedInnerLocal" }
-re "type = class NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*NestedInnerLocal *& *operator *= *\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((void|)\\);\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype NestedInnerLocal" }
+ -re "No symbol \"NestedInnerLocal\" in current context\.\r\n$gdb_prompt $" {
+ pass "ptype NestedInnerLocal"
+ }
-re ".*$gdb_prompt $" { fail "ptype NestedInnerLocal" }
timeout { fail "(timeout) ptype NestedInnerLocal" }
}
-# gdb incorrectly interprets the NestedInnerLocal in
-# InnerLocal::NestedInnerLocal as field name instead of a type name;
-# See CLLbs14784.
+set re_class "((struct|class) InnerLocal::NestedInnerLocal \{${ws}public:|struct InnerLocal::NestedInnerLocal \{)"
+set re_fields "int nil;"
+set re_methods "int nil_foo\\(int\\);"
+set re_synth_gcc_23 "InnerLocal::NestedInnerLocal & operator=\\(InnerLocal::NestedInnerLocal const ?&\\);${ws}NestedInnerLocal\\(InnerLocal::NestedInnerLocal const ?&\\);${ws}NestedInnerLocal\\(\\);"
-#---
-# Pattern 3:
-# FAIL
-# The comment above, about CLLbs14784, is still correct.
-# dwarf-2
-# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
-# stabs+
-# gcc 2.95.3, 2.96-rh, 3.0.4, gcc-3_1-branch, HEAD
-#
-# chastain 2002-04-08
-
-send_gdb "ptype InnerLocal::NestedInnerLocal\n"
-gdb_expect {
- -re "type = class InnerLocal::NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal::NestedInnerLocal" }
- -re "type = class InnerLocal::NestedInnerLocal \{\[\r\n\t \]*public:\[\r\n\t \]*int nil;\[\r\n\t \]*NestedInnerLocal *& *operator *= *\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((main${sep}::|)InnerLocal::NestedInnerLocal const *&\\);\[\r\n\t \]*NestedInnerLocal\\((void|)\\);\[\r\n\t \]*int nil_foo\\(int\\);\[\r\n\t \]*\}.*$gdb_prompt $" { pass "ptype InnerLocal::NestedInnerLocal" }
- -re "There is no field named NestedInnerLocal.*$gdb_prompt $" {
- setup_kfail "gdb/482" *-*-*
- fail "ptype InnerLocal::NestedInnerLocal"
- }
- -re "No symbol .*NestedInnerLocal.* in current context.*$gdb_prompt $" { fail "ptype InnerLocal::NestedInnerLocal (bogus symbol lookup)" }
- -re ".*$gdb_prompt $" { fail "ptype InnerLocal::NestedInnerLocal" }
- timeout { fail "(timeout) ptype InnerLocal::NestedInnerLocal" }
+set name "ptype InnerLocal::NestedInnerLocal"
+gdb_test_multiple "ptype InnerLocal::NestedInnerLocal" $name {
+ -re "type = $re_class${ws}$re_fields${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+ # gcc -gdwarf-2 should produce this but does not yet
+ pass $name
+ }
+ -re "type = $re_class${ws}$re_fields${ws}$re_synth_gcc_23${ws}$re_methods${ws}$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc v3 -gstabs+, abi 1
+ pass $name
+ }
+ -re "type = $re_class${ws}$re_fields${ws}$re_methods${ws}$re_synth_gcc_23${ws}$nl\}$nl$gdb_prompt $" {
+ # gcc v3 -gstabs+, abi 2
+ pass $name
+ }
+ -re "There is no field named NestedInnerLocal.*$gdb_prompt $" {
+ # gcc v3 -gdwarf-2
+ kfail "gdb/482" $name
+ }
}
diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
index d291135fb06..56cd7bc3bfc 100644
--- a/gdb/testsuite/gdb.cp/m-static.exp
+++ b/gdb/testsuite/gdb.cp/m-static.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
@@ -33,16 +33,22 @@ set prms_id 0
set bug_id 0
set testfile "m-static"
-set srcfile ${testfile}.cc
-set srcfile1 ${testfile}1.cc
-set binfile ${objdir}/${subdir}/${testfile}
+set srcfile "${srcdir}/${subdir}/${testfile}.cc"
+set srcfile1 "${srcdir}/${subdir}/${testfile}1.cc"
+set objfile "${objdir}/${subdir}/${testfile}.o"
+set objfile1 "${objdir}/${subdir}/${testfile}1.o"
+set binfile "${objdir}/${subdir}/${testfile}"
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile1}" "${binfile}" executable {debug c++}] != "" } {
+if { [gdb_compile "${srcfile}" "${objfile}" object {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
+if { [gdb_compile "${srcfile1}" "${objfile1}" object {debug c++}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+if { [gdb_compile "${objfile} ${objfile1}" "${binfile}" executable {debug c++}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
gdb_exit
diff --git a/gdb/testsuite/gdb.cp/maint.exp b/gdb/testsuite/gdb.cp/maint.exp
index 710e14ae648..fd93333b758 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 4beb92616d4..e668c4623c1 100644
--- a/gdb/testsuite/gdb.cp/member-ptr.cc
+++ b/gdb/testsuite/gdb.cp/member-ptr.cc
@@ -1,3 +1,24 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ 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
+ 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.
+ */
+
+
+
extern "C" {
#include <stdio.h>
}
diff --git a/gdb/testsuite/gdb.cp/member-ptr.exp b/gdb/testsuite/gdb.cp/member-ptr.exp
index f21cd1506e7..f6a9d4039b0 100644
--- a/gdb/testsuite/gdb.cp/member-ptr.exp
+++ b/gdb/testsuite/gdb.cp/member-ptr.exp
@@ -1,4 +1,6 @@
-# Copyright 1998, 1999 Free Software Foundation, Inc.
+# Copyright 1998, 1999, 2003, 2004 Free Software Foundation, Inc.
+
+# This file is part of the gdb testsuite
# 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,29 +16,20 @@
# 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
-# This file is part of the gdb testsuite
+# TODO: copyright notice for member-ptr.cc
+set vhn "\\$\[0-9\]+"
if $tracelevel then {
- strace $tracelevel
- }
+ strace $tracelevel
+}
if { [skip_cplus_tests] } { continue }
-#
-# test running programs
-#
-
-# Start with a fresh gdb
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
set prms_id 0
set bug_id 0
@@ -44,506 +37,586 @@ set testfile "member-ptr"
set srcfile ${testfile}.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
}
-# Nearly all of these tests fail when compiled with G++, so just give up
-# until GDB gets enhanced. -sts 1999-06-22
-
-if {$gcc_compiled} {
- continue
-}
-
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."
}
-
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
-
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
-send_gdb "break 83\n"
-gdb_expect {
- -re "Breakpoint \[0-9\]*.*line 83\\.\r\n$gdb_prompt $" {
- pass "set break at 83"
- }
- -re ".*$gdb_prompt $" { fail "set break at 83" }
- timeout { fail "(timeout) set break at 83" }
-}
+gdb_breakpoint [gdb_get_line_number "pmi = NULL"]
+gdb_continue_to_breakpoint "continue to pmi = NULL"
-send_gdb "continue\n"
-gdb_expect {
- -re "Continuing\\.\r\n\r\nBreakpoint.*at.*member-ptr\\.cc:83\r\n83\[ \t]*pmi = NULL;\r\n$gdb_prompt $" {
- pass "continue to 83"
- }
- -re ".*$gdb_prompt $" { fail "continue to 83" }
- timeout { fail "(timeout) continue to 83" }
+# gcc is not ready for production
+# -- chastain 2004-01-12
+
+if { [test_compiler_info "gcc-*"] } {
+ continue
}
+# ======================
+# pointer to member data
+# ======================
+
# ptype on pointer to data member
-send_gdb "ptype pmi\n"
-gdb_expect {
- -re "type = int \\( A::\\*\\)\r\n$gdb_prompt $" {
- pass "ptype pmi"
+set name "ptype pmi (A::j)"
+gdb_test_multiple "ptype pmi" $name {
+ -re "type = int *\\( ?A::\\*\\)\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "type = int *A::\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "ptype pmi" }
- timeout { fail "(timeout) ptype pmi" }
}
# print pointer to data member
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print pmi\n"
-gdb_expect {
- -re "\\$\[0-9\]* = \\(int \\( A::\\*\\)\\) &A::j\r\n$gdb_prompt $" {
- pass "print pmi"
+set name "print pmi (A::j) "
+gdb_test_multiple "print pmi" $name {
+ -re "$vhn = &A::j\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "$vhn = \\(int ?\\( ?A::\\*\\)\\) &A::j\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "$vhn = \\(int ?\\( ?A::\\*\\)\\) ?&A::j ?\\+ ?1 bytes\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ kfail "gdb/NNNN" $name
+ }
+ -re "$vhn = &A::j ?\\+ ?1 bytes\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ kfail "gdb/NNNN" $name
+ }
+ -re "$vhn = not implemented: member type in c_val_print\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-11 05:33:21 -gdwarf-2
+ # gcc HEAD 2004-01-11 05:33:21 -gstabs+
+ kfail "gdb/NNNN" $name
+ }
+ -re "$vhn = \\(int ?\\( A::\\*\\)\\) 536870920\r\n$gdb_prompt $" {
+ # the value is 0x20000008 hex. 0x20000000 is an internal flag.
+ # Use '|' to add in more values as needed.
+ # hpacc A.03.45
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print pmi" }
- timeout { fail "(timeout) print pmi" }
}
-
# print dereferenced pointer to data member
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print a.*pmi\n"
-gdb_expect {
- -re "\\$\[0-9\]* = 121\r\n$gdb_prompt $" {
- pass "print a.*pmi"
+set name "print a.*pmi (A::j)"
+gdb_test_multiple "print a.*pmi" $name {
+ -re "$vhn = 121\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "$vhn = 855638016\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 2.95.3 -gstabs+
+ kfail "gdb/NNNN" $name
+ }
+ -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print a.*pmi" }
- timeout { fail "(timeout) print a.*pmi" }
}
# print dereferenced pointer to data member
# this time, dereferenced through a pointer
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print a_p->*pmi\n"
-gdb_expect {
- -re "\\$\[0-9\]* = 121\r\n$gdb_prompt $" {
- pass "print a->*pmi"
+set name "print a_p->*pmi (A::j)"
+gdb_test_multiple "print a_p->*pmi" $name {
+ -re "$vhn = 121\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "$vhn = 855638016\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 2.95.3 -gstabs+
+ kfail "gdb/NNNN" $name
+ }
+ -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print a->*pmi" }
- timeout { fail "(timeout) print a->*pmi" }
}
+# set the pointer to a different data member
-# set the pointer to data member
-
-send_gdb "set var pmi = &A::jj\n"
-gdb_expect {
- -re "$gdb_prompt $" {
- pass "set var (not really a pass)"
+set name "set var pmi = &A::jj"
+gdb_test_multiple "set var pmi = &A::jj" $name {
+ -re "Invalid cast.\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
+ }
+ -re "set var pmi = &A::jj\r\n$gdb_prompt $" {
+ # I have to match the echo'ed input explicitly here.
+ # If I leave it out, the pattern becomes too general
+ # and matches anything that ends in "$gdb_prompt $".
+ pass $name
}
- timeout { fail "(timeout) " }
}
-# Now print the pointer again
+# print the pointer again
-send_gdb "print pmi\n"
-gdb_expect {
- -re "\\$\[0-9\]* = \\(int \\( A::\\*\\)\\) &A::jj\r\n$gdb_prompt $" {
- pass "print pmi after setting"
+set name "print pmi (A::jj)"
+gdb_test_multiple "print pmi" $name {
+ -re "$vhn = &A::jj\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "$vhn = \\(int ?\\( ?A::\\*\\)\\) &A::jj\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "$vhn = not implemented: member type in c_val_print\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-11 05:33:21 -gdwarf-2
+ # gcc HEAD 2004-01-11 05:33:21 -gstabs+
+ kfail "gdb/NNNN" $name
+ }
+ -re "$vhn = \\(int ?\\( A::\\*\\)\\) 536870924\r\n$gdb_prompt $" {
+ # the value is 0x20000008 hex. 0x20000000 is an internal flag.
+ # Use '|' to add in more values as needed.
+ # hpacc A.03.45
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print pmi after setting" }
- timeout { fail "(timeout) print pmi after setting" }
}
# print dereferenced pointer to data member again
-send_gdb "print a.*pmi\n"
-gdb_expect {
- -re "\\$\[0-9\]* = 1331\r\n$gdb_prompt $" {
- pass "print a.*pmi after setting"
+set name "print a.*pmi (A::jj)"
+gdb_test_multiple "print a.*pmi" $name {
+ -re "$vhn = 1331\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print a.*pmi after setting" }
- timeout { fail "(timeout) print a.*pmi after setting" }
}
# set the pointer to data member back to A::j
-send_gdb "set var pmi = &A::j\n"
-gdb_expect {
- -re "$gdb_prompt $" {
- pass "set var back to A::j (not really a pass)"
+set name "set var pmi = &A::j"
+gdb_test_multiple "set var pmi = &A::j" $name {
+ -re "Invalid cast.\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
+ }
+ -re "set var pmi = &A::j\r\n$gdb_prompt $" {
+ # I have to match the echo'ed input explicitly here.
+ # If I leave it out, the pattern becomes too general
+ # and matches anything that ends in "$gdb_prompt $".
+ pass $name
}
- timeout { fail "(timeout) set var pmi" }
}
# print dereferenced pointer to data member yet again (extra check, why not)
-send_gdb "print a.*pmi\n"
-gdb_expect {
- -re "\\$\[0-9\]* = 121\r\n$gdb_prompt $" {
- pass "print a.*pmi after resetting"
+set name "print a.*pmi (A::j) (again)"
+gdb_test_multiple "print a.*pmi" $name {
+ -re "$vhn = 121\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print a.*pmi after resetting" }
- timeout { fail "(timeout) print a.*pmi after resetting" }
}
# Set the data member pointed to.
-send_gdb "print a.*pmi = 33\n"
-gdb_expect {
- -re "\\$\[0-9\]* = 33\r\n$gdb_prompt $" {
- pass "print command to set"
+set name "print a.*pmi = 33"
+gdb_test_multiple "print a.*pmi = 33" $name {
+ -re "$vhn = 33\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print command to set" }
- timeout { fail "(timeout) print command to set" }
}
# Now check that the data really was changed
-send_gdb "print a.*pmi\n"
-gdb_expect {
- -re "\\$\[0-9\]* = 33\r\n$gdb_prompt $" {
- pass "print a.*pmi after setting member pointed to"
- }
- -re ".*$gdb_prompt $" { fail "print a.*pmi after setting member pointed to" }
- timeout { fail "(timeout) print a.*pmi after setting member pointed to" }
-}
-# Double-check by printing a.
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print a\n"
-gdb_expect {
- -re "\\$\[0-9\]* = \{c = 120 'x', j = 33, jj = 1331, static s = 10, Virtual table at $hex\}\r\n$gdb_prompt $" {
- pass "print a after setting member pointed to by pmi"
+set name "print a.*pmi (A::j) (33)"
+gdb_test_multiple "print a.*pmi" $name {
+ -re "$vhn = 33\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print a after setting member pointed to by pmi" }
- timeout { fail "(timeout) print a after setting member pointed to by pmi" }
}
+# Double-check by printing a.
-# Set the data member pointed to, using ->*
-
-send_gdb "print a_p->*pmi = 44\n"
-gdb_expect {
- -re "\\$\[0-9\]* = 44\r\n$gdb_prompt $" {
- pass "print command to set (->)"
+set name "print a (j = 33)"
+gdb_test_multiple "print a" $name {
+ -re "$vhn = \{c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10, (_vptr.A|_vptr\\$) = ($hex|$hex <A virtual table>)\}\r\n$gdb_prompt $" {
+ pass $name
}
- -re ".*$gdb_prompt $" { fail "print command to set (->)" }
- timeout { fail "(timeout) print command to set (->)" }
-}
-
-# Now check that the data really was changed
-send_gdb "print a_p->*pmi\n"
-gdb_expect {
- -re "\\$\[0-9\]* = 44\r\n$gdb_prompt $" {
- pass "print a_p->*pmi after setting member pointed to"
+ -re "$vhn = \{c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10, Virtual table at $hex\}\r\n$gdb_prompt $" {
+ pass $name
}
- -re ".*$gdb_prompt $" { fail "print a_p->*pmi after setting member pointed to" }
- timeout { fail "(timeout) print a_p->*pmi after setting member pointed to" }
-}
-
-# Double-check by printing a.
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print a\n"
-gdb_expect {
- -re "\\$\[0-9\]* = \{c = 120 'x', j = 44, jj = 1331, static s = 10, Virtual table at $hex\}\r\n$gdb_prompt $" {
- pass "print a after setting member pointed to by pmi (->) "
+ -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 121, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print a after setting member pointed to by pmi (->) " }
- timeout { fail "(timeout) print a after setting member pointed to by pmi (->) " }
}
+# Set the data member pointed to, using ->*
-# Do a ptype on the dereferenced pointer to member
-# pai/1997-08-20 Doesn't work
-
-# send_gdb "ptype a.*pmi\n"
-# gdb_expect {
-# -re "type = int\r\n$gdb_prompt $" {
-# pass "ptype a.*pmi"
-# }
-# -re ".*$gdb_prompt $" { fail "ptype a.*pmi" }
-# timeout { fail "(timeout) ptype a.*pmi" }
-#}
-
-# Try to dereference the pointer to data member without any object
-
-send_gdb "print *pmi\n"
-gdb_expect {
- -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" {
- pass "attempt to print ptr to member without object"
+set name "print a_p->*pmi = 44"
+gdb_test_multiple "print a_p->*pmi = 44" $name {
+ -re "$vhn = 44\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "attempt to print ptr to member without object" }
- timeout { fail "(timeout) attempt to print ptr to member without object" }
}
-# Try to ptype a dereference of the pointer to data member without any object
+# Check that the data really was changed
-send_gdb "ptype *pmi\n"
-gdb_expect {
- -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" {
- pass "attempt to ptype ptr to member without object"
+set name "print a_p->*pmi (44)"
+gdb_test_multiple "print a_p->*pmi" $name {
+ -re "$vhn = 44\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "attempt to ptype ptr to member without object" }
- timeout { fail "(timeout) attempt to ptype ptr to member without object" }
}
-# Ptype a pointer to a method.
+# Double-check by printing a.
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "ptype pmf\n"
-gdb_expect {
- -re "type = int \\( A::\\*\\)\\(\\.\\.\\.\\)\r\n$gdb_prompt $" {
- pass "ptype pmf"
+set name "print a (j = 44)"
+gdb_test_multiple "print a" $name {
+ -re "$vhn = \{c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10, (_vptr.A|_vptr\\$) = ($hex|$hex <A virtual table>)\}\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "$vhn = \{c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10, Virtual table at $hex\}\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "$vhn = \{(_vptr.A|_vptr\\$) = $hex, c = 120 'x', j = 121, jj = 1331, (static|static int) s = 10\}\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "ptype pmf" }
- timeout { fail "(timeout) ptype pmf" }
}
-# print a pointer to a method
+# ptype the dereferenced pointer to member.
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print pmf\n"
-gdb_expect {
- -re "\\$\[0-9\]* = \\(int \\( A::\\*\\)\\(\\.\\.\\.\\)\\) \\?\\? <not supported with HP aCC>\r\n$gdb_prompt $" {
- pass "print pmf"
+set name "ptype a.*pmi"
+gdb_test_multiple "ptype a.*pmi" $name {
+ -re "type = int\r\n$gdb_prompt" {
+ pass $name
+ }
+ -re "not implemented: member types in unpack_long\r\n$gdb_prompt $" {
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print pmf" }
- timeout { fail "(timeout) print pmf" }
}
+# dereference the pointer to data member without any object
+# this is not allowed: a pmi must be bound to an object to dereference
-# Ptype a pointer to a pointer to a method
-
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "ptype pmf_p\n"
-gdb_expect {
- -re "type = int \\( A::\\*\\*\\)\\(\\.\\.\\.\\)\r\n$gdb_prompt $" {
- pass "ptype pmf_p"
+set name "print *pmi"
+gdb_test_multiple "print *pmi" $name {
+ -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "Cannot access memory at address 0x4\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ kfail "gdb/NNNN" $name
+ }
+ -re "Cannot access memory at address 0x8\r\n$gdb_prompt $" {
+ # gcc 3.3.2 -gdwarf-2
+ # gcc 3.3.2 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "ptype pmf_p" }
- timeout { fail "(timeout) ptype pmf_p" }
}
-# print a pointer to a pointer to a method
+# dereference the pointer to data member without any object
+# this is not allowed: a pmi must be bound to an object to dereference
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print pmf_p\n"
-gdb_expect {
- -re "\\$\[0-9\]* = \\(int \\( A::\\*\\*\\)\\(\\.\\.\\.\\)\\) $hex\r\n$gdb_prompt $" {
- pass "print pmf_p"
+set name "ptype *pmi"
+gdb_test_multiple "ptype *pmi" $name {
+ -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "type = int A::\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print pmf_p" }
- timeout { fail "(timeout) print pmf_p" }
}
-# print dereferenced pointer to method
+# Check cast of pointer to member to integer.
+# This is similar to "offset-of".
+# such as "A a; print (size_t) &A.j - (size_t) &A".
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print a.*pmf\n"
-gdb_expect {
- -re "Pointers to methods not supported with HP aCC\r\n$gdb_prompt $" {
- pass "print a.*pmf (known aCC limitation)"
+set name "print (int) pmi"
+gdb_test_multiple "print (int) pmi" $name {
+ -re "$vhn = (4|8)\r\n$gdb_prompt" {
+ pass $name
}
- -re ".*$gdb_prompt $" { fail "print a.*pmf" }
- timeout { fail "(timeout) print a.*pmf" }
}
-# print dereferenced pointer to method, using ->*
+# Check "(int) pmi" explicitly for equality.
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print a_p->*pmf\n"
-gdb_expect {
- -re "Pointers to methods not supported with HP aCC\r\n$gdb_prompt $" {
- pass "print a_p->*pmf (known aCC limitation)"
+set name "print ((int) pmi) == ((char *) &a.j - (char *) &a)"
+gdb_test_multiple "print ((int) pmi) == ((char *) &a.j - (char *) & a)" $name {
+ -re "$vhn = true\r\n$gdb_prompt" {
+ pass $name
}
- -re ".*$gdb_prompt $" { fail "print a_p->*pmf" }
- timeout { fail "(timeout) print a_p->*pmf" }
}
-# set the pointer to data member
+# ==========================
+# pointer to member function
+# ==========================
+
+# ptype a pointer to a method
-setup_xfail "hppa*-*-*"
-send_gdb "set var pmf = &A::foo\n"
-gdb_expect {
- -re "Assignment to pointers to methods not implemented with HP aCC\r\n$gdb_prompt $" {
- pass "set var pmf (known aCC limitation)"
+set name "ptype pmf"
+gdb_test_multiple "ptype pmf" $name {
+ -re "type = int \\( ?A::\\*\\)\\(int\\)\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "type = int \\( ?A::\\*\\)\\(void\\)\r\n$gdb_prompt $" {
+ # hpacc A.03.45
+ kfail "gdb/NNNN" $name
+ }
+ -re "type = struct \{.*\}\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.2.2 -gdwarf-2
+ # gcc 3.2.2 -gstabs+
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "set var pmf" }
- timeout { fail "(timeout) set var pmf" }
}
-# Try to dereference the pointer to method without any object
+# print a pointer to a method
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print *pmf\n"
-gdb_expect {
- -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" {
- pass "attempt to print ptr to method without object"
+set name "print pmf"
+gdb_test_multiple "print pmf" $name {
+ -re "$vhn = &A::bar\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "$vhn = .*not supported with HP aCC.*\r\n$gdb_prompt $" {
+ # hpacc A.03.45
+ kfail "gdb/NNNN" $name
+ }
+ -re "$vhn = \{.*\}\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.2.2 -gdwarf-2
+ # gcc 3.2.2 -gstabs+
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "attempt to print ptr to method without object" }
- timeout { fail "(timeout) attempt to print ptr to method without object" }
}
-# Try to ptype a dereference of the pointer to method without any object
+# ptype a pointer to a pointer to a method
-send_gdb "ptype *pmi\n"
-gdb_expect {
- -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" {
- pass "attempt to ptype ptr to member without object"
+set name "ptype pmf_p"
+gdb_test_multiple "ptype pmf_p" $name {
+ -re "type = int \\( ?A::\\*\\*\\)\\(int\\)\r\n$gdb_prompt $" {
+ pass $name
}
- -re ".*$gdb_prompt $" { fail "attempt to ptype ptr to member without object" }
- timeout { fail "(timeout) attempt to ptype ptr to member without object" }
-}
-
-# Check cast of pointer to member to integer
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print (int) pmi\n"
-gdb_expect {
- -re "\\$\[0-9\]* = 8\r\n$gdb_prompt $" {
- pass "casting pmi to int"
+ -re "type = int \\( ?A::\\*\\*\\)\\(void\\)\r\n$gdb_prompt $" {
+ # hpacc A.03.45
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "casting pmi to int" }
- timeout { fail "(timeout) casting pmi to int" }
-}
-
-# Check cast of pointer to method to integer
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print (int) pmf\n"
-gdb_expect {
- -re "Pointers to methods not supported with HP aCC\r\n$gdb_prompt $" {
- pass "casting pmf to int (known aCC limitation)"
+ -re "type = struct \{.*\} \\*\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.2.2 -gdwarf-2
+ # gcc 3.2.2 -gstabs+
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "casting pmf to int" }
- timeout { fail "(timeout) casting pmf to int" }
}
-# Try to invoke a function through a pointer to data member
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print (a.*pmi)(3)\n"
-gdb_expect {
- -re "Not implemented: function invocation through pointer to method with HP aCC\r\n$gdb_prompt $" {
- pass "print (a.*pmi)(3) -- error message should be different"
- }
- -re ".*$gdb_prompt $" { fail "print (a.*pmi)(3)" }
- timeout { fail "(timeout) print (a.*pmi)(3)" }
-}
+# print a pointer to a pointer to a method
-# Try to invoke a function through a pointer to a method
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print (a.*pmf)(3)\n"
-gdb_expect {
- -re "Not implemented: function invocation through pointer to method with HP aCC\r\n$gdb_prompt $" {
- pass "print (a.*pmi)(3) -- known aCC limitation"
+set name "print pmf_p"
+gdb_test_multiple "print pmf_p" $name {
+ -re "$vhn = \\(int \\( ?A::\\*\\*\\)\\)\\(int\\)\\) $hex\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "$vhn = \\(PMF \\*\\) $hex\r\n$gdb_prompt $" {
+ pass "gdb/NNNN"
+ }
+ -re "$vhn = \\(int \\( ?A::\\*\\*\\)\\(void\\)\\) $hex\r\n$gdb_prompt $" {
+ # hpacc A.03.45
+ kfail "gdb/NNNN" $name
+ }
+ -re "$vhn = \\(struct \{.*\} \\*\\) $hex\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print (a.*pmf)(3)" }
- timeout { fail "(timeout) print (a.*pmf)(3)" }
}
+# print dereferenced pointer to method
-# Go past assignment of NULL to pmi
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "next\n"
-gdb_expect {
- -re "\r\n85\[ \t\]*k = \\(a.\\*pmf\\)\\(3\\);\r\n$gdb_prompt $" {
- pass "next past 83"
+set name "print a.*pmf"
+gdb_test_multiple "print a.*pmf" $name {
+ -re "$vhn = \\(int \\(\\*\\)\\(int\\)\\) $hex <A::bar\\(int\\)>\r\n$gdb_prompt$ " {
+ pass $name
+ }
+ -re "Pointers to methods not supported with HP aCC\r\n$gdb_prompt $" {
+ # hpacc A.03.45
+ kfail "gdb/NNNN" $name
+ }
+ -re "Value can't be converted to integer.\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.2.2 -gdwarf-2
+ # gcc 3.2.2 -gstabs+
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "next past 83" }
- timeout { fail "(timeout) next past 83" }
}
-#send_gdb "print pmi\n"
-#gdb_expect {
-# -re "Attempted dereference of null pointer-to-member\r\n$gdb_prompt $" {
-# pass ""
-# }
-# -re ".*$gdb_prompt $" { fail "" }
-# timeout { fail "(timeout) " }
-#}
+# print dereferenced pointer to method, using ->*
-# Dereference the null pointer to member
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print a.*pmi\n"
-gdb_expect {
- -re "Attempted dereference of null pointer-to-member\r\n$gdb_prompt $" {
- pass "print a.*NULL"
+set name "print a_p->*pmf"
+gdb_test_multiple "print a_p->*pmf" $name {
+ -re "$vhn = \\(int \\(\\*\\)\\(int\\)\\) $hex <A::bar\\(int\\)>\r\n$gdb_prompt$ " {
+ pass $name
+ }
+ -re "Pointers to methods not supported with HP aCC\r\n$gdb_prompt $" {
+ # hpacc A.03.45
+ kfail "gdb/NNNN" $name
+ }
+ -re "Value can't be converted to integer.\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.2.2 -gdwarf-2
+ # gcc 3.2.2 -gstabs+
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print a.*NULL" }
- timeout { fail "(timeout) print a.*NULL" }
}
+# set the pointer to data member
-# Go to another part of the program
-send_gdb "break 91\n"
-gdb_expect {
- -re "Breakpoint \[0-9\]*.*line 91\\.\r\n$gdb_prompt $" {
- pass "set break at 91"
+set name "set var pmf = &A::foo"
+gdb_test_multiple "set var pmf = &A::foo" $name {
+ -re "set var pmf = &A::foo\r\n$gdb_prompt $" {
+ # I have to match the echo'ed input explicitly here.
+ # If I leave it out, the pattern becomes too general
+ # and matches anything that ends in "$gdb_prompt $".
+ pass $name
}
- -re ".*$gdb_prompt $" { fail "set break at 91" }
- timeout { fail "(timeout) set break at 91" }
-}
-
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "continue\n"
-gdb_expect {
- -re "Continuing\\.\r\n\r\nBreakpoint.*at.*member-ptr\\.cc:91\r\n91\[ \t]*k = \\(a.\\*pmf\\)\\(4\\);\r\n$gdb_prompt $" {
- pass "continue to 91"
+ -re "Invalid cast.\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.2.2 -gdwarf-2
+ # gcc 3.2.2 -gstabs+
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
+ }
+ -re "Assignment to pointers to methods not implemented with HP aCC\r\n$gdb_prompt $" {
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "continue to 91" }
- timeout { fail "(timeout) continue to 91" }
}
+# dereference the pointer to data member without any object
+# this is not allowed: a pmf must be bound to an object to dereference
-# Now check again that pmi works even when not set to
-# something that's at the beginning of the object
-
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print pmi\n"
-gdb_expect {
- -re "\\$\[0-9\]* = \\(int \\( A::\\*\\)\\) &A::jj\r\n$gdb_prompt $" {
- pass "print pmi (2)"
+set name "print *pmf"
+gdb_test_multiple "print *pmf" $name {
+ -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "Structure has no component named operator\\*.\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gdwarf-2
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print pmi (2)" }
- timeout { fail "(timeout) print pmi (2)" }
}
+# dereference the pointer to data member without any object
+# this is not allowed: a pmf must be bound to an object to dereference
-# print dereferenced pointer to data member
-
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print a.*pmi\n"
-gdb_expect {
- -re "\\$\[0-9\]* = 1331\r\n$gdb_prompt $" {
- pass "print a.*pmi (2)"
+set name "ptype *pmf"
+gdb_test_multiple "ptype *pmf" $name {
+ -re "Attempt to dereference pointer to member without an object\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "Structure has no component named operator\\*.\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gdwarf-2
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print a.*pmi (2)" }
- timeout { fail "(timeout) print a.*pmi (2)" }
}
-# print dereferenced pointer to data member
-# this time, dereferenced through a pointer
+# Call a function through a pmf.
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "print a_p->*pmi\n"
-gdb_expect {
- -re "\\$\[0-9\]* = 1331\r\n$gdb_prompt $" {
- pass "print a->*pmi"
+set name "print (a.*pmf)(3)"
+gdb_test_multiple "print (a.*pmf)(3)" $name {
+ -re "$vhn = 50\r\n$gdb_prompt $" {
+ pass $name
+ }
+ -re "Not implemented: function invocation through pointer to method with HP aCC\r\n$gdb_prompt $" {
+ # hpacc A.03.45
+ kfail "gdb/NNNN" $name
+ }
+ -re "Value can't be converted to integer.\r\n$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 2.95.3 -gstabs+
+ # gcc 3.3.2 -gdwarf-2
+ # gcc 3.3.2 -gstabs+
+ # gcc HEAD 2004-01-10 -gdwarf-2
+ # gcc HEAD 2004-01-10 -gstabs+
+ kfail "gdb/NNNN" $name
}
- -re ".*$gdb_prompt $" { fail "print a->*pmi (2)" }
- timeout { fail "(timeout) print a->*pmi (2)" }
}
-
-
-# p a.*pmf - fail
-
-# p pmi
-
-# p a.*pmi
-
diff --git a/gdb/testsuite/gdb.cp/method.exp b/gdb/testsuite/gdb.cp/method.exp
index a085b14cdcc..87666d833a8 100644
--- a/gdb/testsuite/gdb.cp/method.exp
+++ b/gdb/testsuite/gdb.cp/method.exp
@@ -1,4 +1,4 @@
-# Copyright 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+# Copyright 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
@@ -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
@@ -96,7 +93,7 @@ gdb_test "break A::bar" \
"Breakpoint \[0-9\]* at $hex.*file .*method.cc, line 44\\."
gdb_test "continue" \
- "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, A::bar(\\(int\\) const|) \\(this=$hex, arg=15\\) at .*method\\.cc:44\r\n44\[\t \]*return arg \\+ 2 \\* x;" \
+ "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, A::bar(|\\(int\\) const| const) \\(this=$hex, arg=15\\) at .*method\\.cc:44\r\n44\[\t \]*return arg \\+ 2 \\* x;" \
"continue to A::bar"
# Check ability to access this-relative stuff.
@@ -170,6 +167,9 @@ gdb_expect {
-re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*A & operator=\\(A const ?&\\);\r\n\[ \]*A\\(A const ?&\\);\r\n\[ \]*A\\((void|)\\);\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\) volatile;\r\n\[ \]*int qux\\(int, float\\) (const volatile|volatile const);\r\n\}\r\n$gdb_prompt $" {
pass "ptype A"
}
+ -re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\) volatile;\r\n\[ \]*int qux\\(int, float\\) (const volatile|volatile const);\r\n\[ \]*A & operator=\\(A const ?&\\);\r\n\[ \]*A\\(A const ?&\\);\r\n\[ \]*A\\((void|)\\);\r\n\}\r\n$gdb_prompt $" {
+ pass "ptype A"
+ }
-re "type = class A \{\r\n\[ \]*public:\r\n\[ \]*int x;\r\n\[ \]*int y;\r\n\r\n\[ \]*int foo\\(int\\);\r\n\[ \]*int bar\\(int\\) const;\r\n\[ \]*int baz\\(int, char\\);\r\n\[ \]*int qux\\(int, float\\) const;\r\n\}\r\n$gdb_prompt $" {
pass "ptype A (HP aCC bug -- volatile not indicated)"
}
diff --git a/gdb/testsuite/gdb.cp/misc.cc b/gdb/testsuite/gdb.cp/misc.cc
index 286c02bc6df..7d69ed225ae 100644
--- a/gdb/testsuite/gdb.cp/misc.cc
+++ b/gdb/testsuite/gdb.cp/misc.cc
@@ -1,3 +1,23 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+ 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.
+ */
+
// Test various -*- C++ -*- things.
// ====================== basic C++ types =======================
diff --git a/gdb/testsuite/gdb.cp/misc.exp b/gdb/testsuite/gdb.cp/misc.exp
index a2d122fc69e..2758cd0ae64 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 7b9a173d819..ee55168528b 100644
--- a/gdb/testsuite/gdb.cp/namespace.cc
+++ b/gdb/testsuite/gdb.cp/namespace.cc
@@ -75,6 +75,11 @@ namespace
namespace G
{
int Xg = 10;
+
+ namespace
+ {
+ int XgX = 11;
+ }
}
}
@@ -83,6 +88,22 @@ namespace C
int c = 1;
int shadow = 12;
+ class CClass {
+ public:
+ int x;
+ class NestedClass {
+ public:
+ int y;
+ };
+ };
+
+ 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;
@@ -90,6 +111,11 @@ namespace C
namespace F
{
int cXf = 7;
+
+ namespace
+ {
+ int cXfX = 8;
+ }
}
}
@@ -98,6 +124,11 @@ namespace C
int cc = 2;
}
+ namespace E
+ {
+ int ce = 4;
+ }
+
namespace D
{
int cd = 3;
@@ -118,14 +149,18 @@ namespace C
//cc;
C::cc;
cd;
+ //C::D::cd;
E::cde;
shadow;
+ //E::ce;
cX;
F::cXf;
+ F::cXfX;
X;
G::Xg;
//cXOtherFile;
//XOtherFile;
+ G::XgX;
return;
}
diff --git a/gdb/testsuite/gdb.cp/namespace.exp b/gdb/testsuite/gdb.cp/namespace.exp
index 6952c8fb53c..4b3f1e255c7 100644
--- a/gdb/testsuite/gdb.cp/namespace.exp
+++ b/gdb/testsuite/gdb.cp/namespace.exp
@@ -1,4 +1,5 @@
-# Copyright 1997, 1998, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+# Copyright 1997, 1998, 2000, 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,18 +15,15 @@
# 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
-# Written by Satish Pai <pai@apollo.hp.com> 1997-07-23
+# Originally written by Satish Pai <pai@apollo.hp.com> 1997-07-23
# This file is part of the gdb testsuite
-# Note: These tests are geared to the HP aCC compiler,
+# Note: The original tests were geared to the HP aCC compiler,
# which has an idiosyncratic way of emitting debug info
# for namespaces.
-# Note: As of 2000-06-03, these pass under g++ - djb
+# Note: As of 2000-06-03, they passed under g++ - djb
if $tracelevel then {
@@ -44,7 +42,7 @@ set srcfile1 ${testfile}1.cc
set objfile1 ${objdir}/${subdir}/${testfile}1.o
set binfile ${objdir}/${subdir}/${testfile}
-if [get_compiler_info ${binfile}] {
+if [get_compiler_info ${binfile} c++] {
return -1;
}
@@ -82,7 +80,12 @@ if ![runto 'marker1'] then {
gdb_test "up" ".*main.*" "up from marker1"
# Access a data item inside a namespace using colons and
-# single quotes :-(
+# single quotes. :-(
+
+# NOTE: carlton/2003-09-24: the quotes are becoming less necessary (or
+# even desirable.) For tests where it should still work with quotes,
+# I'm including versions both with and without quotes; for tests that
+# shouldn't work with quotes, I'm only including one version.
send_gdb "print 'AAA::c'\n"
gdb_expect {
@@ -91,6 +94,13 @@ gdb_expect {
timeout { fail "(timeout) print 'AAA::c'" }
}
+send_gdb "print AAA::c\n"
+gdb_expect {
+ -re "\\$\[0-9\]* = 0 '\\\\(0|000)'\r\n$gdb_prompt $" { pass "print AAA::c" }
+ -re ".*$gdb_prompt $" { fail "print AAA::c" }
+ timeout { fail "(timeout) print AAA::c" }
+}
+
# An object declared using "using".
send_gdb "print ina\n"
@@ -107,6 +117,9 @@ gdb_expect {
-re "type = class (AAA::|)inA \{\r\n\[ \]*public:\r\n\[ \]*int xx;\r\n\[ \]*\r\n\[ \]*.*int fum\\(int\\);\r\n\}\r\n$gdb_prompt $" {
pass "ptype ina"
}
+ -re "type = class (AAA::|)inA \{\r\n\[ \]*public:\r\n\[ \]*int xx;\r\n\[ \]*\r\n\[ \]*int fum\\(int\\);\r\n.*\}\r\n$gdb_prompt $" {
+ pass "ptype ina"
+ }
-re ".*$gdb_prompt $" { fail "ptype ina" }
timeout { fail "(timeout) ptype ina" }
}
@@ -137,6 +150,15 @@ gdb_expect {
timeout { fail "(timeout) print 'AAA::xyzq'('x')" }
}
+send_gdb "print AAA::xyzq('x')\n"
+gdb_expect {
+ -re "\\$\[0-9\]* = 97 'a'\r\n$gdb_prompt $" {
+ pass "print AAA::xyzq('x')"
+ }
+ -re ".*$gdb_prompt $" { fail "print AAA::xyzq('x')" }
+ timeout { fail "(timeout) print AAA::xyzq('x')" }
+}
+
# Break on a function in a namespace
send_gdb "break AAA::xyzq\n"
@@ -159,6 +181,15 @@ gdb_expect {
timeout { fail "(timeout) print 'BBB::CCC::xyzq'('x')" }
}
+send_gdb "print BBB::CCC::xyzq('x')\n"
+gdb_expect {
+ -re "\\$\[0-9\]* = 122 'z'\r\n$gdb_prompt $" {
+ pass "print BBB::CCC::xyzq('x')"
+ }
+ -re ".*$gdb_prompt $" { fail "print BBB::CCC::xyzq('x')" }
+ timeout { fail "(timeout) print BBB::CCC::xyzq('x')" }
+}
+
# Break on a function in a nested namespace
send_gdb "break BBB::CCC::xyzq\n"
@@ -181,6 +212,15 @@ gdb_expect {
timeout { fail "(timeout) print 'BBB::Class::xyzq'" }
}
+send_gdb "print BBB::Class::xyzq\n"
+gdb_expect {
+ -re "\\$\[0-9\]* = \{char \\((BBB::|)Class \\*( const|), (char|int)\\)\} $hex <BBB::Class::xyzq\\(char\\)>\r\n$gdb_prompt $" {
+ pass "print BBB::Class::xyzq"
+ }
+ -re ".*$gdb_prompt $" { fail "print BBB::Class::xyzq" }
+ timeout { fail "(timeout) print BBB::Class::xyzq" }
+}
+
# Break on a function in a class in a namespace
send_gdb "break BBB::Class::xyzq\n"
@@ -204,18 +244,46 @@ if ![runto "C::D::marker2"] then {
gdb_test "print c" "\\$\[0-9\].* = 1"
gdb_test "print cc" "No symbol \"cc\" in current context."
gdb_test "print 'C::cc'" "\\$\[0-9\].* = 2"
+gdb_test "print C::cc" "\\$\[0-9\].* = 2"
gdb_test "print cd" "\\$\[0-9\].* = 3"
+gdb_test "print C::D::cd" "No type \"D\" within class or namespace \"C::C\"."
gdb_test "print 'E::cde'" "\\$\[0-9\].* = 5"
+gdb_test "print E::cde" "\\$\[0-9\].* = 5"
gdb_test "print shadow" "\\$\[0-9\].* = 13"
-gdb_test "print cOtherFile" "\\$\[0-9\].* = 316"
+gdb_test "print E::ce" "No symbol \"ce\" in namespace \"C::D::E\"."
gdb_test "ptype C" "type = namespace C::C"
gdb_test "ptype E" "type = namespace C::D::E"
+gdb_test "ptype CClass" "type = class C::CClass \{\r\n public:\r\n int x;\r\n\}"
+gdb_test "ptype CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n public:\r\n int y;\r\n\}"
+gdb_test "ptype NestedClass" "No symbol \"NestedClass\" in current context."
+setup_kfail "gdb/1448" "*-*-*"
+gdb_test "ptype ::C::CClass" "type = class C::CClass \{\r\n public:\r\n int x;\r\n\}"
+setup_kfail "gdb/1448" "*-*-*"
+gdb_test "ptype ::C::CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n public:\r\n int y;\r\n\}"
+setup_kfail "gdb/1448" "*-*-*"
+gdb_test "ptype ::C::NestedClass" "No symbol \"NestedClass\" in namespace \"C\"."
+gdb_test "ptype C::CClass" "No symbol \"CClass\" in namespace \"C::C\"."
+gdb_test "ptype C::CClass::NestedClass" "No type \"CClass\" within class or namespace \"C::C\"."
+gdb_test "ptype C::NestedClass" "No symbol \"NestedClass\" in namespace \"C::C\"."
+
+# Tests involving multiple files
+
+gdb_test "print cOtherFile" "\\$\[0-9\].* = 316"
+gdb_test "ptype OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n\}"
+setup_kfail "gdb/1448" "*-*-*"
+gdb_test "ptype ::C::OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n\}"
+gdb_test "ptype C::OtherFileClass" "No symbol \"OtherFileClass\" in namespace \"C::C\"."
+
# Some anonymous namespace tests.
gdb_test "print cX" "\\$\[0-9\].* = 6"
gdb_test "print 'F::cXf'" "\\$\[0-9\].* = 7"
+gdb_test "print F::cXf" "\\$\[0-9\].* = 7"
+gdb_test "print F::cXfX" "\\$\[0-9\].* = 8"
gdb_test "print X" "\\$\[0-9\].* = 9"
gdb_test "print 'G::Xg'" "\\$\[0-9\].* = 10"
+gdb_test "print G::Xg" "\\$\[0-9\].* = 10"
+gdb_test "print G::XgX" "\\$\[0-9\].* = 11"
gdb_test "print cXOtherFile" "No symbol \"cXOtherFile\" in current context."
gdb_test "print XOtherFile" "No symbol \"XOtherFile\" in current context."
diff --git a/gdb/testsuite/gdb.cp/namespace1.cc b/gdb/testsuite/gdb.cp/namespace1.cc
index 4a5900a8b3d..c3ad6921ba8 100644
--- a/gdb/testsuite/gdb.cp/namespace1.cc
+++ b/gdb/testsuite/gdb.cp/namespace1.cc
@@ -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
@@ -13,12 +13,23 @@
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
{
+ class OtherFileClass {
+ public:
+ 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 56afc96884e..a41e14dc198 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 3e14678e4c2..b09c58e3859 100644
--- a/gdb/testsuite/gdb.cp/overload.exp
+++ b/gdb/testsuite/gdb.cp/overload.exp
@@ -1,4 +1,5 @@
-# Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+# Copyright 1998, 1999, 2000, 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,24 +15,20 @@
# 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>
# This file is part of the gdb testsuite
-#
-# tests for overloaded member functions. Command Line calls
-#
+# Tests for overloaded member functions.
if $tracelevel then {
- strace $tracelevel
- }
+ strace $tracelevel
+}
+
+set ws "\[\r\n\t \]+"
+set nl "\[\r\n\]+"
-#
-# test running programs
-#
set prms_id 0
set bug_id 0
@@ -45,21 +42,12 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
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}
-# set it up at a breakpoint so we can play with the variable values
-#
-if ![runto_main] then {
- perror "couldn't run to breakpoint"
- continue
-}
+# Set it up at a breakpoint so we can play with the variable values.
if ![runto 'marker1'] then {
perror "couldn't run to marker1"
@@ -68,63 +56,108 @@ if ![runto 'marker1'] then {
gdb_test "up" ".*main.*" "up from marker1"
-send_gdb "print foo_instance1\n"
-gdb_expect {
- -re ".\[0-9\]* = \{ifoo = 111, ccpfoo = 0x0\}\r\n$gdb_prompt $" {
- pass "print foo_instance1"
- }
- -re ".*$gdb_prompt $" { fail "print foo_instance1" }
- timeout { fail "(timeout) print foo_instance1" }
- }
-
-
-setup_xfail "hppa*-*-*" CLLbs16901
-send_gdb "ptype foo_instance1\n"
-gdb_expect {
- -re "type = class foo \{.*public:.*int ifoo;.*const char \\*ccpfoo;.*foo\\(int\\);.*foo\\(int, (const char|char const) \\*\\);.*foo\\(foo &\\);.*~foo\\(void\\);.*void foofunc\\(int\\);.*void foofunc\\(int, signed char \\*\\);.*int overload1arg\\(void\\);.*int overload1arg\\(char\\);.*int overload1arg\\(signed char\\);.*int overload1arg\\(unsigned char\\);.*int overload1arg\\(short\\);.*int overload1arg\\(unsigned short\\);.*int overload1arg\\(int\\);.*int overload1arg\\(unsigned int\\);.*int overload1arg\\(long\\);.*int overload1arg\\(unsigned long\\);.*int overload1arg\\(float\\);.*int overload1arg\\(double\\);.*int overloadargs\\(int\\);.*int overloadargs\\(int, int\\);.*int overloadargs\\(int, int, int\\);.*int overloadargs\\(int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int, int, int\\);.*int overloadargs\\(int, int, int, int, int, int, int, int, int, int, int\\);\r\n\}\r\n$gdb_prompt $" {
- pass "ptype foo_instance1 (HP aCC -- known quirk with ~foo parameter list)"
- }
- -re "type = class foo .*int overloadargs\\(int, int, int, int, int, int, int, int, int, int, int\\);\r\n\}\r\n$gdb_prompt $" {
+# Print the monster class type.
+# See virtfunc.exp for a discussion of ptype.
+#
+# This is hairy to begin with. It is even more hairy because of the
+# XX_* alternate patterns to catch the KFAIL and XFAIL cases.
+
+set re_class "((struct|class) foo \{${ws}public:|struct foo \{)"
+set re_fields "int ifoo;${ws}const char ?\\* ?ccpfoo;"
+set XX_fields "int ifoo;${ws}char ?\\* ?ccpfoo;"
+set re_ctor "foo\\(int\\);${ws}foo\\(int, (char const|const char) ?\\*\\);${ws}foo\\(foo ?&\\);"
+set re_dtor "~foo\\((void|)\\);"
+set XX_dtor "~foo\\(int\\);"
+set re_methods "void foofunc\\(int\\);"
+set re_methods "${re_methods}${ws}void foofunc\\(int, signed char ?\\*\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\((void|)\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\(char\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\(signed char\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\(unsigned char\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\(short\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\(unsigned short\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\(int\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\(unsigned int\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\(long\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\(unsigned long\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\(float\\);"
+set re_methods "${re_methods}${ws}int overload1arg\\(double\\);"
+set re_methods "${re_methods}${ws}int overloadfnarg\\((void|)\\);"
+set re_methods "${re_methods}${ws}int overloadfnarg\\(int\\);"
+set re_methods "${re_methods}${ws}int overloadfnarg\\(int, int ?\\(\\*\\) ?\\(int\\)\\);"
+set re_methods "${re_methods}${ws}int overloadargs\\(int\\);"
+set re_methods "${re_methods}${ws}int overloadargs\\(int, int\\);"
+set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int\\);"
+set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int\\);"
+set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int, int\\);"
+set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int\\);"
+set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int\\);"
+set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int, int\\);"
+set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int, int, int\\);"
+set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int, int, int, int\\);"
+set re_methods "${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int, int, int, int, int\\);"
+set re_synth "foo & operator=\\(foo const ?&\\);"
+
+gdb_test "print foo_instance1" "\\$\[0-9\]+ = \{ifoo = 111, ccpfoo = 0x0\}"
+
+gdb_test_multiple "ptype foo_instance1" "ptype foo_instance1" {
+ -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gdwarf-2
+ # TODO: this is not a quirk!
+ pass "ptype foo_instance1 (HP aCC -- known quirk with ~foo parameter list)"
+ }
+ -re "type = $re_class${ws}$XX_fields${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+, no "const" on "const char *"
+ # TODO: gdb.base/constvar.exp has XFAILed this kind of problem for a
+ # long time, but an XFAIL really needs an external bug report.
+ # -- chastain 2003-12-31
+ # setup_xfail "*-*-*"
+ # fail "ptype foo_instance1"
+ # TODO: this should be a KFAIL.
+ pass "ptype foo_instance1 (shorter match)"
+ }
+ -re "type = $re_class${ws}$re_fields${ws}$re_synth${ws}$re_dtor${ws}$re_ctor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+ # gcc 2.95.3 -gstabs+ if "const char *" ever gets fixed
+ pass "ptype foo_instance1"
+ }
+ -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$XX_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gdwarf-2, "~foo(int)"
+ # TODO: kfail this
+ # kfail "gdb/1113" "ptype foo_instance1"
+ pass "ptype foo_instance1 (shorter match)"
+ }
+ -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gdwarf-2, if the dtor bug gets fixed
+ # gcc HEAD -gdwarf-2 (abi-2)
+ # TODO: just pass this
+ pass "ptype foo_instance1 (shorter match)"
+ }
+ -re "type = $re_class${ws}$re_fields${ws}$re_synth${ws}$re_ctor${ws}$re_dtor${ws}$re_methods$nl\}$nl$gdb_prompt $" {
+ # gcc 3.3.2 -gstabs+
+ # TODO: enough with the "shorter match"
+ pass "ptype foo_instance1 (shorter match)"
+ }
+ -re "type = $re_class${ws}$re_fields${ws}$re_ctor${ws}$re_dtor${ws}$re_methods${ws}$re_synth$nl\}$nl$gdb_prompt $" {
+ # gcc HEAD -gstabs+ (abi-2)
pass "ptype foo_instance1 (shorter match)"
}
- -re ".*$gdb_prompt $" { fail "ptype foo_instance1" }
- timeout { fail "(timeout) ptype foo_instance1" }
- }
-
-send_gdb "print foo_instance2\n"
-gdb_expect {
- -re ".\[0-9\]* = \{ifoo = 222, ccpfoo = $hex \"A\"\}\r\n$gdb_prompt $" {
- pass "print foo_instance2"
- }
- -re ".*$gdb_prompt $" { fail "print foo_instance2" }
- timeout { fail "(timeout) print foo_instance2" }
- }
-
-send_gdb "print foo_instance3\n"
-gdb_expect {
- -re ".\[0-9\]* = \{ifoo = 222, ccpfoo = $hex \"A\"\}\r\n$gdb_prompt $" {
- pass "print foo_instance3"
- }
- -re ".*$gdb_prompt $" { fail "print foo_instance3" }
- timeout { fail "(timeout) print foo_instance3" }
- }
-
-
-send_gdb "print foo_instance1.overloadargs(1)\n"
-gdb_expect {
- -re ".\[0-9\]* = 1\r\n$gdb_prompt $" {
- pass "print call overloaded func 1 arg"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func 1 arg" }
- timeout { fail "(timeout) print call overloaded func 1 arg" }
- }
+}
+
+# Print variables and method calls.
+# This is a walk in the park.
+gdb_test "print foo_instance2" "\\$\[0-9\]+ = \{ifoo = 222, ccpfoo = $hex \"A\"\}"
+gdb_test "print foo_instance3" "\\$\[0-9\]+ = \{ifoo = 222, ccpfoo = $hex \"A\"\}"
+
+gdb_test "print foo_instance1.overloadargs(1)" "\\$\[0-9\]+ = 1" \
+ "print call overloaded func 1 arg"
# If GDB fails to restore the selected frame properly after the
# inferior function call above (see GDB PR 1155 for an explanation of
# why this might happen), all the subsequent tests will fail. We
# should detect and report that failure, but let the marker call
# finish so that the rest of the tests can run undisturbed.
+
gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" {
-re "#0 marker1.*$gdb_prompt $" {
setup_kfail "gdb/1155" s390-*-linux-gnu
@@ -137,254 +170,118 @@ gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" {
}
}
+gdb_test "print foo_instance1.overloadargs(1, 2)" \
+ "\\$\[0-9\]+ = 2" \
+ "print call overloaded func 2 args"
-send_gdb "print foo_instance1.overloadargs(1, 2)\n"
-gdb_expect {
- -re ".\[0-9\]* = 2\r\n$gdb_prompt $" {
- pass "print call overloaded func 2 args"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func 2 args" }
- timeout { fail "(timeout) print call overloaded func 2 args" }
- }
-
-
-send_gdb "print foo_instance1.overloadargs(1, 2, 3)\n"
-gdb_expect {
- -re ".\[0-9\]* = 3\r\n$gdb_prompt $" {
- pass "print call overloaded func 3 args"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func 3 args" }
- timeout { fail "(timeout) print call overloaded func 3 args" }
- }
-
-
-send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4)\n"
-gdb_expect {
- -re ".\[0-9\]* = 4\r\n$gdb_prompt $" {
- pass "print call overloaded func 4 args"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func 4 args" }
- timeout { fail "(timeout) print call overloaded func 4 args" }
- }
-
-
-send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5)\n"
-gdb_expect {
- -re ".\[0-9\]* = 5\r\n$gdb_prompt $" {
- pass "print call overloaded func 5 args"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func 5 args" }
- timeout { fail "(timeout) print call overloaded func 5 args" }
- }
-
-
-send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6)\n"
-gdb_expect {
- -re ".\[0-9\]* = 6\r\n$gdb_prompt $" {
- pass "print call overloaded func 6 args"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func 6 args" }
- timeout { fail "(timeout) print call overloaded func 6 args" }
- }
-
-
-send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7)\n"
-gdb_expect {
- -re ".\[0-9\]* = 7\r\n$gdb_prompt $" {
- pass "print call overloaded func 7 args"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func 7 args" }
- timeout { fail "(timeout) print call overloaded func 7 args" }
- }
-
-
-send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8)\n"
-gdb_expect {
- -re ".\[0-9\]* = 8\r\n$gdb_prompt $" {
- pass "print call overloaded func 8 args"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func 8 args" }
- timeout { fail "(timeout) print call overloaded func 8 args" }
- }
-
-
-send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9)\n"
-gdb_expect {
- -re ".\[0-9\]* = 9\r\n$gdb_prompt $" {
- pass "print call overloaded func 9 args"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func 9 args" }
- timeout { fail "(timeout) print call overloaded func 9 args" }
- }
-
-
-send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\n"
-gdb_expect {
- -re ".\[0-9\]* = 10\r\n$gdb_prompt $" {
- pass "print call overloaded func 10 args"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func 10 args" }
- timeout { fail "(timeout) print call overloaded func 10 args" }
- }
-
-
-send_gdb "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)\n"
-gdb_expect {
- -re ".\[0-9\]* = 11\r\n$gdb_prompt $" {
- pass "print call overloaded func 11 args"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func 11 args" }
- timeout { fail "(timeout) print call overloaded func 11 args" }
- }
-
-
-send_gdb "print foo_instance1.overload1arg()\n"
-gdb_expect {
- -re ".\[0-9\]* = 1\r\n$gdb_prompt $" {
- pass "print call overloaded func void arg"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func void arg" }
- timeout { fail "(timeout) print call overloaded func void arg" }
- }
-
-
-send_gdb "print foo_instance1.overload1arg((char)arg2)\n"
-gdb_expect {
- -re ".\[0-9\]* = 2\r\n$gdb_prompt $" {
- pass "print call overloaded func char arg"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func char arg" }
- timeout { fail "(timeout) print call overloaded func char arg" }
- }
-
-
-send_gdb "print foo_instance1.overload1arg((signed char)arg3)\n"
-gdb_expect {
- -re ".\[0-9\]* = 3\r\n$gdb_prompt $" {
- pass "print call overloaded func signed char arg"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func signed char arg" }
- timeout { fail "(timeout) print call overloaded func signed char arg" }
- }
-
-
-send_gdb "print foo_instance1.overload1arg((unsigned char)arg4)\n"
-gdb_expect {
- -re ".\[0-9\]* = 4\r\n$gdb_prompt $" {
- pass "print call overloaded func unsigned char arg"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned char arg" }
- timeout { fail "(timeout) print call overloaded func unsigned char arg" }
- }
-
-
-send_gdb "print foo_instance1.overload1arg((short)arg5)\n"
-gdb_expect {
- -re ".\[0-9\]* = 5\r\n$gdb_prompt $" {
- pass "print call overloaded func short arg"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func short arg" }
- timeout { fail "(timeout) print call overloaded func short arg" }
- }
-
-
-send_gdb "print foo_instance1.overload1arg((unsigned short)arg6)\n"
-gdb_expect {
- -re ".\[0-9\]* = 6\r\n$gdb_prompt $" {
- pass "print call overloaded func unsigned short arg"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned short arg" }
- timeout { fail "(timeout) print call overloaded func unsigned short arg" }
- }
-
-
-send_gdb "print foo_instance1.overload1arg((int)arg7)\n"
-gdb_expect {
- -re ".\[0-9\]* = 7\r\n$gdb_prompt $" {
- pass "print call overloaded func int arg"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func int arg" }
- timeout { fail "(timeout) print call overloaded func int arg" }
- }
-
-
-send_gdb "print foo_instance1.overload1arg((unsigned int)arg8)\n"
-gdb_expect {
- -re ".\[0-9\]* = 8\r\n$gdb_prompt $" {
- pass "print call overloaded func unsigned int arg"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned int arg" }
- timeout { fail "(timeout) print call overloaded func unsigned int arg" }
- }
-
-
-send_gdb "print foo_instance1.overload1arg((long)arg9)\n"
-gdb_expect {
- -re ".\[0-9\]* = 9\r\n$gdb_prompt $" {
- pass "print call overloaded func long arg"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func long arg" }
- timeout { fail "(timeout) print call overloaded func long arg" }
- }
-
-
-send_gdb "print foo_instance1.overload1arg((unsigned long)arg10)\n"
-gdb_expect {
- -re ".\[0-9\]* = 10\r\n$gdb_prompt $" {
- pass "print call overloaded func unsigned long arg"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func unsigned long arg" }
- timeout { fail "(timeout) print call overloaded func unsigned long arg" }
- }
-
-
-send_gdb "print foo_instance1.overload1arg((float)arg11)\n"
-gdb_expect {
- -re ".\[0-9\]* = 11\r\n$gdb_prompt $" {
- pass "print call overloaded func float arg"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func float arg" }
- timeout { fail "(timeout) print call overloaded func float arg" }
- }
-
-
-send_gdb "print foo_instance1.overload1arg((double)arg12)\n"
-gdb_expect {
- -re ".\[0-9\]* = 12\r\n$gdb_prompt $" {
- pass "print call overloaded func double arg"
- }
- -re ".*$gdb_prompt $" { fail "print call overloaded func double arg" }
- timeout { fail "(timeout) print call overloaded func double arg" }
- }
-
-# Now some tests to see if we can list overloaded functions properly:
+gdb_test "print foo_instance1.overloadargs(1, 2, 3)" \
+ "\\$\[0-9\]+ = 3" \
+ "print call overloaded func 3 args"
-gdb_test "set listsize 1" "" ""
-# send_gdb "set listsize 1\n"
-# gdb_expect -re ".*$gdb_prompt $"
+gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4)" \
+ "\\$\[0-9\]+ = 4" \
+ "print call overloaded func 4 args"
-#
-# Decide whether to use "()" or "(void)"
-#
+gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5)" \
+ "\\$\[0-9\]+ = 5" \
+ "print call overloaded func 5 args"
-send_gdb "info func overloadfnarg\n"
-gdb_expect {
+gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6)" \
+ "\\$\[0-9\]+ = 6" \
+ "print call overloaded func 6 args"
+
+gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7)" \
+ "\\$\[0-9\]+ = 7" \
+ "print call overloaded func 7 args"
+
+gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8)" \
+ "\\$\[0-9\]+ = 8" \
+ "print call overloaded func 8 args"
+
+gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9)" \
+ "\\$\[0-9\]+ = 9" \
+ "print call overloaded func 9 args"
+
+gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)" \
+ "\\$\[0-9\]+ = 10" \
+ "print call overloaded func 10 args"
+
+gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)" \
+ "\\$\[0-9\]+ = 11" \
+ "print call overloaded func 11 args"
+
+gdb_test "print foo_instance1.overload1arg()" \
+ "\\$\[0-9\]+ = 1" \
+ "print call overloaded func void arg"
+
+gdb_test "print foo_instance1.overload1arg((char)arg2)" \
+ "\\$\[0-9\]+ = 2" \
+ "print call overloaded func char arg"
+
+gdb_test "print foo_instance1.overload1arg((signed char)arg3)" \
+ "\\$\[0-9\]+ = 3" \
+ "print call overloaded func signed char arg"
+
+gdb_test "print foo_instance1.overload1arg((unsigned char)arg4)" \
+ "\\$\[0-9\]+ = 4" \
+ "print call overloaded func unsigned char arg"
+
+gdb_test "print foo_instance1.overload1arg((short)arg5)" \
+ "\\$\[0-9\]+ = 5" \
+ "print call overloaded func short arg"
+
+gdb_test "print foo_instance1.overload1arg((unsigned short)arg6)" \
+ "\\$\[0-9\]+ = 6" \
+ "print call overloaded func unsigned short arg"
+
+gdb_test "print foo_instance1.overload1arg((int)arg7)" \
+ "\\$\[0-9\]+ = 7" \
+ "print call overloaded func int arg"
+
+gdb_test "print foo_instance1.overload1arg((unsigned int)arg8)" \
+ "\\$\[0-9\]+ = 8" \
+ "print call overloaded func unsigned int arg"
+
+gdb_test "print foo_instance1.overload1arg((long)arg9)" \
+ "\\$\[0-9\]+ = 9" \
+ "print call overloaded func long arg"
+
+gdb_test "print foo_instance1.overload1arg((unsigned long)arg10)" \
+ "\\$\[0-9\]+ = 10" \
+ "print call overloaded func unsigned long arg"
+
+gdb_test "print foo_instance1.overload1arg((float)arg11)" \
+ "\\$\[0-9\]+ = 11" \
+ "print call overloaded func float arg"
+
+gdb_test "print foo_instance1.overload1arg((double)arg12)" \
+ "\\$\[0-9\]+ = 12" \
+ "print call overloaded func double arg"
+
+# ---
+
+# List overloaded functions.
+
+# The void case is tricky because some compilers say "(void)"
+# and some compilers say "()".
+
+gdb_test "set listsize 1" "" ""
+gdb_test_multiple "info func overloadfnarg" "list overloaded function with no args" {
-re ".*overloadfnarg\\(void\\).*$gdb_prompt $" {
+ # gcc 2
gdb_test "list foo::overloadfnarg(void)"\
".*int foo::overloadfnarg.*\\(void\\).*" \
"list overloaded function with no args"
}
-re ".*overloadfnarg\\(\\).*$gdb_prompt $" {
+ # gcc 3
gdb_test "list foo::overloadfnarg()"\
".*int foo::overloadfnarg.*\\(void\\).*" \
"list overloaded function with no args"
}
- -re ".*$gdb_prompt $" {
- fail "list overloaded function with no args (no matching symbol)"
- }
}
-gdb_test "list foo::overloadfnarg(int)"\
+gdb_test "list foo::overloadfnarg(int)" \
"int foo::overloadfnarg.*\\(int arg\\).*" \
"list overloaded function with int arg"
@@ -392,9 +289,26 @@ gdb_test "list foo::overloadfnarg(int, int (*)(int))" \
"int foo::overloadfnarg.*\\(int arg, int \\(\\*foo\\) \\(int\\)\\).*" \
"list overloaded function with function ptr args"
-# This one crashes GDB. Don't know why yet.
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"
-gdb_test "print intToChar(1)" ".\[0-9\]* = 297"
+# 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?
+
+gdb_test "print intToChar(1)" "\\$\[0-9\]+ = 297"
diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp
index 043243d23ff..b6dfa5ceabb 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/pr-1553.cc b/gdb/testsuite/gdb.cp/pr-1553.cc
new file mode 100644
index 00000000000..58441fdb80f
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/pr-1553.cc
@@ -0,0 +1,53 @@
+class A {
+public:
+ class B;
+ class C;
+};
+
+class A::B {
+ int a_b;
+
+public:
+ C* get_c(int i);
+};
+
+class A::C
+{
+ int a_c;
+};
+
+class E {
+public:
+ class F;
+};
+
+class E::F {
+public:
+ int e_f;
+
+ F& operator=(const F &other);
+};
+
+void refer_to (E::F *f) {
+ // Do nothing.
+}
+
+void refer_to (A::C **ref) {
+ // Do nothing. But, while we're at it, force out debug info for
+ // A::B and E::F.
+
+ A::B b;
+ E::F f;
+
+ refer_to (&f);
+}
+
+int main () {
+ A::C* c_var;
+ A::B* b_var;
+ E *e_var;
+
+ // Keep around a reference so that GCC 3.4 doesn't optimize the variable
+ // away.
+ refer_to (&c_var);
+}
diff --git a/gdb/testsuite/gdb.cp/pr-1553.exp b/gdb/testsuite/gdb.cp/pr-1553.exp
new file mode 100644
index 00000000000..fe9e2a26171
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/pr-1553.exp
@@ -0,0 +1,62 @@
+# 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.
+
+# Test for PR gdb/1553.
+
+# This file is part of the gdb testsuite.
+
+set ws "\[\r\n\t \]+"
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+if { [skip_cplus_tests] } { continue }
+
+#
+# test running programs
+#
+set prms_id 0
+set bug_id 0
+
+set testfile "pr-1553"
+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}
+
+if ![runto_main] then {
+ perror "couldn't run to breakpoint"
+ continue
+}
+
+gdb_test "ptype c_var" "type = class A::C \{${ws}private:${ws}int a_c;${ws}\} \\*"
+
+gdb_test "ptype E::F" "type = class E::F \{${ws}public:${ws}int e_f;${ws}E::F & operator=\\(E::F const ?&\\);${ws}\}"
+
+gdb_exit
+return 0
diff --git a/gdb/testsuite/gdb.cp/psmang.exp b/gdb/testsuite/gdb.cp/psmang.exp
index 31dd34643f0..b13737956cc 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 dd06f027111..764ba8b6b76 100644
--- a/gdb/testsuite/gdb.cp/ref-types.exp
+++ b/gdb/testsuite/gdb.cp/ref-types.exp
@@ -1,5 +1,5 @@
# Tests for reference types with short type variables in GDB.
-# Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
+# Copyright 1998, 1999, 2000, 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)
if $tracelevel then {
@@ -72,8 +69,6 @@ proc gdb_start_again {} {
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
- source ${binfile}.ci
-
#
# set it up at a breakpoint so we can play with the variable values
#
diff --git a/gdb/testsuite/gdb.cp/rtti.exp b/gdb/testsuite/gdb.cp/rtti.exp
index f99637a28a9..18f3cc295da 100644
--- a/gdb/testsuite/gdb.cp/rtti.exp
+++ b/gdb/testsuite/gdb.cp/rtti.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
@@ -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,11 +79,16 @@ 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 $" {
+ # gdb HEAD 2003-12-05
+ kfail "gdb/488" "print *e1"
+ }
-re "warning: can't find class named `n1::D1', as given by C\\+\\+ RTTI.*$gdb_prompt $" {
+ # gdb 6.0
kfail "gdb/488" "print *e1"
}
-re "\\$\[0-9\]* = {<n1::Base1> = .*}\r\n$gdb_prompt $" {
@@ -97,23 +103,26 @@ gdb_test_multiple "print *e1" "print *e1" {
}
}
-# NOTE: carlton/2003-05-16: This test fails on my branch with an
-# "<incomplete type>" message because, within rtt1.cc, GDB has no way
-# of knowing that the class is called 'n2::D2' instead of just 'D2'.
-# This is an artifical test case, though: if we were using these
-# classes in a more substantial way, G++ would emit more debug info.
-# As is, I don't think there's anything that GDB can do about this
-# case until G++ starts emitting DW_TAG_namespace info; when that part
-# of the branch gets merged in, then we'll probably want to convert
-# that fail branch to an xfail.
+# NOTE: carlton/2004-01-14: This test with an "<incomplete type>"
+# message because, within rtt1.cc, GDB has no way of knowing that the
+# class is called 'n2::D2' instead of just 'D2'. This is an artifical
+# test case, though: if we were using these classes in a more
+# substantial way, G++ would emit more debug info. As is, I don't
+# think there's anything that GDB can do about this case until G++
+# starts emitting DW_TAG_namespace info; this should arrive with GCC
+# 3.4.
gdb_test_multiple "print *e2" "print *e2" {
+ -re "warning: RTTI symbol not found for class 'n2::D2'.*$gdb_prompt $" {
+ # gdb HEAD 2003-12-05
+ kfail "gdb/488" "print *e2"
+ }
-re "warning: can't find class named `n2::D2', as given by C\\+\\+ RTTI.*$gdb_prompt $" {
+ # gdb 6.0
kfail "gdb/488" "print *e2"
}
-re "\\$\[0-9\]* = <incomplete type>\r\n$gdb_prompt $" {
- # See above NOTE.
- fail "print *e2"
+ kfail "gdb/1511" "print *e2"
}
-re "\\$\[0-9\]* = {<n2::Base2> = .*}\r\n$gdb_prompt $" {
pass "print *e2"
@@ -123,5 +132,18 @@ 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_breakpoint [gdb_get_line_number "func3-constructs-done"]
+gdb_continue_to_breakpoint "end of constructors in func3"
+
+gdb_test "print *obj3" "\\$\[0-9\]* = {<n2::C2> = .*}"
+
gdb_exit
return 0
diff --git a/gdb/testsuite/gdb.cp/rtti.h b/gdb/testsuite/gdb.cp/rtti.h
index 879896d0dc8..c3249252f09 100644
--- a/gdb/testsuite/gdb.cp/rtti.h
+++ b/gdb/testsuite/gdb.cp/rtti.h
@@ -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.
@@ -45,4 +45,12 @@ namespace n2 {
};
extern C2 *create2();
+
+ namespace n3 {
+ class C3 : public C2 {
+ public:
+ };
+ }
+
+ extern n3::C3 *create3();
}
diff --git a/gdb/testsuite/gdb.cp/rtti1.cc b/gdb/testsuite/gdb.cp/rtti1.cc
index 6e9d862bb13..d32ac047d44 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,43 @@ 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.
+}
+
+void refer_to (n2::n3::C3 *obj)
+{
+ // Do nothing.
+}
+
+namespace n2
+{
+ void func ()
+ {
+ C2 *obj = create2 ();
+
+ refer_to (obj); // func-constructs-done
+
+ return;
+ }
+
+ namespace n3
+ {
+ void func3 ()
+ {
+ C3 *obj3 = create3 ();
+
+ refer_to (obj3); // func3-constructs-done
+
+ return;
+ }
+ }
+}
+
int main()
{
using namespace n1;
@@ -63,5 +100,8 @@ int main()
C1 *e1 = create1();
C2 *e2 = create2();
- return 0; // constructs-done
+ n2::func(); // main-constructs-done
+ n2::n3::func3();
+
+ return 0;
}
diff --git a/gdb/testsuite/gdb.cp/rtti2.cc b/gdb/testsuite/gdb.cp/rtti2.cc
index 8bb1ed6c99f..353a1f8c7b8 100644
--- a/gdb/testsuite/gdb.cp/rtti2.cc
+++ b/gdb/testsuite/gdb.cp/rtti2.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.
@@ -33,4 +33,8 @@ namespace n2 {
return new D2(0, 0);
}
+ n3::C3 *create3() {
+ return new n3::C3();
+ }
+
}
diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp
index 0ae878865fe..00a5598629c 100644
--- a/gdb/testsuite/gdb.cp/templates.exp
+++ b/gdb/testsuite/gdb.cp/templates.exp
@@ -1,4 +1,4 @@
-# Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2003
+# Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2000, 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 Fred Fish. (fnf@cygnus.com)
set ws "\[\r\n\t \]+"
@@ -37,7 +34,6 @@ set binfile ${objdir}/${subdir}/${testfile}
if [get_compiler_info ${binfile} "c++"] {
return -1
}
-source ${binfile}.ci
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."
@@ -56,12 +52,15 @@ proc test_ptype_of_templates {} {
-re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" {
pass "ptype T5<int>"
}
+ -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}\}\r\n$gdb_prompt $" {
+ pass "ptype T5<int>"
+ }
-re "type = class T5<int> \\{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}${ws}T5 \\(int\\);${ws}T5 \\(const class T5<int> &\\);${ws}void ~T5 \\(int\\);${ws}static void \\* new \\(unsigned int\\);${ws}static void delete \\(void ?\\*\\);${ws}int value \\((void|)\\);${ws}\\}${ws}$gdb_prompt $" { pass "ptype T5<int> -- new with unsigned int" }
-re "type = class T5<int> \\{.*public:.*static int X;.*int x;.*int val;.*T5 \\(int\\);.*T5 \\(const class T5<int> &\\);.*void ~T5 \\(int\\);.*static void \\* new \\(unsigned long\\);.*static void delete \\(void ?\\*\\);.*int value \\((void|)\\);.*\\}\r\n$gdb_prompt $" { pass "ptype T5<int> -- new with unsigned long" }
-re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;((${ws}T5<int> & operator=\\(T5<int> const ?&\\);)|(${ws}T5\\(int\\);)|(${ws}T5\\((T5<int> const|const T5<int>) ?&\\);)|(${ws}~T5\\((void|)\\);)|(${ws}static void \\* operator new\\(unsigned( int| long)?\\);)|(${ws}static void operator delete\\(void ?\\*\\);)|(${ws}int value\\((void|)\\);))*${ws}\}\r\n$gdb_prompt $" {
pass "ptype T5<int> (obsolescent gcc or gdb)"
}
- -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\(unsigned( long|)\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" {
+ -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\(unsigned( int| long|)\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" {
# This also triggers gdb/1113...
kfail "gdb/1111" "ptype T5<int>"
}
@@ -84,10 +83,13 @@ proc test_ptype_of_templates {} {
-re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" {
pass "ptype t5i"
}
+ -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}T5\\(int\\);${ws}T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\((void|)\\);${ws}static void \\* operator new\\(unsigned( int| long)?\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}T5<int> & operator=\\(T5<int> const ?&\\);${ws}\}\r\n$gdb_prompt $" {
+ pass "ptype t5i"
+ }
-re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;((${ws}T5<int> & operator=\\(T5<int> const ?&\\);)|(${ws}T5\\(int\\);)|(${ws}T5\\(T5<int> const ?&\\);)|(${ws}~T5\\((void|)\\);)|(${ws}static void \\* operator new\\(unsigned( int| long)?\\);)|(${ws}static void operator delete\\(void ?\\*\\);)|(${ws}int value\\((void|)\\);))*${ws}\}\r\n$gdb_prompt $" {
pass "ptype t5i (obsolescent gcc or gdb)"
}
- -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\(unsigned( long|)\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" {
+ -re "type = class T5<int> \{${ws}public:${ws}static int X;${ws}int x;${ws}int val;${ws}void T5\\(int\\);${ws}void T5\\((T5<int> const|const T5<int>) ?&\\);${ws}~T5\\(int\\);${ws}static void \\* operator new\\(unsigned( int| long|)\\);${ws}static void operator delete\\(void ?\\*\\);${ws}int value\\((void|)\\);${ws}\}\r\n$gdb_prompt $" {
# This also triggers gdb/1113...
kfail "gdb/1111" "ptype T5<int>"
}
@@ -197,7 +199,6 @@ proc do_tests {} {
global srcdir
global binfile
global gdb_prompt
- global supports_template_debugging
set prms_id 0
set bug_id 0
@@ -209,11 +210,6 @@ proc do_tests {} {
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $binfile
- if { !$supports_template_debugging } {
- warning "compiler lacks debugging info for templates; tests suppressed." 0
- return
- }
-
runto_main
test_ptype_of_templates
@@ -294,6 +290,7 @@ gdb_expect {
send_gdb "ptype fint\n"
gdb_expect {
-re "type = (class |)Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int foo\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype fint" }
+ -re "type = (class |)Foo<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int foo\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { pass "ptype fint" }
-re "$gdb_prompt $" { fail "ptype fint" }
timeout { fail "(timeout) ptype fint" }
}
@@ -303,6 +300,7 @@ gdb_expect {
send_gdb "ptype fchar\n"
gdb_expect {
-re "type = (class |)Foo<char> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*.*char foo\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype fchar" }
+ -re "type = (class |)Foo<char> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char foo\\(int, char\\);.*\r\n\\}\r\n$gdb_prompt $" { pass "ptype fchar" }
-re "$gdb_prompt $" { fail "ptype fchar" }
timeout { fail "(timeout) ptype fchar" }
}
@@ -312,6 +310,10 @@ gdb_expect {
send_gdb "ptype fvpchar\n"
gdb_expect {
-re "type = (class |)Foo<volatile char ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char \\* foo\\(int,.*char.*\\*\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype fvpchar" }
+ -re "type = (class |)Foo<volatile char ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char \\* foo\\(int,.*char.*\\*\\);.*\r\n\\}\r\n$gdb_prompt $" { pass "ptype fvpchar" }
+ -re "type = (class |)Foo<char volatile ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char \\* foo\\(int,.*char.*\\*\\);\r\n\\}\r\n$gdb_prompt $" {
+ kfail "gdb/1512" "ptype fvpchar"
+ }
-re "$gdb_prompt $" { fail "ptype fvpchar" }
timeout { fail "(timeout) ptype fvpchar" }
}
@@ -326,8 +328,10 @@ gdb_expect {
-re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<volatile char ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { pass "print Foo<volatile char *>::foo" }
-re "No symbol \"Foo<volatile char \\*>\" in current context.\r\n$gdb_prompt $"
{
- # This used to be a kfail gdb/33, but it shouldn't occur any more now.
- fail "print Foo<volatile char *>::foo"
+ # This used to be a kfail gdb/33. That problem has been
+ # fixed, but now gdb/931 and gdb/1512 are rearing their ugly
+ # heads.
+ kfail "gdb/931" "print Foo<volatile char *>::foo"
}
-re "$gdb_prompt $" { fail "print Foo<volatile char *>::foo" }
timeout { fail "(timeout) print Foo<volatile char *>::foo" }
@@ -338,8 +342,10 @@ gdb_expect {
-re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<volatile char ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { pass "print Foo<volatile char*>::foo" }
-re "No symbol \"Foo<volatile char\\*>\" in current context.\r\n$gdb_prompt $"
{
- # This used to be a kfail gdb/33, but it shouldn't occur any more now.
- fail "print Foo<volatile char *>::foo"
+ # This used to be a kfail gdb/33. That problem has been
+ # fixed, but now gdb/931 and gdb/1512 are rearing their ugly
+ # heads.
+ kfail "gdb/931" "print Foo<volatile char*>::foo"
}
-re "$gdb_prompt $" { fail "print Foo<volatile char*>::foo" }
timeout { fail "(timeout) print Foo<volatile char*>::foo" }
@@ -352,7 +358,7 @@ send_gdb "ptype Bar\n"
gdb_expect {
-re "type = template <(class |)T, (class |)sz> (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Bar<int,(\\(int\\)|)1>\r\n\[ \t\]*(class |)Bar<int,(\\(int\\)|)33>\r\n$gdb_prompt $" { pass "ptype Bar" }
-re "type = <(class |)T, (class |)sz> (class |)Bar \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Bar" }
- -re "ptype Bar\r\ntype = class Bar<int,33> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);\r\n}\r\n$gdb_prompt $"
+ -re "ptype Bar\r\ntype = class Bar<int, ?33> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);\r\n}\r\n$gdb_prompt $"
{ # GCC 3.1, DWARF-2 output.
kfail "gdb/57" "ptype Bar" }
-re "No symbol \"Bar\" in current context.\r\n$gdb_prompt $"
@@ -367,7 +373,8 @@ gdb_expect {
send_gdb "ptype bint\n"
gdb_expect {
- -re "type = (class |)Bar<int,(\\(int\\)|)33> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int bar\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bint" }
+ -re "type = (class |)Bar<int, ?(\\(int\\)|)33> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int bar\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bint" }
+ -re "type = (class |)Bar<int,(\\(int\\)|)33> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { pass "ptype bint" }
-re "$gdb_prompt $" { fail "ptype bint" }
timeout { fail "(timeout) ptype bint" }
}
@@ -376,7 +383,8 @@ gdb_expect {
send_gdb "ptype bint2\n"
gdb_expect {
- -re "type = (class |)Bar<int,(\\(int\\)|)1> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int bar\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bint2" }
+ -re "type = (class |)Bar<int, ?(\\(int\\)|)1> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int bar\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bint2" }
+ -re "type = (class |)Bar<int,(\\(int\\)|)1> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { pass "ptype bint2" }
-re "$gdb_prompt $" { fail "ptype bint2" }
timeout { fail "(timeout) ptype bint2" }
}
@@ -386,11 +394,14 @@ gdb_expect {
# Same as Foo, for g++
send_gdb "ptype Baz\n"
gdb_expect {
- -re "type = template <(class |)T, (class |)sz> (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Baz<char,(\\(char\\)|)97>\r\n\[ \t\]*(class |)Baz<int,(\\(char\\)|)115>\r\n$gdb_prompt $" { pass "ptype Baz" }
- -re "type = <(class |)T, (class |)sz> (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Baz" }
- -re "type = class Baz<int,'s'> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\);\r\n}\r\n$gdb_prompt $"
+ -re "type = template <(class |)T, ?(class |)sz> (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Baz<char,(\\(char\\)|)97>\r\n\[ \t\]*(class |)Baz<int,(\\(char\\)|)115>\r\n$gdb_prompt $" { pass "ptype Baz" }
+ -re "type = <(class |)T, ?(class |)sz> (class |)Baz \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Baz" }
+ -re "type = class Baz<int, ?'s'> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\);\r\n}\r\n$gdb_prompt $"
{ # GCC 3.1, DWARF-2 output.
kfail "gdb/57" "ptype Baz" }
+ -re "type = class Baz<int, ?115> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\);\r\n}\r\n$gdb_prompt $"
+ { # GCC 3.x, DWARF-2 output, running into gdb/57 and gdb/1512.
+ kfail "gdb/57" "ptype Baz" }
-re "No symbol \"Baz\" in current context.\r\n$gdb_prompt $"
{ # GCC 2.95.3, stabs+ output.
pass "ptype Baz" }
@@ -403,7 +414,8 @@ gdb_expect {
send_gdb "ptype bazint\n"
gdb_expect {
- -re "type = (class |)Baz<int,(\\(char\\)|)(115|\\'s\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int baz\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bazint" }
+ -re "type = (class |)Baz<int, ?(\\(char\\)|)(115|\\'s\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int baz\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bazint" }
+ -re "type = (class |)Baz<int,(\\(char\\)|)(115|\\'s\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int baz\\(int, int\\).*;\r\n\\}\r\n$gdb_prompt $" { pass "ptype bazint" }
-re "$gdb_prompt $" { fail "ptype bazint" }
timeout { fail "(timeout) ptype bazint" }
}
@@ -412,7 +424,8 @@ gdb_expect {
send_gdb "ptype bazint2\n"
gdb_expect {
- -re "type = (class |)Baz<char,(\\(char\\)|)(97|\\'a\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*.*char baz\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bazint2" }
+ -re "type = (class |)Baz<char, ?(\\(char\\)|)(97|\\'a\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*.*char baz\\(int, char\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype bazint2" }
+ -re "type = (class |)Baz<char,(\\(char\\)|)(97|\\'a\\')> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char baz\\(int, char\\);.*\r\n\\}\r\n$gdb_prompt $" { pass "ptype bazint2" }
-re "$gdb_prompt $" { fail "ptype bazint2" }
timeout { fail "(timeout) ptype bazint2" }
}
@@ -421,11 +434,14 @@ gdb_expect {
# Same as Foo for g++
send_gdb "ptype Qux\n"
gdb_expect {
- -re "type = template <(class |)T, (class |)sz> (class |)Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Qux<int,&string>\r\n\[ \t\]*(class |)Qux<char,&string>\r\n$gdb_prompt $" { pass "ptype Qux" }
- -re ".*type = template <(class |)T.*, (class |)sz> (class |)Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}.*$gdb_prompt $" { pass "ptype Qux" }
- -re "type = class Qux<char,&string> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char qux\\(int, char\\);\r\n}\r\n$gdb_prompt $"
+ -re "type = template <(class |)T, ?(class |)sz> (class |)Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Qux<int,&string>\r\n\[ \t\]*(class |)Qux<char,&string>\r\n$gdb_prompt $" { pass "ptype Qux" }
+ -re ".*type = template <(class |)T.*, ?(class |)sz> (class |)Qux \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*T t;\r\n\\}.*$gdb_prompt $" { pass "ptype Qux" }
+ -re "type = class Qux<char, ?&string> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char qux\\(int, char\\);\r\n}\r\n$gdb_prompt $"
{ # GCC 3.1, DWARF-2 output.
kfail "gdb/57" "ptype Qux" }
+ -re "type = class Qux<char, ?&\\(string\\)> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*char t;\r\n\r\n\[ \t\]*char qux\\(int, char\\);\r\n}\r\n$gdb_prompt $"
+ { # GCC 3.x, DWARF-2 output; gdb/57 + gdb/1512.
+ kfail "gdb/57" "ptype Qux" }
-re "No symbol \"Qux\" in current context.\r\n$gdb_prompt $"
{ # GCC 2.95.3, stabs+ output.
pass "ptype Qux" }
@@ -437,7 +453,12 @@ gdb_expect {
send_gdb "ptype quxint\n"
gdb_expect {
- -re "type = class Qux<int,&string> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int qux\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype quxint" }
+ -re "type = class Qux<int, ?&string> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int qux\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype quxint" }
+ -re "type = class Qux<int, ?&string> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { pass "ptype quxint" }
+ -re "type = class Qux<int, ?\\(char ?\\*\\)\\(&string\\)> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { pass "ptype quxint" }
+ -re "type = class Qux<int, ?&\\(string\\)> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" {
+ kfail "gdb/1512" "ptype quxint"
+ }
-re "$gdb_prompt $" { fail "ptype quxint" }
timeout { fail "(timeout) ptype quxint" }
}
@@ -460,7 +481,7 @@ send_gdb "ptype Spec\n"
gdb_expect {
-re "type = template <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\ntemplate instantiations:\r\n\[ \t\]*(class |)Spec<int,int \\*>\r\n\[ \t\]*(class |)Spec<int,char>\r\n$gdb_prompt $" { pass "ptype Spec" }
-re "type = <(class |)T1, (class |)T2> (class |)Spec \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\\}\r\n$gdb_prompt $" { xfail "ptype Spec" }
- -re "type = class Spec<int,char> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*int spec\\(char\\);\r\n}\r\n$gdb_prompt $"
+ -re "type = class Spec<int, ?char> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*int spec\\(char\\);\r\n}\r\n$gdb_prompt $"
{ # GCC 3.1, DWARF-2 output.
kfail "gdb/57" "ptype Spec" }
-re "No symbol \"Spec\" in current context.\r\n$gdb_prompt $"
@@ -474,7 +495,8 @@ gdb_expect {
send_gdb "ptype siip\n"
gdb_expect {
- -re "type = class Spec<int,int ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*.*int spec\\(int ?\\*\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype siip" }
+ -re "type = class Spec<int, ?int ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*.*int spec\\(int ?\\*\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype siip" }
+ -re "type = class Spec<int,int ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\r\n\[ \t\]*int spec\\(int ?\\*\\);.*\r\n\\}\r\n$gdb_prompt $" { pass "ptype siip" }
-re "$gdb_prompt $" { fail "ptype siip" }
timeout { fail "(timeout) ptype siip" }
}
@@ -484,6 +506,7 @@ gdb_expect {
send_gdb "ptype Garply<int>\n"
gdb_expect {
-re "type = class Garply<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int garply\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype Garply<int>" }
+ -re "type = class Garply<int> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int garply\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { pass "ptype Garply<int>" }
-re "$gdb_prompt $" { fail "ptype Garply<int>" }
timeout { fail "(timeout) ptype Garply<int>" }
}
@@ -493,6 +516,7 @@ gdb_expect {
send_gdb "ptype Garply<Garply<char> >\n"
gdb_expect {
-re "type = (class |)Garply<Garply<char> > \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*(class |)Garply<char> t;\r\n\r\n\[ \t\]*.*(class |)Garply<char> garply\\(int, (class |)Garply<char>\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype Garply<Garply<char> >" }
+ -re "type = (class |)Garply<Garply<char> > \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*(class |)Garply<char> t;\r\n\r\n\[ \t\]*(class |)Garply<char> garply\\(int, (class |)Garply<char>\\);.*\r\n\\}\r\n$gdb_prompt $" { pass "ptype Garply<Garply<char> >" }
-re "$gdb_prompt $" { fail "ptype Garply<Garply<char> >" }
timeout { fail "(timeout) ptype Garply<Garply<char> >" }
}
diff --git a/gdb/testsuite/gdb.cp/userdef.exp b/gdb/testsuite/gdb.cp/userdef.exp
index 4575249ce5a..5c9c9338a87 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 dbd575cfb32..bd931a629e3 100644
--- a/gdb/testsuite/gdb.cp/virtfunc.exp
+++ b/gdb/testsuite/gdb.cp/virtfunc.exp
@@ -1,4 +1,4 @@
-# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003
+# Copyright 1992, 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
@@ -15,16 +15,15 @@
# 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\]+"
+set wsopt "\[\r\n\t \]*"
+set ws "\[\r\n\t \]+"
+set nl "\[\r\n\]+"
if $tracelevel then {
- strace $tracelevel
+ strace $tracelevel
}
if { [skip_cplus_tests] } { continue }
@@ -33,708 +32,455 @@ set testfile "virtfunc"
set srcfile ${testfile}.cc
set binfile ${objdir}/${subdir}/${testfile}
-if [get_compiler_info ${binfile} "c++"] {
- return -1
-}
-
-source ${binfile}.ci
-
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
-proc gdb_virtfunc_init {} {
- global srcdir subdir binfile
- global gdb_prompt
-
- gdb_reinitialize_dir $srcdir/$subdir
- gdb_load $binfile
-
- send_gdb "set language c++\n"
- gdb_expect -re "$gdb_prompt $"
- send_gdb "set width 0\n"
- gdb_expect -re "$gdb_prompt $"
-}
-
-proc gdb_virtfunc_restart {} {
- gdb_exit;
- gdb_start;
- gdb_virtfunc_init;
- runto 'test_calls';
-}
-
+# Test ptype of a class.
+#
+# Different C++ compilers produce different output. I build up regular
+# expressions piece by piece to accommodate all the compilers that I
+# have seen: gcc 2.95.3, gcc 3.3.2 (ABI 1), gcc 3.4 prerelease (ABI 2);
+# and all the debug formats I have seen: dwarf-2 and stabs+.
+#
+# A complicated class declaration looks like this:
+#
+# class A : public virtual V { // re_class
+# private:
+# V * _vb$V; // re_vbptr
+# int a; // re_fields
+#
+# public: // re_access_methods
+# A & operator=(A const &); // re_synth_gcc_2
+# A(int, A const &); // ...
+# A(int); // ...
+# virtual int f(void); // re_methods
+# }
+#
+# RE_CLASS matches the class declaration. C++ allows multiple ways of
+# expressing this.
#
-# Test printing of the types of various classes.
+# struct ... { private: ... };
+# class ... { private: ... };
+# class ... { ... };
#
+# RE_VBPTR matches the virtual base declarations. gcc 2.95.3 sometimes
+# emits these, but gcc 3.X.Y never emits these. The name depends on the
+# debug format.
+#
+# RE_FIELDS matches the data fields of the class.
+# RE_METHODS matches the methods explicitly declared for the class.
+#
+# RE_SYNTH_GCC_2 and RE_SYNTH_GCC_3 match the optional synthetic methods
+# of the class. gcc -gstabs+ emits these methods, and gcc -gdwarf-2
+# does not.
+#
+# RE_ACCESS_METHODS is an access specifier after RE_FIELDS and before
+# the methods (explicit methods and/or synthetic methods).
+# There is also an RE_ACCESS_FIELDS.
+#
+# When I get HP-UX aCC, I hope that I can just add RE_SYNTH_ACC_NNN.
+#
+# Yet another twist: with gcc v2, ctor and dtor methods have a hidden
+# argument in front, the "in-charge" flag. With gcc v3, there is no
+# hidden argument; instead, there are multiple object functions for
+# each ctor and dtor.
+#
+# -- chastain 2004-01-01
-proc test_ptype_of_classes {} {
+proc test_one_ptype { command testname re_class re_vbptr re_access_fields re_fields re_access_methods re_methods re_synth_gcc_2 re_synth_gcc_3 re_star } {
global gdb_prompt
+ global wsopt
global ws
global nl
- # This used to be a fail if it printed "struct" not "class". But
- # since this struct doesn't use any special C++ features, it is
- # considered right for GDB to print it as "struct".
- send_gdb "ptype VA\n"
- gdb_expect {
- -re "type = (struct|class) VA \{(${ws}public:|)${ws}int va;${ws}VA & operator=\\(VA const ?&\\);${ws}VA\\((VA const|const VA) ?&\\);${ws}VA\\((void|)\\);${ws}\}.*$gdb_prompt $" {
- pass "ptype VA"
- }
- -re "type = (struct|class) VA \{(${ws}public:|)${ws}int va;((${ws}VA & operator=\\(VA const ?&\\);)|(${ws}VA\\(VA const ?&\\);)|(${ws}VA\\((void|)\\);))*${ws}\}.*$gdb_prompt $" {
- pass "ptype VA (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype VA"
- }
- timeout {
- fail "ptype VA (timeout)"
+ gdb_test_multiple "$command" "$testname" {
+ -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" {
+ # gcc 2.95.3, dwarf-2, no vbptr
+ # gcc 3.X, abi 1, dwarf-2
+ # gcc 3.X, abi 2, dwarf-2
+ pass "$testname"
}
- }
-
- send_gdb "ptype VB\n"
- gdb_expect {
- -re "type = class VB \{${ws}public:${ws}int vb;${ws}VB & operator=\\(VB const ?&\\);${ws}VB\\((VB const|const VB) ?&\\);${ws}VB\\((void|)\\);${ws}int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);${ws}\}.*$gdb_prompt $" {
- pass "ptype VB"
- }
- -re "type = class VB \{${ws}public:${ws}int vb;${ws}int fvb \\((void|)\\);${ws}virtual int vvb \\((void|)\\);${ws}\}.*$gdb_prompt $" {
- pass "ptype VB (aCC)"
- }
- -re "type = class VB \{${ws}public:${ws}int vb;((${ws}VB & operator=\\(VB const ?&\\);)|(${ws}VB\\(VB const ?&\\);)|(${ws}VB\\((void|)\\);)|(${ws}int fvb\\((void|)\\);)|(${ws}virtual int vvb\\((void|)\\);))*${ws}\}.*$gdb_prompt $" {
- pass "ptype VB (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype VB"
- }
- timeout {
- fail "ptype VB (timeout)"
- }
- }
-
- send_gdb "ptype V\n"
- gdb_expect {
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const ?&\\);${ws}V\\((V const|const V) ?&\\);${ws}V\\((void|)\\);${ws}int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype V"
- }
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}int f \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype V (aCC)"
- }
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const ?&\\);)|(${ws}V\\(V const ?&\\);)|(${ws}V\\((void|)\\);)|(${ws}int f\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype V (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype V"
- }
- timeout {
- fail "ptype V (timeout)"
- }
- }
-
- # The format of a g++ virtual base pointer.
- set vbptr "(_vb\[$.\]|__vb_)\[0-9\]?"
-
- send_gdb "ptype A\n"
- gdb_expect {
- -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype A"
- }
- -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\((A const|const A) ?&\\);${ws}A\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype A"
- }
- -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype A (aCC)"
- }
- -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:((${ws}A & operator=\\(A const ?&\\);)|(${ws}A\\(int, A const ?&\\);)|(${ws}A\\(int\\);)|(${ws}virtual int f\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype A (obsolescent gcc or gdb)"
- }
- -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}FOO;${ws}int a;${ws}public:${ws}virtual int f.void.;${ws}\}$nl$gdb_prompt $" {
- # This happens because the type is defined only after it is
- # too late.
- fail "ptype A (known failure with gcc cygnus-2.4.5-930417)"
- # Many of the rest of these tests have the same problem.
- return 0
- }
- -re ".*$gdb_prompt $" {
- fail "ptype A"
- }
- timeout {
- fail "ptype A (timeout)"
- }
- }
-
- send_gdb "ptype B\n"
- gdb_expect {
- -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype B"
- }
- -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const ?&\\);${ws}B\\((B const|const B) ?&\\);${ws}B\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype B"
- }
- -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}virtual int f \\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype B (aCC)"
- }
- -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:((${ws}B & operator=\\(B const ?&\\);)|(${ws}B\\(int, B const ?&\\);)|(${ws}B\\(int\\);)|(${ws}virtual int f\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype B (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype B"
- }
- timeout {
- fail "ptype B (timeout)"
- }
- }
-
- send_gdb "ptype C\n"
- gdb_expect {
- -re "type = class C : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int c;${ws}C & operator=\\(C const ?&\\);${ws}C\\(int, C const ?&\\);${ws}C\\(int\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype C"
- }
- -re "type = class C : public virtual V \{${ws}public:${ws}int c;${ws}C & operator=\\(C const ?&\\);${ws}C\\((C const|const C) ?&\\);${ws}C\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype C"
- }
- -re "type = class C : public virtual V \{${ws}public:${ws}int c;${ws}\}$nl$gdb_prompt $" {
- pass "ptype C (aCC)"
- }
- -re "type = class C : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int c;((${ws}C & operator=\\(C const ?&\\);)|(${ws}C\\(int, C const ?&\\);)|(${ws}C\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype C (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype C"
- }
- timeout {
- fail "ptype C (timeout)"
- }
- }
-
- send_gdb "ptype AD\n"
- gdb_expect {
- -re "type = class AD \{${ws}public:${ws}AD & operator=\\(AD const ?&\\);${ws}AD\\((AD const|const AD) ?&\\);${ws}AD\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype AD"
- }
- -re "type = class AD \{${ws}public:${ws}virtual int vg \\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype AD (aCC)"
- }
- -re "type = class AD \{${ws}public:((${ws}AD & operator=\\(AD const ?&\\);)|(${ws}AD\\(AD const ?&\\);)|(${ws}AD\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype AD (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype AD"
- }
- timeout {
- fail "ptype AD (timeout)"
- }
- }
-
- send_gdb "ptype D\n"
- gdb_expect {
- -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype D"
- }
- -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype D"
- }
- -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype D (aCC)"
- }
- -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(int, D const ?&\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vd\\((void|)\\);)|(${ws}int fd\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype D (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype D"
- }
- timeout {
- fail "ptype D (timeout)"
- }
- }
-
- send_gdb "ptype E\n"
- gdb_expect {
- -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);${ws}virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype E"
- }
- -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const ?&\\);${ws}E\\((E const|const E) ?&\\);${ws}E\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype E"
- }
- -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}virtual int f \\((void|)\\);${ws}virtual int vg \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype E (aCC)"
- }
- -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;((${ws}E & operator=\\(E const ?&\\);)|(${ws}E\\(int, E const ?&\\);)|(${ws}E\\(int\\);)|(${ws}virtual int f\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype E (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype E"
- }
- timeout {
- fail "ptype E (timeout)"
- }
- }
-
- send_gdb "ptype dd\n"
- gdb_expect {
- -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype dd"
- }
- -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype dd"
- }
- -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype dd (aCC)"
- }
- -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(int, D const ?&\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vd\\((void|)\\);)|(${ws}int fd\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype dd (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype dd"
- }
- timeout {
- fail "ptype dd (timeout)"
- }
- }
-
- send_gdb "ptype ppd\n"
- gdb_expect {
- -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype ppd"
- }
- -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype ppd"
- }
- -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype ppd (aCC)"
- }
- -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(int, D const ?&\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vd\\((void|)\\);)|(${ws}int fd\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype ppd (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype ppd"
- }
- timeout {
- fail "ptype ppd (timeout)"
- }
- }
-
- send_gdb "ptype pAd\n"
- gdb_expect {
- -re "type = class AD \{${ws}public:${ws}AD & operator=\\(AD const ?&\\);${ws}AD\\((AD const|const AD) ?&\\);${ws}AD\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pAd"
- }
- -re "type = class AD \{${ws}public:${ws}virtual int vg \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pAd (aCC)"
- }
- -re "type = class AD \{${ws}public:((${ws}AD & operator=\\(AD const ?&\\);)|(${ws}AD\\(AD const ?&\\);)|(${ws}AD\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pAd (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype pAd"
- }
- timeout {
- fail "ptype pAd (timeout)"
- }
- }
-
- send_gdb "ptype a\n"
- gdb_expect {
- -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype a"
- }
- -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\((A const|const A) ?&\\);${ws}A\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype a"
- }
- -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype a (aCC)"
- }
- -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:((${ws}A & operator=\\(A const ?&\\);)|(${ws}A\\(int, A const ?&\\);)|(${ws}A\\(int\\);)|(${ws}virtual int f\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype a (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype a"
- }
- timeout {
- fail "ptype a (timeout)"
- }
- }
-
- send_gdb "ptype b\n"
- gdb_expect {
- -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype b"
- }
- -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const ?&\\);${ws}B\\((B const|const B) ?&\\);${ws}B\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype b"
- }
- -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}virtual int f \\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype b (aCC)"
- }
- -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:((${ws}B & operator=\\(B const ?&\\);)|(${ws}B\\(int, B const ?&\\);)|(${ws}B\\(int\\);)|(${ws}virtual int f\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype b (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype b"
- }
- timeout {
- fail "ptype b (timeout)"
- }
- }
-
- send_gdb "ptype c\n"
- gdb_expect {
- -re "type = class C : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int c;${ws}C & operator=\\(C const ?&\\);${ws}C\\(int, C const ?&\\);${ws}C\\(int\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype c"
- }
- -re "type = class C : public virtual V \{${ws}public:${ws}int c;${ws}C & operator=\\(C const ?&\\);${ws}C\\((C const|const C) ?&\\);${ws}C\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype c"
- }
- -re "type = class C : public virtual V \{${ws}public:${ws}int c;${ws}\}$nl$gdb_prompt $" {
- pass "ptype c (aCC)"
- }
- -re "type = class C : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int c;((${ws}C & operator=\\(C const ?&\\);)|(${ws}C\\(int, C const ?&\\);)|(${ws}C\\(int\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype c (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype c"
- }
- timeout {
- fail "ptype c (timeout)"
- }
- }
-
- send_gdb "ptype d\n"
- gdb_expect {
- -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype d"
- }
- -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype d"
- }
- -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype d (aCC)"
- }
- -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(int, D const ?&\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vd\\((void|)\\);)|(${ws}int fd\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype d (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype d"
- }
- timeout {
- fail "ptype d (timeout)"
- }
- }
-
- send_gdb "ptype e\n"
- gdb_expect {
- -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);${ws}virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype e"
- }
- -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const ?&\\);${ws}E\\((E const|const E) ?&\\);${ws}E\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype e"
- }
- -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}virtual int f \\((void|)\\);${ws}virtual int vg \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype e (aCC)"
- }
- -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;((${ws}E & operator=\\(E const ?&\\);)|(${ws}E\\(int, E const ?&\\);)|(${ws}E\\(int\\);)|(${ws}virtual int f\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype e (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype e"
- }
- timeout {
- fail "ptype e (timeout)"
- }
- }
-
- send_gdb "ptype v\n"
- gdb_expect {
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const ?&\\);${ws}V\\((V const|const V) ?&\\);${ws}V\\((void|)\\);${ws}int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype v"
+ -re "type = $re_class${wsopt}$re_vbptr${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" {
+ # gcc 2.95.3, dwarf-2, vbptr
+ # TODO: drow says the vbptr is a bug
+ pass "$testname"
}
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}int f \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype v (aCC)"
+ -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_synth_gcc_2${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" {
+ # gcc 2.95.3, stabs+, no vbptr
+ pass "$testname"
}
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const ?&\\);)|(${ws}V\\(V const ?&\\);)|(${ws}V\\((void|)\\);)|(${ws}int f\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype v (obsolescent gcc or gdb)"
+ -re "type = $re_class${wsopt}$re_vbptr${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_synth_gcc_2${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" {
+ # gcc 2.95.3, stabs+, vbptr
+ # TODO: drow says the vbptr is a bug
+ pass "$testname"
}
- -re ".*$gdb_prompt $" {
- fail "ptype v"
+ -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_synth_gcc_3${wsopt}$re_methods$nl\}$re_star$nl$gdb_prompt $" {
+ # gcc 3.X, abi 1, stabs+
+ pass "$testname"
}
- timeout {
- fail "ptype v (timeout)"
+ -re "type = $re_class${wsopt}$re_access_fields${wsopt}$re_fields${wsopt}$re_access_methods${wsopt}$re_methods${wsopt}$re_synth_gcc_3$nl\}$re_star$nl$gdb_prompt $" {
+ # gcc 3.X, abi 2, stabs+
+ pass "$testname"
}
}
- send_gdb "ptype vb\n"
- gdb_expect {
- -re "type = class VB \{${ws}public:${ws}int vb;${ws}VB & operator=\\(VB const ?&\\);${ws}VB\\((VB const|const VB) ?&\\);${ws}VB\\((void|)\\);${ws}int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype vb"
- }
- -re "type = class VB \{${ws}public:${ws}int vb;${ws}int fvb \\((void|)\\);${ws}virtual int vvb \\((void|)\\);${ws}\}$nl$gdb_prompt $" {
- pass "ptype vb (aCC)"
- }
- -re "type = class VB \{${ws}public:${ws}int vb;((${ws}VB & operator=\\(VB const ?&\\);)|(${ws}VB\\(VB const ?&\\);)|(${ws}VB\\((void|)\\);)|(${ws}int fvb\\((void|)\\);)|(${ws}virtual int vvb\\((void|)\\);))*${ws}\}$nl$gdb_prompt $" {
- pass "ptype vb (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype vb"
- }
- timeout {
- fail "ptype vb (timeout)"
- }
- }
-
- send_gdb "ptype pAa\n"
- gdb_expect {
- -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pAa"
- }
- -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\((A const|const A) ?&\\);${ws}A\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pAa"
- }
- -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pAa (aCC)"
- }
- -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:((${ws}A & operator=\\(A const ?&\\);)|(${ws}A\\(int, A const ?&\\);)|(${ws}A\\(int\\);)|(${ws}virtual int f\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pAa (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype pAa"
- }
- timeout {
- fail "ptype pAa (timeout)"
- }
- }
-
- send_gdb "ptype pAe\n"
- gdb_expect {
- -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\(int, A const ?&\\);${ws}A\\(int\\);${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pAe"
- }
- -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}A & operator=\\(A const ?&\\);${ws}A\\((A const|const A) ?&\\);${ws}A\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pAe"
- }
- -re "type = class A : public virtual V \{${ws}private:${ws}int a;${ws}public:${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pAe (aCC)"
- }
- -re "type = class A : public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}int a;${ws}public:((${ws}A & operator=\\(A const ?&\\);)|(${ws}A\\(int, A const ?&\\);)|(${ws}A\\(int\\);)|(${ws}virtual int f\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pAe (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype pAe"
- }
- timeout {
- fail "ptype pAe (timeout)"
- }
- }
-
- send_gdb "ptype pBe\n"
- gdb_expect {
- -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const ?&\\);${ws}B\\(int, B const ?&\\);${ws}B\\(int\\);${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pBe"
- }
- -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}B & operator=\\(B const ?&\\);${ws}B\\((B const|const B) ?&\\);${ws}B\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pBe"
- }
- -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:${ws}virtual int f \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pBe (aCC)"
- }
- -re "type = class B : public A \{${ws}private:${ws}int b;${ws}public:((${ws}B & operator=\\(B const ?&\\);)|(${ws}B\\(int, B const ?&\\);)|(${ws}B\\(int\\);)|(${ws}virtual int f\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pBe (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype pBe"
- }
- timeout {
- fail "ptype pBe (timeout)"
- }
- }
-
- send_gdb "ptype pDd\n"
- gdb_expect {
- -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pDd"
- }
- -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pDd"
- }
- -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pDd (aCC)"
- }
- -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(int, D const ?&\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vd\\((void|)\\);)|(${ws}int fd\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pDd (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype pDd"
- }
- timeout {
- fail "ptype pDd (timeout)"
- }
- }
-
- send_gdb "ptype pDe\n"
- gdb_expect {
- -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\(int, D const ?&\\);${ws}D\\(int\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pDe"
- }
- -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}D & operator=\\(D const ?&\\);${ws}D\\((D const|const D) ?&\\);${ws}D\\((void|)\\);${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pDe"
- }
- -re "type = class D : public AD, public virtual V \{${ws}public:${ws}int d;${ws}static void s\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vd\\((void|)\\);${ws}int fd\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pDe (aCC)"
- }
- -re "type = class D : public AD, public virtual V \{${ws}private:${ws}V \\*${vbptr}V;${ws}public:${ws}int d;((${ws}D & operator=\\(D const ?&\\);)|(${ws}D\\(int, D const ?&\\);)|(${ws}D\\(int\\);)|(${ws}static void s\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vd\\((void|)\\);)|(${ws}int fd\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pDe (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype pDe"
- }
- timeout {
- fail "ptype pDe (timeout)"
- }
- }
-
- send_gdb "ptype pVa\n"
- gdb_expect {
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const ?&\\);${ws}V\\((V const|const V) ?&\\);${ws}V\\((void|)\\);${ws}int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVa"
- }
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}int f \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVa (aCC)"
- }
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const ?&\\);)|(${ws}V\\(V const ?&\\);)|(${ws}V\\((void|)\\);)|(${ws}int f\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVa (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype pVa"
- }
- timeout {
- fail "ptype pVa (timeout)"
- }
- }
-
- send_gdb "ptype pVv\n"
- gdb_expect {
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const ?&\\);${ws}V\\((V const|const V) ?&\\);${ws}V\\((void|)\\);${ws}int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVv"
- }
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}int f \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVv (aCC)"
- }
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const ?&\\);)|(${ws}V\\(V const ?&\\);)|(${ws}V\\((void|)\\);)|(${ws}int f\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVv (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype pVv"
- }
- timeout {
- fail "ptype pVv (timeout)"
- }
- }
-
- send_gdb "ptype pVe\n"
- gdb_expect {
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const ?&\\);${ws}V\\((V const|const V) ?&\\);${ws}V\\((void|)\\);${ws}int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVe"
- }
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}int f \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVe (aCC)"
- }
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const ?&\\);)|(${ws}V\\(V const ?&\\);)|(${ws}V\\((void|)\\);)|(${ws}int f\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVe (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype pVe"
- }
- timeout {
- fail "ptype pVe (timeout)"
- }
- }
-
- send_gdb "ptype pVd\n"
- gdb_expect {
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}V & operator=\\(V const ?&\\);${ws}V\\((V const|const V) ?&\\);${ws}V\\((void|)\\);${ws}int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVd"
- }
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;${ws}int f \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVd (aCC)"
- }
- -re "type = class V : public VA, public VB \{${ws}public:${ws}int w;((${ws}V & operator=\\(V const ?&\\);)|(${ws}V\\(V const ?&\\);)|(${ws}V\\((void|)\\);)|(${ws}int f\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVd (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype pVd"
- }
- timeout {
- fail "ptype pVd (timeout)"
- }
- }
-
- send_gdb "ptype pADe\n"
- gdb_expect {
- -re "type = class AD \{${ws}public:${ws}AD & operator=\\(AD const ?&\\);${ws}AD\\((AD const|const AD) ?&\\);${ws}AD\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pADe"
- }
- -re "type = class AD \{${ws}public:${ws}virtual int vg \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pADe (aCC)"
- }
- -re "type = class AD \{${ws}public:((${ws}AD & operator=\\(AD const ?&\\);)|(${ws}AD\\(AD const ?&\\);)|(${ws}AD\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pADe (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype pADe"
- }
- timeout {
- fail "ptype pADe (timeout)"
- }
- }
+}
- send_gdb "ptype pEe\n"
- gdb_expect {
- -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const ?&\\);${ws}E\\(int, E const ?&\\);${ws}E\\(int\\);${ws}virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pEe"
- }
- -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}E & operator=\\(E const ?&\\);${ws}E\\((E const|const E) ?&\\);${ws}E\\((void|)\\);${ws}virtual int f\\((void|)\\);${ws}virtual int vg\\((void|)\\);${ws}virtual int vv\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pEe"
- }
- -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;${ws}virtual int f \\((void|)\\);${ws}virtual int vg \\((void|)\\);${ws}virtual int vv \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pEe (aCC)"
- }
- -re "type = class E : public B, public virtual V, public D, public C \{${ws}public:${ws}int e;((${ws}E & operator=\\(E const ?&\\);)|(${ws}E\\(int, E const ?&\\);)|(${ws}E\\(int\\);)|(${ws}virtual int f\\((void|)\\);)|(${ws}virtual int vg\\((void|)\\);)|(${ws}virtual int vv\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pEe (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype pEe"
- }
- timeout {
- fail "ptype pEe (timeout)"
- }
- }
+proc test_ptype_of_classes {} {
+ global gdb_prompt
+ global ws
+ global nl
- send_gdb "ptype pVB\n"
- gdb_expect {
- -re "type = class VB \{${ws}public:${ws}int vb;${ws}VB & operator=\\(VB const ?&\\);${ws}VB\\((VB const|const VB) ?&\\);${ws}VB\\((void|)\\);${ws}int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVB"
- }
- -re "type = class VB \{${ws}public:${ws}int vb;${ws}int fvb \\((void|)\\);${ws}virtual int vvb \\((void|)\\);${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVB (aCC)"
- }
- -re "type = class VB \{${ws}public:${ws}int vb;((${ws}VB & operator=\\(VB const ?&\\);)|(${ws}VB\\(VB const ?&\\);)|(${ws}VB\\((void|)\\);)|(${ws}int fvb\\((void|)\\);)|(${ws}virtual int vvb\\((void|)\\);))*${ws}\} \[*\]+$nl$gdb_prompt $" {
- pass "ptype pVB (obsolescent gcc or gdb)"
- }
- -re ".*$gdb_prompt $" {
- fail "ptype pVB"
- }
- timeout {
- fail "ptype pVB (timeout)"
- }
- }
+ # class VA
+
+ test_one_ptype "ptype VA" "ptype VA" \
+ "((struct|class) VA \{${ws}public:|struct VA \{)" \
+ "" \
+ "" "int va;" \
+ "" "" \
+ "VA & operator=\\(VA const ?&\\);${ws}VA\\(VA const ?&\\);${ws}VA\\((void|)\\);" \
+ "VA & operator=\\(VA const ?&\\);${ws}VA\\(VA const ?&\\);${ws}VA\\((void|)\\);" \
+ ""
+
+ # class VB
+
+ test_one_ptype "ptype VB" "ptype VB" \
+ "((struct|class) VB \{${ws}public:|struct VB \{)" \
+ "" \
+ "" "int vb;" \
+ "" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \
+ "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
+ "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
+ ""
+
+ # class V
+
+ test_one_ptype "ptype V" "ptype V" \
+ "class V : public VA, public VB \{${ws}public:" \
+ "" \
+ "" "int w;" \
+ "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
+ "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
+ "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
+ ""
+
+ # class A
+
+ test_one_ptype "ptype A" "ptype A" \
+ "class A : public virtual V \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "" "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\\((void|)\\);" \
+ ""
+
+ # class B
+
+ test_one_ptype "ptype B" "ptype B" \
+ "class B : public A \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "" "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\\((void|)\\);" \
+ ""
+
+ # class C
+
+ test_one_ptype "ptype C" "ptype C" \
+ "class C : public virtual V \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "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\\((void|)\\);" \
+ ""
+
+ # class AD
+
+ test_one_ptype "ptype AD" "ptype AD" \
+ "((struct|class) AD \{${ws}public:|struct AD \{)" \
+ "" \
+ "" "" \
+ "" "virtual int vg\\((void|)\\);" \
+ "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
+ "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
+ ""
+
+ # class D
+
+ test_one_ptype "ptype D" "ptype D" \
+ "class D : public AD, public virtual V \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "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\\((void|)\\);" \
+ ""
+
+ # class E
+ # TODO: E does not show a vbptr for V. That seems strange.
+
+ test_one_ptype "ptype E" "ptype E" \
+ "class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \
+ "" \
+ "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\\((void|)\\);" \
+ ""
+
+ # An instance of D
+
+ test_one_ptype "ptype dd" "ptype dd" \
+ "class D : public AD, public virtual V \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "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\\((void|)\\);" \
+ ""
+
+ # An instance of D *
+
+ test_one_ptype "ptype ppd" "ptype ppd" \
+ "class D : public AD, public virtual V \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "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\\((void|)\\);" \
+ " ?\\*"
+
+ # An instance of AD *
+ # TODO: this should be named pADd, not pAd.
+
+ test_one_ptype "ptype pAd" "ptype pAd" \
+ "((struct|class) AD \{${ws}public:|struct AD \{)" \
+ "" \
+ "" "" \
+ "" "virtual int vg\\((void|)\\);" \
+ "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
+ "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
+ " ?\\*"
+
+ # An instance of A
+
+ test_one_ptype "ptype a" "ptype a" \
+ "class A : public virtual V \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "" "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\\((void|)\\);" \
+ ""
+
+ # An instance of B
+
+ test_one_ptype "ptype b" "ptype b" \
+ "class B : public A \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "" "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\\((void|)\\);" \
+ ""
+
+ # An instance of C
+
+ test_one_ptype "ptype c" "ptype c" \
+ "class C : public virtual V \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "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\\((void|)\\);" \
+ ""
+
+ # An instance of D
+
+ test_one_ptype "ptype d" "ptype d" \
+ "class D : public AD, public virtual V \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "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\\((void|)\\);" \
+ ""
+
+ # An instance of E
+
+ test_one_ptype "ptype e" "ptype e" \
+ "class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \
+ "" \
+ "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\\((void|)\\);" \
+ ""
+
+ # An instance of V
+
+ test_one_ptype "ptype v" "ptype v" \
+ "class V : public VA, public VB \{${ws}public:" \
+ "" \
+ "" "int w;" \
+ "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
+ "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
+ "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
+ ""
+
+ # An instance of VB
+
+ test_one_ptype "ptype vb" "ptype vb" \
+ "((struct|class) VB \{${ws}public:|struct VB \{)" \
+ "" \
+ "" "int vb;" \
+ "" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \
+ "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
+ "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
+ ""
+
+ # An instance of A *
+
+ test_one_ptype "ptype pAa" "ptype pAa" \
+ "class A : public virtual V \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "" "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\\((void|)\\);" \
+ " ?\\*"
+
+ # An instance of A *
+
+ test_one_ptype "ptype pAe" "ptype pAe" \
+ "class A : public virtual V \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "" "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\\((void|)\\);" \
+ " ?\\*"
+
+ # An instance of B *
+
+ test_one_ptype "ptype pBe" "ptype pBe" \
+ "class B : public A \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "" "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\\((void|)\\);" \
+ " ?\\*"
+
+ # An instance of D *
+
+ test_one_ptype "ptype pDd" "ptype pDd" \
+ "class D : public AD, public virtual V \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "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\\((void|)\\);" \
+ " ?\\*"
+
+ # An instance of D *
+
+ test_one_ptype "ptype pDe" "ptype pDe" \
+ "class D : public AD, public virtual V \{(${ws}private:|)" \
+ "V \\*(_vb.1V|_vb.V);" \
+ "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\\((void|)\\);" \
+ " ?\\*"
+
+ # An instance of V *
+
+ test_one_ptype "ptype pVa" "ptype pVa" \
+ "class V : public VA, public VB \{${ws}public:" \
+ "" \
+ "" "int w;" \
+ "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
+ "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
+ "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
+ " ?\\*"
+
+ # An instance of V *
+
+ test_one_ptype "ptype pVv" "ptype pVv" \
+ "class V : public VA, public VB \{${ws}public:" \
+ "" \
+ "" "int w;" \
+ "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
+ "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
+ "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
+ " ?\\*"
+
+ # An instance of V *
+
+ test_one_ptype "ptype pVe" "ptype pVe" \
+ "class V : public VA, public VB \{${ws}public:" \
+ "" \
+ "" "int w;" \
+ "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
+ "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
+ "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
+ " ?\\*"
+
+ # An instance of V *
+
+ test_one_ptype "ptype pVd" "ptype pVd" \
+ "class V : public VA, public VB \{${ws}public:" \
+ "" \
+ "" "int w;" \
+ "" "int f\\((void|)\\);${ws}virtual int vv\\((void|)\\);" \
+ "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
+ "V & operator=\\(V const ?&\\);${ws}V\\(V const ?&\\);${ws}V\\((void|)\\);" \
+ " ?\\*"
+
+ # An instance of AD *
+
+ test_one_ptype "ptype pADe" "ptype pADe" \
+ "((struct|class) AD \{${ws}public:|struct AD \{)" \
+ "" \
+ "" "" \
+ "" "virtual int vg\\((void|)\\);" \
+ "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
+ "AD & operator=\\(AD const ?&\\);${ws}AD\\(AD const ?&\\);${ws}AD\\((void|)\\);" \
+ " ?\\*"
+
+ # An instance of E *
+
+ test_one_ptype "ptype pEe" "ptype pEe" \
+ "class E : public B, public virtual V, public D, public C \{(${ws}private:|)" \
+ "" \
+ "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\\((void|)\\);" \
+ " ?\\*"
+
+ # An instance of VB *
+
+ test_one_ptype "ptype pVB" "ptype pVB" \
+ "((struct|class) VB \{${ws}public:|struct VB \{)" \
+ "" \
+ "" "int vb;" \
+ "" "int fvb\\((void|)\\);${ws}virtual int vvb\\((void|)\\);" \
+ "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
+ "VB & operator=\\(VB const ?&\\);${ws}VB\\(VB const ?&\\);${ws}VB\\((void|)\\);" \
+ " ?\\*"
}
-#
-# Test calling of virtual functions.
-#
+# Call virtual functions.
proc test_virtual_calls {} {
global gdb_prompt
- global GDB
global nl
- global gcc_compiled
if [target_info exists gdb,cannot_call_functions] {
setup_xfail "*-*-*" 2416
@@ -742,207 +488,61 @@ proc test_virtual_calls {} {
return 0
}
- send_gdb "print pAe->f()\n"
- gdb_expect {
- -re ".* = 20$nl$gdb_prompt $" { pass "print pAe->f()" }
- -re "Cannot invoke functions on this machine.*$gdb_prompt $" {
- fail "print pAe->f() (cannot invoke functions, skipping virtual calls)"
- return 0
- }
- -re ".*Cannot access memory at address 0x8.*$gdb_prompt $" {
- fail "print pAe->f() \
-(known failure with gcc cygnus-2.4.5-930417, skipping virtual calls)"
- return 0
- }
- -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
- setup_xfail hppa*-*-* CLLbs16899
- fail "print pAe->f()"
- }
- -re ".*$gdb_prompt $" { fail "print pAe->f()" }
- timeout { fail "print pAe->f() (timeout)" }
- eof { fail "print pAe->f() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
- }
-
- send_gdb "print pAa->f()\n"
- gdb_expect {
- -re ".* = 1$nl$gdb_prompt $" { pass "print pAa->f()" }
- -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
- setup_xfail hppa*-*-* CLLbs16899
- fail "print pAa->f()"
- }
- -re ".*$gdb_prompt $" { fail "print pAa->f()" }
- timeout { fail "print pAa->f() (timeout)" }
- eof { fail "print pAa->f() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
- }
-
- send_gdb "print pDe->vg()\n"
- gdb_expect {
- -re ".* = 202$nl$gdb_prompt $" { pass "print pDe->vg()" }
- -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
- setup_xfail hppa*-*-* CLLbs16899
- fail "print pDe->vg()"
- }
- -re ".*$gdb_prompt $" { fail "print pDe->vg()" }
- timeout { fail "print pDe->vg() (timeout)" }
- eof { fail "print pDe->vg() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
- }
-
- send_gdb "print pADe->vg()\n"
- gdb_expect {
- -re ".* = 202$nl$gdb_prompt $" { pass "print pADe->vg()" }
- -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
- setup_xfail hppa*-*-* CLLbs16899
- fail "print pADe->vg()"
- }
- -re ".*$gdb_prompt $" { fail "print pADe->vg()" }
- timeout { fail "print pADe->vg() (timeout)" }
- eof { fail "print pADe->vg() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
- }
-
- send_gdb "print pDd->vg()\n"
- gdb_expect {
- -re ".* = 101$nl$gdb_prompt $" { pass "print pDd->vg()" }
- -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
- setup_xfail hppa*-*-* CLLbs16899
- fail "print pDd->vg()"
- }
- -re ".*$gdb_prompt $" { fail "print pDd->vg()" }
- timeout { fail "print pDd->vg() (timeout)" }
- eof { fail "print pDd->vg() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
- }
-
- send_gdb "print pEe->vvb()\n"
- gdb_expect {
- -re ".* = 411$nl$gdb_prompt $" { pass "print pEe->vvb()" }
- -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
- setup_xfail hppa*-*-* CLLbs16899
- fail "print pEe->vvb()"
- }
- -re ".*$gdb_prompt $" { fail "print pEe->vvb()" }
- timeout { fail "print pEe->vvb() (timeout)" }
- eof { fail "print pEe->vvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
- }
-
- send_gdb "print pVB->vvb()\n"
- gdb_expect {
- -re ".* = 407$nl$gdb_prompt $" { pass "print pVB->vvb()" }
- -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
- setup_xfail hppa*-*-* CLLbs16899
- fail "print pVB->vvb()"
- }
- -re ".*$gdb_prompt $" { fail "print pVB->vvb()" }
- timeout { fail "print pVB->vvb() (timeout)" }
- eof { fail "print pVB->vvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
- }
-
- send_gdb "print pBe->vvb()\n"
- gdb_expect {
- -re ".* = 411$nl$gdb_prompt $" { pass "print pBe->vvb()" }
- -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
- setup_xfail hppa*-*-* CLLbs16899
- fail "print pBe->vvb()"
- }
- -re ".*$gdb_prompt $" { fail "print pBe->vvb()" }
- timeout { fail "print pBe->vvb() (timeout)" }
- eof { fail "print pBe->vvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
- }
-
- send_gdb "print pDe->vvb()\n"
- gdb_expect {
- -re ".* = 411$nl$gdb_prompt $" { pass "print pDe->vvb()" }
- -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
- setup_xfail hppa*-*-* CLLbs16899
- fail "print pDe->vvb()"
- }
- -re ".*$gdb_prompt $" { fail "print pDe->vvb()" }
- timeout { fail "print pDe->vvb() (timeout)" }
- eof { fail "print pDe->vvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
- }
+ gdb_test "print pAe->f()" "\\$\[0-9\]+ = 20"
+ gdb_test "print pAa->f()" "\\$\[0-9\]+ = 1"
+ gdb_test "print pDe->vg()" "\\$\[0-9\]+ = 202"
+ gdb_test "print pADe->vg()" "\\$\[0-9\]+ = 202"
+ gdb_test "print pDd->vg()" "\\$\[0-9\]+ = 101"
+ gdb_test "print pEe->vvb()" "\\$\[0-9\]+ = 411"
+ gdb_test "print pVB->vvb()" "\\$\[0-9\]+ = 407"
+ gdb_test "print pBe->vvb()" "\\$\[0-9\]+ = 411"
+ gdb_test "print pDe->vvb()" "\\$\[0-9\]+ = 411"
+ gdb_test "print pEe->vd()" "\\$\[0-9\]+ = 282"
+ gdb_test "print pEe->fvb()" "\\$\[0-9\]+ = 311"
+
+ # more recent results:
+ # wrong value "202"
+ # gcc 2.95.3 -gdwarf-2
+ # gcc 2.95.3 -gstabs+
+ # attempt to take addres of value not located in memory
+ # gcc 3.3.2 -gdwarf-2
+ # gcc 3.3.2 -gstabs+
+ #
+ # -- chastain 2003-12-31
- send_gdb "print pEe->vd()\n"
- gdb_expect {
- -re ".* = 282$nl$gdb_prompt $" { pass "print pEe->vd()" }
- -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
- setup_xfail hppa*-*-* CLLbs16899
- fail "print pEe->vd()"
+ gdb_test_multiple "print pEe->D::vg()" "print pEe->D::vg()" {
+ -re "\\$\[0-9]+ = 102$nl$gdb_prompt $" {
+ pass "print pEe->D::vg()"
}
- -re ".*$gdb_prompt $" { fail "print pEe->vd()" }
- timeout { fail "print pEe->vd() (timeout)" }
- eof { fail "print pEe->vd() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
- }
-
- send_gdb "print pEe->fvb()\n"
- gdb_expect {
- -re ".* = 311$nl$gdb_prompt $" { pass "print pEe->fvb()" }
- -re "Cannot resolve .* to any overloaded instance.*$gdb_prompt $" {
- setup_xfail hppa*-*-* CLLbs16899
- fail "print pEe->fvb()"
+ -re "Attempt to take address of value not located in memory.$nl$gdb_prompt $" {
+ kfail "gdb/1064" "print pEe->D::vg()"
}
- -re ".*$gdb_prompt $" { fail "print pEe->fvb()" }
- timeout { fail "print pEe->fvb() (timeout)" }
- eof { fail "print pEe->fvb() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
- }
-
- # fails on target=native, host=i686-pc-linux-gnu%rh-7.2,
- # gdb=HEAD%2002-02-16, gcc=2.95.3, goption=-gdwarf-2.
- #
- # fails on target=native, host=i686-pc-linux-gnu%rh-7.2,
- # gdb=HEAD%2002-02-16, gcc=2.95.3, goption=-gstabs+.
- #
- # fails on target=native, host=i686-pc-linux-gnu%rh-7.2,
- # gdb=HEAD%2002-02-16, gcc=3.0.3, goption=-gdwarf-2.
- #
- # fails on target=native, host=i686-pc-linux-gnu%rh-7.2,
- # gdb=HEAD%2002-02-16, gcc=3.0.3, goption=-gstabs+.
- #
- # fails on target=native, host=i686-pc-linux-gnu%rh-7.2,
- # gdb=HEAD%2002-02-16, gcc=3.0.4-20020215, goption=-gdwarf-2.
- #
- # fails on target=native, host=i686-pc-linux-gnu%rh-7.2,
- # gdb=HEAD%2002-02-16, gcc=3.0.4-20020215, goption=-gstabs+.
- #
- # fails on target=native, host=i686-pc-linux-gnu%rh-7.2,
- # gdb=HEAD%2002-02-16, gcc=gcc-3_0-branch%2002-02-16, goption=-gdwarf-2.
- #
- # fails on target=native, host=i686-pc-linux-gnu%rh-7.2,
- # gdb=HEAD%2002-02-16, gcc=gcc-3_0-branch%2002-02-16, goption=-gstabs+.
- #
- # fails on target=native, host=i686-pc-linux-gnu%rh-7.2,
- # gdb=HEAD%2002-02-16, gcc=HEAD%2002-02-16, goption=-gdwarf-2.
- #
- # fails on target=native, host=i686-pc-linux-gnu%rh-7.2,
- # gdb=HEAD%2002-02-16, gcc=HEAD%2002-02-16, goption=-gstabs+.
- #
- # -- chastain 2002-02-20
-
- send_gdb "print pEe->D::vg()\n"
- gdb_expect {
- -re ".* = 102$nl$gdb_prompt $" { pass "print pEe->D::vg()" }
- -re "Attempt to take address of value not located in memory.\r\n$gdb_prompt $"
- { kfail "gdb/1064" "print pEe->D::vg()" }
- -re ".*$gdb_prompt $" { fail "print pEe->D::vg()" }
- timeout { fail "print pEe->D::vg() (timeout)" }
- eof { fail "print pEe->D::vg() ($GDB dumped core) (FIXME)" ; gdb_virtfunc_restart; return }
}
}
proc do_tests {} {
global prms_id
global bug_id
+ global srcdir subdir binfile
+ global gdb_prompt
set prms_id 0
set bug_id 0
- gdb_start;
- gdb_virtfunc_init;
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load $binfile
- runto_main
+ gdb_test "set language c++" "" ""
+ gdb_test "set width 0" "" ""
+ runto_main
test_ptype_of_classes
- if [ runto 'test_calls' ] then {
- test_virtual_calls
- }
+ gdb_breakpoint test_calls
+ gdb_test "continue" ".*Breakpoint .* test_calls.*" ""
+ test_virtual_calls
}
do_tests