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