summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Carlton <carlton@bactrian.org>2003-05-02 17:55:19 +0000
committerDavid Carlton <carlton@bactrian.org>2003-05-02 17:55:19 +0000
commitca1e8e01742758b1f4356f2c3faa008193ec2087 (patch)
tree76e580e240361b727d41c4f7463e3cf4aaf1b14b
parent4f80c69dc297b083c5fe6e3b76f8270697447216 (diff)
downloadgdb-ca1e8e01742758b1f4356f2c3faa008193ec2087.tar.gz
2003-05-02 David Carlton <carlton@bactrian.org>
* gdb.c++/rtti.h: New. * gdb.c++/rtti2.cc: New. * gdb.c++/rtti1.cc: New. * gdb.c++/rtti.exp: New. 2003-05-02 David Carlton <carlton@bactrian.org> * config/djgpp/fnchange.lst: Add testsuite/gdb.c++/rtti files.
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/config/djgpp/fnchange.lst4
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.c++/rtti.exp112
-rw-r--r--gdb/testsuite/gdb.c++/rtti.h48
-rw-r--r--gdb/testsuite/gdb.c++/rtti1.cc67
-rw-r--r--gdb/testsuite/gdb.c++/rtti2.cc36
7 files changed, 278 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f0ade41786f..f712b7ea94f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2003-05-02 David Carlton <carlton@bactrian.org>
+
+ * config/djgpp/fnchange.lst: Add testsuite/gdb.c++/rtti files.
+
2003-04-30 David Carlton <carlton@bactrian.org>
* cp-namespace.c (get_namespace_objfile): Copy the namespace
diff --git a/gdb/config/djgpp/fnchange.lst b/gdb/config/djgpp/fnchange.lst
index b57cdde82a8..c2ed91487be 100644
--- a/gdb/config/djgpp/fnchange.lst
+++ b/gdb/config/djgpp/fnchange.lst
@@ -261,6 +261,10 @@
@V@/gdb/testsuite/gdb.c++/psmang2.cc @V@/gdb/testsuite/gdb.cxx/psmang2.cc
@V@/gdb/testsuite/gdb.c++/ref-types.cc @V@/gdb/testsuite/gdb.cxx/ref-types.cc
@V@/gdb/testsuite/gdb.c++/ref-types.exp @V@/gdb/testsuite/gdb.cxx/ref-types.exp
+@V@/gdb/testsuite/gdb.c++/rtti1.cc @V@/gdb/testsuite/gdb.cxx/rtti1.cc
+@V@/gdb/testsuite/gdb.c++/rtti2.cc @V@/gdb/testsuite/gdb.cxx/rtti2.cc
+@V@/gdb/testsuite/gdb.c++/rtti.h @V@/gdb/testsuite/gdb.cxx/rtti.h
+@V@/gdb/testsuite/gdb.c++/rtti.exp @V@/gdb/testsuite/gdb.cxx/rtti.exp
@V@/gdb/testsuite/gdb.c++/templates.cc @V@/gdb/testsuite/gdb.cxx/templates.cc
@V@/gdb/testsuite/gdb.c++/templates.exp @V@/gdb/testsuite/gdb.cxx/templates.exp
@V@/gdb/testsuite/gdb.c++/try_catch.cc @V@/gdb/testsuite/gdb.cxx/try_catch.cc
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 6b268ac59b1..a6e09e21ee2 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2003-05-02 David Carlton <carlton@bactrian.org>
+
+ * gdb.c++/rtti.h: New.
+ * gdb.c++/rtti2.cc: New.
+ * gdb.c++/rtti1.cc: New.
+ * gdb.c++/rtti.exp: New.
+
2003-04-27 Daniel Jacobowitz <drow@mvista.com>
* gdb.base/signals.exp: Make backtrace tests more specific.
diff --git a/gdb/testsuite/gdb.c++/rtti.exp b/gdb/testsuite/gdb.c++/rtti.exp
new file mode 100644
index 00000000000..6f79c711a7f
--- /dev/null
+++ b/gdb/testsuite/gdb.c++/rtti.exp
@@ -0,0 +1,112 @@
+# Copyright 2003 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 GDB's use of RTTI information. This stems
+# from a bug reported in PR gdb/488 and other places, which leads to
+# statements like 'warning: can't find class named 'C::D', as given by
+# C++ RTTI. It arises from GDB not knowing about classes that are
+# defined in namespaces.
+
+# NOTE: carlton/2003-05-02: I suspect it could arise from nested class
+# issues, too, and even once we fix that, there might be situations
+# (involving templates, in particular) where this problem triggers
+# because GDB and GCC have different ideas what a class is called.
+
+if $tracelevel then {
+ strace $tracelevel
+ }
+
+if { [skip_cplus_tests] } { continue }
+
+#
+# test running programs
+#
+set prms_id 0
+set bug_id 0
+
+set testfile "rtti"
+set srcfile1 "${srcdir}/${subdir}/${testfile}1.cc"
+set objfile1 "${objdir}/${subdir}/${testfile}1.o"
+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}"
+
+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 "${srcfile2}" "${objfile2}" object {debug c++}] != "" } {
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+}
+
+if { [gdb_compile "${objfile1} ${objfile2}" "${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
+}
+
+# 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_test_multiple "print *e1" "print *e1" {
+ -re "warning: can't find class named `n1::D1', as given by C\\+\\+ RTTI.*$gdb_prompt $" {
+ kfail "gdb/488" "print *e1"
+ }
+ -re "\\$\[0-9\]* = {<n1::Base1> = .*}\r\n$gdb_prompt $" {
+ pass "print *e1"
+ }
+}
+
+# NOTE: carlton/2003-05-02: This test fails on my branch 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.
+
+gdb_test_multiple "print *e2" "print *e2" {
+ -re "warning: can't find class named `n2::D2', as given by C\\+\\+ RTTI.*$gdb_prompt $" {
+ kfail "gdb/488" "print *e2"
+ }
+ -re "\\$\[0-9\]* = <incomplete type>\r\n$gdb_prompt $" {
+ kfail "gdb/TBA" "print *e2"
+ }
+ -re "\\$\[0-9\]* = {<n2::Base2> = .*}\r\n$gdb_prompt $" {
+ pass "print *e2"
+ }
+}
+
+gdb_exit
+return 0
diff --git a/gdb/testsuite/gdb.c++/rtti.h b/gdb/testsuite/gdb.c++/rtti.h
new file mode 100644
index 00000000000..879896d0dc8
--- /dev/null
+++ b/gdb/testsuite/gdb.c++/rtti.h
@@ -0,0 +1,48 @@
+/* Code to go along with tests in rtti.exp.
+
+ Copyright 2003 Free Software Foundation, Inc.
+
+ Contributed by David Carlton <carlton@bactrian.org> and by Kealia,
+ 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. */
+
+namespace n2 {
+
+ class C2;
+
+ class Base2 {
+ public:
+ virtual ~Base2() { }
+ };
+
+
+ class C2: public Base2 {
+ public:
+ };
+
+ class D2 : public C2{
+ public:
+ D2(C2 *, C2 *);
+
+ C2* expr_1_;
+ C2* expr_2_;
+ };
+
+ extern C2 *create2();
+}
diff --git a/gdb/testsuite/gdb.c++/rtti1.cc b/gdb/testsuite/gdb.c++/rtti1.cc
new file mode 100644
index 00000000000..6e9d862bb13
--- /dev/null
+++ b/gdb/testsuite/gdb.c++/rtti1.cc
@@ -0,0 +1,67 @@
+/* Code to go along with tests in rtti.exp.
+
+ Copyright 2003 Free Software Foundation, Inc.
+
+ Contributed by David Carlton <carlton@bactrian.org> and by Kealia,
+ 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. */
+
+#include "rtti.h"
+
+namespace n1 {
+
+ class C1;
+
+ class Base1 {
+ public:
+ virtual ~Base1() { }
+ };
+
+
+ class C1: public Base1 {
+ public:
+ };
+
+ class D1 : public C1{
+ public:
+ D1(C1 *, C1 *);
+
+ C1* expr_1_;
+ C1* expr_2_;
+ };
+
+ D1::D1(C1 *expr_1, C1 *expr_2)
+ : expr_1_(expr_1), expr_2_(expr_2) { }
+
+ C1 *create1() {
+ return new D1(0, 0);
+ }
+
+} // n1
+
+int main()
+{
+ using namespace n1;
+ using namespace n2;
+
+ C1 *e1 = create1();
+ C2 *e2 = create2();
+
+ return 0; // constructs-done
+}
diff --git a/gdb/testsuite/gdb.c++/rtti2.cc b/gdb/testsuite/gdb.c++/rtti2.cc
new file mode 100644
index 00000000000..8bb1ed6c99f
--- /dev/null
+++ b/gdb/testsuite/gdb.c++/rtti2.cc
@@ -0,0 +1,36 @@
+/* Code to go along with tests in rtti.exp.
+
+ Copyright 2003 Free Software Foundation, Inc.
+
+ Contributed by David Carlton <carlton@bactrian.org> and by Kealia,
+ 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. */
+
+#include "rtti.h"
+
+namespace n2 {
+
+ D2::D2(C2 *expr_1, C2 *expr_2)
+ : expr_1_(expr_1), expr_2_(expr_2) { }
+
+ C2 *create2() {
+ return new D2(0, 0);
+ }
+
+}