]>
Commit | Line | Data |
---|---|---|
3a58abaf AM |
1 | Index: gdb/testsuite/ChangeLog |
2 | 2005-01-21 Jeff Johnston <jjohnstn@redhat.com> | |
3 | ||
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. | |
7 | ||
8 | 2007-09-22 Jan Kratochvil <jan.kratochvil@redhat.com> | |
9 | ||
10 | * gdb.cp/constructortest.exp, gdb.cp/constructortest.cc: Test also the | |
11 | `$delete' destructor variant. | |
12 | ||
13 | 2007-09-25 Jan Kratochvil <jan.kratochvil@redhat.com> | |
14 | ||
15 | * gdb.cp/constructortest.exp: Delete the FIXME workaround of restarting | |
16 | the whole GDB. | |
17 | ||
18 | 2007-10-05 Jan Kratochvil <jan.kratochvil@redhat.com> | |
19 | ||
20 | * gdb.cp/constructortest.exp: Test BREAKPOINT_RE_SET for multiple PCs | |
21 | by PIE. | |
22 | * gdb.cp/constructortest.exp: Handle the change of settings breakpoints | |
23 | always at all the ctor/dtor variants. | |
24 | ||
25 | [ Removed the `gdb.cp/templates.exp' patch. ] | |
26 | [ Updated the patch for "(X location") of GDB-6.8+. ] | |
27 | ||
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 | |
30 | @@ -0,0 +1,99 @@ | |
31 | +/* This testcase is part of GDB, the GNU debugger. | |
32 | + | |
33 | + Copyright 2005 Free Software Foundation, Inc. | |
34 | + | |
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. | |
39 | + | |
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. | |
44 | + | |
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. */ | |
49 | + | |
50 | +class A | |
51 | +{ | |
52 | + public: | |
53 | + A(); | |
54 | + ~A(); | |
55 | + int k; | |
56 | + private: | |
57 | + int x; | |
58 | +}; | |
59 | + | |
60 | +class B: public A | |
61 | +{ | |
62 | + public: | |
63 | + B(); | |
64 | + private: | |
65 | + int y; | |
66 | +}; | |
67 | + | |
68 | +/* C and D are for the $delete destructor. */ | |
69 | + | |
70 | +class C | |
71 | +{ | |
72 | + public: | |
73 | + C(); | |
74 | + virtual ~C(); | |
75 | + private: | |
76 | + int x; | |
77 | +}; | |
78 | + | |
79 | +class D: public C | |
80 | +{ | |
81 | + public: | |
82 | + D(); | |
83 | + private: | |
84 | + int y; | |
85 | +}; | |
86 | + | |
87 | +int main(int argc, char *argv[]) | |
88 | +{ | |
89 | + A* a = new A; | |
90 | + B* b = new B; | |
91 | + D* d = new D; | |
92 | + delete a; | |
93 | + delete b; | |
94 | + delete d; | |
95 | + return 0; | |
96 | +} | |
97 | + | |
98 | +A::A() /* Constructor A */ | |
99 | +{ | |
100 | + x = 1; /* First line A */ | |
101 | + k = 4; /* Second line A */ | |
102 | +} | |
103 | + | |
104 | +A::~A() /* Destructor A */ | |
105 | +{ | |
106 | + x = 3; /* First line ~A */ | |
107 | + k = 6; /* Second line ~A */ | |
108 | +} | |
109 | + | |
110 | +B::B() | |
111 | +{ | |
112 | + y = 2; /* First line B */ | |
113 | + k = 5; | |
114 | +} | |
115 | + | |
116 | +C::C() /* Constructor C */ | |
117 | +{ | |
118 | + x = 1; /* First line C */ | |
119 | +} | |
120 | + | |
121 | +C::~C() /* Destructor C */ | |
122 | +{ | |
123 | + x = 3; /* First line ~C */ | |
124 | +} | |
125 | + | |
126 | +D::D() | |
127 | +{ | |
128 | + y = 2; /* First line D */ | |
129 | +} | |
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 | |
132 | @@ -0,0 +1,131 @@ | |
133 | +# This testcase is part of GDB, the GNU debugger. | |
134 | + | |
135 | +# Copyright 2005, 2007 Free Software Foundation, Inc. | |
136 | + | |
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. | |
141 | +# | |
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. | |
146 | +# | |
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. | |
150 | + | |
151 | +# Check that GDB can break at multiple forms of constructors. | |
152 | + | |
153 | +if $tracelevel { | |
154 | + strace $tracelevel | |
155 | +} | |
156 | + | |
157 | +set prms_id 0 | |
158 | +set bug_id 0 | |
159 | + | |
160 | +set testfile "constructortest" | |
161 | +set srcfile ${testfile}.cc | |
162 | +set binfile ${objdir}/${subdir}/${testfile} | |
163 | +# PIE is required for testing proper BREAKPOINT_RE_SET of the multiple-PC | |
164 | +# breakpoints. | |
165 | +if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ "additional_flags=-fpie -pie"}] != "" } { | |
166 | + return -1 | |
167 | +} | |
168 | + | |
169 | +gdb_exit | |
170 | +gdb_start | |
171 | +gdb_reinitialize_dir $srcdir/$subdir | |
172 | +gdb_load ${binfile} | |
173 | + | |
174 | +# | |
175 | +# Run to `main' where we begin our tests. | |
176 | +# | |
177 | + | |
178 | +if ![runto_main] then { | |
179 | + gdb_suppress_tests | |
180 | +} | |
181 | + | |
182 | +# Break on the various forms of the A::A constructor | |
183 | +gdb_test "break A\:\:A" "Breakpoint 2 at .* \\(2 locations\\)" "breaking on A::A" | |
184 | + | |
185 | +# Verify that we break for the A constructor two times | |
186 | +# Once for new A and once for new B | |
187 | +gdb_continue_to_breakpoint "First line A" | |
188 | +gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::A" | |
189 | +gdb_continue_to_breakpoint "First line A" | |
190 | +gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::A" | |
191 | + | |
192 | +# Now do the same for destructors | |
193 | +gdb_test "break 'A::~A()'" "" | |
194 | + | |
195 | +# Verify that we break for the A destructor two times | |
196 | +# Once for delete a and once for delete b | |
197 | +gdb_continue_to_breakpoint "First line ~A" | |
198 | +gdb_test "bt" "#0.*~A.*#1.*main.*" "Verify in in-charge A::~A" | |
199 | +gdb_continue_to_breakpoint "First line ~A" | |
200 | +gdb_test "bt" "#0.*~A.*#1.*~B.*#2.*main.*" "Verify in not-in-charge A::~A" | |
201 | + | |
202 | + | |
203 | +# Verify that we can break by line number in a constructor and find | |
204 | +# both occurrences | |
205 | +runto_main | |
206 | +gdb_test "break 'A::A()'" "" "break in constructor A 2" | |
207 | +gdb_continue_to_breakpoint "First line A" | |
208 | +set second_line [gdb_get_line_number "Second line A"] | |
209 | +gdb_test "break $second_line" "Breakpoint .*, line $second_line. \\(2 locations\\)" "break by line in constructor" | |
210 | +gdb_continue_to_breakpoint "Second line A" | |
211 | +gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::A second line" | |
212 | +gdb_continue_to_breakpoint "Second line A" | |
213 | +gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::A second line" | |
214 | + | |
215 | +# Verify that we can break by line number in a destructor and find | |
216 | +# both occurrences | |
217 | +gdb_test "break 'A::~A()'" "" "break in constructor ~A 2" | |
218 | +gdb_continue_to_breakpoint "First line ~A" | |
219 | +set second_line_dtor [gdb_get_line_number "Second line ~A"] | |
220 | +gdb_test "break $second_line_dtor" "Breakpoint .*, line $second_line_dtor. \\(2 locations\\)" "break by line in destructor" | |
221 | +gdb_continue_to_breakpoint "Second line ~A" | |
222 | +gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in in-charge A::~A second line" | |
223 | +# FIXME: Analyse this case better. | |
224 | +gdb_continue_to_breakpoint "Second line ~A" | |
225 | +gdb_test "bt" "#0.*A.*#1.*main.*" "Verify in A::~A second line #2" | |
226 | +gdb_continue_to_breakpoint "Second line ~A" | |
227 | +gdb_test "bt" "#0.*A.*#1.*B.*#2.*main.*" "Verify in not-in-charge A::~A second line" | |
228 | + | |
229 | + | |
230 | +# Test now the $delete destructors. | |
231 | + | |
232 | +gdb_load ${binfile} | |
233 | +runto_main | |
234 | + | |
235 | +# Break on the various forms of the C::~C destructor | |
236 | +gdb_test "break C\:\:~C" "Breakpoint .* \\(3 locations\\)" "breaking on C::~C" | |
237 | +gdb_continue_to_breakpoint "First line ~C" | |
238 | + | |
239 | +# Verify that we can break by line number in a destructor and find | |
240 | +# the $delete occurence | |
241 | + | |
242 | +gdb_load ${binfile} | |
243 | +delete_breakpoints | |
244 | + | |
245 | +set first_line_dtor [gdb_get_line_number "First line ~C"] | |
246 | +gdb_test "break $first_line_dtor" "Breakpoint .*, line $first_line_dtor. \\(3 locations\\)" "break by line in destructor" | |
247 | + | |
248 | +# Run to `main' where we begin our tests. | |
249 | +# Set the breakpoints first to test PIE multiple-PC BREAKPOINT_RE_SET. | |
250 | +# RUNTO_MAIN or RUNTO MAIN are not usable here as it runs DELETE_BREAKPOINTS. | |
251 | + | |
252 | +if ![gdb_breakpoint main] { | |
253 | + gdb_suppress_tests | |
254 | +} | |
255 | +gdb_run_cmd | |
256 | +set test "running to main" | |
257 | +gdb_test_multiple "" $test { | |
258 | + -re "Breakpoint \[0-9\]*, main .*$gdb_prompt $" { | |
259 | + pass $test | |
260 | + } | |
261 | +} | |
262 | + | |
263 | +gdb_continue_to_breakpoint "First line ~C" |