Re: [rfa/c++testsuite] (was Re: patch for PR gdb/574)

David Carlton
2002-08-22T17:09:57Z

[-- Attachment #1: Type: text/plain, Size: 754 bytes --]

In article <ro13ctewgca.fsf_-_@jackfruit.Stanford.EDU>, David Carlton <carlton@math.Stanford.EDU> writes:
> In article <20020816032649.GA30528@nevyn.them.org>, Daniel Jacobowitz
> <drow@mvista.com> writes:

>> Also, I'd appreciate it if you would submit a testsuite patch to run
>> the reduced testcase you wrote. More tests are always good.

> Here it is. The bug seemed idiosyncratic enough to not really fit
> into any of the files or into any other general schema that I could
> think of, so I just put it in a new file named after the bug number.

Here's a slightly revised version.

David Carlton
carlton@math.stanford.edu

2002-08-22 David Carlton <carlton@math.stanford.edu>

* gdb.c++/pr-574.exp: New file.
* gdb.c++/pr-574.cc: New file.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: new file: pr-574.exp --]
[-- Type: text/x-patch, Size: 2107 bytes --]

--- /dev/null Thu Apr 11 07:25:15 2002
+++ pr-574.exp Thu Aug 22 09:34:04 2002
@@ -0,0 +1,69 @@
+# Copyright 2002 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.
+
+# Tests for the bug mentioned in PR gdb/574. It's a bit
+# idiosyncratic, so I gave it its own file.
+
+# 2002-08-16 David Carlton <carlton@math.stanford.edu>
+
+# This file is part of the gdb testsuite
+
+if $tracelevel then {
+ strace $tracelevel
+ }
+
+if { [skip_cplus_tests] } { continue }
+
+#
+# test running programs
+#
+set prms_id 0
+set bug_id 0
+
+set testfile "pr-574"
+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 "next" "" "next"
+
+# This failed, as long as the code was compiled with GCC v. 2.
+
+# Different compilers order the data for differently, so I'm not
+# matching the result exactly.
+
+gdb_test "print *theB" "\\$\[0-9\]* = { = {\[^}\]*}, static b = <optimized out>}" "PR gdb/574"
+
+gdb_exit
+return 0

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: new file: pr-574.cc --]
[-- Type: text/x-patch, Size: 501 bytes --]

--- /dev/null Thu Apr 11 07:25:15 2002
+++ pr-574.cc Tue Aug 20 16:27:07 2002
@@ -0,0 +1,22 @@
+/*
+ An attempt to replicate PR gdb/574 with a shorter program.
+
+ Printing out *theB failed if the program was compiled with GCC 2.95.
+*/
+
+class A {
+public:
+ virtual void foo() {}; // Stick in a virtual function.
+ int a; // Stick in a data member.
+};
+
+class B : public A {
+ static int b; // Stick in a static data member.
+};
+
+int main()
+{
+ B *theB = new B;
+
+ return 0;
+}