gdb/testsuite/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / charset.exp
CommitLineData
0dcd613f
AC
1# This testcase is part of GDB, the GNU debugger.
2
4c38e0a4 3# Copyright 2001, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
dea97812
KB
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
e22f8b7c 7# the Free Software Foundation; either version 3 of the License, or
dea97812 8# (at your option) any later version.
e22f8b7c 9#
dea97812
KB
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
e22f8b7c 14#
dea97812 15# You should have received a copy of the GNU General Public License
e22f8b7c 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
dea97812
KB
17
18# Please email any bugs, comments, and/or additions to this file to:
0dcd613f 19# bug-gdb@gnu.org
dea97812
KB
20
21# Test GDB's character set support.
22
23if $tracelevel then {
24 strace $tracelevel
25}
26
dea97812
KB
27
28set testfile "charset"
29set srcfile ${testfile}.c
51d7d803
JK
30set srcmallocfile ${testfile}-malloc.c
31if { [prepare_for_testing ${testfile}.exp ${testfile} [list $srcfile $srcmallocfile]] } {
f21565d2 32 return -1
dea97812
KB
33}
34
dea97812
KB
35# Parse the output from a `show charset' command. Return the host
36# and target charset as a two-element list.
37proc parse_show_charset_output {testname} {
38 global gdb_prompt
39
40 gdb_expect {
6c7a06a3 41 -re "The host character set is \"(.*)\"\\.\[\r\n\]+The target character set is \"(.*)\"\\.\[\r\n\]+The target wide character set is \"(.*)\"\\.\[\r\n\]+$gdb_prompt $" {
dea97812
KB
42 set host_charset $expect_out(1,string)
43 set target_charset $expect_out(2,string)
e33d66ec
EZ
44 set retlist [list $host_charset $target_charset]
45 pass $testname
46 }
47 -re "The host character set is \"(.*)\"\\.\[\r\n\]+$gdb_prompt $" {
48 set host_charset $expect_out(1,string)
49 set retlist [list $host_charset]
50 pass $testname
51 }
52 -re "The target character set is \"(.*)\"\\.\[\r\n\]+$gdb_prompt $" {
53 set target_charset $expect_out(1,string)
54 set retlist [list $target_charset]
dea97812
KB
55 pass $testname
56 }
57 -re ".*$gdb_prompt $" {
58 fail $testname
59 }
60 timeout {
61 fail "$testname (timeout)"
62 }
63 }
64
e33d66ec 65 return $retlist
dea97812
KB
66}
67
68
6c7a06a3 69# Try the various `show charset' commands.
dea97812
KB
70
71send_gdb "show charset\n"
72set show_charset [parse_show_charset_output "show charset"]
73
74send_gdb "show target-charset\n"
6c7a06a3
TT
75set show_target_charset \
76 [lindex [parse_show_charset_output "show target-charset"] 0]
dea97812 77
6c7a06a3 78if {[lsearch -exact $show_charset $show_target_charset] >= 0} {
dea97812
KB
79 pass "check `show target-charset' against `show charset'"
80} else {
81 fail "check `show target-charset' against `show charset'"
82}
83
84send_gdb "show host-charset\n"
6c7a06a3
TT
85set show_host_charset \
86 [lindex [parse_show_charset_output "show host-charset"] 0]
dea97812 87
6c7a06a3 88if {[lsearch -exact $show_charset $show_host_charset] >= 0} {
dea97812
KB
89 pass "check `show host-charset' against `show charset'"
90} else {
91 fail "check `show host-charset' against `show charset'"
92}
93
e33d66ec
EZ
94# Try a malformed `set charset'.
95gdb_test "set charset" \
96 "Requires an argument. Valid arguments are.*" \
97 "try malformed `set charset'"
98
99# Try using `set host-charset' on an invalid character set.
100gdb_test "set host-charset my_grandma_bonnie" \
101 "Undefined item: \"my_grandma_bonnie\"." \
102 "try `set host-charset' with invalid charset"
dea97812 103
e33d66ec
EZ
104# Try using `set target-charset' on an invalid character set.
105gdb_test "set target-charset my_grandma_bonnie" \
106 "Undefined item: \"my_grandma_bonnie\"." \
107 "try `set target-charset' with invalid charset"
dea97812
KB
108
109# A Tcl array mapping the names of all the character sets we've seen
110# to "1" if the character set can be used as a host character set, or
111# "0" otherwise. We can use `array names charsets' just to get a list
112# of all character sets.
113array set charsets {}
114
115proc all_charset_names {} {
116 global charsets
117 return [array names charsets]
118}
119
dea97812
KB
120proc valid_host_charset {charset} {
121 global charsets
6c7a06a3 122 return [expr {[info exists charsets($charset)] && $charsets($charset)}]
dea97812
KB
123}
124
a8df5de4
TT
125proc valid_target_charset {charset} {
126 global charsets
127 return [info exists charsets($charset)]
128}
129
e33d66ec 130send_gdb "set host-charset\n"
dea97812 131gdb_expect {
b519e2a6
DJ
132 -re "Requires an argument. Valid arguments are (.*)\\.\r\n$gdb_prompt $" {
133 set host_charset_list $expect_out(1,string)
12d79008 134 regsub -all {, } $host_charset_list {,} host_charset_list
b519e2a6
DJ
135 foreach host_charset [split $host_charset_list ","] {
136 set charsets($host_charset) 1
137 }
e33d66ec 138 pass "capture valid host charsets"
dea97812 139 }
e33d66ec
EZ
140
141 -re ".*$gdb_prompt $" {
142 fail "capture valid host charsets"
dea97812 143 }
b519e2a6 144
dea97812 145 timeout {
e33d66ec 146 fail "(timeout) capture valid host charsets"
dea97812
KB
147 }
148}
149
6c7a06a3
TT
150# If gdb was built with a phony iconv, it will only have two character
151# sets: "auto" and the default. In this situation, this set of tests
152# is pointless.
153if {[llength [array names charsets]] < 3} {
154 untested charset.exp
155 return -1
156}
dea97812 157
e33d66ec
EZ
158send_gdb "set target-charset\n"
159gdb_expect {
b519e2a6
DJ
160 -re "Requires an argument. Valid arguments are (.*)\\.\r\n$gdb_prompt $" {
161 set target_charset_list $expect_out(1,string)
12d79008 162 regsub -all {, } $target_charset_list {,} target_charset_list
b519e2a6
DJ
163 foreach target_charset [split $target_charset_list ","] {
164 if {! [info exists charsets($target_charset)]} {
165 set charsets($target_charset) 0
166 }
e33d66ec 167 }
e33d66ec 168 pass "capture valid target charsets"
e33d66ec 169 }
dea97812 170
e33d66ec
EZ
171 -re ".*$gdb_prompt $" {
172 fail "capture valid target charsets"
173 }
dea97812 174
e33d66ec
EZ
175 timeout {
176 fail "(timeout) capture valid target charsets"
177 }
178}
dea97812 179
6c7a06a3
TT
180# We don't want to test all the charset names here, since that would
181# be too many combinations. We we pick a subset.
182set charset_subset {ASCII ISO-8859-1 EBCDIC-US IBM1047}
183foreach host_charset $charset_subset {
dea97812
KB
184 if {[valid_host_charset $host_charset]} {
185
186 set testname "try `set host-charset $host_charset'"
187 send_gdb "set host-charset $host_charset\n"
188 gdb_expect {
189 -re "GDB doesn't know of any character set named.*\[\r\n]+${gdb_prompt} $" {
190 # How did it get into `charsets' then?
191 fail "$testname (didn't recognize name)"
192 }
193 -re "GDB can't use `.*' as its host character set\\.\[\r\n]+${gdb_prompt} $" {
194 # Well, then why does its `charsets' entry say it can?
195 fail $testname
196 }
197 -re "${gdb_prompt} $" {
198 pass $testname
199 }
200 timeout {
201 fail "$testname (timeout)"
202 }
203 }
204
205 # Check that the command actually had its intended effect:
206 # $host_charset should now be the host character set.
207 send_gdb "show charset\n"
208 set result [parse_show_charset_output "parse `show charset' after `set host-charset $host_charset'"]
209 if {! [string compare [lindex $result 0] $host_charset]} {
210 pass "check effect of `set host-charset $host_charset'"
211 } else {
212 fail "check effect of `set host-charset $host_charset'"
213 }
214
215 # Now try setting every possible target character set,
216 # given that host charset.
6c7a06a3 217 foreach target_charset $charset_subset {
a8df5de4
TT
218 if {![valid_target_charset $target_charset]} {
219 continue
220 }
dea97812
KB
221 set testname "try `set target-charset $target_charset'"
222 send_gdb "set target-charset $target_charset\n"
223 gdb_expect {
224 -re "GDB doesn't know of any character set named.*\[\r\n]+${gdb_prompt} $" {
225 fail "$testname (didn't recognize name)"
226 }
227 -re "GDB can't convert from the .* character set to .*\\.\[\r\n\]+${gdb_prompt} $" {
228 # This is a serious problem. GDB should be able to convert
229 # between any arbitrary pair of character sets.
230 fail "$testname (can't convert)"
231 }
232 -re "${gdb_prompt} $" {
233 pass $testname
234 }
235 timeout {
236 fail "$testname (timeout)"
237 }
238 }
239
240 # Check that the command actually had its intended effect:
241 # $target_charset should now be the target charset.
242 send_gdb "show charset\n"
243 set result [parse_show_charset_output "parse `show charset' after `set target-charset $target_charset'"]
244 if {! [string compare $result [list $host_charset $target_charset]]} {
245 pass "check effect of `set target-charset $target_charset'"
246 } else {
247 fail "check effect of `set target-charset $target_charset'"
248 }
249
250 # Test handling of characters in the host charset which
251 # can't be translated into the target charset. \xA2 is
252 # `cent' in ISO-8859-1, which has no equivalent in ASCII.
253 #
254 # On some systems, the pseudo-tty through which we
255 # communicate with GDB insists on stripping the high bit
256 # from input characters, meaning that `cent' turns into
257 # `"'. Since ISO-8859-1 and ASCII are identical in the
258 # lower 128 characters, it's tough to see how we can test
259 # this behavior on such systems, so we just xfail it.
260 #
261 # Note: the \x16 (Control-V) is an escape to allow \xA2 to
262 # get past readline.
263 if {! [string compare $host_charset iso-8859-1] && ! [string compare $target_charset ascii]} {
264
265 set testname "untranslatable character in character literal"
266 send_gdb "print '\x16\xA2'\n"
267 gdb_expect {
268 -re "There is no character corresponding to .* in the target character set .*\\.\[\r\n\]+$gdb_prompt $" {
269 pass $testname
270 }
271 -re " = 34 '\"'\[\r\n\]+$gdb_prompt $" {
272 xfail "$testname (DejaGNU's pseudo-tty strips eighth bit)"
273 }
274 -re "$gdb_prompt $" {
275 fail $testname
276 }
277 timeout {
278 fail "$testname (timeout)"
279 }
280 }
281
282 set testname "untranslatable character in string literal"
283 # If the PTTY zeros bit seven, then this turns into
284 # print """
285 # which gets us a syntax error. We don't care.
286 send_gdb "print \"\x16\xA2\"\n"
287 gdb_expect {
288 -re "There is no character corresponding to .* in the target character set .*\\.\[\r\n\]+$gdb_prompt $" {
289 pass $testname
290 }
291 -re "Unterminated string in expression.\[\r\n\]+$gdb_prompt $" {
292 xfail "$testname (DejaGNU's pseudo-tty strips eighth bit)"
293 }
294 -re "$gdb_prompt $" {
295 fail $testname
296 }
297 timeout {
298 fail "$testname (timeout)"
299 }
300 }
301
302 set testname "untranslatable characters in backslash escape"
303 send_gdb "print '\\\x16\xA2'\n"
304 gdb_expect {
305 -re "The escape sequence .* is equivalent to plain .*, which has no equivalent\[\r\n\]+in the .* character set\\.\[\r\n\]+$gdb_prompt $" {
306 pass $testname
307 }
308 -re " = 34 '\"'\[\r\n\]+$gdb_prompt $" {
309 xfail "$testname (DejaGNU's pseudo-tty strips eighth bit)"
310 }
311 -re "$gdb_prompt $" {
312 fail $testname
313 }
314 timeout {
315 fail "$testname (timeout)"
316 }
317 }
318 }
319 }
320 }
321}
322
323
324# Set the host character set to plain ASCII, and try actually printing
325# some strings in various target character sets. We need to run the
326# test program to the point at which the strings have been
327# initialized.
381bc39b 328gdb_test "break ${srcfile}:[gdb_get_line_number "all strings initialized"]" \
dea97812
KB
329 ".*Breakpoint.* at .*" \
330 "set breakpoint after all strings have been initialized"
331gdb_run_cmd
332gdb_expect {
333 -re "Breakpoint.*all strings initialized.*$gdb_prompt $" {
334 pass "run until all strings have been initialized"
335 }
336 -re "$gdb_prompt $" {
337 fail "run until all strings have been initialized"
338 }
339 timeout {
340 fail "run until all strings have been initialized (timeout)"
341 }
342}
343
344
6c7a06a3
TT
345# We only try the wide character tests on machines where the wchar_t
346# typedef in the test case has the right size.
347set wchar_size [get_sizeof wchar_t 99]
348set wchar_ok 0
349if {$wchar_size == 2} {
b8899f2b 350 lappend charset_subset UTF-16
6c7a06a3
TT
351 set wchar_ok 1
352} elseif {$wchar_size == 4} {
b8899f2b 353 lappend charset_subset UTF-32
6c7a06a3
TT
354 set wchar_ok 1
355}
356
27d3a1a2 357gdb_test_no_output "set host-charset ASCII"
6c7a06a3 358foreach target_charset $charset_subset {
a8df5de4
TT
359 if {![valid_target_charset $target_charset]} {
360 continue
361 }
362
b8899f2b 363 if {$target_charset == "UTF-32" || $target_charset == "UTF-16"} {
6c7a06a3
TT
364 set param target-wide-charset
365 set L L
366 } else {
367 set param target-charset
368 set L ""
369 }
ad3986f0 370 gdb_test_no_output "set $param $target_charset"
dea97812
KB
371
372 # Try printing the null character. There seems to be a bug in
373 # gdb_test that requires us to use gdb_expect here.
6c7a06a3 374 send_gdb "print $L'\\0'\n"
dea97812 375 gdb_expect {
30b66ecc 376 -re "\\\$${decimal} = 0 $L'\\\\000'\[\r\n\]+$gdb_prompt $" {
dea97812
KB
377 pass "print the null character in ${target_charset}"
378 }
379 -re "$gdb_prompt $" {
380 fail "print the null character in ${target_charset}"
381 }
382 timeout {
383 fail "print the null character in ${target_charset} (timeout)"
384 }
385 }
386
387 # Compute the name of the variable in the test program that holds
388 # a string in $target_charset. The variable's name is the
389 # character set's name, in lower-case, with all non-identifier
390 # characters replaced with '_', with "_string" stuck on the end.
b8899f2b
TT
391 if {$target_charset == "UTF-16"} {
392 # We still use the utf_32_string variable -- but the size is
393 # correct for UTF-16.
394 set var_name utf_32_string
6c7a06a3
TT
395 } else {
396 set var_name [string tolower "${target_charset}_string"]
397 regsub -all -- "\[^a-z0-9_\]" $var_name "_" var_name
398 }
dea97812
KB
399
400 # Compute a regexp matching the results we expect. This is static,
401 # but it's easier than writing it out.
0dcd613f 402 regsub -all "." "abfnrtv" "(\\\\&|x)" escapes
dea97812
KB
403 set uppercase "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
404 set lowercase "abcdefghijklmnopqrstuvwxyz"
405 set digits "0123456789"
6c7a06a3 406 set octal_escape "\\\\\[0-9\]+"
dea97812
KB
407
408 send_gdb "print $var_name\n"
409 # ${escapes}${uppercase}${lowercase}${digits}${octal}${octal}
410 gdb_expect {
6c7a06a3 411 -re ".* = $L\"(\\\\a|x)(\\\\b|x)(\\\\f|x)(\\\\n|x)(\\\\r|x)(\\\\t|x)(\\\\v|x)${uppercase}${lowercase}${digits}(${octal_escape}|x)+\"\[\r\n\]+$gdb_prompt $" {
dea97812
KB
412 pass "print string in $target_charset"
413 }
414 -re "$gdb_prompt $" {
415 fail "print string in $target_charset"
416 }
417 timeout {
418 fail "print string in $target_charset (timeout)"
419 }
420 }
421
422 # Try entering a character literal, and see if it comes back unchanged.
6c7a06a3
TT
423 gdb_test "print $L'A'" \
424 " = \[0-9-\]+ $L'A'" \
dea97812
KB
425 "parse character literal in ${target_charset}"
426
427 # Check that the character literal was encoded correctly.
6c7a06a3 428 gdb_test "print $L'A' == $var_name\[7\]" \
dea97812
KB
429 " = 1" \
430 "check value of parsed character literal in ${target_charset}"
431
432 # Try entering a string literal, and see if it comes back unchanged.
6c7a06a3
TT
433 gdb_test "print $L\"abcdefABCDEF012345\"" \
434 " = $L\"abcdefABCDEF012345\"" \
dea97812
KB
435 "parse string literal in ${target_charset}"
436
437 # Check that the string literal was encoded correctly.
6c7a06a3 438 gdb_test "print $L\"q\"\[0\] == $var_name\[49\]" \
dea97812
KB
439 " = 1" \
440 "check value of parsed string literal in ${target_charset}"
441
442 # Test handling of characters in the target charset which
443 # can't be translated into the host charset.
444 if {! [string compare $target_charset iso-8859-1]} {
0dcd613f 445 gdb_test "print iso_8859_1_string\[69\]" \
dea97812
KB
446 " = \[0-9-\]+ '\\\\242'" \
447 "print character with no equivalent in host character set"
448 gdb_test "print iso_8859_1_string + 70" \
449 " = ${hex} \"\\\\242.*\"" \
450 "print string with no equivalent in host character set"
451 }
452
453 # Make sure that we don't apply the ISO-8859-1 `print_literally'
454 # function to ASCII.
455 if {! [string compare $target_charset ascii]} {
0dcd613f 456 gdb_test "print iso_8859_1_string\[69\]" \
dea97812
KB
457 " = \[0-9-\]+ '\\\\242'" \
458 "print ASCII unprintable character"
459 gdb_test "print iso_8859_1_string + 70" \
460 " = ${hex} \"\\\\242.*\"" \
461 "print ASCII unprintable string"
462 }
463
464 # Try printing characters with backslash escape equivalents.
0dcd613f 465 set escapees {a b f n r t v}
dea97812
KB
466 for {set i 0} {$i < [llength $escapees]} {incr i} {
467 set escape [lindex $escapees $i]
468 send_gdb "print $var_name\[$i\]\n"
469 set have_escape 1
470 gdb_expect {
6c7a06a3 471 -re "= \[0-9-\]+ $L'\\\\${escape}'\[\r\n\]+$gdb_prompt $" {
dea97812
KB
472 pass "try printing '\\${escape}' in ${target_charset}"
473 }
474 -re "= \[0-9-\]+ 'x'\[\r\n\]+$gdb_prompt $" {
475 xfail "try printing '\\${escape}' in ${target_charset} (no such escape)"
476 set have_escape 0
477 }
478 -re "$gdb_prompt $" {
479 fail "try printing '\\${escape}' in ${target_charset}"
480 }
481 timeout {
482 fail "try printing '\\${escape}' in ${target_charset} (timeout)"
483 }
484 }
485
486 if {$have_escape} {
487
488 # Try parsing a backslash escape in a character literal.
6c7a06a3 489 gdb_test "print $L'\\${escape}' == $var_name\[$i\]" \
dea97812
KB
490 " = 1" \
491 "check value of '\\${escape}' in ${target_charset}"
492
493 # Try parsing a backslash escape in a string literal.
6c7a06a3 494 gdb_test "print $L\"\\${escape}\"\[0\] == $var_name\[$i\]" \
dea97812
KB
495 " = 1" \
496 "check value of \"\\${escape}\" in ${target_charset}"
497 }
498 }
499
500 # Try printing a character escape that doesn't exist. We should
501 # get the unescaped character, in the target character set.
6c7a06a3 502 gdb_test "print $L'\\q'" " = \[0-9-\]+ $L'q'" \
dea97812 503 "print escape that doesn't exist in $target_charset"
6c7a06a3 504 gdb_test "print $L'\\q' == $var_name\[49\]" " = 1" \
dea97812
KB
505 "check value of escape that doesn't exist in $target_charset"
506}
507
6c7a06a3 508# Reset the target charset.
27d3a1a2 509gdb_test_no_output "set target-charset UTF-8"
6c7a06a3
TT
510
511# \242 is not a valid UTF-8 character.
512gdb_test "print \"\\242\"" " = \"\\\\242\"" \
513 "non-representable target character"
514
515gdb_test "print '\\x'" "\\\\x escape without a following hex digit."
516gdb_test "print '\\u'" "\\\\u escape without a following hex digit."
517gdb_test "print '\\9'" " = \[0-9\]+ '9'"
518
30b66ecc
TT
519# An octal escape can only be 3 digits.
520gdb_test "print \"\\1011\"" " = \"A1\""
521
6c7a06a3 522# Tests for wide- or unicode- strings. L is the prefix letter to use,
b8899f2b 523# either "L" (for wide strings), "u" (for UTF-16), or "U" (for UTF-32).
6c7a06a3
TT
524# NAME is used in the test names and should be related to the prefix
525# letter in some easy-to-undestand way.
526proc test_wide_or_unicode {L name} {
527 gdb_test "print $L\"ab\" $L\"c\"" " = $L\"abc\"" \
528 "basic $name string concatenation"
529 gdb_test "print $L\"ab\" \"c\"" " = $L\"abc\"" \
530 "narrow and $name string concatenation"
531 gdb_test "print \"ab\" $L\"c\"" " = $L\"abc\"" \
532 "$name and narrow string concatenation"
30b66ecc 533 gdb_test "print $L\"\\xe\" $L\"c\"" " = $L\"\\\\016c\"" \
6c7a06a3
TT
534 "$name string concatenation with escape"
535 gdb_test "print $L\"\" \"abcdef\" \"g\"" \
536 "$L\"abcdefg\"" \
537 "concatenate three strings with empty $name string"
538
539 gdb_test "print $L'a'" "= \[0-9\]+ $L'a'" \
540 "basic $name character"
541}
542
543if {$wchar_ok} {
544 test_wide_or_unicode L wide
545}
546
547set ucs2_ok [expr {[get_sizeof char16_t 99] == 2}]
548if {$ucs2_ok} {
b8899f2b 549 test_wide_or_unicode u UTF-16
6c7a06a3
TT
550}
551
552set ucs4_ok [expr {[get_sizeof char32_t 99] == 4}]
553if {$ucs4_ok} {
b8899f2b 554 test_wide_or_unicode U UTF-32
6c7a06a3
TT
555}
556
557# Test an invalid string combination.
558proc test_combination {L1 name1 L2 name2} {
559 gdb_test "print $L1\"abc\" $L2\"def\"" \
560 "Undefined string concatenation." \
561 "undefined concatenation of $name1 and $name2"
562}
563
564if {$wchar_ok && $ucs2_ok} {
b8899f2b 565 test_combination L wide u UTF-16
6c7a06a3
TT
566}
567if {$wchar_ok && $ucs4_ok} {
b8899f2b 568 test_combination L wide U UTF-32
85e306ed
TT
569 # Regression test for a typedef to a typedef.
570 gdb_test "print myvar" "= \[0-9\]+ L'A'" \
571 "typedef to wchar_t"
6c7a06a3
TT
572}
573if {$ucs2_ok && $ucs4_ok} {
b8899f2b 574 test_combination u UTF-16 U UTF-32
6c7a06a3
TT
575}
576
96c07c5b
TT
577if {$ucs2_ok} {
578 set go 1
579 gdb_test_multiple "python print 'hello, world!'" \
580 "verify python support for charset tests" {
581 -re "not supported.*$gdb_prompt $" {
582 unsupported "python support is disabled"
583 set go 0
584 }
585 -re "$gdb_prompt $" {}
586 }
587
588 if {$go} {
589 gdb_test "print u\"abcdef\"" " = u\"abcdef\"" \
590 "set up for python printing of utf-16 string"
591
592 gdb_test "python print gdb.history(0).string()" "abcdef" \
593 "extract utf-16 string using python"
594 }
595}
596
334cc82d
TT
597# Regression test for a cleanup bug in the charset code.
598gdb_test "print 'a' == 'a' || 'b' == 'b'" \
599 ".* = 1" \
600 "EVAL_SKIP cleanup handling regression test"
601
9a22f0d0
PM
602
603proc string_display { var_name set_prefix x_size x_type} {
27d3a1a2 604 gdb_test_no_output "set ${var_name} = ${set_prefix}\"Test String\\0with zeroes\"" "Assign ${var_name} with prefix ${set_prefix}"
9a22f0d0
PM
605 gdb_test "x /2${x_size}s ${var_name}" ".* ${x_type}\"Test String\"\[\r\n\]+.* ${x_type}\"with zeroes\"" "Display String ${var_name} with x/${x_size}s"
606}
607
608string_display String16 u h u
609if {$wchar_size == 2} {
610 string_display String16 L h u
611}
612
613string_display String32 U w U
614if {$wchar_size == 4} {
615 string_display String32 L w U
616}
617
618
dea97812 619gdb_exit
This page took 0.815149 seconds and 4 git commands to generate.