1# This testcase is part of GDB, the GNU debugger. 2 3# Copyright 1988, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 4# 1999, 2000, 2001, 2004 Free Software Foundation, Inc. 5 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 2 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, write to the Free Software 18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 20# Please email any bugs, comments, and/or additions to this file to: 21# bug-gdb@gnu.org 22 23# This file was written by Rob Savoye. (rob@cygnus.com) 24 25if $tracelevel then { 26 strace $tracelevel 27 } 28 29# 30# test running programs 31# 32set prms_id 0 33set bug_id 0 34 35set testfile "setvar" 36set srcfile ${testfile}.c 37set binfile ${objdir}/${subdir}/${testfile} 38if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { 39 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." 40} 41 42# Create and source the file that provides information about the compiler 43# used to compile the test case. 44if [get_compiler_info ${binfile}] { 45 return -1; 46} 47 48gdb_exit 49gdb_start 50gdb_reinitialize_dir $srcdir/$subdir 51gdb_load $binfile 52 53# 54# set it up at a breakpoint so we canplay with the variable values 55# 56send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $" 57 58if ![runto_main] then { 59 perror "couldn't run to breakpoint" 60 continue 61} 62 63# Determine expected output for unsigned long variables, 64# the output varies with sizeof (unsigned long). 65 66set ulong_minus_1 4294967295 67set ulong_minus_456 4294966840 68send_gdb "print sizeof (unsigned long)\n" 69gdb_expect { 70 -re ".\[0-9\]* = 4.*$gdb_prompt $" {} 71 -re ".\[0-9\]* = 8.*$gdb_prompt $" { 72 set ulong_minus_1 18446744073709551615 73 set ulong_minus_456 18446744073709551160 74 } 75 -re ".*$gdb_prompt $" { 76 fail "getting sizeof unsigned long" 77 } 78 default { fail "(timeout) getting sizeof unsigned long" } 79} 80 81proc test_set { args } { 82 global gdb_prompt 83 84 set length [expr [llength $args] - 1]; 85 set message "[lindex $args $length]"; 86 set final [expr $length - 2]; 87 set count 1; 88 89 # Set up the variables. 90 for {set x 0;} {$x < $length} {incr x;} { 91 if { "[lindex $args $x]" != "" } { 92 set arg [lindex $args $x]; 93 if { ($x == $final) || ([string first ".*" [lindex $args [expr $x + 1]]] >= 0) } { 94 set match [lindex $args [expr $x + 1]]; 95 if { $count == 1 } { 96 set mess "$message" 97 } else { 98 set mess "$message (#$count)"; 99 } 100 incr count; 101 incr x; 102 } else { 103 set mess ""; 104 set match "" 105 } 106 verbose "doing $arg $match" 107 if [gdb_test "$arg" "$match" "$mess"] { 108 fail "$message -- $match"; 109 return 1; 110 } 111 } 112 } 113 return 0; 114} 115 116# 117# test "set variable" for type "char" 118# 119# Because bare char types can be either signed or unsigned, we just test the 120# range of values that are common to both (0-127). 121# 122 123test_set "set variable v_char=0" "print v_char" ".\[0-9\]* = 0 \'.0\'" "set variable char=0" 124test_set "set variable v_char=1" "print v_char" ".\[0-9\]* = 1 \'.001\'" "set variable char=1" 125test_set "set variable v_char=7" "print v_char" ".\[0-9\]* = 7 \'.a\'" "set variable char=7 (Bel)" 126test_set "set variable v_char=32" "print v_char" ".\[0-9\]* = 32 \' \'" "set variable char=32 (SPC)" 127test_set "set variable v_char=65" "print v_char" ".\[0-9\]* = 65 \'A\'" "set variable char=65 ('A')" 128test_set "set variable v_char=97" "print v_char" ".\[0-9\]* = 97 \'a\'" "set variable char=97 ('a')" 129test_set "set variable v_char=126" "print v_char" ".\[0-9\]* = 126 \'~\'" "set variable char=126 ('~')" 130test_set "set variable v_char=127" "print v_char" ".\[0-9\]* = 127 \'.177\'" "set variable char=127 (8-bit)" 131# 132# test "set variable" for type "signed char" 133# 134test_set "set variable v_char=0" "print v_signed_char" ".\[0-9\]* = 0 \'.0\'" "set variable signed char=0" 135test_set "set variable v_signed_char=1" "print v_signed_char" ".\[0-9\]* = 1 \'.001\'" "set variable signed char=1" 136test_set "set variable v_signed_char=7" "print v_signed_char" ".\[0-9\]* = 7 \'.a\'" "set variable signed char=7 (Bel)" 137test_set "set variable v_signed_char=32" "print v_signed_char" ".\[0-9\]* = 32 \' \'" "set variable signed char=32 (SPC)" 138test_set "set variable v_signed_char=65" "print v_signed_char" ".\[0-9\]* = 65 \'A\'" "set variable signed char=65 ('A')" 139test_set "set variable v_signed_char=97" "print v_signed_char" ".\[0-9\]* = 97 \'a\'" "set variable signed char=97 ('a')" 140test_set "set variable v_signed_char=126" "print v_signed_char" ".\[0-9\]* = 126 \'~\'" "set variable signed char=126 ('~')" 141test_set "set variable v_signed_char=127" "print v_signed_char" ".\[0-9\]* = 127 \'.177\'" "set variable signed char=127 (8-bit)" 142gdb_test "set variable v_signed_char=-1" "" 143if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" } 144gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \ 145 "set variable signed char=-1 (-1)" 146gdb_test "set variable v_signed_char=0xFF" "" 147if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" } 148gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \ 149 "set variable signed char=0xFF (0xFF)" 150# 151# test "set variable" for type "unsigned char" 152# 153test_set "set variable v_unsigned_char=0" "print v_unsigned_char" ".\[0-9\]* = 0 \'.0\'" "set variable unsigned char=0" 154test_set "set variable v_unsigned_char=1" "print v_unsigned_char" ".\[0-9\]* = 1 \'.001\'" "set variable unsigned char=1" 155test_set "set variable v_unsigned_char=7" "print v_unsigned_char" ".\[0-9\]* = 7 \'.a\'" "set variable unsigned char=7 (Bel)" 156test_set "set variable v_unsigned_char=32" "print v_unsigned_char" ".\[0-9\]* = 32 \' \'" "set variable unsigned char=32 (SPC)" 157test_set "set variable v_unsigned_char=65" "print v_unsigned_char" ".\[0-9\]* = 65 \'A\'" "set variable unsigned char=65 ('A')" 158test_set "set variable v_unsigned_char=97" "print v_unsigned_char" ".\[0-9\]* = 97 \'a\'" "set variable unsigned char=97 ('a')" 159test_set "set variable v_unsigned_char=126" "print v_unsigned_char" ".\[0-9\]* = 126 \'~\'" "set variable unsigned char=126 ('~')" 160test_set "set variable v_unsigned_char=~0" "print v_unsigned_char" ".\[0-9\]* = 255 \'.377\'" "set variable unsigned char=255 (8-bit)" 161# 162# test "set variable" for type "short" 163# 164test_set "set variable v_short=0" "print v_short" ".\[0-9\]* = 0" "set variable short=0" 165test_set "set variable v_short=1" "print v_short" ".\[0-9\]* = 1" "set variable short=1" 166test_set "set variable v_short=-1" "print v_short" ".\[0-9\]* = -1" "set variable short=-1 (minus)" 167# 168# test "set variable" for type "signed short" 169# 170test_set "set variable v_signed_short=0" "print v_signed_short" ".\[0-9\]* = 0" "set variable signed short=0" 171test_set "set variable v_signed_short=1" "print v_signed_short" ".\[0-9\]* = 1" "set variable signed short=1" 172test_set "set variable v_signed_short=-1" "print v_signed_short" ".\[0-9\]* = -1" "set variable signed short=-1 (minus)" 173# 174# test "set variable" for type "unsigned short" 175# 176test_set "set variable v_unsigned_short=0" "print v_unsigned_short" ".\[0-9\]* = 0" "set variable unsigned short=0" 177test_set "set variable v_unsigned_short=1" "print v_unsigned_short" ".\[0-9\]* = 1" "set variable unsigned short=1" 178test_set "set variable v_unsigned_short=~0" "print v_unsigned_short" ".\[0-9\]* = 65535" "set variable unsigned short=~0 (minus)" 179# 180# test "set variable" for type "int" 181# 182test_set "set variable v_int=0" "print v_int" ".\[0-9\]* = 0" "set variable int=0" 183test_set "set variable v_int=1" "print v_int" ".\[0-9\]* = 1" "set variable int=1" 184test_set "set variable v_int=-1" "print v_int" ".\[0-9\]* = -1" "set variable int=-1 (minus)" 185# 186# test "set variable" for type "signed int" 187# 188test_set "set variable v_signed_int=0" "print v_signed_int" ".\[0-9\]* = 0" "set variable signed int=0" 189test_set "set variable v_signed_int=1" "print v_signed_int" ".\[0-9\]* = 1" "set variable signed int=1" 190test_set "set variable v_signed_int=-1" "print v_signed_int" ".\[0-9\]* = -1" "set variable signed int=-1 (minus)" 191# 192# test "set variable" for type "unsigned int" 193# 194test_set "set variable v_unsigned_int=0" "print v_unsigned_int" ".\[0-9\]* = 0" "set variable unsigned int=0" 195test_set "set variable v_unsigned_int=1" "print v_unsigned_int" ".\[0-9\]* = 1" "set variable unsigned int=1" 196test_set "set variable v_unsigned_int=~0" "print v_unsigned_int" ".\[0-9\]* = (4294967295|65535)" "set variable unsigned int=~0 (minus)" 197#test_set ".\[0-9\]* = 65535" "set variable unsigned int=~0 (minus)" 198# 199# test "set variable" for type "long" 200# 201test_set "set variable v_long=0" "print v_long" ".\[0-9\]* = 0" "set variable long=0" 202test_set "set variable v_long=1" "print v_long" ".\[0-9\]* = 1" "set variable long=1" 203test_set "set variable v_long=-1" "print v_long" ".\[0-9\]* = -1" "set variable long=-1 (minus)" 204# 205# test "set variable" for type "signed long" 206# 207test_set "set variable v_signed_long=0" "print v_signed_long" ".\[0-9\]* = 0" "set variable signed long=0" 208test_set "set variable v_signed_long=1" "print v_signed_long" ".\[0-9\]* = 1" "set variable signed long=1" 209test_set "set variable v_signed_long=-1" "print v_signed_long" ".\[0-9\]* = -1" "set variable signed long=-1 (minus)" 210# 211# test "set variable" for type "unsigned long" 212# 213test_set "set variable v_unsigned_long=0" "print v_unsigned_long" ".\[0-9\]* = 0" "set variable unsigned long=0" 214test_set "set variable v_unsigned_long=1" "print v_unsigned_long" ".\[0-9\]* = 1" "set variable unsigned long=1" 215test_set "set variable v_unsigned_long=~0" "print v_unsigned_long" ".\[0-9\]* = $ulong_minus_1" "set variable unsigned long=~0 (minus)" 216# 217# test "set variable" for type "float" 218# 219test_set "set variable v_float=0.0" "print v_float" ".\[0-9\]* = 0" "set variable float=0" 220test_set "set variable v_float=1.0" "print v_float" ".\[0-9\]* = 1" "set variable float=1" 221test_set "set variable v_float=-1.0" "print v_float" ".\[0-9\]* = -1" "set variable float=-1 (minus)" 222# 223# test "set variable" for type "double" 224# 225test_set "set variable v_double=0.0" "print v_double" ".\[0-9\]* = 0" "set variable double=0" 226test_set "set variable v_double=1.0" "print v_double" ".\[0-9\]* = 1" "set variable double=1" 227test_set "set variable v_double=-1.0" "print v_double" ".*.\[0-9\]* = -1" "set variable double=-1 (minus)" 228# 229# test "set variable" for "char array[2]" 230# 231test_set "set variable v_char_array\[0\]='h'" "set variable v_char_array\[1\]='i'" "print v_char_array" ".*.\[0-9\]* =.*\"hi\"" "set variable char array=\"hi\" (string)" 232# 233# test "set variable" for "signed char array[2]" 234# 235test_set "set variable v_signed_char_array\[0\]='h'" "set variable v_signed_char_array\[1\]='i'" "print v_signed_char_array" ".*.\[0-9\]* =.*\"hi\"" "set variable signed char array=\"hi\" (string)" 236# 237# test "set variable" for "unsigned char array[2]" 238# 239test_set "set variable v_unsigned_char_array\[0\]='h'" "set variable v_unsigned_char_array\[1\]='i'" "print v_unsigned_char_array" ".*.\[0-9\]* =.*\"hi\"" "set variable unsigned char array=\"hi\" (string)" 240# 241# test "set variable" for "short array[2]" 242# 243test_set "set variable v_short_array\[0\]=123" "set variable v_short_array\[1\]=-456" "print v_short_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable short array" 244# 245# test "set variable" for "signed short array[2]" 246# 247test_set "set variable v_signed_short_array\[0\]=123" "set variable v_signed_short_array\[1\]=-456" "print v_signed_short_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable signed short array" 248# 249# test "set variable" for "unsigned short array[2]" 250# 251test_set "set variable v_unsigned_short_array\[0\]=123" "set variable v_unsigned_short_array\[1\]=-456" "print v_unsigned_short_array" ".*.\[0-9\]* =.*\\{123,.*65080\\}" "set variable unsigned short array" 252# 253# test "set variable" for "int array[2]" 254# 255test_set "set variable v_int_array\[0\]=123" "set variable v_int_array\[1\]=-456" "print v_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable int array" 256# 257# test "set variable" for "signed int array[2]" 258# 259test_set "set variable v_signed_int_array\[0\]=123" "set variable v_signed_int_array\[1\]=-456" "print v_signed_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable signed int array" 260# 261# test "set variable" for "unsigned int array[2]" 262# 263test_set "set variable v_unsigned_int_array\[0\]=123" "set variable v_unsigned_int_array\[1\]=-456" "print v_unsigned_int_array" ".*.\[0-9\]* =.*\\{123,.*(4294966840|65080)\\}" "set variable unsigned int array" 264# 265# test "set variable" for "long array[2]" 266# 267test_set "set variable v_long_array\[0\]=123" "set variable v_long_array\[1\]=-456" "print v_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable long array" 268# 269# test "set variable" for "signed long array[2]" 270# 271test_set "set variable v_signed_long_array\[0\]=123" "set variable v_signed_long_array\[1\]=-456" "print v_signed_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable signed long array" 272# 273# test "set variable" for "unsigned long array[2]" 274# 275test_set "set variable v_unsigned_long_array\[0\]=123" "set variable v_unsigned_long_array\[1\]=-456" "print v_unsigned_long_array" ".*.\[0-9\]* =.*\\{123,.*$ulong_minus_456\\}" "set variable unsigned long array" 276# 277# test "set variable" for "float array[2]" 278# 279test_set "set variable v_float_array\[0\]=123.0" "set variable v_float_array\[1\]=-456.0" "print v_float_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable float array" 280# 281# test "set variable" for "double array[2]" 282# 283test_set "set variable v_double_array\[0\]=123.0" "set variable v_double_array\[1\]=-456.0" "print v_double_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "set variable double array" 284# 285# test "set variable" for type "char *" 286# 287test_set "set v_char_pointer=v_char_array" "set variable *(v_char_pointer)='h'" "set variable *(v_char_pointer+1)='i'" "print v_char_array" ".*.\[0-9\]* =.*\"hi\"" "print *(v_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'" "set variable char pointer=\"hi\" (string)" 288# 289# test "set variable" for type "signed char *" 290# 291test_set "set v_signed_char_pointer=v_signed_char_array" "set variable *(v_signed_char_pointer)='h'" "set variable *(v_signed_char_pointer+1)='i'" "print v_signed_char_array" ".*.\[0-9\]* =.*\"hi\"" "print *(v_signed_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'" "set variable signed char pointer=\"hi\" (string)" 292# 293# test "set variable" for type "unsigned char *" 294# 295test_set "set v_unsigned_char_pointer=v_unsigned_char_array" "set variable *(v_unsigned_char_pointer)='h'" "set variable *(v_unsigned_char_pointer+1)='i'" "print v_unsigned_char_array" ".*.\[0-9\]* =.*\"hi\"" "print *(v_unsigned_char_pointer+1)" ".*.\[0-9\]* = 105 \'i\'" "set variable unsigned char pointer=\"hi\" (string)" 296# 297# test "set variable" for type "short *" 298# 299test_set "set v_short_pointer=v_short_array" "set variable *(v_short_pointer)=123" "set variable *(v_short_pointer+1)=-456" "print v_short_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_short_pointer+1)" ".*.\[0-9\]* = -456" "set variable short pointer" 300# 301# test "set variable" for type "signed short *" 302# 303gdb_test "set v_signed_short_pointer=v_signed_short_array" "" 304gdb_test "set variable *(v_signed_short_pointer)=123" "" 305gdb_test "set variable *(v_signed_short_pointer+1)=-456" "" 306gdb_test "print v_signed_short_array" ".\[0-9\]* =.*\\{123,.*-456\\}" \ 307 "set variable signed short pointer" 308gdb_test "print *(v_signed_short_pointer+1)" ".\[0-9\]*.*=.*-456" 309# 310# test "set variable" for type "unsigned short *" 311# 312gdb_test "set v_unsigned_short_pointer=v_unsigned_short_array" "" 313gdb_test "set variable *(v_unsigned_short_pointer)=123" "" 314gdb_test "set variable *(v_unsigned_short_pointer+1)=-456" "" 315gdb_test "print v_unsigned_short_array" ".\[0-9\]* =.*\\{123,.*65080\\}" \ 316 "set variable unsigned short pointer" 317gdb_test "print *(v_unsigned_short_pointer+1)" ".\[0-9\]* = 65080" 318# 319# test "set variable" for type "int *" 320# 321test_set "set v_int_pointer=v_int_array" "set variable *(v_int_pointer)=123" "set variable *(v_int_pointer+1)=-456" "print v_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_int_pointer+1)" ".*.\[0-9\]* = -456" "set variable int pointer" 322# 323# test "set variable" for type "signed int *" 324# 325test_set "set v_signed_int_pointer=v_signed_int_array" "set variable *(v_signed_int_pointer)=123" "set variable *(v_signed_int_pointer+1)=-456" "print v_signed_int_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_signed_int_pointer+1)" ".*.\[0-9\]* = -456" "set variable signed int pointer" 326# 327# test "set variable" for type "unsigned int *" 328# 329test_set "set v_unsigned_int_pointer=v_unsigned_int_array" "set variable *(v_unsigned_int_pointer)=123" "set variable *(v_unsigned_int_pointer+1)=-456" "print v_unsigned_int_array" ".*.\[0-9\]* =.*\\{123,.*(4294966840|65080)\\}" "set variable unsigned int pointer" 330test_set "" "print *(v_unsigned_int_pointer+1)" ".*.\[0-9\]* = (4294966840|65080)" "print variable unsigned int pointer+1" 331# 332# test "set variable" for type "long *" 333# 334test_set "set v_long_pointer=v_long_array" "set variable *(v_long_pointer)=123" "set variable *(v_long_pointer+1)=-456" "print v_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_long_pointer+1)" ".*.\[0-9\]* = -456" "set variable long pointer" 335# 336# test "set variable" for type "signed long *" 337# 338test_set "set v_signed_long_pointer=v_signed_long_array" "set variable *(v_signed_long_pointer)=123" "set variable *(v_signed_long_pointer+1)=-456" "print v_signed_long_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_signed_long_pointer+1)" ".*.\[0-9\]* = -456" "set variable signed long pointer" 339# 340# test "set variable" for type "unsigned long *" 341# 342test_set "set v_unsigned_long_pointer=v_unsigned_long_array" "set variable *(v_unsigned_long_pointer)=123" "set variable *(v_unsigned_long_pointer+1)=-456" "print v_unsigned_long_array" ".*.\[0-9\]* =.*\\{123,.*$ulong_minus_456\\}" "print *(v_unsigned_long_pointer+1)" ".*.\[0-9\]* = $ulong_minus_456" "set variable unsigned long pointer" 343# 344# test "set variable" for type "float *" 345# 346test_set "set v_float_pointer=v_float_array" "set variable *(v_float_pointer)=123.0" "set variable *(v_float_pointer+1)=-456.0" "print v_float_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_float_pointer+1)" ".*.\[0-9\]* = -456" "set variable float pointer" 347# 348# test "set variable" for type "double *" 349# 350test_set "set v_double_pointer=v_double_array" "set variable *(v_double_pointer)=123.0" "set variable *(v_double_pointer+1)=-456.0" "print v_double_array" ".*.\[0-9\]* =.*\\{123,.*-456\\}" "print *(v_double_pointer+1)" ".*.\[0-9\]* = -456" "set variable double pointer" 351# 352# test "set variable" for struct members 353# 354test_set "set variable v_struct1.v_char_member='h'" "print v_struct1.v_char_member" ".*.\[0-9\]* = 104 \'h\'" "set variable structure char member" 355test_set "set variable v_struct1.v_short_member=1" "print v_struct1.v_short_member" ".*.\[0-9\]* = 1" "set variable structure short member" 356test_set "set variable v_struct1.v_int_member=2" "print v_struct1.v_int_member" ".*.\[0-9\]* = 2" "set variable structure int member" 357test_set "set variable v_struct1.v_long_member=3" "print v_struct1.v_long_member" ".*.\[0-9\]* = 3" "set variable structure long member" 358test_set "set variable v_struct1.v_float_member=4.0" "print v_struct1.v_float_member" ".*.\[0-9\]* = 4" "set variable structure float member" 359test_set "set variable v_struct1.v_double_member=5.0" "print v_struct1.v_double_member" ".*.\[0-9\]* = 5" "set variable structure double member" 360 361gdb_test "print v_struct1" \ 362 ".*.\[0-9\]* = \{.*v_char_member = 104 \'h\',.*v_short_member = 1,\ 363.*v_int_member = 2,.*\ 364v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\}" \ 365 "set print structure #1" 366 367# Some believe that the following should be an error. GCC extensions for 368# structure constants require the type of the structure to be specified, as in 369# v_struct1 = (struct t_struct) {32, 33, 34, 35, 36, 37} 370# The argument is that GDB should do the same if it wants to provide this 371# feature, i.e., require the cast. 372# We decided that we don't want the debugger to be as picky as a 373# compiler and make us type complex casts. 374 375# We need to up this because this can be really slow on some boards. 376# (malloc() is called as part of the test). 377set timeout 60; 378 379# Change the values 380test_set "set variable v_struct1 = {32, 33, 34, 35, 36, 37}" \ 381 "print v_struct1" \ 382 ".*.\[0-9\]* = \\{.*v_char_member = 32 \' \',.*v_short_member = 33,\ 383.*v_int_member = 34,.*\ 384v_long_member = 35,.*v_float_member = 36,.*v_double_member = 37.*\\}" \ 385 "set print structure #2" 386 387# Change them back 388test_set "set variable v_struct1 = {'h', 1, 2, 3, 4.0, 5.0}" \ 389 "print v_struct1" \ 390 ".*.\[0-9\]* = \\{.*v_char_member = 104 \'h\',.*v_short_member = 1,\ 391.*v_int_member = 2,.*\ 392v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\\}" \ 393 "set print structure #3" 394 395# Test printing of enumeration bitfields. 396# GNU C supports them, some other compilers don't. 397 398if {$gcc_compiled} then { 399 gdb_test "print sef.field=sm1" ".*.\[0-9\]* = sm1" 400 gdb_test "print sef.field" ".*.\[0-9\]* = sm1" "print sef.field (sm1)" 401 gdb_test "print sef.field=s1" ".*.\[0-9\]* = s1" 402 gdb_test "print sef.field" ".*.\[0-9\]* = s1" "print sef.field (s1)" 403 gdb_test "print uef.field=u2" ".*.\[0-9\]* = u2" 404 gdb_test "print uef.field" ".*.\[0-9\]* = u2" "print uef.field (u2)" 405 gdb_test "print uef.field=u1" ".*.\[0-9\]* = u1" 406 gdb_test "print uef.field" ".*.\[0-9\]* = u1" "print uef.field (u1)" 407 408 # Test for truncation when assigning invalid values to bitfields. 409 gdb_test "print sef.field=7" \ 410 ".*warning: Value does not fit in 2 bits.*\[0-9\]* = sm1" 411 gdb_test "print uef.field=6" \ 412 ".*warning: Value does not fit in 2 bits.*\[0-9\]* = u2" 413} 414