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