# This testcase is part of GDB, the GNU debugger.
-# Copyright 2001, 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+# Copyright 2001-2016 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# Test GDB's character set support.
-if $tracelevel then {
- strace $tracelevel
-}
-set prms_id 0
-set bug_id 0
+standard_testfile .c charset-malloc.c
-set testfile "charset"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- untested "couldn't compile ${srcdir}/${subdir}/${srcfile}"
+if { [prepare_for_testing ${testfile}.exp ${testfile} [list $srcfile $srcfile2]] } {
return -1
}
-# Start with a fresh gdb.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
# Parse the output from a `show charset' command. Return the host
# and target charset as a two-element list.
proc parse_show_charset_output {testname} {
".*Breakpoint.* at .*" \
"set breakpoint after all strings have been initialized"
gdb_run_cmd
-gdb_expect {
- -re "Breakpoint.*all strings initialized.*$gdb_prompt $" {
- pass "run until all strings have been initialized"
- }
- -re "$gdb_prompt $" {
- fail "run until all strings have been initialized"
- }
- timeout {
- fail "run until all strings have been initialized (timeout)"
- }
-}
-
+gdb_test "" "Breakpoint.*all strings initialized.*" "run until all strings have been initialized"
# We only try the wide character tests on machines where the wchar_t
# typedef in the test case has the right size.
set wchar_ok 1
}
-gdb_test "set host-charset ASCII" ""
+gdb_test_no_output "set host-charset ASCII"
foreach target_charset $charset_subset {
if {![valid_target_charset $target_charset]} {
continue
set param target-charset
set L ""
}
- send_gdb "set $param $target_charset\n"
- gdb_expect {
- -re "$gdb_prompt $" {
- pass "set $param $target_charset"
- }
- timeout {
- fail "set $param $target_charset (timeout)"
- }
- }
+ gdb_test_no_output "set $param $target_charset"
# Try printing the null character. There seems to be a bug in
# gdb_test that requires us to use gdb_expect here.
}
# Reset the target charset.
-gdb_test "set target-charset UTF-8" ""
+gdb_test_no_output "set target-charset UTF-8"
# \242 is not a valid UTF-8 character.
gdb_test "print \"\\242\"" " = \"\\\\242\"" \
}
set ucs2_ok [expr {[get_sizeof char16_t 99] == 2}]
+
+if ![valid_host_charset "UTF-16"] {
+ verbose -log "Disabling UTF-16 tests."
+ set ucs2_ok 0
+}
+
if {$ucs2_ok} {
test_wide_or_unicode u UTF-16
}
if {$ucs2_ok} {
set go 1
- gdb_test_multiple "python print 'hello, world!'" \
+ gdb_test_multiple "python print ('hello, world!')" \
"verify python support for charset tests" {
-re "not supported.*$gdb_prompt $" {
unsupported "python support is disabled"
gdb_test "print u\"abcdef\"" " = u\"abcdef\"" \
"set up for python printing of utf-16 string"
- gdb_test "python print gdb.history(0).string()" "abcdef" \
+ gdb_test "python print (gdb.history(0).string())" "abcdef" \
"extract utf-16 string using python"
}
}
proc string_display { var_name set_prefix x_size x_type} {
- gdb_test "set ${var_name} = ${set_prefix}\"Test String\\0with zeroes\"" "" "Assign ${var_name} with prefix ${set_prefix}"
- 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"
+ gdb_test_no_output "set ${var_name} = ${set_prefix}\"Test String\\0with zeroes\"" "Assign ${var_name} with prefix ${set_prefix}"
+ gdb_test "x /2${x_size}s ${var_name}" ".*\t${x_type}\"Test String\"\[\r\n\]+.*\t${x_type}\"with zeroes\"" "Display String ${var_name} with x/${x_size}s"
}
-string_display String16 u h u
-if {$wchar_size == 2} {
- string_display String16 L h u
+if {$ucs2_ok} {
+ string_display String16 u h u
+ if {$wchar_size == 2} {
+ string_display String16 L h u
+ }
}
-
+
string_display String32 U w U
if {$wchar_size == 4} {
string_display String32 L w U
}
+foreach name {short int long} {
+ # We're really just checking to make sure this doesn't give an
+ # error.
+ gdb_test "print ${name}_array = \"hi\"" \
+ " = {.*}" \
+ "assign string to $name array"
+}
+
+
gdb_exit