1234353Sdim# Copyright 1998, 1999, 2007, 2008, 2009, 2010, 2011 2193323Sed# Free Software Foundation, Inc. 3193323Sed 4193323Sed# This program is free software; you can redistribute it and/or modify 5193323Sed# it under the terms of the GNU General Public License as published by 6193323Sed# the Free Software Foundation; either version 3 of the License, or 7193323Sed# (at your option) any later version. 8193323Sed# 9193323Sed# This program is distributed in the hope that it will be useful, 10224145Sdim# but WITHOUT ANY WARRANTY; without even the implied warranty of 11193323Sed# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12193323Sed# GNU General Public License for more details. 13193323Sed# 14193323Sed# You should have received a copy of the GNU General Public License 15249423Sdim# along with this program. If not, see <http://www.gnu.org/licenses/>. 16218893Sdim 17249423Sdim# This file was written by Elena Zannoni (ezannoni@cygnus.com) 18249423Sdim 19249423Sdim# This file is part of the gdb testsuite 20249423Sdim# 21243830Sdim# tests for all the assignemnt operators 22249423Sdim# with mixed types and with int type variables 23224145Sdim# 24224145Sdim 25224145Sdimif $tracelevel then { 26224145Sdim strace $tracelevel 27224145Sdim } 28193323Sed 29193323Sed# 30194710Sed# test running programs 31194710Sed# 32194710Sed 33194710Sedset testfile "all-types" 34199989Srdivackyset srcfile ${testfile}.c 35263508Sdimset binfile ${objdir}/${subdir}/${testfile} 36199989Srdivacky 37218893Sdimif { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { 38243830Sdim untested assign.exp 39243830Sdim return -1 40243830Sdim } 41263508Sdim 42263508Sdim 43263508Sdim 44263508Sdimgdb_exit 45263508Sdimgdb_start 46218893Sdimgdb_reinitialize_dir $srcdir/$subdir 47263508Sdimgdb_load ${binfile} 48263508Sdim 49263508Sdim 50263508Sdim# 51263508Sdim# set it up at a breakpoint so we can play with the variable values 52263508Sdim# 53263508Sdim 54263508Sdimif ![runto_main] then { 55263508Sdim perror "couldn't run to breakpoint" 56263508Sdim continue 57263508Sdim} 58263508Sdim 59263508Sdimgdb_test "next" "return 0;" "continuing after dummy()" 60263508Sdim 61263508Sdimgdb_test_multiple "print v_int=57" "v_int=57" { 62263508Sdim -re " = 57.*$gdb_prompt $" { 63263508Sdim gdb_test "print v_int" " = 57" "v_int=57" 64263508Sdim } 65263508Sdim} 66263508Sdim 67263508Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6" 68263508Sdim 69263508Sdimgdb_test_multiple "print v_int+=57" "v_int+=57" { 70263508Sdim -re " = 63.*$gdb_prompt $" { 71263508Sdim gdb_test "print v_int" " = 63" "v_int+=57" 72263508Sdim } 73263508Sdim} 74263508Sdim 75263508Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (2)" 76263508Sdim 77224145Sdimgdb_test_multiple "print v_int-=57" "v_int-=57" { 78249423Sdim -re " = -51.*$gdb_prompt $" { 79224145Sdim gdb_test "print v_int" " = -51" "v_int-=57" 80218893Sdim } 81263508Sdim} 82193323Sed 83224145Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (3)" 84218893Sdim 85249423Sdimgdb_test_multiple "print v_int*=5" "v_int*=5" { 86193323Sed -re " = 30.*$gdb_prompt $" { 87249423Sdim gdb_test "print v_int" " = 30" "v_int*=5" 88249423Sdim } 89249423Sdim} 90249423Sdim 91249423Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (4)" 92249423Sdim 93249423Sdimgdb_test_multiple "print v_int/=4" "v_int/=4" { 94249423Sdim -re " = 1.*$gdb_prompt $" { 95249423Sdim gdb_test "print v_int" " = 1" "v_int/=4" 96263508Sdim } 97249423Sdim} 98249423Sdim 99263508Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (5)" 100249423Sdim 101249423Sdimgdb_test_multiple "print v_int%=4" "v_int%=4" { 102249423Sdim -re " = 2.*$gdb_prompt $" { 103263508Sdim gdb_test "print v_int" " = 2" "v_int%=4" 104249423Sdim } 105249423Sdim} 106249423Sdim 107249423Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (6)" 108249423Sdim 109249423Sdimgdb_test_multiple "print v_int+=v_char" "v_int+=char" { 110249423Sdim -re " = 71.*$gdb_prompt $" { 111249423Sdim gdb_test "print v_int" " = 71" "v_int+=char" 112249423Sdim } 113249423Sdim} 114249423Sdim 115249423Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (7)" 116249423Sdim 117249423Sdimgdb_test_multiple "print v_int+=v_signed_char" "v_int+=signed_char" { 118249423Sdim -re " = 72.*$gdb_prompt $" { 119249423Sdim gdb_test "print v_int" " = 72" "v_int+=signed_char" 120249423Sdim } 121249423Sdim} 122249423Sdim 123249423Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (8)" 124249423Sdim 125249423Sdimgdb_test_multiple "print v_int+=v_unsigned_char" "v_int+=unsigned_char" { 126249423Sdim -re " = 73.*$gdb_prompt $" { 127249423Sdim gdb_test "print v_int" " = 73" "v_int+=unsigned_char" 128263508Sdim } 129249423Sdim} 130263508Sdim 131251662Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (9)" 132263508Sdim 133263508Sdimgdb_test_multiple "print v_int+=v_short" "v_int+=short" { 134249423Sdim -re " = 9.*$gdb_prompt $" { 135249423Sdim gdb_test "print v_int" " = 9" "v_int+=short" 136249423Sdim } 137249423Sdim} 138249423Sdim 139249423Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (10)" 140249423Sdim 141249423Sdimgdb_test_multiple "print v_int+=v_signed_short" "v_int+=signed_short" { 142249423Sdim -re " = 10.*$gdb_prompt $" { 143249423Sdim gdb_test "print v_int" " = 10" "v_int+=signed_short" 144249423Sdim } 145249423Sdim} 146249423Sdim 147249423Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (11)" 148249423Sdim 149249423Sdimgdb_test_multiple "print v_int+=v_unsigned_short" "v_int=+unsigned_short" { 150249423Sdim -re " = 11.*$gdb_prompt $" { 151249423Sdim gdb_test "print v_int" " = 11" "v_int=+unsigned_short" 152249423Sdim } 153249423Sdim} 154249423Sdim 155249423Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (12)" 156249423Sdim 157263508Sdimgdb_test_multiple "print v_int+=v_signed_int" "v_int+=signed_int" { 158263508Sdim -re " = 13.*$gdb_prompt $" { 159263508Sdim gdb_test "print v_int" " = 13" "v_int+=signed_int" 160263508Sdim } 161263508Sdim} 162263508Sdim 163263508Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (13)" 164193323Sed 165224145Sdimgdb_test_multiple "print v_int+=v_unsigned_int" "v_int+=unsigned_int" { 166224145Sdim -re " = 14.*$gdb_prompt $" { 167224145Sdim gdb_test "print v_int" " = 14" "v_int+=unsigned_int" 168249423Sdim } 169249423Sdim} 170224145Sdim 171224145Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (14)" 172249423Sdim 173224145Sdimgdb_test_multiple "print v_int+=v_long" "v_int+=long" { 174224145Sdim -re " = 15.*$gdb_prompt $" { 175218893Sdim gdb_test "print v_int" " = 15" "v_int+=long" 176224145Sdim } 177204961Srdivacky} 178224145Sdim 179224145Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (15)" 180224145Sdim 181263508Sdimgdb_test_multiple "print v_int+=v_signed_long" "v_int+=signed_long" { 182193323Sed -re " = 16.*$gdb_prompt $" { 183239462Sdim gdb_test "print v_int" " = 16" "v_int+=signed_long" 184239462Sdim } 185239462Sdim} 186224145Sdim 187224145Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (16)" 188193323Sed 189249423Sdimgdb_test_multiple "print v_int+=v_unsigned_long" "v_int+=unsigned_long" { 190249423Sdim -re " = 17.*$gdb_prompt $" { 191234353Sdim gdb_test "print v_int" " = 17" "v_int+=unsigned_long" 192234353Sdim } 193224145Sdim} 194198090Srdivacky 195193323Sedgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (17)" 196193323Sed 197193323Sedgdb_test_multiple "print v_int+=v_float" "v_int+=v_float" { 198263508Sdim -re " = 106.*$gdb_prompt $" { 199263508Sdim gdb_test "print v_int" " = 106" "v_int+=v_float" 200263508Sdim } 201263508Sdim} 202263508Sdim 203224145Sdimgdb_test_no_output "set variable v_int = 6" "set v_int to 6 (18)" 204234353Sdim 205218893Sdimgdb_test_multiple "print v_int+=v_double" "v_int+=double" { 206198090Srdivacky -re " = 206.*$gdb_prompt $" { 207198396Srdivacky gdb_test "print v_int" " = 206" "v_int+=double" 208198396Srdivacky } 209218893Sdim} 210263508Sdim