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