import gdb-1999-06-28 snapshot
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / call-ar-st.exp
CommitLineData
c906108c
SS
1# Copyright (C) 1998
2# Free Software Foundation, Inc.
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
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8#
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.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18# Please email any bugs, comments, and/or additions to this file to:
19# bug-gdb@prep.ai.mit.edu
20
21# This file was written by Elena Zannoni (ezannoni@cygnus.com)
22
23
24if $tracelevel then {
25 strace $tracelevel
26}
27
28set prms_id 0
29set bug_id 0
30
31set testfile "call-ar-st"
32set srcfile ${testfile}.c
33set binfile ${objdir}/${subdir}/${testfile}
34
35
36if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
37 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
38}
39
40
41# Create and source the file that provides information about the compiler
42# used to compile the test case.
43
44if [get_compiler_info ${binfile}] {
45 return -1;
46}
47
48# The a29k can't call functions, so don't even bother with this test.
49if [target_info exists gdb,cannot_call_functions] {
50 setup_xfail "*-*-*" 2416
51 fail "This target can not call functions"
52 continue
53}
54
55# Set the current language to C. This counts as a test. If it
56# fails, then we skip the other tests.
57
58proc set_lang_c {} {
59 global gdb_prompt
60
61 send_gdb "set language c\n"
62 gdb_expect {
63 -re ".*$gdb_prompt $" {}
64 timeout { fail "set language c (timeout)" ; return 0; }
65 }
66
67 send_gdb "show language\n"
68 gdb_expect {
69 -re ".* source language is \"c\".*$gdb_prompt $" {
70 pass "set language to \"c\""
71 return 1
72 }
73 -re ".*$gdb_prompt $" {
74 fail "setting language to \"c\""
75 return 0
76 }
77 timeout {
78 fail "can't show language (timeout)"
79 return 0
80 }
81 }
82}
83
84
85source ${binfile}.ci
86
87
88# Start with a fresh gdb.
89
90gdb_exit
91gdb_start
92gdb_reinitialize_dir $srcdir/$subdir
93gdb_load ${binfile}
94send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
95send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $"
96send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $"
97
98
99if ![runto_main] then {
100 perror "couldn't run to breakpoint"
101 continue
102}
103
085dd6e6
JM
104#go -until 1209
105gdb_test "tbreak 1209" \
106 "Breakpoint \[0-9\]+.*file.*$srcfile, line 1209.*" \
107 "tbreakpoint line 1209"
c906108c
SS
108
109gdb_test continue \
085dd6e6 110"Continuing\\..*main \\(\\) at.*$srcfile:1209.*" \
c906108c
SS
111"run until breakpoint set at a line"
112
113
114#call print_double_array(double_array)
9e086581
JM
115if {![target_info exists gdb,skip_float_tests]} {
116 send_gdb "print print_double_array(double_array)\n"
085dd6e6
JM
117 gdb_expect_list "print print_double_array(double_array)" ".*$gdb_prompt $" {
118 "\[ \t\r\n\]+array_d :"
119 "\[ \t\r\n\]+========="
120 "\[ \t\r\n\]+0.000000"
121 "\[ \t\r\n\]+23.456700 46.913400 70.370100 93.826800 117.283500 140.740200 164.196900 187.653600"
122 "\[ \t\r\n\]+211.110300 234.567000 258.023700 281.480400 304.937100 328.393800 351.850500 375.307200"
123 "\[ \t\r\n\]+398.763900 422.220600 445.677300 469.134000 492.590700 516.047400 539.504100 562.960800"
124 "\[ \t\r\n\]+586.417500 609.874200 633.330900 656.787600 680.244300 703.701000 727.157700 750.614400"
125 "\[ \t\r\n\]+774.071100 797.527800 820.984500 844.441200 867.897900 891.354600 914.811300 938.268000"
126 "\[ \t\r\n\]+961.724700 985.181400 1008.638100 1032.094800 1055.551500 1079.008200 1102.464900 1125.921600"
127 "\[ \t\r\n\]+1149.378300 1172.835000 1196.291700 1219.748400 1243.205100 1266.661800 1290.118500 1313.575200"
128 "\[ \t\r\n\]+1337.031900 1360.488600 1383.945300 1407.402000 1430.858700 1454.315400 1477.772100 1501.228800"
129 "\[ \t\r\n\]+1524.685500 1548.142200 1571.598900 1595.055600 1618.512300 1641.969000 1665.425700 1688.882400"
130 "\[ \t\r\n\]+1712.339100 1735.795800 1759.252500 1782.709200 1806.165900 1829.622600 1853.079300 1876.536000"
131 "\[ \t\r\n\]+1899.992700 1923.449400 1946.906100 1970.362800 1993.819500 2017.276200 2040.732900 2064.189600"
132 "\[ \t\r\n\]+2087.646300 2111.103000 2134.559700 2158.016400 2181.473100 2204.929800 2228.386500 2251.843200"
133 "\[ \t\r\n\]+2275.299900 2298.756600 2322.213300\[ \t\r\n\]+\[ \t\r\n\]+"
c906108c 134 }
9e086581 135}
c906108c
SS
136
137#call print_char_array(char_array)
7a292a7a 138
c906108c
SS
139send_gdb "print print_char_array(char_array)\n"
140gdb_expect {
141 -re "array_c :\[ \t\r\n\]+=========\[ \t\r\n\]+\[ \t\r\n\]+Z\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZa\[ \t\r\n\]+\[ \t\r\n\]+.*\[ \t\r\n\]+.*$gdb_prompt $" {
142 pass "print print_char_array(char_array)"
143 }
144 -re ".*$gdb_prompt $" { fail "print print_char_array(char_array)" }
145 timeout { fail "(timeout) print print_char_array(char_array)" }
146 }
147
148
149
085dd6e6
JM
150#go -until 1216
151gdb_test "tbreak 1216" \
152"Breakpoint.*file.*$srcfile, line 1216.*" \
153"tbreakpoint line 1216"
c906108c
SS
154
155send_gdb "continue\n"
156gdb_expect {
085dd6e6
JM
157 -re "array_c :\[ \t\r\n\]+=========\[ \t\r\n\]+\[ \t\r\n\]+Z\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZa\[ \t\r\n\]+\[ \t\r\n\]+\[ \t\r\n\]+main.*at.*$srcfile:1216\[ \t\r\n\]+.*print_double_array\\(double_array\\).*$gdb_prompt $" {
158 pass "continue to 1216"
c906108c 159 }
085dd6e6
JM
160 -re ".*$gdb_prompt $" { fail "continue to 1216" }
161 timeout { fail "(timeout) continue to 1216" }
c906108c
SS
162}
163
164# I am disabling this test, because it takes too long. I verified by
165# hand that it works, feel free to check for yourself.
166#call print_all_arrays(integer_array, char_array, float_array, double_array)
167#send_gdb "print print_all_arrays(integer_array, char_array, float_array, double_array)\n"
168#gdb_expect {
169# -re ".*array_i :\[ \t\r\n\]+=========\[ \t\r\n\]+\[ \t\r\n\]+0\[ \t\r\n\]+-1 -2 -3 -4 -5 -6 -7 -8\[ \t\r\n\]+-9 -10 -11 -12 -13 -14 -15 -16\[ \t\r\n\]+-17 -18 -19 -20 -21 -22 -23 -24\[ \t\r\n\]+-25 -26 -27 -28 -29 -30 -31 -32\[ \t\r\n\]+-33 -34 -35 -36 -37 -38 -39 -40\[ \t\r\n\]+-41 -42 -43 -44 -45 -46 -47 -48\[ \t\r\n\]+-49\[ \t\r\n\]+\[ \t\r\n\]+array_c :\[ \t\r\n\]+=========\[ \t\r\n\]+\[ \t\r\n\]+Z\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZa\[ \t\r\n\]+\[ \t\r\n\]+array_f :\[ \t\r\n\]+=========\[ \t\r\n\]+\[ \t\r\n\]+0.000000\[ \t\r\n\]+0.142450 0.284900 0.427350 0.569801 0.712251 0.854701 0.997151 1.139601\[ \t\r\n\]+1.282051 1.424501 1.566952 1.709402 1.851852 1.994302\[ \t\r\n\]+\[ \t\r\n\]+array_d :\[ \t\r\n\]+=========\[ \t\r\n\]+\[ \t\r\n\]+0.000000\[ \t\r\n\]+23.456700 46.913400 70.370100 93.826800 117.283500 140.740200 164.196900 187.653600\[ \t\r\n\]+211.110300 234.567000 258.023700 281.480400 304.937100 328.393800 351.850500 375.307200\[ \t\r\n\]+398.763900 422.220600 445.677300 469.134000 492.590700 516.047400 539.504100 562.960800\[ \t\r\n\]+586.41750 609.874200 633.330900 656.787600 680.244300 703.701000 727.157700 750.614400\[ \t\r\n\]+774.071100 797.527800 820.984500 844.441200 867.897900 891.354600 914.811300 938.268000\[ \t\r\n\]+961.724700 985.181400 1008.638100 1032.094800 1055.551500 1079.008200 1102.464900 1125.921600\[ \t\r\n\]+1149.378300 1172.835000 1196.291700 1219.748400 1243.205100 1266.661800 1290.118500 1313.575200\[ \t\r\n\]+1337.031900 1360.488600 1383.945300 1407.402000 1430.858700 1454.315400 1477.772100 1501.228800\[ \t\r\n\]+1524.685500 1548.142200 1571.598900 1595.055600 1618.512300 1641.969000 1665.425700 1688.882400\[ \t\r\n\]+1712.339100 1735.795800 1759.252500 1782.709200 1806.165900 1829.622600 1853.079300 1876.536000\[ \t\r\n\]+1899.992700 1923.449400 1946.906100 1970.362800 1993.819500 2017.276200 2040.732900 2064.189600\[ \t\r\n\]+2087.646300 2111.103000 2134.559700 2158.016400 2181.473100 2204.929800 2228.386500 2251.843200\[ \t\r\n\]+2275.299900 2298.756600 2322.213300.*$gdb_prompt $" {
170# pass "print print_all_arrays(integer_array, char_array, float_array, double_array)"
171# }
172# -re ".*$gdb_prompt $" { fail "print print_all_arrays(integer_array, char_array, float_array, double_array)" }
173# timeout { fail "(timeout) print print_all_arrays(integer_array, char_array, float_array, double_array)" }
174# }
175
176#set timeout $oldtimeout
085dd6e6
JM
177#go -until 1220
178gdb_test "tbreak 1220" \
179 "Breakpoint.* file .*$srcfile, line 1220.*" \
180 "tbreakpoint line 1220"
c906108c 181
085dd6e6
JM
182send_gdb "continue\n"
183gdb_expect_list "continuing to breakpoint 1220" ".*$gdb_prompt $" {
184 "Continuing\\."
185 "\[ \t\r\n\]+array_d :"
186 "\[ \t\r\n\]+========="
187 "\[ \t\r\n\]+0.000000"
188 "\[ \t\r\n\]+23.456700 46.913400 70.370100 93.826800 117.283500 140.740200 164.196900 187.653600"
189 "\[ \t\r\n\]+211.110300 234.567000 258.023700 281.480400 304.937100 328.393800 351.850500 375.307200"
190 "\[ \t\r\n\]+398.763900 422.220600 445.677300 469.134000 492.590700 516.047400 539.504100 562.960800"
191 "\[ \t\r\n\]+586.417500 609.874200 633.330900 656.787600 680.244300 703.701000 727.157700 750.614400"
192 "\[ \t\r\n\]+774.071100 797.527800 820.984500 844.441200 867.897900 891.354600 914.811300 938.268000"
193 "\[ \t\r\n\]+961.724700 985.181400 1008.638100 1032.094800 1055.551500 1079.008200 1102.464900 1125.921600"
194 "\[ \t\r\n\]+1149.378300 1172.835000 1196.291700 1219.748400 1243.205100 1266.661800 1290.118500 1313.575200"
195 "\[ \t\r\n\]+1337.031900 1360.488600 1383.945300 1407.402000 1430.858700 1454.315400 1477.772100 1501.228800"
196 "\[ \t\r\n\]+1524.685500 1548.142200 1571.598900 1595.055600 1618.512300 1641.969000 1665.425700 1688.882400"
197 "\[ \t\r\n\]+1712.339100 1735.795800 1759.252500 1782.709200 1806.165900 1829.622600 1853.079300 1876.536000"
198 "\[ \t\r\n\]+1899.992700 1923.449400 1946.906100 1970.362800 1993.819500 2017.276200 2040.732900 2064.189600"
199 "\[ \t\r\n\]+2087.646300 2111.103000 2134.559700 2158.016400 2181.473100 2204.929800 2228.386500 2251.843200"
200 "\[ \t\r\n\]+2275.299900 2298.756600 2322.213300\[ \t\r\n\]+\[ \t\r\n\]+"
201 ".*array_f :"
202 ".*student id :\[\t \]+.*YELLOW"
203 ".*array_i :"
204 ".*main \\(\\) at .*call-ar-st.c:1220\[ \t\r\n\]+.*print_all_arrays\\(integer_array, char_array, float_array, double_array\\)."
205}
c906108c
SS
206
207#step
208 send_gdb "step\n"
209 gdb_expect {
085dd6e6 210 -re "print_all_arrays \\(array_i=, array_c=.ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa., array_f=, array_d=\\) at .*call-ar-st.c:306\[ \t\r\n\]+306.*print_int_array\\(array_i\\);.*$gdb_prompt $" {pass "step inside print_all_arrays"}
c906108c
SS
211 -re ".*$gdb_prompt $" { fail "step inside print_all_arrays" }
212 timeout { fail "step inside print_all_arrays (timeout)" }
213 }
214
215
216#step -over
217 send_gdb "next\n"
218 gdb_expect {
085dd6e6 219 -re "array_i :.*307.*print_char_array\\(array_c\\);.*$gdb_prompt $" {pass "next over print_int_array in print-all_arrays"}
c906108c
SS
220 -re ".*$gdb_prompt $" { fail "next over print_int_array in print-all_arrays" }
221 timeout { fail "next over print_int_array in print-all_arrays (timeout)" }
222 }
223
224
225
226#call print_double_array(array_d)
9e086581
JM
227if {![target_info exists gdb,skip_float_tests]} {
228 send_gdb "print print_double_array(array_d)\n"
085dd6e6
JM
229 gdb_expect_list "print print_double_array(array_d)" ".*$gdb_prompt $" {
230 "array_d :"
231 "\[ \t\r\n\]+========="
232 "\[ \t\r\n\]+\[ \t\r\n\]+0.000000"
233 "\[ \t\r\n\]+23.456700 46.913400 70.370100 93.826800 117.283500 140.740200 164.196900 187.653600"
234 "\[ \t\r\n\]+211.110300 234.567000 258.023700 281.480400 304.937100 328.393800 351.850500 375.307200"
235 "\[ \t\r\n\]+398.763900 422.220600 445.677300 469.134000 492.590700 516.047400 539.504100 562.960800"
236 "\[ \t\r\n\]+586.417500 609.874200 633.330900 656.787600 680.244300 703.701000 727.157700 750.614400"
237 "\[ \t\r\n\]+774.071100 797.527800 820.984500 844.441200 867.897900 891.354600 914.811300 938.268000"
238 "\[ \t\r\n\]+961.724700 985.181400 1008.638100 1032.094800 1055.551500 1079.008200 1102.464900 1125.921600"
239 "\[ \t\r\n\]+1149.378300 1172.835000 1196.291700 1219.748400 1243.205100 1266.661800 1290.118500 1313.575200"
240 "\[ \t\r\n\]+1337.031900 1360.488600 1383.945300 1407.402000 1430.858700 1454.315400 1477.772100 1501.228800"
241 "\[ \t\r\n\]+1524.685500 1548.142200 1571.598900 1595.055600 1618.512300 1641.969000 1665.425700 1688.882400"
242 "\[ \t\r\n\]+1712.339100 1735.795800 1759.252500 1782.709200 1806.165900 1829.622600 1853.079300 1876.536000"
243 "\[ \t\r\n\]+1899.992700 1923.449400 1946.906100 1970.362800 1993.819500 2017.276200 2040.732900 2064.189600"
244 "\[ \t\r\n\]+2087.646300 2111.103000 2134.559700 2158.016400 2181.473100 2204.929800 2228.386500 2251.843200"
245 "\[ \t\r\n\]+2275.299900 2298.756600 2322.213300\[ \t\r\n\]+\[ \t\r\n\]+"
c906108c 246 }
9e086581 247}
c906108c 248
085dd6e6
JM
249#go -until 1236
250gdb_test "tbreak 1236" \
251"Breakpoint.* file .*$srcfile, line 1236.*" \
252"tbreakpoint line 1236"
c906108c 253
085dd6e6
JM
254send_gdb "continue\n"
255gdb_expect_list "continuing to 1236" ".*$gdb_prompt $" {
256 "Continuing\\..*array_c"
257 ".*array_f"
258 "\[ \t\r\n\]+array_d :"
259 "\[ \t\r\n\]+========="
260 "\[ \t\r\n\]+0.000000"
261 "\[ \t\r\n\]+23.456700 46.913400 70.370100 93.826800 117.283500 140.740200 164.196900 187.653600"
262 "\[ \t\r\n\]+211.110300 234.567000 258.023700 281.480400 304.937100 328.393800 351.850500 375.307200"
263 "\[ \t\r\n\]+398.763900 422.220600 445.677300 469.134000 492.590700 516.047400 539.504100 562.960800"
264 "\[ \t\r\n\]+586.417500 609.874200 633.330900 656.787600 680.244300 703.701000 727.157700 750.614400"
265 "\[ \t\r\n\]+774.071100 797.527800 820.984500 844.441200 867.897900 891.354600 914.811300 938.268000"
266 "\[ \t\r\n\]+961.724700 985.181400 1008.638100 1032.094800 1055.551500 1079.008200 1102.464900 1125.921600"
267 "\[ \t\r\n\]+1149.378300 1172.835000 1196.291700 1219.748400 1243.205100 1266.661800 1290.118500 1313.575200"
268 "\[ \t\r\n\]+1337.031900 1360.488600 1383.945300 1407.402000 1430.858700 1454.315400 1477.772100 1501.228800"
269 "\[ \t\r\n\]+1524.685500 1548.142200 1571.598900 1595.055600 1618.512300 1641.969000 1665.425700 1688.882400"
270 "\[ \t\r\n\]+1712.339100 1735.795800 1759.252500 1782.709200 1806.165900 1829.622600 1853.079300 1876.536000"
271 "\[ \t\r\n\]+1899.992700 1923.449400 1946.906100 1970.362800 1993.819500 2017.276200 2040.732900 2064.189600"
272 "\[ \t\r\n\]+2087.646300 2111.103000 2134.559700 2158.016400 2181.473100 2204.929800 2228.386500 2251.843200"
273 "\[ \t\r\n\]+2275.299900 2298.756600 2322.213300.*HELLO WORLD.*main \\(\\) at .*call-ar-st.c:1236.*printf\\(.BYE BYE FOR NOW.n.\\)."
274}
c906108c
SS
275
276
277#call sum_array_print(10, *list1, *list2, *list3, *list4)
b83266a0 278
c906108c
SS
279send_gdb "print sum_array_print(10, *list1, *list2, *list3, *list4)\n"
280gdb_expect {
281 -re ".*Sum of 4 arrays, by element \\(add in seed as well\\):\[ \t\r\n\]+Seed: 10\[ \t\r\n\]+Element Index . Sum\[ \t\r\n\]+-------------------------\[ \t\r\n\]+.*\[ \t\]+0\[ \t\]+52\[ \t\r\n\]+1\[ \t\]+60\[ \t\r\n\]+2\[ \t\]+68\[ \t\r\n\]+3\[ \t\]+76\[ \t\r\n\]+4\[ \t\]+84\[ \t\r\n\]+5\[ \t\]+92\[ \t\r\n\]+6\[ \t\]+100\[ \t\r\n\]+7\[ \t\]+108\[ \t\r\n\]+8\[ \t\]+116\[ \t\r\n\]+9\[ \t\]+124\[ \t\r\n\]+.*$gdb_prompt $" {
282 pass "print sum_array_print(10, *list1, *list2, *list3, *list4)"
283 }
284 -re ".*$gdb_prompt $" { fail "print sum_array_print(10, *list1, *list2, *list3, *list4)" }
285 timeout { fail "(timeout) print sum_array_print(10, *list1, *list2, *list3, *list4)" }
286 }
287
b83266a0
SS
288#step over
289send_gdb "n\n"
290gdb_expect {
085dd6e6
JM
291 -re ".*BYE BYE FOR NOW.*1237.*printf\\(.VERY GREEN GRASS.n.\\);.*$gdb_prompt $" { pass "next to 1237"}
292 -re ".*$gdb_prompt $" { fail "next to 1237" }
293 timeout { fail "next to 1237(timeout)" }
b83266a0 294}
c906108c
SS
295
296#call print_array_rep(\*list1, \*list2, \*list3)
297
298send_gdb "print print_array_rep(\*list1, \*list2, \*list3)\n"
299gdb_expect {
b83266a0 300 -re ".*$gdb_prompt $" {
c906108c
SS
301 pass "print print_array_rep(*list1, *list2, *list3)"
302 }
303 -re ".*$gdb_prompt $" { fail "print print_array_rep(*list1, *list2, *list3)" }
7a292a7a 304 timeout { fail "(timeout) print print_array_rep(*list1, *list2, *list3)" }
c906108c
SS
305 }
306
085dd6e6
JM
307#go -until 1241
308gdb_test "tbreak 1241" \
309 "Breakpoint..* file .*$srcfile, line 1241.*" \
310 "tbreakpoint line 1241"
c906108c
SS
311
312send_gdb "continue\n"
313gdb_expect {
085dd6e6
JM
314 -re ".*main \\(\\) at .*call-ar-st.c:1241\r\n1241\t\[ \]+sum_array_print\\(10, \\*list1, \\*list2, \\*list3, \\*list4\\);.*$gdb_prompt $" {
315 pass "continue to 1241"}
316 -re ".*$gdb_prompt $" { fail "continue to 1241"}
317 timeout { fail "(timeout) continue to 1241"}
c906108c
SS
318}
319
320
321
322# Run into sum_array_print, and verify that the arguments were passed
323# accurately.
324#
325# Note that we shouldn't use a `step' here to get into
326# sum_array_print; GCC may emit calls to memcpy to put the arguments
327# in the right place, and a step may end up in memcpy instead. This
328# may itself be a bug, but it's not the one we're trying to catch
329# here. I've added something to step-test.exp for this.
330gdb_test "break sum_array_print" \
331 ".*Breakpoint ${decimal}: file .*call-ar-st.c, line.*" \
332 "set breakpoint in sum_array_print"
333gdb_test "continue" \
085dd6e6 334 ".*Breakpoint ${decimal}, sum_array_print \\(seed=10, linked_list1=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .4, 6, 8, 10, 12, 14, 16, 18, 20, 22., head = 0., linked_list2=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .8, 10, 12, 14, 16, 18, 20, 22, 24, 26., head = 0., linked_list3=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .10, 12, 14, 16, 18, 20, 22, 24, 26, 28., head = 0., linked_list4=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .20, 22, 24, 26, 28, 30, 32, 34, 36, 38., head = 0.\\) at .*call-ar-st.c:1105\[ \t\n\r\]+1105.*printf\\(.Sum of 4 arrays, by element \\(add in seed as well\\).*\\);.*" \
c906108c
SS
335 "check args of sum_array_print"
336
337#call print_array_rep(linked_list1, linked_list2, linked_list3)
338# this calls works from gdb without gdb_expect. But it does seem to hang
339#from within gdb_expect.
340#I comment this out
341#send_gdb "print print_array_rep(linked_list1, linked_list2, linked_list3)\n"
342#gdb_expect {
343# -re ".*Contents of linked list1:\[ \t\n\r\]+Element Value . Index of Next Element\[ \t\n\r\]+-------------------------------------\[ \t\n\r\]+.*\[ \t\n\r\]+.*4.*1\[ \t\n\r\]+.*6.*2\[ \t\n\r\]+.*8.*3\[ \t\n\r\]+.*10.*4\[ \t\n\r\]+.*12.*5\[ \t\n\r\]+.*14.*6\[ \t\n\r\]+.*16.*7\[ \t\n\r\]+.*18.*8\[ \t\n\r\]+.*20.*9\[ \t\n\r\]+.*22.*10\[ \t\n\r\]+Contents of linked list2:\[ \t\n\r\]+Element Value | Index of Next Element\[ \t\n\r\]+-------------------------------------\[ \t\n\r\]+.*\[ \t\n\r\]+.*8.*1\[ \t\n\r\]+.*10.*2\[ \t\n\r\]+.*12.*3\[ \t\n\r\]+.*14.*4\[ \t\n\r\]+.*16.*5\[ \t\n\r\]+.*18.*6\[ \t\n\r\]+.*20.*7\[ \t\n\r\]+.*22.*8\[ \t\n\r\]+.*24.*9\[ \t\n\r\]+.*26.*10\[ \t\n\r\]+Contents of linked list3:\[ \t\n\r\]+Element Value | Index of Next Element\[ \t\n\r\]+-------------------------------------\[ \t\n\r\]+.*\[ \t\n\r\]+.*10.*1\[ \t\n\r\]+.*12.*2\[ \t\n\r\]+.*14.*3\[ \t\n\r\]+.*16.*4\[ \t\n\r\]+.*18.*5\[ \t\n\r\]+.*20.*6\[ \t\n\r\]+.*22.*7\[ \t\n\r\]+.*24.*8\[ \t\n\r\]+.*26.*9\[ \t\n\r\]+.*28.*10\[ \t\n\r\]+.*$gdb_prompt $" {
344# pass "print print_array_rep(linked_list1, linked_list2, linked_list3)"
345# }
346# -re ".*$gdb_prompt $" { fail "print print_array_rep(linked_list1, linked_list2, linked_list3)" }
347# timeout { fail "(timeout) print print_array_rep(linked_list1, linked_list2, linked_list3)" }
348#}
349
350
085dd6e6
JM
351#go -until 1281
352gdb_test "tbreak 1281" \
353 "Breakpoint.* file .*call-ar-st.c, line 1281.*" \
354 "tbreakpoint line 1281"
c906108c
SS
355
356send_gdb "continue\n"
357gdb_expect {
085dd6e6
JM
358 -re "Continuing\\..*Sum of 4 arrays.*Contents of linked list1.*Contents of two_floats_t.*main \\(\\) at .*call-ar-st.c:1281.*c = 0.*$gdb_prompt $" {
359 pass "continue to 1281"}
360 -re ".*$gdb_prompt $" { fail "continue to 1281"}
361 timeout { fail "(timeout) continue to 1281"}
c906108c
SS
362}
363
364#call print_small_structs(*struct1, *struct2, *struct3, *struct4,*flags, *flags_combo,
365#*three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3)
9e086581
JM
366if {![target_info exists gdb,skip_float_tests]} {
367 send_gdb "print print_small_structs(*struct1, *struct2, *struct3, *struct4, *flags, *flags_combo, *three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3)\n"
368 gdb_expect {
c906108c 369 -re ".*alpha\[\t\r\n \]+gamma\[\t\r\n \]+epsilon\[\t\r\n \]+alpha\[\t\r\n \]+gamma\[\t\r\n \]+epsilon\[\t\r\n \]+ch1: y\tch2: n\[\t\r\n \]+Contents of three_char_t:\[\t\r\n \]+a\tb\tc\[\t\r\n \]+Contents of five_char_t:\[\t\r\n \]+l\tm\tn\to\tp\[\t\r\n \]+Contents of int_char_combo_t:\[\t\r\n \]+123.*z\[\t\r\n \]+Sum of the 4 struct values and seed :\[\t\r\n \]+52\[\t\r\n \]+Contents of struct1:\[\t\r\n \]+6.*0\[\t\r\n \]+Contents of struct2:\[\t\r\n \]+10.*0\[\t\r\n \]+Contents of struct3:\[\t\r\n \]+12.*0\[\t\r\n \]+Contents of one_double_t:\[\t\r\n \]+10.500000\[\t\r\n \]+Contents of one_double_t:.*-3.340000\[\t\r\n \]+Contents of one_double_t:.*675.091230\[\t\r\n \]+Contents of two_floats_t:.*45.234001.*43.599998\[\t\r\n \]+Contents of two_floats_t:.*78.010002.*122.099998\[\t\r\n \]+Contents of two_floats_t:.*-1232.344971.*-199.210007\[\t\r\n \]+.*$gdb_prompt $" {
9e086581
JM
370 pass "print print_small_structs"
371 }
c906108c
SS
372 -re ".*$gdb_prompt $" { fail "print print_small_structs" }
373 timeout { fail "(timeout) print_small_structs" }
374 }
9e086581 375}
c906108c
SS
376
377#call compute_with_small_structs(20)
378send_gdb "print compute_with_small_structs(20)\n"
379gdb_expect {
380 -re ".*\[0-9\]+ =.*$gdb_prompt $" {
381 pass "print compute_with_small_structs(20)"
382 }
383 -re ".*$gdb_prompt $" { fail "print compute_with_small_structs(20)" }
384 timeout { fail "(timeout) compute_with_small_structs(20)" }
385 }
386
387
388#call print_ten_doubles(123.456, 123.456, -0.12, -1.23, 343434.8, 89.098, 3.14, -5678.12345, -0.11111111, 216.97065)
9e086581
JM
389if {![target_info exists gdb,skip_float_tests]} {
390 send_gdb "print print_ten_doubles(123.456, 123.456, -0.12, -1.23, 343434.8, 89.098, 3.14, -5678.12345, -0.11111111, 216.97065)\n"
391 gdb_expect {
c906108c 392 -re ".*Two Doubles : 123.456000.*123.456000\[\t\r\n \]+Two Doubles : -0.120000.*-1.230000\[\t\r\n \]+Two Doubles : 343434.800000.*89.098000\[\t\r\n \]+Two Doubles : 3.140000.*-5678.123450\[\t\r\n \]+Two Doubles : -0.111111.*216.970650\[\t\r\n \]+.*$gdb_prompt $" {
9e086581
JM
393 pass "print print_ten_doubles"
394 }
c906108c
SS
395 -re ".*$gdb_prompt $" { fail "print print_ten_doubles" }
396 timeout { fail "(timeout) print_ten_doubles" }
397 }
9e086581 398}
c906108c 399
085dd6e6
JM
400#go -until 1286
401gdb_test "tbreak 1286" \
402 "Breakpoint .* file .*call-ar-st.c, line 1286.*" \
403 "tbreakpoint line 1286"
404
405gdb_test continue "Continuing\\..*main \\(.*\\) at.*call-ar-st.c:1286\[\t\r\n \]+1286.*print_long_arg_list \\( a, b, c, d, e, f, .struct1, .struct2, .struct3, .struct4,.*" "continue to 1286"
406
407if { [istarget "hppa*-*-hpux*"] } {
408 #
409 # NOTE:(FIXME)
410 # the aCC demangler cannot demangle the name of a function with >10 args.
411 # so I added a .* after the name of the function, to match the
412 # incredibly long mangled name
413 # (getting aCC's libdemangle.a bundled w/ the system?)
414 # DTS CLLbs16994 coulter 990114
415 #
416 # FIXME: use step for hppa* testing for now
417 # guo 990621
418 #
419 send_gdb "step\n"
420 gdb_expect {
421 -re ".*print_long_arg_list.*\\(a=22.219999999999999, b=33.332999999999998, c=0, d=-25, e=100, f=2345, struct1=\{value = 6, head = 0\}, struct2=\{value = 10, head = 0\}, struct3=\{value = 12, head = 0\}, struct4=\{value = 14, head = 0\}, flags=\{alpha = 1, beta = 0, gamma = 1, delta = 0, epsilon = 1, omega = 0\}, flags_combo=\{alpha = 1, beta = 0, ch1 = 121 \'y\', gamma = 1, delta = 0, ch2 = 110 \'n\', epsilon = 1, omega = 0\}, three_char=\{ch1 = 97 \'a\', ch2 = 98 \'b\', ch3 = 99 \'c\'\}, five_char=\{ch1 = 108 \'l\', ch2 = 109 \'m\', ch3 = 110 \'n\', ch4 = 111 \'o\', ch5 = 112 \'p\'\}, int_char_combo=\{int1 = 123, ch1 = 122 \'z\'\}, d1=\{double1 = 10.5\}, d2=\{double1 = -3.3399999999999999\}, d3=\{double1 = 675.09123\}, f1=\{float1 = 45.2340012, float2 = 43.5999985\}, f2=\{float1 = 78.0100021, float2 = 122.099998\}, f3=\{float1 = -1232.34497, float2 = -199.210007\}\\) at ${srcdir}/${subdir}/${srcfile}:992\[\r\n\]+992\[ \t\]+printf\\(\"double :.*\", a\\);.*$gdb_prompt $" {pass "step into print_long_arg_list"}
422 -re ".*$gdb_prompt $" { fail "step into print_long_arg_list" }
423 timeout { fail "step into print_long_arg_list (timeout)" }
424 }
9e086581 425} else {
085dd6e6
JM
426
427 # We can't just assume that a "step" will get us into print_long_arg_list here,either.
428 gdb_test "tbreak print_long_arg_list" \
429 "Breakpoint .* file .*call-ar-st.c, line .*" \
430 "tbreak in print_long_arg_list after stepping into memcpy"
431 send_gdb "continue\n"
432 if {![target_info exists gdb,skip_float_tests]} {
433 gdb_expect {
434 -re ".*print_long_arg_list \\(a=22.219999999999999, b=33.332999999999998, c=0, d=-25, e=100, f=2345, struct1=\{value = 6, head = 0\}, struct2=\{value = 10, head = 0\}, struct3=\{value = 12, head = 0\}, struct4=\{value = 14, head = 0\}, flags=\{alpha = 1, beta = 0, gamma = 1, delta = 0, epsilon = 1, omega = 0\}, flags_combo=\{alpha = 1, beta = 0, ch1 = 121 \'y\', gamma = 1, delta = 0, ch2 = 110 \'n\', epsilon = 1, omega = 0\}, three_char=\{ch1 = 97 \'a\', ch2 = 98 \'b\', ch3 = 99 \'c\'\}, five_char=\{ch1 = 108 \'l\', ch2 = 109 \'m\', ch3 = 110 \'n\', ch4 = 111 \'o\', ch5 = 112 \'p\'\}, int_char_combo=\{int1 = 123, ch1 = 122 \'z\'\}, d1=\{double1 = 10.5\}, d2=\{double1 = -3.3399999999999999\}, d3=\{double1 = 675.09123\}, f1=\{float1 = 45.2340012, float2 = 43.5999985\}, f2=\{float1 = 78.0100021, float2 = 122.099998\}, f3=\{float1 = -1232.34497, float2 = -199.210007\}\\) at ${srcdir}/${subdir}/${srcfile}:992\[\r\n\]+992\[ \t\]+printf\\(\"double :.*\", a\\);.*$gdb_prompt $" {pass "step into print_long_arg_list"}
435 -re ".*$gdb_prompt $" { fail "step into print_long_arg_list" }
436 timeout { fail "step into print_long_arg_list (timeout)" }
437 }
438 } else {
439 gdb_expect {
440 -re ".*print_long_arg_list \\(.*\\).*$gdb_prompt $" { pass "step into print_long_arg_list" }
441 -re ".*$gdb_prompt $" { fail "step into print_long_arg_list" }
442 timeout { fail "step into print_long_arg_list (timeout)" }
443 }
444 }
9e086581 445}
c906108c
SS
446
447#call print_small_structs(struct1, struct2, struct3, struct4, flags, flags_combo, three_char, five_char, int_char_combo, d1, d2, d3, f1, f2, f3)
9e086581
JM
448if {![target_info exists gdb,skip_float_tests]} {
449 send_gdb "print print_small_structs(struct1, struct2, struct3, struct4, flags, flags_combo, three_char, five_char, int_char_combo, d1, d2, d3, f1, f2, f3)\n"
450 gdb_expect {
c906108c 451 -re ".*alpha\[\t\r\n \]+gamma\[\t\r\n \]+epsilon\[\t\r\n \]+alpha\[\t\r\n \]+gamma\[\t\r\n \]+epsilon\[\t\r\n \]+ch1: y\tch2: n\[\t\r\n \]+Contents of three_char_t:\[\t\r\n \]+a\tb\tc\[\t\r\n \]+Contents of five_char_t:\[\t\r\n \]+l\tm\tn\to\tp\[\t\r\n \]+Contents of int_char_combo_t:\[\t\r\n \]+123.*z\[\t\r\n \]+Sum of the 4 struct values and seed :\[\t\r\n \]+52\[\t\r\n \]+Contents of struct1:\[\t\r\n \]+6.*0\[\t\r\n \]+Contents of struct2:\[\t\r\n \]+10.*0\[\t\r\n \]+Contents of struct3:\[\t\r\n \]+12.*0\[\t\r\n \]+Contents of one_double_t:\[\t\r\n \]+10.500000\[\t\r\n \]+Contents of one_double_t:\[\t\r\n \]+-3.340000\[\t\r\n \]+Contents of one_double_t:\[\t\r\n \]+675.091230\[\t\r\n \]+Contents of two_floats_t:\[\t\r\n \]+45.234001.*43.599998\[\t\r\n \]+Contents of two_floats_t:\[\t\r\n \]+78.010002.*122.099998\[\t\r\n \]+Contents of two_floats_t:\[\t\r\n \]+-1232.344971.*-199.210007\[\t\r\n \]+.*$gdb_prompt $" {
9e086581
JM
452 pass "print print_small_structs from print_long_arg_list "
453 }
c906108c
SS
454 -re ".*$gdb_prompt $" { fail "print print_small_structs from print_long_arg_list" }
455 timeout { fail "(timeout) print_small_structs from print_long_arg_list" }
456 }
9e086581 457}
c906108c
SS
458
459
085dd6e6
JM
460#go -until 1300
461gdb_test "tbreak 1300" \
462 "Breakpoint.* file .*call-ar-st.c, line 1300.*" \
463 "tbreakpoint line 1300"
464
465gdb_test continue "Continuing\\..*Contents of two_floats_t:.*main \\(\\) at.*call-ar-st.c:1300.*1300.*init_bit_flags_combo\\(flags_combo, \\(unsigned\\)1, \\(unsigned\\)0, .y.,.*" \
466 "continue to 1300"
467
c906108c 468
085dd6e6
JM
469# FIXME:
470# HP aCC demangler currently does not handle hp aCC functions with >10 args
471# DTS CLLbs16994 coulter 990114
c906108c 472
085dd6e6 473if {$hp_aCC_compiler} {setup_xfail "hppa*-*-*"}
c906108c
SS
474#step
475 send_gdb "step\n"
476 gdb_expect {
477 -re "
085dd6e6 478init_bit_flags_combo \\(bit_flags_combo=, a=1, b=0, ch1=121 .y., g=1, d=0, ch2=110 .n., e=1, o=0\\) at .*call-ar-st.c:416\[ \t\n\r\]+416.*bit_flags_combo->alpha = a;.*$gdb_prompt $" {
c906108c
SS
479 pass "step into init_bit_flags_combo"}
480 -re ".*$gdb_prompt $" { fail "step into init_bit_flags_combo" }
481 timeout { fail "step into init_bit_flags_combo (timeout)" }
482 }
483
484#call print_bit_flags_combo(*bit_flags_combo)
485send_gdb "print print_bit_flags_combo(*bit_flags_combo)\n"
486gdb_expect {
487 -re ".*alpha.*gamma.*epsilon.*ch1: y\tch2: n.*$gdb_prompt $" {
488 pass "print print_bit_flags_combo from init_bit_flags_combo"
489 }
490 -re ".*$gdb_prompt $" { fail "print print_bit_flags_combo from init_bit_flags_combo" }
491 timeout { fail "(timeout) print_bit_flags_combo from init_bit_flags_combo" }
492 }
493
494
085dd6e6
JM
495#go -until 1305
496gdb_test "tbreak 1305" \
497 "Breakpoint.* file .*call-ar-st.c, line 1305.*" \
498 "tbreakpoint line 1305"
c906108c 499
085dd6e6
JM
500gdb_test continue "Continuing\\..*main \\(\\) at .*call-ar-st.c:1305\[\r\n\t \]+1305.*init_int_char_combo\\(int_char_combo, 13, .!.\\);" \
501"continue to 1305"
c906108c
SS
502
503#call print_long_arg_list(a, b, c, d, e, f, *struct1, *struct2, *struct3, *struct4, *flags, *flags_combo, *three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3)
9e086581
JM
504if {![target_info exists gdb,skip_float_tests]} {
505 send_gdb "print print_long_arg_list(a, b, c, d, e, f, *struct1, *struct2, *struct3, *struct4, *flags, *flags_combo, *three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3)\n"
506 gdb_expect {
c906108c 507 -re ".*double : 22.220000.*double : 33.333000.*int : 0.*int : -25.*int : 100.*int : 2345.*alpha.*gamma.*epsilon.*ch1: y\tch2: n.*Contents of three_char_t:.*x\ty\tz.*Contents of five_char_t:.*h\te\tl\tl\to.*Contents of int_char_combo_t:.*123\tz.*Sum of the 4 struct values and seed :.*52.*Contents of struct1:.*6\[ \]+0.*Contents of struct2:.*10\[ \]+0.*Contents of struct3:.*12.*0.*Contents of one_double_t:\[ \n\r\t\]+1.111110\[ \n\r\t\]+Contents of one_double_t:\[ \n\r\t\]+-345.340000\[ \n\r\t\]+Contents of one_double_t:\[ \n\r\t\]+546464.200000\[ \n\r\t\]+Contents of two_floats_t:\[ \n\r\t\]+0.234000\t453.100006\[ \n\r\t\]+Contents of two_floats_t:\[ \n\r\t\]+78.345001\t23.090000\[ \n\r\t\]+Contents of two_floats_t:\[ \n\r\t\]+-2.345000\t1.000000.*$gdb_prompt $" {
9e086581
JM
508 pass "print print_long_arg_list"
509 }
c906108c
SS
510 -re ".*$gdb_prompt $" { fail "print print_long_arg_list" }
511 timeout { fail "(timeout) print_long_arg_list" }
512 }
9e086581 513}
c906108c
SS
514
515
085dd6e6
JM
516#go -until 1311
517gdb_test "tbreak 1311" \
518 "Breakpoint.* file .*call-ar-st.c, line 1311.*" \
519 "tbreakpoint line 1311"
c906108c 520
085dd6e6
JM
521gdb_test continue "Continuing\\..*main \\(\\) at .*call-ar-st.c:1311\[ \t\n\r\]+1311.*compute_with_small_structs\\(35\\);" \
522"continue to 1311"
c906108c
SS
523
524
525#call sum_struct_print(10, *struct1, *struct2, *struct3, *struct4)
526send_gdb "print sum_struct_print(10, *struct1, *struct2, *struct3, *struct4)\n"
527gdb_expect {
528 -re ".*Sum of the 4 struct values and seed :\[ \t\n\r\]+218.*$gdb_prompt $" {
529 pass "print sum_struct_print(10, *struct1, *struct2, *struct3, *struct4)"
530 }
531 -re ".*$gdb_prompt $" { fail "print sum_struct_print(10, *struct1, *struct2, *struct3, *struct4)" }
532 timeout { fail "(timeout) sum_struct_print(10, *struct1, *struct2, *struct3, *struct4)" }
533 }
534
535
536#call print_struct_rep(*struct1, *struct2, *struct3)
537send_gdb "print print_struct_rep(*struct1, *struct2, *struct3)\n"
538gdb_expect {
539 -re ".*Contents of struct1:\[ \t\n\r\]+ 22 0\[ \t\n\r\]+Contents of struct2:\[ \t\n\r\]+ 42 0\[ \t\n\r\]+Contents of struct3:\[ \t\n\r\]+ 62 0\[ \t\n\r\]+.*$gdb_prompt $" {
540 pass "print print_struct_rep(*struct1, *struct2, *struct3)"
541 }
542 -re ".*$gdb_prompt $" { fail "print print_struct_rep(*struct1, *struct2, *struct3)" }
543 timeout { fail "(timeout) print_struct_rep(*struct1, *struct2, *struct3)" }
544 }
545
546send_gdb "print print_one_large_struct(*list1)\n"
547gdb_expect {
548 -re ".* 4 1.*$gdb_prompt $" {
549 pass "print print_one_large_struct(*list1)"
550 }
551 -re ".*$gdb_prompt $" { fail "print print_one_large_struct(*list1)" }
552 timeout { fail "(timeout) print_one_large_struct(*list1)" }
553 }
554
555return
556
557~
This page took 0.052126 seconds and 4 git commands to generate.