Blame SOURCES/gdb-6.3-test-dtorfix-20050121.patch

f9426a
Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.cp/constructortest.cc
f9426a
===================================================================
f9426a
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
f9426a
+++ gdb-7.4.50.20111219/gdb/testsuite/gdb.cp/constructortest.cc	2011-12-19 22:05:02.825431735 +0100
f9426a
@@ -0,0 +1,99 @@
f9426a
+/* This testcase is part of GDB, the GNU debugger.
f9426a
+
f9426a
+   Copyright 2005 Free Software Foundation, Inc.
f9426a
+
f9426a
+   This program is free software; you can redistribute it and/or modify
f9426a
+   it under the terms of the GNU General Public License as published by
f9426a
+   the Free Software Foundation; either version 2 of the License, or
f9426a
+   (at your option) any later version.
f9426a
+
f9426a
+   This program is distributed in the hope that it will be useful,
f9426a
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
f9426a
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f9426a
+   GNU General Public License for more details.
f9426a
+
f9426a
+   You should have received a copy of the GNU General Public License
f9426a
+   along with this program; if not, write to the Free Software
f9426a
+   Foundation, Inc., 59 Temple Place - Suite 330,
f9426a
+   Boston, MA 02111-1307, USA.  */
f9426a
+
f9426a
+class A
f9426a
+{
f9426a
+  public:
f9426a
+    A();
f9426a
+    ~A();
f9426a
+    int  k;
f9426a
+  private:
f9426a
+    int  x;
f9426a
+};
f9426a
+
f9426a
+class B: public A
f9426a
+{
f9426a
+  public:
f9426a
+    B();
f9426a
+  private:
f9426a
+    int  y;
f9426a
+};
f9426a
+
f9426a
+/* C and D are for the $delete destructor.  */
f9426a
+
f9426a
+class C
f9426a
+{
f9426a
+  public:
f9426a
+    C();
f9426a
+    virtual ~C();
f9426a
+  private:
f9426a
+    int  x;
f9426a
+};
f9426a
+
f9426a
+class D: public C
f9426a
+{
f9426a
+  public:
f9426a
+    D();
f9426a
+  private:
f9426a
+    int  y;
f9426a
+};
f9426a
+
f9426a
+int main(int argc, char *argv[])
f9426a
+{
f9426a
+  A* a = new A;
f9426a
+  B* b = new B;
f9426a
+  D* d = new D;
f9426a
+  delete a;
f9426a
+  delete b;
f9426a
+  delete d;
f9426a
+  return 0;
f9426a
+}
f9426a
+
f9426a
+A::A() /* Constructor A */
f9426a
+{
f9426a
+   x = 1; /* First line A */
f9426a
+   k = 4; /* Second line A */
f9426a
+}
f9426a
+
f9426a
+A::~A() /* Destructor A */
f9426a
+{
f9426a
+   x = 3; /* First line ~A */
f9426a
+   k = 6; /* Second line ~A */
f9426a
+}
f9426a
+
f9426a
+B::B()
f9426a
+{
f9426a
+   y = 2; /* First line B */
f9426a
+   k = 5;
f9426a
+}
f9426a
+
f9426a
+C::C() /* Constructor C */
f9426a
+{
f9426a
+   x = 1; /* First line C */
f9426a
+}
f9426a
+
f9426a
+C::~C() /* Destructor C */
f9426a
+{
f9426a
+   x = 3; /* First line ~C */
f9426a
+}
f9426a
+
f9426a
+D::D()
f9426a
+{
f9426a
+   y = 2; /* First line D */
f9426a
+}
f9426a
Index: gdb-7.4.50.20111219/gdb/testsuite/gdb.cp/constructortest.exp
f9426a
===================================================================
f9426a
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
f9426a
+++ gdb-7.4.50.20111219/gdb/testsuite/gdb.cp/constructortest.exp	2011-12-19 23:07:24.148290893 +0100
f9426a
@@ -0,0 +1,130 @@
f9426a
+# This testcase is part of GDB, the GNU debugger.
f9426a
+
f9426a
+# Copyright 2005, 2007 Free Software Foundation, Inc.
f9426a
+
f9426a
+# This program is free software; you can redistribute it and/or modify
f9426a
+# it under the terms of the GNU General Public License as published by
f9426a
+# the Free Software Foundation; either version 2 of the License, or
f9426a
+# (at your option) any later version.
f9426a
+#
f9426a
+# This program is distributed in the hope that it will be useful,
f9426a
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
f9426a
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f9426a
+# GNU General Public License for more details.
f9426a
+#
f9426a
+# You should have received a copy of the GNU General Public License
f9426a
+# along with this program; if not, write to the Free Software
f9426a
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
f9426a
+
f9426a
+# Check that GDB can break at multiple forms of constructors.
f9426a
+
f9426a
+set testfile "constructortest"
f9426a
+set srcfile ${testfile}.cc
f9426a
+set binfile ${objdir}/${subdir}/${testfile}
f9426a
+# PIE is required for testing proper BREAKPOINT_RE_SET of the multiple-PC
f9426a
+# breakpoints.
f9426a
+if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ "additional_flags=-fpie -pie"}] != "" } {
f9426a
+    return -1
f9426a
+}
f9426a
+
f9426a
+gdb_exit
f9426a
+gdb_start
f9426a
+gdb_reinitialize_dir $srcdir/$subdir
f9426a
+gdb_load ${binfile}
f9426a
+
f9426a
+#
f9426a
+# Run to `main' where we begin our tests.
f9426a
+#
f9426a
+
f9426a
+if ![runto_main] then {
f9426a
+    gdb_suppress_tests
f9426a
+}
f9426a
+
f9426a
+# Break on the various forms of the A::A constructor.
f9426a
+# " (2 locations)" is displayed depending on G++ version.
f9426a
+gdb_test "break A\:\:A" "Breakpoint 2 at .*" "breaking on A::A"
f9426a
+        
f9426a
+# Verify that we break for the A constructor two times
f9426a
+# Once for new A and once for new B
f9426a
+gdb_continue_to_breakpoint "First line A"
f9426a
+gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::A"
f9426a
+gdb_continue_to_breakpoint "First line A"
f9426a
+gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::A"
f9426a
+
f9426a
+# Now do the same for destructors
f9426a
+gdb_test "break 'A::~A()'" ""
f9426a
+
f9426a
+# Verify that we break for the A destructor two times
f9426a
+# Once for delete a and once for delete b
f9426a
+gdb_continue_to_breakpoint "First line ~A"
f9426a
+gdb_test "bt" "#0.*~A.*#1.*main.*" "Verify in in-charge A::~A"
f9426a
+gdb_continue_to_breakpoint "First line ~A"
f9426a
+gdb_test "bt" "#0.*~A.*#1.*~B.*#2.*main.*" "Verify in not-in-charge A::~A"
f9426a
+
f9426a
+
f9426a
+# Verify that we can break by line number in a constructor and find
f9426a
+# both occurrences
f9426a
+runto_main
f9426a
+gdb_test "break 'A::A()'" "" "break in constructor A 2"
f9426a
+gdb_continue_to_breakpoint "First line A"
f9426a
+set second_line [gdb_get_line_number "Second line A"]
f9426a
+# " (2 locations)" is displayed depending on G++ version.
f9426a
+gdb_test "break $second_line" "Breakpoint .*, line $second_line\\..*" "break by line in constructor"
f9426a
+gdb_continue_to_breakpoint "Second line A"
f9426a
+gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::A second line"
f9426a
+gdb_continue_to_breakpoint "Second line A"
f9426a
+gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::A second line"
f9426a
+
f9426a
+# Verify that we can break by line number in a destructor and find
f9426a
+# both occurrences
f9426a
+gdb_test "break 'A::~A()'" "" "break in constructor ~A 2"
f9426a
+gdb_continue_to_breakpoint "First line ~A"
f9426a
+set second_line_dtor [gdb_get_line_number "Second line ~A"]
f9426a
+# " (2 locations)" is displayed depending on G++ version.
f9426a
+gdb_test "break $second_line_dtor" "Breakpoint .*, line $second_line_dtor\\..*" "break by line in destructor"
f9426a
+gdb_continue_to_breakpoint "Second line ~A"
f9426a
+gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::~A second line"
f9426a
+# FIXME: Analyse this case better.
f9426a
+gdb_continue_to_breakpoint "Second line ~A"
f9426a
+gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in A::~A second line #2"
f9426a
+gdb_continue_to_breakpoint "Second line ~A"
f9426a
+gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::~A second line"
f9426a
+
f9426a
+
f9426a
+# Test now the $delete destructors.
f9426a
+
f9426a
+gdb_load ${binfile}
f9426a
+runto_main
f9426a
+
f9426a
+set first_line_dtor [gdb_get_line_number "First line ~C"]
f9426a
+set define_line_dtor [gdb_get_line_number "Destructor C"]
f9426a
+# Break on the various forms of the C::~C destructor
f9426a
+# " ([23] locations)" is displayed depending on G++ version.
f9426a
+gdb_test "break C\:\:~C" "Breakpoint .*: C::~C\\. \\(2 locations\\)" "breaking on C::~C"
f9426a
+gdb_continue_to_breakpoint "First line ~C"
f9426a
+
f9426a
+# Verify that we can break by line number in a destructor and find
f9426a
+# the $delete occurence
f9426a
+
f9426a
+gdb_load ${binfile}
f9426a
+delete_breakpoints
f9426a
+
f9426a
+# " (3 locations)" is displayed depending on G++ version.
f9426a
+gdb_test "break $first_line_dtor" "Breakpoint .*, line $first_line_dtor\\..*" "break by line in destructor"
f9426a
+
f9426a
+# Run to `main' where we begin our tests.
f9426a
+# Set the breakpoints first to test PIE multiple-PC BREAKPOINT_RE_SET.
f9426a
+# RUNTO_MAIN or RUNTO MAIN are not usable here as it runs DELETE_BREAKPOINTS.
f9426a
+
f9426a
+if ![gdb_breakpoint main] {
f9426a
+    gdb_suppress_tests
f9426a
+}
f9426a
+gdb_run_cmd
f9426a
+set test "running to main"
f9426a
+gdb_test_multiple "" $test {
f9426a
+    -re "Breakpoint \[0-9\]*, main .*$gdb_prompt $" {
f9426a
+	pass $test
f9426a
+    }
f9426a
+}
f9426a
+
f9426a
+gdb_continue_to_breakpoint "First line ~C"