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

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