1 # Copyright 1998, 1999, 2000, 2007, 2008, 2009, 2010, 2011
2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # This file is part of the gdb testsuite
19 # file written by Elena Zannoni (ezannoni@cygnus.com)
22 # tests for expressions with struct/array elements and mixed operator types
23 # with elementary types
30 # By default, the datastructures are allocated on the stack. For targets
31 # with very small stack, that will not work. In that case, just set
32 # storage to `-DSTORAGE=static' which changes the datastructures to be
33 # allocated in data segment.
34 set storage "-DSTORAGE="
35 if [target_info exists gdb,small_stack_section] {
36 set storage "-DSTORAGE=static"
39 set additional_flags "additional_flags=${storage}"
42 # test running programs
45 set testfile "miscexprs"
46 set srcfile ${testfile}.c
47 set binfile ${objdir}/${subdir}/${testfile}
49 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags} nowarnings]] != "" } {
50 untested miscexprs.exp
54 if [get_compiler_info ${binfile}] {
60 gdb_reinitialize_dir $srcdir/$subdir
65 # set it up at a breakpoint so we can play with the variable values
67 if ![runto_main] then {
68 perror "couldn't run to breakpoint"
72 gdb_test "break marker1" ".*" ""
75 "Break.* marker1 \\(\\) at .*:$decimal.*" \
78 gdb_test "up" " main .*" "up from marker1"
82 gdb_test "print &ibig.i\[0\]" " = \\(int \\*\\) $hex" \
83 "print value of &ibig.i\[0\]"
85 gdb_test_multiple "print &cbig.c\[0\]" "print value of &cbig.c\[0\]" {
86 -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" {
87 pass "print value of &cbig.c\[0\]"
89 -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" {
90 pass "print value of &cbig.c\[0\]"
94 gdb_test "print &fbig.f\[0\]" " = \\(float \\*\\) $hex" \
95 "print value of &fbig.f\[0\]"
97 gdb_test "print &dbig.d\[0\]" " = \\(double \\*\\) $hex" \
98 "print value of &dbig.d\[0\]"
100 gdb_test_multiple "print &sbig.s\[0\]" "print value of &sbig.s\[0\]" {
101 -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" {
102 pass "print value of &sbig.s\[0\]"
104 -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" {
105 pass "print value of &sbig.s\[0\]"
109 gdb_test_multiple "print &lbig.l\[0\]" "print value of &lbig.l\[0\]" {
110 -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" {
111 pass "print value of &lbig.l\[0\]"
113 -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" {
114 pass "print value of &lbig.l\[0\]"
118 gdb_test "print ibig.i\[100\] | 1" " = 5" \
119 "print value of ibig.i\[100\] | 1"
121 gdb_test "print sbig.s\[90\] & 127" " = 127" \
122 "print value of sbig.s\[90\] & 127"
124 gdb_test "print !ibig.i\[100\]" " = $false" \
125 "print value of !ibig.i\[100\]"
127 gdb_test "print !sbig.s\[90\]" " = $false" \
128 "print value of !sbig.s\[90\]"
130 gdb_test "print !fbig.f\[100\]" " = $false" \
131 "print value of !ibig.i\[100\]"
133 gdb_test "print !dbig.d\[202\]" " = $false" \
134 "print value of !ibig.i\[100\]"
136 gdb_test "print sbig.s\[90\] * 10" " = 2550" \
137 "print value of !sbig.s\[90\] * 10"
139 gdb_test "print ibig.i\[100\] * sbig.s\[90\]" " = 1275" \
140 "print value of ibig.i\[100\] * sbig.s\[90\]"
142 gdb_test "print fbig.f\[100\] * dbig.d\[202\]" " = 119.99\[0-9\]*" \
143 "print value of fbig.f\[100\] * dbig.d\[202\]"
145 gdb_test "print !(sbig.s\[90\] * 2)" " = $false" \
146 "print value of !(sbig.s\[90\] * 2)"
148 gdb_test "print sizeof(sbig)" " = 800" "print value of sizeof sbig"
150 gdb_test "print sizeof(cbig)" " = 100" "print value of sizeof cbig"
152 gdb_test "print sizeof(lbig)/sizeof(long)" " = 900" \
153 "print value of sizeof lbig / sizeof long"
155 gdb_test "print ibig.i\[100\] << 2" " = 20" \
156 "print value of ibig.i\[100\] << 2"
158 gdb_test "print sbig.s\[90\] >> 4" " = 15" \
159 "print value of sbig.s\[90\] >> 4"
161 gdb_test "print lbig.l\[333\] >> 6" " = 15624999" \
162 "print value of lbig.l\[333\] >> 6"