]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-6.3-test-dtorfix-20050121.patch
- rel 7
[packages/gdb.git] / gdb-6.3-test-dtorfix-20050121.patch
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,130 @@
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 +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
157 +# breakpoints.
158 +if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ "additional_flags=-fpie -pie"}] != "" } {
159 +    return -1
160 +}
161 +
162 +gdb_exit
163 +gdb_start
164 +gdb_reinitialize_dir $srcdir/$subdir
165 +gdb_load ${binfile}
166 +
167 +#
168 +# Run to `main' where we begin our tests.
169 +#
170 +
171 +if ![runto_main] then {
172 +    gdb_suppress_tests
173 +}
174 +
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"
178 +        
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"
185 +
186 +# Now do the same for destructors
187 +gdb_test "break 'A::~A()'" ""
188 +
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"
195 +
196 +
197 +# Verify that we can break by line number in a constructor and find
198 +# both occurrences
199 +runto_main
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"
209 +
210 +# Verify that we can break by line number in a destructor and find
211 +# both occurrences
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"
224 +
225 +
226 +# Test now the $delete destructors.
227 +
228 +gdb_load ${binfile}
229 +runto_main
230 +
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"
237 +
238 +# Verify that we can break by line number in a destructor and find
239 +# the $delete occurence
240 +
241 +gdb_load ${binfile}
242 +delete_breakpoints
243 +
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"
246 +
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.
250 +
251 +if ![gdb_breakpoint main] {
252 +    gdb_suppress_tests
253 +}
254 +gdb_run_cmd
255 +set test "running to main"
256 +gdb_test_multiple "" $test {
257 +    -re "Breakpoint \[0-9\]*, main .*$gdb_prompt $" {
258 +       pass $test
259 +    }
260 +}
261 +
262 +gdb_continue_to_breakpoint "First line ~C"
This page took 0.05493 seconds and 3 git commands to generate.