2011-07-26 Pedro Alves <pedro@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / miscexprs.exp
CommitLineData
7b6bb8da 1# Copyright 1998, 1999, 2000, 2007, 2008, 2009, 2010, 2011
4c38e0a4 2# Free Software Foundation, Inc.
c906108c
SS
3
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
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
c906108c 7# (at your option) any later version.
e22f8b7c 8#
c906108c
SS
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.
e22f8b7c 13#
c906108c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 16
c906108c
SS
17
18# This file is part of the gdb testsuite
19# file written by Elena Zannoni (ezannoni@cygnus.com)
20
21#
22# tests for expressions with struct/array elements and mixed operator types
23# with elementary types
24#
25
26if $tracelevel then {
27 strace $tracelevel
28 }
29
aaa68313
CV
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.
34set storage "-DSTORAGE="
35if [target_info exists gdb,small_stack_section] {
36 set storage "-DSTORAGE=static"
37}
38
fc91c6c2 39set additional_flags "additional_flags=${storage}"
aaa68313 40
c906108c
SS
41#
42# test running programs
43#
c906108c
SS
44
45set testfile "miscexprs"
46set srcfile ${testfile}.c
47set binfile ${objdir}/${subdir}/${testfile}
48
fc91c6c2 49if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags} nowarnings]] != "" } {
b60f0898
JB
50 untested miscexprs.exp
51 return -1
c906108c
SS
52}
53
085dd6e6
JM
54if [get_compiler_info ${binfile}] {
55 return -1;
56}
c906108c
SS
57
58gdb_exit
59gdb_start
60gdb_reinitialize_dir $srcdir/$subdir
61gdb_load ${binfile}
62
63
64#
65# set it up at a breakpoint so we can play with the variable values
66#
67if ![runto_main] then {
68 perror "couldn't run to breakpoint"
69 continue
70}
71
de7ff789 72gdb_test "break marker1" ".*" ""
65731a6b
MS
73
74gdb_test "cont" \
75 "Break.* marker1 \\(\\) at .*:$decimal.*" \
76 "continue to marker1"
77
78gdb_test "up" " main .*" "up from marker1"
c906108c
SS
79
80global hex
81
65731a6b
MS
82gdb_test "print &ibig.i\[0\]" " = \\(int \\*\\) $hex" \
83 "print value of &ibig.i\[0\]"
84
85gdb_test_multiple "print &cbig.c\[0\]" "print value of &cbig.c\[0\]" {
c906108c
SS
86 -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" {
87 pass "print value of &cbig.c\[0\]"
65731a6b 88 }
085dd6e6
JM
89 -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" {
90 pass "print value of &cbig.c\[0\]"
65731a6b
MS
91 }
92}
93
94gdb_test "print &fbig.f\[0\]" " = \\(float \\*\\) $hex" \
95 "print value of &fbig.f\[0\]"
96
97gdb_test "print &dbig.d\[0\]" " = \\(double \\*\\) $hex" \
98 "print value of &dbig.d\[0\]"
99
100gdb_test_multiple "print &sbig.s\[0\]" "print value of &sbig.s\[0\]" {
7a292a7a
SS
101 -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" {
102 pass "print value of &sbig.s\[0\]"
103 }
c906108c
SS
104 -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" {
105 pass "print value of &sbig.s\[0\]"
7a292a7a 106 }
65731a6b 107}
c906108c 108
65731a6b 109gdb_test_multiple "print &lbig.l\[0\]" "print value of &lbig.l\[0\]" {
7a292a7a
SS
110 -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" {
111 pass "print value of &lbig.l\[0\]"
112 }
c906108c
SS
113 -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" {
114 pass "print value of &lbig.l\[0\]"
7a292a7a 115 }
65731a6b
MS
116}
117
118gdb_test "print ibig.i\[100\] | 1" " = 5" \
119 "print value of ibig.i\[100\] | 1"
120
121gdb_test "print sbig.s\[90\] & 127" " = 127" \
122 "print value of sbig.s\[90\] & 127"
123
124gdb_test "print !ibig.i\[100\]" " = $false" \
125 "print value of !ibig.i\[100\]"
126
127gdb_test "print !sbig.s\[90\]" " = $false" \
128 "print value of !sbig.s\[90\]"
129
130gdb_test "print !fbig.f\[100\]" " = $false" \
131 "print value of !ibig.i\[100\]"
132
133gdb_test "print !dbig.d\[202\]" " = $false" \
134 "print value of !ibig.i\[100\]"
135
136gdb_test "print sbig.s\[90\] * 10" " = 2550" \
137 "print value of !sbig.s\[90\] * 10"
138
139gdb_test "print ibig.i\[100\] * sbig.s\[90\]" " = 1275" \
140 "print value of ibig.i\[100\] * sbig.s\[90\]"
141
142gdb_test "print fbig.f\[100\] * dbig.d\[202\]" " = 119.99\[0-9\]*" \
143 "print value of fbig.f\[100\] * dbig.d\[202\]"
144
145gdb_test "print !(sbig.s\[90\] * 2)" " = $false" \
146 "print value of !(sbig.s\[90\] * 2)"
147
148gdb_test "print sizeof(sbig)" " = 800" "print value of sizeof sbig"
149
150gdb_test "print sizeof(cbig)" " = 100" "print value of sizeof cbig"
151
152gdb_test "print sizeof(lbig)/sizeof(long)" " = 900" \
153 "print value of sizeof lbig / sizeof long"
154
155gdb_test "print ibig.i\[100\] << 2" " = 20" \
156 "print value of ibig.i\[100\] << 2"
157
158gdb_test "print sbig.s\[90\] >> 4" " = 15" \
159 "print value of sbig.s\[90\] >> 4"
160
161gdb_test "print lbig.l\[333\] >> 6" " = 15624999" \
162 "print value of lbig.l\[333\] >> 6"
163
This page took 1.318212 seconds and 4 git commands to generate.