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

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