1 Index: gdb/testsuite/ChangeLog
2 2005-01-21 Jeff Johnston <jjohnstn@redhat.com>
4 * gdb.cp/constructortest.exp: New test.
5 * gdb.cp/constructortest.cc: Ditto.
6 * gdb.cp/templates.exp: Change break of dtor to be fully quoted.
8 2007-09-22 Jan Kratochvil <jan.kratochvil@redhat.com>
10 * gdb.cp/constructortest.exp, gdb.cp/constructortest.cc: Test also the
11 `$delete' destructor variant.
13 2007-09-25 Jan Kratochvil <jan.kratochvil@redhat.com>
15 * gdb.cp/constructortest.exp: Delete the FIXME workaround of restarting
18 2007-10-05 Jan Kratochvil <jan.kratochvil@redhat.com>
20 * gdb.cp/constructortest.exp: Test BREAKPOINT_RE_SET for multiple PCs
22 * gdb.cp/constructortest.exp: Handle the change of settings breakpoints
23 always at all the ctor/dtor variants.
25 [ Removed the `gdb.cp/templates.exp' patch. ]
26 [ Updated the patch for "(X location") of GDB-6.8+. ]
28 --- gdb-6.3/gdb/testsuite/gdb.cp/constructortest.cc.fix Fri Jan 21 17:06:56 2005
29 +++ gdb-6.3/gdb/testsuite/gdb.cp/constructortest.cc Fri Jan 21 17:05:18 2005
31 +/* This testcase is part of GDB, the GNU debugger.
33 + Copyright 2005 Free Software Foundation, Inc.
35 + This program is free software; you can redistribute it and/or modify
36 + it under the terms of the GNU General Public License as published by
37 + the Free Software Foundation; either version 2 of the License, or
38 + (at your option) any later version.
40 + This program is distributed in the hope that it will be useful,
41 + but WITHOUT ANY WARRANTY; without even the implied warranty of
42 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43 + GNU General Public License for more details.
45 + You should have received a copy of the GNU General Public License
46 + along with this program; if not, write to the Free Software
47 + Foundation, Inc., 59 Temple Place - Suite 330,
48 + Boston, MA 02111-1307, USA. */
68 +/* C and D are for the $delete destructor. */
87 +int main(int argc, char *argv[])
98 +A::A() /* Constructor A */
100 + x = 1; /* First line A */
101 + k = 4; /* Second line A */
104 +A::~A() /* Destructor A */
106 + x = 3; /* First line ~A */
107 + k = 6; /* Second line ~A */
112 + y = 2; /* First line B */
116 +C::C() /* Constructor C */
118 + x = 1; /* First line C */
121 +C::~C() /* Destructor C */
123 + x = 3; /* First line ~C */
128 + y = 2; /* First line D */
130 --- gdb-6.3/gdb/testsuite/gdb.cp/constructortest.exp.fix Fri Jan 21 17:07:02 2005
131 +++ gdb-6.3/gdb/testsuite/gdb.cp/constructortest.exp Fri Jan 21 17:05:29 2005
133 +# This testcase is part of GDB, the GNU debugger.
135 +# Copyright 2005, 2007 Free Software Foundation, Inc.
137 +# This program is free software; you can redistribute it and/or modify
138 +# it under the terms of the GNU General Public License as published by
139 +# the Free Software Foundation; either version 2 of the License, or
140 +# (at your option) any later version.
142 +# This program is distributed in the hope that it will be useful,
143 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
144 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
145 +# GNU General Public License for more details.
147 +# You should have received a copy of the GNU General Public License
148 +# along with this program; if not, write to the Free Software
149 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
151 +# Check that GDB can break at multiple forms of constructors.
153 +set testfile "constructortest"
154 +set srcfile ${testfile}.cc
155 +set binfile ${objdir}/${subdir}/${testfile}
156 +# PIE is required for testing proper BREAKPOINT_RE_SET of the multiple-PC
158 +if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ "additional_flags=-fpie -pie"}] != "" } {
164 +gdb_reinitialize_dir $srcdir/$subdir
168 +# Run to `main' where we begin our tests.
171 +if ![runto_main] then {
175 +# Break on the various forms of the A::A constructor.
176 +# " (2 locations)" is displayed depending on G++ version.
177 +gdb_test "break A\:\:A" "Breakpoint 2 at .*" "breaking on A::A"
179 +# Verify that we break for the A constructor two times
180 +# Once for new A and once for new B
181 +gdb_continue_to_breakpoint "First line A"
182 +gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::A"
183 +gdb_continue_to_breakpoint "First line A"
184 +gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::A"
186 +# Now do the same for destructors
187 +gdb_test "break 'A::~A()'" ""
189 +# Verify that we break for the A destructor two times
190 +# Once for delete a and once for delete b
191 +gdb_continue_to_breakpoint "First line ~A"
192 +gdb_test "bt" "#0.*~A.*#1.*main.*" "Verify in in-charge A::~A"
193 +gdb_continue_to_breakpoint "First line ~A"
194 +gdb_test "bt" "#0.*~A.*#1.*~B.*#2.*main.*" "Verify in not-in-charge A::~A"
197 +# Verify that we can break by line number in a constructor and find
200 +gdb_test "break 'A::A()'" "" "break in constructor A 2"
201 +gdb_continue_to_breakpoint "First line A"
202 +set second_line [gdb_get_line_number "Second line A"]
203 +# " (2 locations)" is displayed depending on G++ version.
204 +gdb_test "break $second_line" "Breakpoint .*, line $second_line\\..*" "break by line in constructor"
205 +gdb_continue_to_breakpoint "Second line A"
206 +gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::A second line"
207 +gdb_continue_to_breakpoint "Second line A"
208 +gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::A second line"
210 +# Verify that we can break by line number in a destructor and find
212 +gdb_test "break 'A::~A()'" "" "break in constructor ~A 2"
213 +gdb_continue_to_breakpoint "First line ~A"
214 +set second_line_dtor [gdb_get_line_number "Second line ~A"]
215 +# " (2 locations)" is displayed depending on G++ version.
216 +gdb_test "break $second_line_dtor" "Breakpoint .*, line $second_line_dtor\\..*" "break by line in destructor"
217 +gdb_continue_to_breakpoint "Second line ~A"
218 +gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::~A second line"
219 +# FIXME: Analyse this case better.
220 +gdb_continue_to_breakpoint "Second line ~A"
221 +gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in A::~A second line #2"
222 +gdb_continue_to_breakpoint "Second line ~A"
223 +gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::~A second line"
226 +# Test now the $delete destructors.
231 +set first_line_dtor [gdb_get_line_number "First line ~C"]
232 +set define_line_dtor [gdb_get_line_number "Destructor C"]
233 +# Break on the various forms of the C::~C destructor
234 +# " ([23] locations)" is displayed depending on G++ version.
235 +gdb_test "break C\:\:~C" "Breakpoint .*, line ($define_line_dtor|$define_line_dtor)\\..*" "breaking on C::~C"
236 +gdb_continue_to_breakpoint "First line ~C"
238 +# Verify that we can break by line number in a destructor and find
239 +# the $delete occurence
244 +# " (3 locations)" is displayed depending on G++ version.
245 +gdb_test "break $first_line_dtor" "Breakpoint .*, line $first_line_dtor\\..*" "break by line in destructor"
247 +# Run to `main' where we begin our tests.
248 +# Set the breakpoints first to test PIE multiple-PC BREAKPOINT_RE_SET.
249 +# RUNTO_MAIN or RUNTO MAIN are not usable here as it runs DELETE_BREAKPOINTS.
251 +if ![gdb_breakpoint main] {
255 +set test "running to main"
256 +gdb_test_multiple "" $test {
257 + -re "Breakpoint \[0-9\]*, main .*$gdb_prompt $" {
262 +gdb_continue_to_breakpoint "First line ~C"