]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright 1998-2023 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 | 39 | |
f8b41b00 | 40 | standard_testfile .c |
c906108c | 41 | |
fc91c6c2 | 42 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags} nowarnings]] != "" } { |
84c93cd5 | 43 | untested "failed to compile" |
b60f0898 | 44 | return -1 |
085dd6e6 | 45 | } |
c906108c | 46 | |
f8b41b00 | 47 | clean_restart ${binfile} |
c906108c SS |
48 | |
49 | ||
50 | # | |
51 | # set it up at a breakpoint so we can play with the variable values | |
52 | # | |
65a33d75 | 53 | if {![runto_main]} { |
cdd42066 | 54 | return |
c906108c SS |
55 | } |
56 | ||
80c0a3bf AB |
57 | # This is used as an expected result value. |
58 | set false 0 | |
59 | ||
de7ff789 | 60 | gdb_test "break marker1" ".*" "" |
65731a6b MS |
61 | |
62 | gdb_test "cont" \ | |
63 | "Break.* marker1 \\(\\) at .*:$decimal.*" \ | |
64 | "continue to marker1" | |
65 | ||
66 | gdb_test "up" " main .*" "up from marker1" | |
c906108c SS |
67 | |
68 | global hex | |
69 | ||
aaff91fd | 70 | gdb_test "print &ibig.i\[0\]" " = \\(int \\*\\) $hex" |
65731a6b | 71 | |
aaff91fd | 72 | gdb_test_multiple "print &cbig.c\[0\]" "" { |
c906108c | 73 | -re ".\[0-9\]* = $hex \"\".*$gdb_prompt $" { |
aaff91fd | 74 | pass $gdb_test_name |
65731a6b | 75 | } |
085dd6e6 | 76 | -re ".\[0-9\]* = $hex \"*\".*$gdb_prompt $" { |
aaff91fd | 77 | pass $gdb_test_name |
65731a6b MS |
78 | } |
79 | } | |
80 | ||
aaff91fd | 81 | gdb_test "print &fbig.f\[0\]" " = \\(float \\*\\) $hex" |
65731a6b | 82 | |
aaff91fd | 83 | gdb_test "print &dbig.d\[0\]" " = \\(double \\*\\) $hex" |
65731a6b | 84 | |
aaff91fd | 85 | gdb_test_multiple "print &sbig.s\[0\]" "" { |
7a292a7a | 86 | -re ".\[0-9\]* = \\(short \\*\\) $hex.*$gdb_prompt $" { |
aaff91fd | 87 | pass $gdb_test_name |
7a292a7a | 88 | } |
c906108c | 89 | -re ".\[0-9\]* = \\(short int \\*\\) $hex.*$gdb_prompt $" { |
aaff91fd | 90 | pass $gdb_test_name |
7a292a7a | 91 | } |
65731a6b | 92 | } |
c906108c | 93 | |
aaff91fd | 94 | gdb_test_multiple "print &lbig.l\[0\]" "" { |
7a292a7a | 95 | -re ".\[0-9\]* = \\(long \\*\\) $hex.*$gdb_prompt $" { |
aaff91fd | 96 | pass $gdb_test_name |
7a292a7a | 97 | } |
c906108c | 98 | -re ".\[0-9\]* = \\(long int \\*\\) $hex.*$gdb_prompt $" { |
aaff91fd | 99 | pass $gdb_test_name |
7a292a7a | 100 | } |
65731a6b MS |
101 | } |
102 | ||
aaff91fd | 103 | gdb_test "print ibig.i\[100\] | 1" " = 5" |
65731a6b | 104 | |
aaff91fd | 105 | gdb_test "print sbig.s\[90\] & 127" " = 127" |
65731a6b | 106 | |
aaff91fd | 107 | gdb_test "print !ibig.i\[100\]" " = $false" |
65731a6b | 108 | |
aaff91fd | 109 | gdb_test "print !sbig.s\[90\]" " = $false" |
65731a6b | 110 | |
aaff91fd | 111 | gdb_test "print !fbig.f\[100\]" " = $false" |
65731a6b | 112 | |
aaff91fd | 113 | gdb_test "print !dbig.d\[202\]" " = $false" |
65731a6b | 114 | |
aaff91fd | 115 | gdb_test "print sbig.s\[90\] * 10" " = 2550" |
65731a6b | 116 | |
aaff91fd | 117 | gdb_test "print ibig.i\[100\] * sbig.s\[90\]" " = 1275" |
65731a6b | 118 | |
aaff91fd | 119 | gdb_test "print fbig.f\[100\] * dbig.d\[202\]" " = 119.99\[0-9\]*" |
65731a6b | 120 | |
aaff91fd | 121 | gdb_test "print !(sbig.s\[90\] * 2)" " = $false" |
65731a6b | 122 | |
aaff91fd | 123 | gdb_test "print sizeof(sbig)" " = 800" |
65731a6b | 124 | |
aaff91fd | 125 | gdb_test "print sizeof(cbig)" " = 100" |
65731a6b | 126 | |
aaff91fd | 127 | gdb_test "print sizeof(lbig)/sizeof(long)" " = 900" |
65731a6b | 128 | |
aaff91fd | 129 | gdb_test "print ibig.i\[100\] << 2" " = 20" |
65731a6b | 130 | |
aaff91fd | 131 | gdb_test "print sbig.s\[90\] >> 4" " = 15" |
65731a6b | 132 | |
aaff91fd | 133 | gdb_test "print lbig.l\[333\] >> 6" " = 15624999" |
65731a6b | 134 |