264 lines
7.6 KiB
Diff
264 lines
7.6 KiB
Diff
|
Index: gdb/testsuite/ChangeLog
|
||
|
2005-01-21 Jeff Johnston <jjohnstn@redhat.com>
|
||
|
|
||
|
* gdb.cp/constructortest.exp: New test.
|
||
|
* gdb.cp/constructortest.cc: Ditto.
|
||
|
* gdb.cp/templates.exp: Change break of dtor to be fully quoted.
|
||
|
|
||
|
2007-09-22 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||
|
|
||
|
* gdb.cp/constructortest.exp, gdb.cp/constructortest.cc: Test also the
|
||
|
`$delete' destructor variant.
|
||
|
|
||
|
2007-09-25 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||
|
|
||
|
* gdb.cp/constructortest.exp: Delete the FIXME workaround of restarting
|
||
|
the whole GDB.
|
||
|
|
||
|
2007-10-05 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||
|
|
||
|
* gdb.cp/constructortest.exp: Test BREAKPOINT_RE_SET for multiple PCs
|
||
|
by PIE.
|
||
|
* gdb.cp/constructortest.exp: Handle the change of settings breakpoints
|
||
|
always at all the ctor/dtor variants.
|
||
|
|
||
|
[ Removed the `gdb.cp/templates.exp' patch. ]
|
||
|
[ Updated the patch for "(X location") of GDB-6.8+. ]
|
||
|
|
||
|
--- gdb-6.3/gdb/testsuite/gdb.cp/constructortest.cc.fix Fri Jan 21 17:06:56 2005
|
||
|
+++ gdb-6.3/gdb/testsuite/gdb.cp/constructortest.cc Fri Jan 21 17:05:18 2005
|
||
|
@@ -0,0 +1,99 @@
|
||
|
+/* This testcase is part of GDB, the GNU debugger.
|
||
|
+
|
||
|
+ Copyright 2005 Free Software Foundation, Inc.
|
||
|
+
|
||
|
+ This program is free software; you can redistribute it and/or modify
|
||
|
+ it under the terms of the GNU General Public License as published by
|
||
|
+ the Free Software Foundation; either version 2 of the License, or
|
||
|
+ (at your option) any later version.
|
||
|
+
|
||
|
+ This program is distributed in the hope that it will be useful,
|
||
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
+ GNU General Public License for more details.
|
||
|
+
|
||
|
+ You should have received a copy of the GNU General Public License
|
||
|
+ along with this program; if not, write to the Free Software
|
||
|
+ Foundation, Inc., 59 Temple Place - Suite 330,
|
||
|
+ Boston, MA 02111-1307, USA. */
|
||
|
+
|
||
|
+class A
|
||
|
+{
|
||
|
+ public:
|
||
|
+ A();
|
||
|
+ ~A();
|
||
|
+ int k;
|
||
|
+ private:
|
||
|
+ int x;
|
||
|
+};
|
||
|
+
|
||
|
+class B: public A
|
||
|
+{
|
||
|
+ public:
|
||
|
+ B();
|
||
|
+ private:
|
||
|
+ int y;
|
||
|
+};
|
||
|
+
|
||
|
+/* C and D are for the $delete destructor. */
|
||
|
+
|
||
|
+class C
|
||
|
+{
|
||
|
+ public:
|
||
|
+ C();
|
||
|
+ virtual ~C();
|
||
|
+ private:
|
||
|
+ int x;
|
||
|
+};
|
||
|
+
|
||
|
+class D: public C
|
||
|
+{
|
||
|
+ public:
|
||
|
+ D();
|
||
|
+ private:
|
||
|
+ int y;
|
||
|
+};
|
||
|
+
|
||
|
+int main(int argc, char *argv[])
|
||
|
+{
|
||
|
+ A* a = new A;
|
||
|
+ B* b = new B;
|
||
|
+ D* d = new D;
|
||
|
+ delete a;
|
||
|
+ delete b;
|
||
|
+ delete d;
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+
|
||
|
+A::A() /* Constructor A */
|
||
|
+{
|
||
|
+ x = 1; /* First line A */
|
||
|
+ k = 4; /* Second line A */
|
||
|
+}
|
||
|
+
|
||
|
+A::~A() /* Destructor A */
|
||
|
+{
|
||
|
+ x = 3; /* First line ~A */
|
||
|
+ k = 6; /* Second line ~A */
|
||
|
+}
|
||
|
+
|
||
|
+B::B()
|
||
|
+{
|
||
|
+ y = 2; /* First line B */
|
||
|
+ k = 5;
|
||
|
+}
|
||
|
+
|
||
|
+C::C() /* Constructor C */
|
||
|
+{
|
||
|
+ x = 1; /* First line C */
|
||
|
+}
|
||
|
+
|
||
|
+C::~C() /* Destructor C */
|
||
|
+{
|
||
|
+ x = 3; /* First line ~C */
|
||
|
+}
|
||
|
+
|
||
|
+D::D()
|
||
|
+{
|
||
|
+ y = 2; /* First line D */
|
||
|
+}
|
||
|
--- gdb-6.3/gdb/testsuite/gdb.cp/constructortest.exp.fix Fri Jan 21 17:07:02 2005
|
||
|
+++ gdb-6.3/gdb/testsuite/gdb.cp/constructortest.exp Fri Jan 21 17:05:29 2005
|
||
|
@@ -0,0 +1,131 @@
|
||
|
+# This testcase is part of GDB, the GNU debugger.
|
||
|
+
|
||
|
+# Copyright 2005, 2007 Free Software Foundation, Inc.
|
||
|
+
|
||
|
+# This program is free software; you can redistribute it and/or modify
|
||
|
+# it under the terms of the GNU General Public License as published by
|
||
|
+# the Free Software Foundation; either version 2 of the License, or
|
||
|
+# (at your option) any later version.
|
||
|
+#
|
||
|
+# This program is distributed in the hope that it will be useful,
|
||
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
+# GNU General Public License for more details.
|
||
|
+#
|
||
|
+# You should have received a copy of the GNU General Public License
|
||
|
+# along with this program; if not, write to the Free Software
|
||
|
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||
|
+
|
||
|
+# Check that GDB can break at multiple forms of constructors.
|
||
|
+
|
||
|
+if $tracelevel {
|
||
|
+ strace $tracelevel
|
||
|
+}
|
||
|
+
|
||
|
+set prms_id 0
|
||
|
+set bug_id 0
|
||
|
+
|
||
|
+set testfile "constructortest"
|
||
|
+set srcfile ${testfile}.cc
|
||
|
+set binfile ${objdir}/${subdir}/${testfile}
|
||
|
+# PIE is required for testing proper BREAKPOINT_RE_SET of the multiple-PC
|
||
|
+# breakpoints.
|
||
|
+if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ "additional_flags=-fpie -pie"}] != "" } {
|
||
|
+ return -1
|
||
|
+}
|
||
|
+
|
||
|
+gdb_exit
|
||
|
+gdb_start
|
||
|
+gdb_reinitialize_dir $srcdir/$subdir
|
||
|
+gdb_load ${binfile}
|
||
|
+
|
||
|
+#
|
||
|
+# Run to `main' where we begin our tests.
|
||
|
+#
|
||
|
+
|
||
|
+if ![runto_main] then {
|
||
|
+ gdb_suppress_tests
|
||
|
+}
|
||
|
+
|
||
|
+# Break on the various forms of the A::A constructor
|
||
|
+gdb_test "break A\:\:A" "Breakpoint 2 at .* \\(2 locations\\)" "breaking on A::A"
|
||
|
+
|
||
|
+# Verify that we break for the A constructor two times
|
||
|
+# Once for new A and once for new B
|
||
|
+gdb_continue_to_breakpoint "First line A"
|
||
|
+gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::A"
|
||
|
+gdb_continue_to_breakpoint "First line A"
|
||
|
+gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::A"
|
||
|
+
|
||
|
+# Now do the same for destructors
|
||
|
+gdb_test "break 'A::~A()'" ""
|
||
|
+
|
||
|
+# Verify that we break for the A destructor two times
|
||
|
+# Once for delete a and once for delete b
|
||
|
+gdb_continue_to_breakpoint "First line ~A"
|
||
|
+gdb_test "bt" "#0.*~A.*#1.*main.*" "Verify in in-charge A::~A"
|
||
|
+gdb_continue_to_breakpoint "First line ~A"
|
||
|
+gdb_test "bt" "#0.*~A.*#1.*~B.*#2.*main.*" "Verify in not-in-charge A::~A"
|
||
|
+
|
||
|
+
|
||
|
+# Verify that we can break by line number in a constructor and find
|
||
|
+# both occurrences
|
||
|
+runto_main
|
||
|
+gdb_test "break 'A::A()'" "" "break in constructor A 2"
|
||
|
+gdb_continue_to_breakpoint "First line A"
|
||
|
+set second_line [gdb_get_line_number "Second line A"]
|
||
|
+gdb_test "break $second_line" "Breakpoint .*, line $second_line. \\(2 locations\\)" "break by line in constructor"
|
||
|
+gdb_continue_to_breakpoint "Second line A"
|
||
|
+gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::A second line"
|
||
|
+gdb_continue_to_breakpoint "Second line A"
|
||
|
+gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::A second line"
|
||
|
+
|
||
|
+# Verify that we can break by line number in a destructor and find
|
||
|
+# both occurrences
|
||
|
+gdb_test "break 'A::~A()'" "" "break in constructor ~A 2"
|
||
|
+gdb_continue_to_breakpoint "First line ~A"
|
||
|
+set second_line_dtor [gdb_get_line_number "Second line ~A"]
|
||
|
+gdb_test "break $second_line_dtor" "Breakpoint .*, line $second_line_dtor. \\(2 locations\\)" "break by line in destructor"
|
||
|
+gdb_continue_to_breakpoint "Second line ~A"
|
||
|
+gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::~A second line"
|
||
|
+# FIXME: Analyse this case better.
|
||
|
+gdb_continue_to_breakpoint "Second line ~A"
|
||
|
+gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in A::~A second line #2"
|
||
|
+gdb_continue_to_breakpoint "Second line ~A"
|
||
|
+gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::~A second line"
|
||
|
+
|
||
|
+
|
||
|
+# Test now the $delete destructors.
|
||
|
+
|
||
|
+gdb_load ${binfile}
|
||
|
+runto_main
|
||
|
+
|
||
|
+# Break on the various forms of the C::~C destructor
|
||
|
+gdb_test "break C\:\:~C" "Breakpoint .* \\(3 locations\\)" "breaking on C::~C"
|
||
|
+gdb_continue_to_breakpoint "First line ~C"
|
||
|
+
|
||
|
+# Verify that we can break by line number in a destructor and find
|
||
|
+# the $delete occurence
|
||
|
+
|
||
|
+gdb_load ${binfile}
|
||
|
+delete_breakpoints
|
||
|
+
|
||
|
+set first_line_dtor [gdb_get_line_number "First line ~C"]
|
||
|
+gdb_test "break $first_line_dtor" "Breakpoint .*, line $first_line_dtor. \\(3 locations\\)" "break by line in destructor"
|
||
|
+
|
||
|
+# Run to `main' where we begin our tests.
|
||
|
+# Set the breakpoints first to test PIE multiple-PC BREAKPOINT_RE_SET.
|
||
|
+# RUNTO_MAIN or RUNTO MAIN are not usable here as it runs DELETE_BREAKPOINTS.
|
||
|
+
|
||
|
+if ![gdb_breakpoint main] {
|
||
|
+ gdb_suppress_tests
|
||
|
+}
|
||
|
+gdb_run_cmd
|
||
|
+set test "running to main"
|
||
|
+gdb_test_multiple "" $test {
|
||
|
+ -re "Breakpoint \[0-9\]*, main .*$gdb_prompt $" {
|
||
|
+ pass $test
|
||
|
+ }
|
||
|
+}
|
||
|
+
|
||
|
+gdb_continue_to_breakpoint "First line ~C"
|