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