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

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