Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright 1992-2015 Free Software Foundation, Inc. |
c906108c SS |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
c906108c SS |
8 | # This program is distributed in the hope that it will be useful, |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
e22f8b7c | 12 | # |
c906108c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 15 | |
c906108c | 16 | # This file was written by Fred Fish. (fnf@cygnus.com) |
99f78f56 | 17 | # Adapted for g++ 3.0 ABI by Michael Chastain. (chastain@redhat.com) |
c906108c | 18 | |
d4f3574e | 19 | if { [skip_cplus_tests] } { continue } |
c906108c | 20 | |
f5f3a911 | 21 | standard_testfile .cc |
c906108c | 22 | |
4c93b1db | 23 | if { [get_compiler_info "c++"] } { |
a0b3c4fd JM |
24 | return -1 |
25 | } | |
26 | ||
f5f3a911 TT |
27 | if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { |
28 | return -1 | |
d4f3574e SS |
29 | } |
30 | ||
c906108c | 31 | # |
99f78f56 MC |
32 | # g++ changed its ABI between 2.95 and 3.0. gdb has two demanglers |
33 | # for the two different styles. The two demanglers have some subtle | |
34 | # discrepancies in their output. | |
35 | # | |
36 | # old demangler new demangler | |
37 | # --- --------- --- --------- | |
38 | # "operator, " "operator," | |
39 | # "char *" "char*" | |
40 | # "int *" "int*" | |
41 | # "long *" "long*" | |
42 | # "void *" "void*" | |
43 | # "foo &" "foo&" | |
44 | # "unsigned int" "unsigned" | |
45 | # "void" "" | |
46 | # | |
47 | # I probe for the forms in use. | |
48 | # The defaults are for the v3 demangler (as of 2001-02-13). | |
c906108c SS |
49 | # |
50 | ||
99f78f56 MC |
51 | set dm_operator_comma "," |
52 | set dm_type_char_star "char*" | |
3f08ced9 | 53 | set dm_type_char_star_quoted "char\\*" |
99f78f56 MC |
54 | set dm_type_foo_ref "foo&" |
55 | set dm_type_int_star "int*" | |
56 | set dm_type_long_star "long*" | |
57 | set dm_type_unsigned_int "unsigned" | |
a4216f37 | 58 | set dm_type_void "void" |
99f78f56 MC |
59 | set dm_type_void_star "void*" |
60 | ||
cec808ec KS |
61 | # Some other vagaries of GDB's type printing machinery. The integer types |
62 | # may have unsigned before or after their length, and may have "int" | |
63 | # appended. The char* conversion operator may have name "char*" even if | |
64 | # the type is "char *", because the name comes from the debug information | |
65 | # and the type from GDB. Function types may not see through typedefs. | |
66 | ||
67 | set dm_type_short "short" | |
68 | set dm_type_long "long" | |
69 | set dm_type_unsigned_short "unsigned short" | |
70 | set dm_type_unsigned_long "unsigned long" | |
71 | set dm_operator_char_star "char*" | |
72 | set dm_operator_char_star_quoted "char\\*" | |
73 | set dm_type_typedef 0 | |
74 | ||
99f78f56 | 75 | proc probe_demangler { } { |
c906108c | 76 | global gdb_prompt |
99f78f56 | 77 | global dm_operator_comma |
cec808ec KS |
78 | global dm_operator_char_star |
79 | global dm_operator_char_star_quoted | |
99f78f56 | 80 | global dm_type_char_star |
3f08ced9 | 81 | global dm_type_char_star_quoted |
99f78f56 MC |
82 | global dm_type_foo_ref |
83 | global dm_type_int_star | |
84 | global dm_type_long_star | |
85 | global dm_type_unsigned_int | |
86 | global dm_type_void | |
87 | global dm_type_void_star | |
cec808ec KS |
88 | global dm_type_short |
89 | global dm_type_unsigned_short | |
90 | global dm_type_long | |
91 | global dm_type_unsigned_long | |
92 | global dm_type_typedef | |
99f78f56 | 93 | |
f8d3bf8f MS |
94 | gdb_test_multiple "print &foo::operator,(foo&)" \ |
95 | "detect dm_operator_comma" { | |
96 | -re ".*foo::operator, \\(.*foo.*&.*\\).*\r\n$gdb_prompt $" { | |
97 | # v2 demangler | |
98 | set dm_operator_comma ", " | |
99 | pass "detect dm_operator_comma" | |
100 | } | |
101 | -re ".*foo::operator,\\(.*foo.*&.*\\).*\r\n$gdb_prompt $" { | |
102 | # v3 demangler | |
103 | pass "detect dm_operator_comma" | |
104 | } | |
105 | } | |
106 | ||
107 | gdb_test_multiple "print &foo::operator char*($dm_type_void)" \ | |
108 | "detect dm_operator_char_star" { | |
109 | -re ".*foo::operator char \\*\\(void\\).*\r\n$gdb_prompt $" { | |
110 | # v2 demangler or GDB type printer | |
111 | set dm_operator_char_star "char *" | |
112 | set dm_operator_char_star_quoted "char \\*" | |
113 | pass "detect dm_operator_char_star" | |
114 | } | |
115 | -re ".*foo::operator char\\*\\(\\).*\r\n$gdb_prompt $" { | |
116 | # v3 demangler | |
117 | pass "detect dm_operator_char_star" | |
118 | } | |
119 | } | |
120 | ||
121 | gdb_test_multiple "print &dm_type_char_star" \ | |
122 | "detect dm_type_char_star" { | |
123 | -re ".*dm_type_char_star\\(char \\*\\).*\r\n$gdb_prompt $" { | |
124 | # v2 demangler | |
125 | set dm_type_char_star "char *" | |
126 | set dm_type_char_star_quoted "char \\*" | |
127 | pass "detect dm_type_char_star" | |
128 | } | |
129 | -re ".*dm_type_char_star\\(char\\*\\).*\r\n$gdb_prompt $" { | |
130 | # v3 demangler | |
131 | pass "detect dm_type_char_star" | |
132 | } | |
133 | } | |
134 | ||
135 | gdb_test_multiple "print &dm_type_foo_ref" \ | |
136 | "detect dm_type_foo_ref" { | |
137 | -re ".*dm_type_foo_ref\\(foo &\\).*\r\n$gdb_prompt $" { | |
138 | # v2 demangler | |
139 | set dm_type_foo_ref "foo &" | |
140 | pass "detect dm_type_foo_ref" | |
141 | } | |
142 | -re ".*dm_type_foo_ref\\(foo&\\).*\r\n$gdb_prompt $" { | |
143 | # v3 demangler | |
144 | pass "detect dm_type_foo_ref" | |
145 | } | |
146 | } | |
147 | ||
148 | gdb_test_multiple "print &dm_type_int_star" \ | |
149 | "detect dm_type_int_star" { | |
150 | -re ".*dm_type_int_star\\(int \\*\\).*\r\n$gdb_prompt $" { | |
151 | # v2 demangler | |
152 | set dm_type_int_star "int *" | |
153 | pass "detect dm_type_int_star" | |
154 | } | |
155 | -re ".*dm_type_int_star\\(int\\*\\).*\r\n$gdb_prompt $" { | |
156 | # v3 demangler | |
157 | pass "detect dm_type_int_star" | |
158 | } | |
159 | } | |
160 | ||
161 | gdb_test_multiple "print &dm_type_long_star" \ | |
162 | "detect dm_type_long_star" { | |
163 | -re ".*dm_type_long_star\\(long \\*\\).*\r\n$gdb_prompt $" { | |
164 | # v2 demangler | |
165 | set dm_type_long_star "long *" | |
166 | pass "detect dm_type_long_star" | |
167 | } | |
168 | -re ".*dm_type_long_star\\(long\\*\\).*\r\n$gdb_prompt $" { | |
169 | # v3 demangler | |
170 | pass "detect dm_type_long_star" | |
171 | } | |
172 | -re ".*dm_type_long_star\\(long int \\*\\).*\r\n$gdb_prompt $" { | |
173 | # GCC v3 and GDB's type printer | |
174 | set dm_type_long_star "long int *" | |
175 | pass "detect dm_type_long_star" | |
176 | } | |
177 | } | |
178 | ||
179 | gdb_test_multiple "print &dm_type_unsigned_int" \ | |
180 | "detect dm_type_unsigned_int" { | |
181 | -re ".*dm_type_unsigned_int\\(unsigned int\\).*\r\n$gdb_prompt $" { | |
182 | # v2 demangler | |
183 | set dm_type_unsigned_int "unsigned int" | |
184 | pass "detect dm_type_unsigned_int" | |
185 | } | |
186 | -re ".*dm_type_unsigned_int\\(unsigned\\).*\r\n$gdb_prompt $" { | |
187 | # v3 demangler | |
188 | pass "detect dm_type_unsigned_int" | |
189 | } | |
190 | } | |
191 | ||
192 | gdb_test_multiple "print &dm_type_void" \ | |
193 | "detect dm_type_void" { | |
194 | -re ".*dm_type_void\\(void\\).*\r\n$gdb_prompt $" { | |
195 | # v2 demangler | |
196 | set dm_type_void "void" | |
197 | pass "detect dm_type_void" | |
198 | } | |
199 | -re ".*dm_type_void\\(\\).*\r\n$gdb_prompt $" { | |
200 | # v3 demangler | |
201 | pass "detect dm_type_void" | |
202 | } | |
203 | } | |
204 | ||
205 | gdb_test_multiple "print &dm_type_void_star" \ | |
206 | "detect dm_type_void_star" { | |
207 | -re ".*dm_type_void_star\\(void \\*\\).*\r\n$gdb_prompt $" { | |
208 | # v2 demangler | |
209 | set dm_type_void_star "void *" | |
210 | pass "detect dm_type_void_star" | |
211 | } | |
212 | -re ".*dm_type_void_star\\(void\\*\\).*\r\n$gdb_prompt $" { | |
213 | # v3 demangler | |
214 | pass "detect dm_type_void_star" | |
215 | } | |
216 | } | |
217 | ||
218 | gdb_test_multiple "print &dm_type_short" \ | |
219 | "detect dm_type_short" { | |
220 | -re ".*dm_type_short\\(short\\).*\r\n$gdb_prompt $" { | |
221 | # v2 and v3 demanglers | |
222 | pass "detect dm_type_short" | |
223 | } | |
224 | -re ".*dm_type_short\\(short int\\).*\r\n$gdb_prompt $" { | |
225 | # GDB type printer | |
226 | set dm_type_short "short int" | |
227 | pass "detect dm_type_short" | |
228 | } | |
229 | } | |
230 | ||
231 | gdb_test_multiple "print &dm_type_unsigned_short" \ | |
232 | "detect dm_type_unsigned_short" { | |
233 | -re ".*dm_type_unsigned_short\\(unsigned short\\).*\r\n$gdb_prompt $" { | |
234 | # v2 and v3 demanglers | |
235 | pass "detect dm_type_unsigned_short" | |
236 | } | |
237 | -re ".*dm_type_unsigned_short\\(short unsigned int\\).*\r\n$gdb_prompt $" { | |
238 | # GDB type printer | |
239 | set dm_type_unsigned_short "short unsigned int" | |
240 | pass "detect dm_type_unsigned_short" | |
241 | } | |
242 | } | |
243 | ||
244 | gdb_test_multiple "print &dm_type_long" \ | |
245 | "detect dm_type_long" { | |
246 | -re ".*dm_type_long\\(long\\).*\r\n$gdb_prompt $" { | |
247 | # v2 and v3 demanglers | |
248 | pass "detect dm_type_long" | |
249 | } | |
250 | -re ".*dm_type_long\\(long int\\).*\r\n$gdb_prompt $" { | |
251 | # GDB type printer | |
252 | set dm_type_long "long int" | |
253 | pass "detect dm_type_long" | |
254 | } | |
255 | } | |
256 | ||
257 | gdb_test_multiple "print &dm_type_unsigned_long" \ | |
258 | "detect dm_type_unsigned_long" { | |
259 | -re ".*dm_type_unsigned_long\\(unsigned long\\).*\r\n$gdb_prompt $" { | |
260 | # v2 and v3 demanglers | |
261 | pass "detect dm_type_unsigned_long" | |
262 | } | |
263 | -re ".*dm_type_unsigned_long\\(long unsigned int\\).*\r\n$gdb_prompt $" { | |
264 | # GDB type printer | |
265 | set dm_type_unsigned_long "long unsigned int" | |
266 | pass "detect dm_type_unsigned_long" | |
267 | } | |
268 | } | |
269 | ||
270 | gdb_test_multiple "print &dm_type_typedef" \ | |
271 | "detect dm_type_typedef" { | |
272 | -re ".*dm_type_typedef\\(int\\).*\r\n$gdb_prompt $" { | |
273 | # v2 and v3 demanglers | |
274 | pass "detect dm_type_typedef" | |
275 | } | |
276 | -re ".*dm_type_typedef\\(myint\\).*\r\n$gdb_prompt $" { | |
277 | # GDB type printer | |
278 | set dm_type_typedef 1 | |
279 | pass "detect dm_type_typedef" | |
280 | } | |
99f78f56 | 281 | } |
99f78f56 MC |
282 | } |
283 | ||
284 | # | |
285 | # Lookup a specific C++ function and print the demangled type. | |
286 | # This form accepts the demangled type as a regexp. | |
287 | # | |
288 | ||
289 | proc info_func_regexp { name demangled } { | |
290 | global gdb_prompt | |
291 | ||
8c2fb5de | 292 | regsub {\\\(void\\\)} $demangled {\(\)} demangled |
f8d3bf8f MS |
293 | |
294 | gdb_test "info function $name" \ | |
295 | "File .*:\r\n(class|)${demangled}.*" \ | |
296 | "info function for \"$name\"" | |
c906108c SS |
297 | } |
298 | ||
299 | # | |
99f78f56 MC |
300 | # Lookup a specific C++ function and print the demangled type. |
301 | # This form accepts the demangled type as a literal string. | |
c906108c SS |
302 | # |
303 | ||
99f78f56 MC |
304 | proc info_func { name demangled } { |
305 | info_func_regexp "$name" [string_to_regexp "$demangled"] | |
306 | } | |
307 | ||
308 | # | |
309 | # Print the address of a function. | |
310 | # This checks that I can lookup a fully qualified C++ function. | |
311 | # This also checks the argument types on the return string. | |
d2b29e01 DC |
312 | |
313 | # Note: carlton/2003-01-16: If you modify this, make a corresponding | |
314 | # modification to print_addr_2_kfail. | |
99f78f56 MC |
315 | |
316 | proc print_addr_2 { name good } { | |
c906108c SS |
317 | global gdb_prompt |
318 | global hex | |
319 | ||
99f78f56 MC |
320 | set good_pattern [string_to_regexp $good] |
321 | ||
f8d3bf8f MS |
322 | gdb_test "print &$name" \ |
323 | ".* = .* $hex <$good_pattern>" | |
c906108c SS |
324 | } |
325 | ||
d2b29e01 DC |
326 | # NOTE: carlton/2003-01-16: hairyfunc5-6 fail on GCC 3.x (for at least |
327 | # x=1 and x=2.1). So I'm modifying print_addr_2 to accept a failure | |
328 | # condition. FIXME: It would be nice if the failure condition were | |
329 | # conditional on the compiler version, but I'm not sufficiently | |
330 | # motivated. I did hardwire in the versions of char * and int *, | |
331 | # which will give some compiler-specificity to the failure. | |
332 | ||
333 | proc print_addr_2_kfail { name good bad bugid } { | |
334 | global gdb_prompt | |
335 | global hex | |
336 | ||
337 | set good_pattern [string_to_regexp $good] | |
338 | set bad_pattern [string_to_regexp $bad] | |
339 | ||
f8d3bf8f | 340 | gdb_test_multiple "print &$name" "print &$name" { |
d2b29e01 | 341 | -re ".* = .* $hex <$good_pattern>\r\n$gdb_prompt $" { |
a4216f37 | 342 | pass "print &$name" |
d2b29e01 DC |
343 | } |
344 | -re ".* = .* $hex <$bad_pattern>\r\n$gdb_prompt $" { | |
a4216f37 | 345 | kfail $bugid "print &$name" |
d2b29e01 | 346 | } |
d2b29e01 DC |
347 | } |
348 | } | |
349 | ||
99f78f56 MC |
350 | # |
351 | # Simple interfaces to print_addr_2. | |
352 | # | |
353 | ||
354 | proc print_addr { name } { | |
8c2fb5de | 355 | regsub {\(void\)} $name {()} expected |
a4216f37 KS |
356 | if {[string first "::" $name] == -1} { |
357 | # C function -- must be qutoed | |
358 | set name "'$name'" | |
359 | } | |
360 | print_addr_2 "$name" $expected | |
99f78f56 MC |
361 | } |
362 | ||
c906108c SS |
363 | # |
364 | # Test name demangling for operators. | |
365 | # | |
366 | # The '(' at the end of each regex input pattern is so that we match only | |
367 | # the one we are looking for. I.E. "operator&" would match both | |
368 | # "operator&(foo &)" and "operator&&(foo &)". | |
369 | # | |
99f78f56 MC |
370 | # gdb-gnats bug gdb/18: |
371 | # "gdb can't parse "info func operator*" or "info func operator\*". | |
372 | # The star in "operator*" is interpreted as a regexp, but the "\*" | |
373 | # in "operator\*" is not a legal operator. | |
374 | # | |
c906108c SS |
375 | |
376 | proc test_lookup_operator_functions {} { | |
99f78f56 | 377 | global dm_operator_comma |
cec808ec | 378 | global dm_operator_char_star |
99f78f56 | 379 | global dm_type_char_star |
cec808ec | 380 | global dm_operator_char_star_quoted |
99f78f56 MC |
381 | global dm_type_foo_ref |
382 | global dm_type_void | |
383 | global dm_type_void_star | |
c906108c | 384 | |
3f08ced9 MS |
385 | # operator* requires quoting so that GDB does not treat it as a regexp. |
386 | info_func "operator\\*(" "void foo::operator*($dm_type_foo_ref);" | |
99f78f56 MC |
387 | info_func "operator%(" "void foo::operator%($dm_type_foo_ref);" |
388 | info_func "operator-(" "void foo::operator-($dm_type_foo_ref);" | |
389 | info_func "operator>>(" "void foo::operator>>($dm_type_foo_ref);" | |
390 | info_func "operator!=(" "void foo::operator!=($dm_type_foo_ref);" | |
391 | info_func "operator>(" "void foo::operator>($dm_type_foo_ref);" | |
392 | info_func "operator>=(" "void foo::operator>=($dm_type_foo_ref);" | |
393 | info_func "operator|(" "void foo::operator|($dm_type_foo_ref);" | |
394 | info_func "operator&&(" "void foo::operator&&($dm_type_foo_ref);" | |
395 | info_func "operator!(" "void foo::operator!($dm_type_void);" | |
396 | info_func "operator++(" "void foo::operator++(int);" | |
397 | info_func "operator=(" "void foo::operator=($dm_type_foo_ref);" | |
398 | info_func "operator+=(" "void foo::operator+=($dm_type_foo_ref);" | |
3f08ced9 MS |
399 | # operator*= requires quoting so that GDB does not treat it as a regexp. |
400 | info_func "operator\\*=(" "void foo::operator*=($dm_type_foo_ref);" | |
99f78f56 MC |
401 | info_func "operator%=(" "void foo::operator%=($dm_type_foo_ref);" |
402 | info_func "operator>>=(" "void foo::operator>>=($dm_type_foo_ref);" | |
403 | info_func "operator|=(" "void foo::operator|=($dm_type_foo_ref);" | |
404 | info_func "operator$dm_operator_comma\(" \ | |
405 | "void foo::operator$dm_operator_comma\($dm_type_foo_ref);" | |
406 | info_func "operator/(" "void foo::operator/($dm_type_foo_ref);" | |
407 | info_func "operator+(" "void foo::operator+($dm_type_foo_ref);" | |
408 | info_func "operator<<(" "void foo::operator<<($dm_type_foo_ref);" | |
409 | info_func "operator==(" "void foo::operator==($dm_type_foo_ref);" | |
410 | info_func "operator<(" "void foo::operator<($dm_type_foo_ref);" | |
411 | info_func "operator<=(" "void foo::operator<=($dm_type_foo_ref);" | |
412 | info_func "operator&(" "void foo::operator&($dm_type_foo_ref);" | |
413 | info_func "operator^(" "void foo::operator^($dm_type_foo_ref);" | |
414 | info_func "operator||(" "void foo::operator||($dm_type_foo_ref);" | |
415 | info_func "operator~(" "void foo::operator~($dm_type_void);" | |
416 | info_func "operator--(" "void foo::operator--(int);" | |
417 | info_func "operator->(" "foo *foo::operator->($dm_type_void);" | |
418 | info_func "operator-=(" "void foo::operator-=($dm_type_foo_ref);" | |
419 | info_func "operator/=(" "void foo::operator/=($dm_type_foo_ref);" | |
420 | info_func "operator<<=(" "void foo::operator<<=($dm_type_foo_ref);" | |
421 | info_func "operator&=(" "void foo::operator&=($dm_type_foo_ref);" | |
422 | info_func "operator^=(" "void foo::operator^=($dm_type_foo_ref);" | |
3f08ced9 MS |
423 | # operator->* requires quoting so that GDB does not treat it as a regexp. |
424 | info_func "operator->\\*(" "void foo::operator->*($dm_type_foo_ref);" | |
99f78f56 | 425 | |
3f08ced9 MS |
426 | # operator[] needs double backslashes, so that a single backslash |
427 | # will be sent to GDB, preventing the square brackets from being | |
428 | # evaluated as a regular expression. | |
429 | info_func "operator\\\[\\\](" "void foo::operator\[\]($dm_type_foo_ref);" | |
99f78f56 MC |
430 | |
431 | # These are gnarly because they might end with 'static'. | |
432 | set dm_type_void_star_regexp [string_to_regexp $dm_type_void_star] | |
433 | info_func_regexp "operator new(" "void \\*foo::operator new\\(.*\\)(| static);" | |
434 | info_func_regexp "operator delete(" "void foo::operator delete\\($dm_type_void_star_regexp\\)(| static);" | |
435 | ||
436 | info_func "operator int(" "int foo::operator int($dm_type_void);" | |
437 | info_func "operator()(" "void foo::operator()($dm_type_foo_ref);" | |
cec808ec KS |
438 | info_func "operator $dm_operator_char_star_quoted\(" \ |
439 | "char *foo::operator $dm_operator_char_star\($dm_type_void);" | |
99f78f56 | 440 | |
c906108c SS |
441 | } |
442 | ||
443 | ||
444 | proc test_paddr_operator_functions {} { | |
445 | global hex | |
a0b3c4fd | 446 | global hp_aCC_compiler |
99f78f56 MC |
447 | global dm_operator_comma |
448 | global dm_type_char_star | |
449 | global dm_type_foo_ref | |
450 | global dm_type_long_star | |
451 | global dm_type_unsigned_int | |
452 | global dm_type_void | |
453 | global dm_type_void_star | |
cec808ec | 454 | global dm_operator_char_star |
99f78f56 MC |
455 | |
456 | print_addr "foo::operator*($dm_type_foo_ref)" | |
457 | print_addr "foo::operator%($dm_type_foo_ref)" | |
458 | print_addr "foo::operator-($dm_type_foo_ref)" | |
459 | print_addr "foo::operator>>($dm_type_foo_ref)" | |
460 | print_addr "foo::operator!=($dm_type_foo_ref)" | |
461 | print_addr "foo::operator>($dm_type_foo_ref)" | |
462 | print_addr "foo::operator>=($dm_type_foo_ref)" | |
463 | print_addr "foo::operator|($dm_type_foo_ref)" | |
464 | print_addr "foo::operator&&($dm_type_foo_ref)" | |
465 | print_addr "foo::operator!($dm_type_void)" | |
466 | print_addr "foo::operator++(int)" | |
467 | print_addr "foo::operator=($dm_type_foo_ref)" | |
468 | print_addr "foo::operator+=($dm_type_foo_ref)" | |
469 | print_addr "foo::operator*=($dm_type_foo_ref)" | |
470 | print_addr "foo::operator%=($dm_type_foo_ref)" | |
471 | print_addr "foo::operator>>=($dm_type_foo_ref)" | |
472 | print_addr "foo::operator|=($dm_type_foo_ref)" | |
473 | print_addr "foo::operator$dm_operator_comma\($dm_type_foo_ref)" | |
474 | print_addr "foo::operator/($dm_type_foo_ref)" | |
475 | print_addr "foo::operator+($dm_type_foo_ref)" | |
476 | print_addr "foo::operator<<($dm_type_foo_ref)" | |
477 | print_addr "foo::operator==($dm_type_foo_ref)" | |
478 | print_addr "foo::operator<($dm_type_foo_ref)" | |
479 | print_addr "foo::operator<=($dm_type_foo_ref)" | |
480 | print_addr "foo::operator&($dm_type_foo_ref)" | |
481 | print_addr "foo::operator^($dm_type_foo_ref)" | |
482 | print_addr "foo::operator||($dm_type_foo_ref)" | |
483 | print_addr "foo::operator~($dm_type_void)" | |
484 | print_addr "foo::operator--(int)" | |
485 | print_addr "foo::operator->($dm_type_void)" | |
486 | print_addr "foo::operator-=($dm_type_foo_ref)" | |
487 | print_addr "foo::operator/=($dm_type_foo_ref)" | |
488 | print_addr "foo::operator<<=($dm_type_foo_ref)" | |
489 | print_addr "foo::operator&=($dm_type_foo_ref)" | |
490 | print_addr "foo::operator^=($dm_type_foo_ref)" | |
491 | print_addr "foo::operator->*($dm_type_foo_ref)" | |
492 | print_addr "foo::operator\[\]($dm_type_foo_ref)" | |
493 | print_addr "foo::operator()($dm_type_foo_ref)" | |
c906108c | 494 | |
a4216f37 | 495 | gdb_test "print &foo::operator new" \ |
99f78f56 | 496 | " = .* $hex <foo::operator new\\(.*\\)(| static)>" |
a4216f37 KS |
497 | gdb_test "print &foo::operator new\[\]" \ |
498 | " = .* $hex <foo::operator new\\\[\\\]\\(.*\\)(| static)>" | |
a0b3c4fd | 499 | if { !$hp_aCC_compiler } { |
99f78f56 | 500 | print_addr "foo::operator delete($dm_type_void_star)" |
a4216f37 | 501 | print_addr "foo::operator delete[]($dm_type_void_star)" |
a0b3c4fd | 502 | } else { |
99f78f56 | 503 | gdb_test "print &'foo::operator delete($dm_type_void_star) static'" \ |
a0b3c4fd JM |
504 | " = .*(0x\[0-9a-f\]+|) <foo::operator delete.*>" |
505 | } | |
99f78f56 MC |
506 | |
507 | print_addr "foo::operator int($dm_type_void)" | |
cec808ec | 508 | print_addr "foo::operator $dm_operator_char_star\($dm_type_void)" |
c906108c SS |
509 | } |
510 | ||
511 | # | |
512 | # Test overloaded functions (1 arg). | |
513 | # | |
514 | ||
515 | proc test_paddr_overloaded_functions {} { | |
99f78f56 MC |
516 | global dm_type_unsigned_int |
517 | global dm_type_void | |
cec808ec KS |
518 | global dm_type_short |
519 | global dm_type_unsigned_short | |
520 | global dm_type_long | |
521 | global dm_type_unsigned_long | |
99f78f56 MC |
522 | |
523 | print_addr "overload1arg($dm_type_void)" | |
524 | print_addr "overload1arg(char)" | |
525 | print_addr "overload1arg(signed char)" | |
526 | print_addr "overload1arg(unsigned char)" | |
cec808ec KS |
527 | print_addr "overload1arg($dm_type_short)" |
528 | print_addr "overload1arg($dm_type_unsigned_short)" | |
99f78f56 MC |
529 | print_addr "overload1arg(int)" |
530 | print_addr "overload1arg($dm_type_unsigned_int)" | |
cec808ec KS |
531 | print_addr "overload1arg($dm_type_long)" |
532 | print_addr "overload1arg($dm_type_unsigned_long)" | |
99f78f56 MC |
533 | print_addr "overload1arg(float)" |
534 | print_addr "overload1arg(double)" | |
535 | ||
536 | print_addr "overloadargs(int)" | |
537 | print_addr "overloadargs(int, int)" | |
538 | print_addr "overloadargs(int, int, int)" | |
539 | print_addr "overloadargs(int, int, int, int)" | |
540 | print_addr "overloadargs(int, int, int, int, int)" | |
541 | print_addr "overloadargs(int, int, int, int, int, int)" | |
542 | print_addr "overloadargs(int, int, int, int, int, int, int)" | |
543 | print_addr "overloadargs(int, int, int, int, int, int, int, int)" | |
544 | print_addr "overloadargs(int, int, int, int, int, int, int, int, int)" | |
545 | print_addr "overloadargs(int, int, int, int, int, int, int, int, int, int)" | |
546 | print_addr "overloadargs(int, int, int, int, int, int, int, int, int, int, int)" | |
c906108c SS |
547 | } |
548 | ||
549 | proc test_paddr_hairy_functions {} { | |
99f78f56 MC |
550 | global gdb_prompt |
551 | global hex | |
552 | global dm_type_char_star | |
553 | global dm_type_int_star | |
554 | global dm_type_long_star | |
cec808ec | 555 | global dm_type_typedef |
99f78f56 MC |
556 | |
557 | print_addr_2 "hairyfunc1" "hairyfunc1(int)" | |
cec808ec KS |
558 | |
559 | if {$dm_type_typedef == 0} { | |
560 | print_addr_2 "hairyfunc2" "hairyfunc2(int (*)($dm_type_char_star))" | |
561 | print_addr_2 "hairyfunc3" "hairyfunc3(int (*)(short (*)($dm_type_long_star)))" | |
562 | print_addr_2 "hairyfunc4" "hairyfunc4(int (*)(short (*)($dm_type_char_star)))" | |
563 | ||
564 | # gdb-gnats bug gdb/19: | |
565 | # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7" | |
566 | print_addr_2_kfail "hairyfunc5" "hairyfunc5(int (*(*)($dm_type_char_star))(long))" "hairyfunc5(int (*)(long) (*)(char*))" "gdb/19" | |
567 | print_addr_2_kfail "hairyfunc6" "hairyfunc6(int (*(*)($dm_type_int_star))(long))" "hairyfunc6(int (*)(long) (*)(int*))" "gdb/19" | |
568 | print_addr_2_kfail "hairyfunc7" "hairyfunc7(int (*(*)(int (*)($dm_type_char_star)))(long))" "hairyfunc7(int (*)(long) (*)(int (*)(char*)))" "gdb/19" | |
569 | } else { | |
570 | print_addr_2 "hairyfunc2" "hairyfunc2(PFPc_i)" | |
571 | print_addr_2 "hairyfunc3" "hairyfunc3(PFPFPl_s_i)" | |
572 | print_addr_2 "hairyfunc4" "hairyfunc4(PFPFPc_s_i)" | |
573 | ||
574 | # gdb-gnats bug gdb/19: | |
575 | # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7" | |
576 | print_addr_2 "hairyfunc5" "hairyfunc5(PFPc_PFl_i)" | |
577 | print_addr_2 "hairyfunc6" "hairyfunc6(PFPi_PFl_i)" | |
578 | print_addr_2 "hairyfunc7" "hairyfunc7(PFPFPc_i_PFl_i)" | |
579 | } | |
c906108c SS |
580 | } |
581 | ||
582 | proc do_tests {} { | |
c906108c | 583 | global binfile |
11ef0d76 | 584 | global dm_type_int_star |
c906108c | 585 | |
f5f3a911 | 586 | clean_restart $binfile |
c906108c | 587 | |
f8d3bf8f | 588 | gdb_test_no_output "set width 0" |
c906108c | 589 | |
40f235b7 | 590 | runto_main |
c906108c | 591 | |
1cf0e11f | 592 | gdb_test_no_output "set language c++" |
99f78f56 | 593 | probe_demangler |
c906108c SS |
594 | test_paddr_overloaded_functions |
595 | test_paddr_operator_functions | |
596 | test_paddr_hairy_functions | |
597 | test_lookup_operator_functions | |
11ef0d76 KS |
598 | |
599 | # A regression test on errors involving operators | |
600 | gdb_test "list foo::operator $dm_type_int_star" \ | |
dcf9f4ab | 601 | "Function \"foo::operator [string_to_regexp $dm_type_int_star]\" not defined\\." |
c906108c SS |
602 | } |
603 | ||
604 | do_tests |