1# Copyright 1998, 1999, 2007 Free Software Foundation, Inc. 2 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16# Please email any bugs, comments, and/or additions to this file to: 17# bug-gdb@prep.ai.mit.edu 18 19# This file was written by Elena Zannoni (ezannoni@cygnus.com) 20 21# This file is part of the gdb testsuite 22# 23# tests for whatis command on expressions. 24# used in file eval.c. This flavor of whatis 25# command performs evaluation of expressions w/o actually 26# computing the value, but just the type 27# of the result. It goes through the evaluate_subexp_standard 28# with the EVAL_AVOID_SIDE_EFFECTS flag rather than EVAL_NORMAL 29# 30 31if $tracelevel then { 32 strace $tracelevel 33 } 34 35# 36# test running programs 37# 38set prms_id 0 39set bug_id 0 40 41set testfile "int-type" 42set srcfile ${testfile}.c 43set binfile ${objdir}/${subdir}/${testfile} 44if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { 45 untested whatis-exp.exp 46 return -1 47 } 48 49 50gdb_exit 51gdb_start 52gdb_reinitialize_dir $srcdir/$subdir 53gdb_load ${binfile} 54 55 56# 57# set it up at a breakpoint so we can play with the variable values 58# 59 60if ![runto_main] then { 61 perror "couldn't run to breakpoint" 62 continue 63} 64 65# 66# test expressions with "int" types 67# 68 69gdb_test "set variable x=14" "" "set variable x=14" 70gdb_test "set variable y=2" "" "set variable y=2" 71gdb_test "set variable z=2" "" "set variable z=2" 72gdb_test "set variable w=3" "" "set variable w=3" 73 74send_gdb "print x\n" 75gdb_expect { 76 -re ".*14.*$gdb_prompt $" { 77 pass "print value of x" 78 } 79 -re ".*$gdb_prompt $" { fail "print value of x" } 80 timeout { fail "(timeout) print value of x" } 81 } 82 83 84send_gdb "print y\n" 85gdb_expect { 86 -re ".*2.*$gdb_prompt $" { 87 pass "print value of y" 88 } 89 -re ".*$gdb_prompt $" { fail "print value of y" } 90 timeout { fail "(timeout) print value of y" } 91 } 92 93send_gdb "print z\n" 94gdb_expect { 95 -re ".*2.*$gdb_prompt $" { 96 pass "print value of z" 97 } 98 -re ".*$gdb_prompt $" { fail "print value of z" } 99 timeout { fail "(timeout) print value of z" } 100 } 101 102send_gdb "print w\n" 103gdb_expect { 104 -re ".*3.*$gdb_prompt $" { 105 pass "print value of w" 106 } 107 -re ".*$gdb_prompt $" { fail "print value of w" } 108 timeout { fail "(timeout) print value of w" } 109 } 110 111 112 113send_gdb "whatis x+y\n" 114gdb_expect { 115 -re ".*type = long.*$gdb_prompt $" { 116 pass "whatis value of x+y" 117 } 118 -re ".*$gdb_prompt $" { fail "whatis value of x+y" } 119 timeout { fail "(timeout) whatis value of x+y" } 120 } 121 122send_gdb "whatis x-y\n" 123gdb_expect { 124 -re ".*type = long.*$gdb_prompt $" { 125 pass "whatis value of x-y" 126 } 127 -re ".*$gdb_prompt $" { fail "whatis value of x-y" } 128 timeout { fail "(timeout) whatis value of x-y" } 129 } 130 131send_gdb "whatis x*y\n" 132gdb_expect { 133 -re ".*type = long.*$gdb_prompt $" { 134 pass "whatis value of x*y" 135 } 136 -re ".*$gdb_prompt $" { fail "whatis value of x*y" } 137 timeout { fail "(timeout) whatis value of x*y" } 138 } 139 140send_gdb "whatis x/y\n" 141gdb_expect { 142 -re ".*type = int.*$gdb_prompt $" { 143 pass "whatis value of x/y" 144 } 145 -re ".*$gdb_prompt $" { fail "whatis value of x/y" } 146 timeout { fail "(timeout) whatis value of x/y" } 147 } 148 149send_gdb "whatis x%y\n" 150gdb_expect { 151 -re ".*type = int.*$gdb_prompt $" { 152 pass "whatis value of x%y" 153 } 154 -re ".*$gdb_prompt $" { fail "whatis value of x%y" } 155 timeout { fail "(timeout) whatis value of x%y" } 156 } 157 158 159 160send_gdb "whatis x=y\n" 161gdb_expect { 162 -re ".*type = int.*$gdb_prompt $" { 163 pass "whatis value of x=y" 164 } 165 -re ".*$gdb_prompt $" { fail "whatis value of x=y" } 166 timeout { fail "(timeout) whatis value of x=y" } 167 } 168 169 170send_gdb "whatis x+=2\n" 171gdb_expect { 172 -re ".*type = int.*$gdb_prompt $" { 173 pass "whatis value of x+=2" 174 } 175 -re ".*$gdb_prompt $" { fail "whatis value of x+=2" } 176 timeout { fail "(timeout) whatis value of x+=2" } 177 } 178 179 180send_gdb "whatis ++x\n" 181gdb_expect { 182 -re ".*type = int.*$gdb_prompt $" { 183 pass "whatis value of ++x" 184 } 185 -re ".*$gdb_prompt $" { fail "whatis value of ++x" } 186 timeout { fail "(timeout) whatis value of ++x" } 187 } 188 189send_gdb "whatis --x\n" 190gdb_expect { 191 -re ".*type = int.*$gdb_prompt $" { 192 pass "whatis value of --x" 193 } 194 -re ".*$gdb_prompt $" { fail "whatis value of --x" } 195 timeout { fail "(timeout) whatis value of --x" } 196 } 197 198send_gdb "whatis x++\n" 199gdb_expect { 200 -re ".*type = int.*$gdb_prompt $" { 201 pass "whatis value of x++" 202 } 203 -re ".*$gdb_prompt $" { fail "whatis value of x++" } 204 timeout { fail "(timeout) whatis value of x++" } 205 } 206 207send_gdb "whatis x--\n" 208gdb_expect { 209 -re ".*type = int.*$gdb_prompt $" { 210 pass "whatis value of x--" 211 } 212 -re ".*$gdb_prompt $" { fail "whatis value of x--" } 213 timeout { fail "(timeout) whatis value of x--" } 214 } 215 216gdb_exit 217return 0 218