1# Copyright 1998-2017 Free Software Foundation, Inc. 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 5# the Free Software Foundation; either version 3 of the License, or 6# (at your option) any later version. 7# 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. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16# This file was written by Elena Zannoni (ezannoni@cygnus.com) 17 18 19 20standard_testfile 21 22# Some targets can't call functions, so don't even bother with this 23# test. 24if [target_info exists gdb,cannot_call_functions] { 25 unsupported "this target can not call functions" 26 continue 27} 28 29# Create and source the file that provides information about the compiler 30# used to compile the test case. 31 32if [get_compiler_info] { 33 return -1 34} 35 36set skip_float_test [gdb_skip_float_test] 37 38if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { 39 return -1 40} 41 42 43set oldtimeout $timeout 44set timeout [expr "$timeout + 60"] 45 46gdb_test_no_output "set print sevenbit-strings" 47gdb_test_no_output "set print address off" 48gdb_test_no_output "set width 0" 49 50 51if ![runto_main] then { 52 perror "couldn't run to breakpoint" 53 continue 54} 55 56get_debug_format 57 58set stop_line [gdb_get_line_number "-tbreak1-"] 59gdb_test "tbreak $stop_line" \ 60 "Temporary breakpoint ${decimal}.*file.*$srcfile, line $stop_line.*" \ 61 "tbreakpoint at tbreak1" 62 63gdb_test continue \ 64"Continuing\\..*main \\(\\) at.*$srcfile:$stop_line.*" \ 65"run until breakpoint set at a line" 66 67 68#call print_double_array(double_array) 69if {!$skip_float_test && \ 70 ![gdb_skip_stdio_test "print print_double_array(double_array)"] } { 71 72 gdb_test_stdio "print print_double_array(double_array)" \ 73 [multi_line \ 74 "array_d :" \ 75 "=========" \ 76 "" \ 77 "0.000000 *" \ 78 "23.456\[0-9\]* 46.913\[0-9\]* 70.370\[0-9\]* 93.826\[0-9\]* 117.283\[0-9\]* 140.740\[0-9\]* 164.196\[0-9\]* 187.653\[0-9\]"] 79} 80 81#call print_char_array(char_array) 82 83set array_c_re \ 84 [multi_line \ 85 "array_c :" \ 86 "=========" \ 87 "" \ 88 "Z" \ 89 "aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ" \ 90 "aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ" \ 91 "aZaZaZaZaZaZaZaZaZa"] 92 93if ![gdb_skip_stdio_test "print_char_array(char_array)"] { 94 gdb_test_stdio "print print_char_array(char_array)" $array_c_re 95} 96 97set stop_line [gdb_get_line_number "-tbreak2-"] 98gdb_test "tbreak $stop_line" \ 99"Temporary breakpoint.*file.*$srcfile, line $stop_line.*" \ 100"tbreakpoint at tbreak2" 101 102if ![gdb_skip_stdio_test "continue to tbreak2"] { 103 set gdb_re \ 104 [multi_line \ 105 "main.*at.*:\[0-9\]+" \ 106 "\[0-9\]+.*print_double_array\\(double_array\\).*"] 107 gdb_test_stdio "continue" $array_c_re $gdb_re "continue to tbreak2" 108} else { 109 gdb_test "continue" ".*" "" 110} 111 112# I am disabling this test, because it takes too long. I verified by 113# hand that it works, feel free to check for yourself. 114#call print_all_arrays(integer_array, char_array, float_array, double_array) 115#send_gdb "print print_all_arrays(integer_array, char_array, float_array, double_array)\n" 116#gdb_expect { 117# -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 $" { 118# pass "print print_all_arrays(integer_array, char_array, float_array, double_array)" 119# } 120# -re ".*$gdb_prompt $" { fail "print print_all_arrays(integer_array, char_array, float_array, double_array)" } 121# timeout { fail "(timeout) print print_all_arrays(integer_array, char_array, float_array, double_array)" } 122# } 123 124#set timeout $oldtimeout 125set stop_line [gdb_get_line_number "-tbreak3-"] 126gdb_test "tbreak $stop_line" \ 127 "Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \ 128 "tbreakpoint at tbreak3" 129 130if {!$skip_float_test && \ 131 ![gdb_skip_stdio_test "continuing to tbreak3"] } { 132 133 gdb_test_stdio "continue" \ 134 [multi_line \ 135 "array_d :" \ 136 "=========" \ 137 "" \ 138 "0.000000 *" \ 139 "23.456\[0-9\]* 46.913\[0-9\]* 70.370\[0-9\]* 93.826\[0-9\]* 117.283\[0-9\]* 140.740\[0-9\]* 164.196\[0-9\]* 187.653\[0-9\]* *" \ 140 "" \ 141 "" \ 142 "array_f :" \ 143 ".*" \ 144 "student id :\[\t \]+.*YELLOW" \ 145 "array_i :" \ 146 ] \ 147 "main \\(\\) at .*call-ar-st.c:\[0-9\]+\[ \t\r\n\]+.*print_all_arrays\\(integer_array, char_array, float_array, double_array\\)..*" \ 148 "continuing to tbreak3" 149 150} else { 151 gdb_test "continue" ".*" "" 152} 153 154#step 155set stop_line [gdb_get_line_number "-step1-"] 156gdb_test "step" \ 157 "print_all_arrays \\(array_i=<integer_array.*>, array_c=<char_array.*> .ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa., array_f=<float_array.*>, array_d=<double_array.*>\\) at .*$srcfile:$stop_line\[ \t\r\n\]+$stop_line.*print_int_array\\(array_i\\);.*" \ 158 "step inside print_all_arrays" 159 160#step -over 161if ![gdb_skip_stdio_test "next over print_int_array in print_all_arrays"] { 162 set stop_line [gdb_get_line_number "-next1-"] 163 gdb_test_stdio "next" \ 164 "array_i :" \ 165 "$stop_line.*print_char_array.*" \ 166 "next over print_int_array in print-all_arrays" 167} else { 168 gdb_test "next" ".*" "" 169} 170 171#call print_double_array(array_d) 172if {!$skip_float_test && \ 173 ![gdb_skip_stdio_test "print print_double_array(array_d)"] } { 174 175 gdb_test_stdio "print print_double_array(array_d)" \ 176 [multi_line \ 177 "array_d :" \ 178 "=========" \ 179 "" \ 180 "0.000000 *" \ 181 "23.456\[0-9\]* 46.913\[0-9\]* 70.370\[0-9\]* 93.826\[0-9\]* 117.283\[0-9\]* 140.740\[0-9\]* 164.196\[0-9\]* 187.653\[0-9\]*" \ 182 ] 183} 184 185set stop_line [gdb_get_line_number "-tbreak4-"] 186gdb_test "tbreak $stop_line" \ 187"Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \ 188"tbreakpoint at tbreak4" 189 190if {!$skip_float_test && \ 191 ![gdb_skip_stdio_test "continuing to tbreak4"] } { 192 193 gdb_test_stdio "continue" \ 194 [multi_line \ 195 "array_d :" \ 196 "=========" \ 197 "" \ 198 "0.000000 *" \ 199 "23.456\[0-9\]* 46.913\[0-9\]* 70.370\[0-9\]* 93.826\[0-9\]* 117.283\[0-9\]* 140.740\[0-9\]* 164.196\[0-9\]* 187.653\[0-9\]*" \ 200 ] \ 201 "" \ 202 "continuing to tbreak4" 203} else { 204 gdb_test "continue" ".*" "" 205} 206 207 208#call sum_array_print(10, *list1, *list2, *list3, *list4) 209 210if ![gdb_skip_stdio_test "print sum_array_print(...)"] { 211 212 gdb_test_stdio "print sum_array_print(10, *list1, *list2, *list3, *list4)" \ 213 [multi_line \ 214 "Sum of 4 arrays, by element \\(add in seed as well\\): " \ 215 "" \ 216 "Seed: 10" \ 217 "Element Index . Sum " \ 218 "-------------------------" \ 219 ".*" \ 220 "\[ \t\]+0\[ \t\]+52" \ 221 "\[ \t\]+1\[ \t\]+60" \ 222 "\[ \t\]+2\[ \t\]+68" \ 223 "\[ \t\]+3\[ \t\]+76" \ 224 "\[ \t\]+4\[ \t\]+84" \ 225 "\[ \t\]+5\[ \t\]+92" \ 226 "\[ \t\]+6\[ \t\]+100" \ 227 "\[ \t\]+7\[ \t\]+108" \ 228 "\[ \t\]+8\[ \t\]+116" \ 229 "\[ \t\]+9\[ \t\]+124" \ 230 ] 231} 232 233#step over 234set stop_line [gdb_get_line_number "-next2-"] 235if ![gdb_skip_stdio_test "next to next2"] { 236 gdb_test_stdio "next" \ 237 "BYE BYE FOR NOW" \ 238 "$stop_line.*printf\\(.VERY GREEN GRASS.n.\\);.*" \ 239 "next to next2" 240} else { 241 gdb_test "next" ".*" "" 242} 243 244#call print_array_rep(\*list1, \*list2, \*list3) 245 246if ![gdb_skip_stdio_test "print print_array_rep(...)"] { 247 gdb_test_stdio "print print_array_rep(\*list1, \*list2, \*list3)" \ 248 "Contents of linked list3:" 249} 250 251set stop_line [gdb_get_line_number "-tbreak5-"] 252gdb_test "tbreak $stop_line" \ 253 "Temporary breakpoint..* file .*$srcfile, line $stop_line.*" \ 254 "tbreakpoint at tbreak5" 255 256gdb_test "continue" \ 257 "main \\(\\) at .*$srcfile:$stop_line\r\n$stop_line\[\t \]+sum_array_print\\(10, \\*list1, \\*list2, \\*list3, \\*list4\\);.*" \ 258 "continue to tbreak5" 259 260 261# Run into sum_array_print, and verify that the arguments were passed 262# accurately. 263# 264# Note that we shouldn't use a `step' here to get into 265# sum_array_print; GCC may emit calls to memcpy to put the arguments 266# in the right place, and a step may end up in memcpy instead. This 267# may itself be a bug, but it's not the one we're trying to catch 268# here. I've added something to step-test.exp for this. 269gdb_test "break sum_array_print" \ 270 ".*Breakpoint ${decimal}: file .*$srcfile, line.*" \ 271 "set breakpoint in sum_array_print" 272gdb_test_no_output "set print frame-arguments all" 273gdb_test "continue" \ 274 ".*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 .*$srcfile:${decimal}\[ \t\n\r\]+${decimal}.*printf\\(.Sum of 4 arrays, by element \\(add in seed as well\\).*\\);.*" \ 275 "check args of sum_array_print" 276 277#call print_array_rep(linked_list1, linked_list2, linked_list3) 278# this calls works from gdb without gdb_expect. But it does seem to hang 279#from within gdb_expect. 280#I comment this out 281#send_gdb "print print_array_rep(linked_list1, linked_list2, linked_list3)\n" 282#gdb_expect { 283# -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 $" { 284# pass "print print_array_rep(linked_list1, linked_list2, linked_list3)" 285# } 286# -re ".*$gdb_prompt $" { fail "print print_array_rep(linked_list1, linked_list2, linked_list3)" } 287# timeout { fail "(timeout) print print_array_rep(linked_list1, linked_list2, linked_list3)" } 288#} 289 290 291set stop_line [gdb_get_line_number "-tbreak6-"] 292gdb_test "tbreak $stop_line" \ 293 "Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \ 294 "tbreakpoint at tbreak6" 295 296if ![gdb_skip_stdio_test "continuing to tbreak6"] { 297 gdb_test_stdio "continue" \ 298 "Sum of 4 arrays.*Contents of linked list1.*Contents of two_floats_t" \ 299 "main \\(\\) at .*$srcfile:$stop_line.*c = 0.*" \ 300 "continue to tbreak6" 301} else { 302 gdb_test "continue" ".*" "" 303} 304 305#call print_small_structs(*struct1, *struct2, *struct3, *struct4, 306# *flags, *flags_combo, *three_char, *five_char, 307# *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3) 308 309if {!$skip_float_test && \ 310 ![gdb_skip_stdio_test "print print_small_structs(...)"] } { 311 gdb_test_stdio "print print_small_structs(*struct1, *struct2, *struct3, *struct4, *flags, *flags_combo, *three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3)" \ 312 [multi_line \ 313 "alpha" \ 314 "gamma" \ 315 "epsilon" \ 316 "alpha" \ 317 "gamma" \ 318 "epsilon" \ 319 "ch1: y\[ \t\]*ch2: n" \ 320 "Contents of three_char_t: " \ 321 "" \ 322 "a\[ \t\]*b\[ \t\]*c" \ 323 "Contents of five_char_t: " \ 324 "" \ 325 "l\[ \t\]*m\[ \t\]*n\[ \t\]*o\[ \t\]*p" \ 326 "Contents of int_char_combo_t: " \ 327 "" \ 328 "123\[ \t\]*z" \ 329 "Sum of the 4 struct values and seed : " \ 330 "" \ 331 "\[ \t\]*52" \ 332 "Contents of struct1: " \ 333 "" \ 334 "\[ \t\]*6\[ \t\]*0" \ 335 "Contents of struct2: " \ 336 "" \ 337 "\[ \t\]*10\[ \t\]*0" \ 338 "Contents of struct3: " \ 339 "" \ 340 "\[ \t\]*12\[ \t\]*0" \ 341 "Contents of one_double_t: " \ 342 "" \ 343 "10.500000" \ 344 "Contents of one_double_t: " \ 345 "" \ 346 "-3.375000" \ 347 "Contents of one_double_t: " \ 348 "" \ 349 "675.093750" \ 350 "Contents of two_floats_t: " \ 351 "" \ 352 "\[ \t\]*45.234001\[ \t\]*43.599998" \ 353 "Contents of two_floats_t: " \ 354 "" \ 355 "\[ \t\]*78.010002\[ \t\]*122.099998" \ 356 "Contents of two_floats_t: " \ 357 "" \ 358 "-1232.344971\[ \t\]*-199.210007" \ 359 ] \ 360 "" \ 361 "print print_small_structs" 362} 363 364#call compute_with_small_structs(20) 365gdb_test "print compute_with_small_structs(20)" \ 366 "\[0-9\]+ = void" \ 367 "print compute_with_small_structs(20)" 368 369 370#call print_ten_doubles(123.456, 123.456, -0.12, -1.23, 343434.8, 89.098, 371# 3.14, -5678.12345, -0.11111111, 216.97065) 372 373if {!$skip_float_test && \ 374 ![gdb_skip_stdio_test "print print_ten_doubles(...)"]} { 375 gdb_test_stdio "print print_ten_doubles(123.456, 123.456, -0.12, -1.23, 343434.8, 89.098, 3.14, -5678.12345, -0.11111111, 216.97065)" \ 376 [multi_line \ 377 "Two Doubles : 123.45\[0-9\]*.*123.45\[0-9\]*" \ 378 "Two Doubles : -0.1200\[0-9\]*.*-1.2300\[0-9\]*" \ 379 "Two Doubles : 343434.\[0-9\]*.*89.09\[0-9\]*" \ 380 "Two Doubles : 3.1400\[0-9\]*.*-5678.123\[0-9\]*" \ 381 "Two Doubles : -0.1111\[0-9\]*.*216.97\[0-9\]*" \ 382 ] 383} 384 385set stop_line [gdb_get_line_number "-tbreak7-"] 386gdb_test "tbreak $stop_line" \ 387 "Temporary breakpoint .* file .*$srcfile, line $stop_line.*" \ 388 "tbreakpoint at tbreak7" 389 390gdb_test continue "Continuing\\..*main \\(.*\\) at.*$srcfile:$stop_line\[\t\r\n \]+$stop_line.*print_long_arg_list \\( a, b, c, d, e, f, .struct1, .struct2, .struct3, .struct4,.*" "continue to tbreak7" 391 392set stop_line [gdb_get_line_number "-step2-"] 393# We can't just assume that a "step" will get us into 394# print_long_arg_list here,either. 395gdb_test "tbreak print_long_arg_list" \ 396 "Temporary breakpoint .* file .*$srcfile, line .*" \ 397 "tbreak in print_long_arg_list after stepping into memcpy" 398# The short match case below handles cases where a buffer 399# overflows or something, and expect can't deal with the full 400# line. Perhaps a more elegant solution exists... -sts 1999-08-17 401if {!$skip_float_test} { 402 gdb_test_multiple "continue" "step into print_long_arg_list" { 403 -re ".*print_long_arg_list \\(a=22.25, b=33.375, 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.375\}, d3=\{double1 = 675.09375\}, f1=\{float1 = 45.2340012, float2 = 43.5999985\}, f2=\{float1 = 78.0100021, float2 = 122.099998\}, f3=\{float1 = -1232.34497, float2 = -199.210007\}\\) at .*${srcfile}:$stop_line\[\r\n\]+$stop_line\[ \t\]+printf\\(\"double :.*\", a\\);.*$gdb_prompt $" { 404 pass "step into print_long_arg_list" 405 } 406 -re ".*print_long_arg_list.*\\(a=22.25, b=33.375, 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\'\}.*\\) at .*${srcfile}:$stop_line\[\r\n\]+$stop_line\[ \t\]+printf\\(\"double :.*\", a\\);.*$gdb_prompt $" { 407 pass "step into print_long_arg_list (short match)" 408 } 409 } 410} else { 411 # If skipping float tests, don't expect anything in arg list. 412 gdb_test "continue" \ 413 "print_long_arg_list \\(.*\\).*" \ 414 "step into print_long_arg_list" 415} 416 417set ws "\[\n\r\t \]+" 418 419#call print_small_structs(struct1, struct2, struct3, struct4, flags, 420# flags_combo, three_char, five_char, int_char_combo, 421# d1, d2, d3, f1, f2, f3) 422 423if {!$skip_float_test && \ 424 ![gdb_skip_stdio_test "print_small_structs from print_long_arg_list"] } { 425 426 # On 32-bit SPARC, some of the args are passed by ref, others by 427 # value, and GDB gets confused and says "Invalid cast" because it 428 # thinks it has to cast the structure into a pointer to structure. 429 if { [test_debug_format "stabs"] } then { 430 setup_kfail "gdb/1539" "sparc-*-*" 431 } 432 433 434 gdb_test_stdio "print print_small_structs(struct1, struct2, struct3, struct4, flags, flags_combo, three_char, five_char, int_char_combo, d1, d2, d3, f1, f2, f3)" \ 435 [multi_line \ 436 "alpha" \ 437 "gamma" \ 438 "epsilon" \ 439 "alpha" \ 440 "gamma" \ 441 "epsilon" \ 442 "ch1: y\[ \t\]*ch2: n" \ 443 "Contents of three_char_t: " \ 444 "" \ 445 "a\[ \t\]*b\[ \t\]*c" \ 446 "Contents of five_char_t: " \ 447 "" \ 448 "l\[ \t\]*m\[ \t\]*n\[ \t\]*o\[ \t\]*p" \ 449 "Contents of int_char_combo_t: " \ 450 "" \ 451 "123\[ \t\]*z" \ 452 "Sum of the 4 struct values and seed : " \ 453 "" \ 454 "\[ \t\]*52" \ 455 "Contents of struct1: " \ 456 "" \ 457 "\[ \t\]*6\[ \t\]*0" \ 458 "Contents of struct2: " \ 459 "" \ 460 "\[ \t\]*10\[ \t\]*0" \ 461 "Contents of struct3: " \ 462 "" \ 463 "\[ \t\]*12\[ \t\]*0" \ 464 "Contents of one_double_t: " \ 465 "" \ 466 "10.500000" \ 467 "Contents of one_double_t: " \ 468 "" \ 469 "-3.375000" \ 470 "Contents of one_double_t: " \ 471 "" \ 472 "675.093750" \ 473 "Contents of two_floats_t: " \ 474 "" \ 475 "\[ \t\]*45.234001\[ \t\]*43.599998" \ 476 "Contents of two_floats_t: " \ 477 "" \ 478 "\[ \t\]*78.010002\[ \t\]*122.099998" \ 479 "Contents of two_floats_t: " \ 480 "" \ 481 "-1232.344971\[ \t\]*-199.210007" \ 482 ] \ 483 "" \ 484 "print print_small_structs from print_long_arg_list" 485} 486 487set stop_line [gdb_get_line_number "-tbreak8-"] 488gdb_test "tbreak $stop_line" \ 489 "Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \ 490 "tbreakpoint at tbreak8" 491 492if ![gdb_skip_stdio_test "continuing to tbreak8"] { 493 gdb_test_stdio "continue" \ 494 "Contents of two_floats_t:" \ 495 ".*main \\(\\) at.*$srcfile:$stop_line.*$stop_line.*init_bit_flags_combo\\(flags_combo, \\(unsigned\\)1, \\(unsigned\\)0, .y.,.*" \ 496 "continue to tbreak8" 497} else { 498 gdb_test "continue" ".*" "" 499} 500 501#step 502set stop_line [gdb_get_line_number "-step3-"] 503gdb_test "step" \ 504 "init_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 .*$srcfile:$stop_line\[ \t\n\r\]+$stop_line.*bit_flags_combo->alpha = a;.*" \ 505 "step into init_bit_flags_combo" 506 507#call print_bit_flags_combo(*bit_flags_combo) 508if ![gdb_skip_stdio_test "continuing at step3"] { 509 gdb_test_stdio "print print_bit_flags_combo(*bit_flags_combo)" \ 510 "alpha.*gamma.*epsilon.*ch1: y.*ch2: n" 511} 512 513 514set stop_line [gdb_get_line_number "-tbreak9-"] 515gdb_test "tbreak $stop_line" \ 516 "Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \ 517 "tbreakpoint at tbreak9" 518 519gdb_test continue "Continuing\\..*main \\(\\) at .*$srcfile:$stop_line\[\r\n\t \]+$stop_line.*init_int_char_combo\\(int_char_combo, 13, .!.\\);.*" \ 520"continue to tbreak9" 521 522#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) 523 524if {!$skip_float_test && \ 525 ![gdb_skip_stdio_test "print print_long_arg_list"] } { 526 527 gdb_test_stdio "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)" \ 528 [multi_line \ 529 "double : 22.250000" \ 530 "double : 33.375000" \ 531 "int : 0" \ 532 "int : -25" \ 533 "int : 100" \ 534 "int : 2345" \ 535 "alpha" \ 536 "gamma" \ 537 "epsilon" \ 538 "alpha" \ 539 "gamma" \ 540 "epsilon" \ 541 "ch1: y\[ \t\]*ch2: n" \ 542 "Contents of three_char_t: " \ 543 "" \ 544 "x\[ \t\]*y\[ \t\]*z" \ 545 "Contents of five_char_t: " \ 546 "" \ 547 "h\[ \t\]*e\[ \t\]*l\[ \t\]*l\[ \t\]*o" \ 548 "Contents of int_char_combo_t: " \ 549 "" \ 550 "123\[ \t\]*z" \ 551 "Sum of the 4 struct values and seed : " \ 552 "" \ 553 "\[ \t\]*52" \ 554 "Contents of struct1: " \ 555 "" \ 556 "\[ \t\]*6\[ \t\]*0" \ 557 "Contents of struct2: " \ 558 "" \ 559 "\[ \t\]*10\[ \t\]*0" \ 560 "Contents of struct3: " \ 561 "" \ 562 "\[ \t\]*12\[ \t\]*0" \ 563 "Contents of one_double_t: " \ 564 "" \ 565 "1.111110" \ 566 "Contents of one_double_t: " \ 567 "" \ 568 "-345.340000" \ 569 "Contents of one_double_t: " \ 570 "" \ 571 "546464.200000" \ 572 "Contents of two_floats_t: " \ 573 "" \ 574 "0.234000\[ \t\]*453.100006" \ 575 "Contents of two_floats_t: " \ 576 "" \ 577 "78.345001\[ \t\]*23.090000" \ 578 "Contents of two_floats_t: " \ 579 "" \ 580 "-2.345000\[ \t\]*1.000000" \ 581 ] \ 582 "" \ 583 "print print_long_arg_list" 584} 585 586 587set stop_line [gdb_get_line_number "-tbreak10-"] 588gdb_test "tbreak $stop_line" \ 589 "Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \ 590 "tbreakpoint at tbreak10" 591 592gdb_test continue "Continuing\\..*main \\(\\) at .*$srcfile:$stop_line\[ \t\n\r\]+$stop_line.*compute_with_small_structs\\(35\\);.*" \ 593"continue to tbreak10" 594 595 596#call sum_struct_print(10, *struct1, *struct2, *struct3, *struct4) 597if ![gdb_skip_stdio_test "print sum_struct_print(...)"] { 598 gdb_test_stdio "print sum_struct_print(10,*struct1,*struct2,*struct3,*struct4)" \ 599 "Sum of the 4 struct values and seed :\[ \t\n\r\]+218" 600} 601 602 603#call print_struct_rep(*struct1, *struct2, *struct3) 604if ![gdb_skip_stdio_test "print print_struct_rep(...)"] { 605 gdb_test_stdio "print print_struct_rep(*struct1, *struct2, *struct3)" \ 606 [multi_line \ 607 "Contents of struct1: " \ 608 "" \ 609 " 22 0" \ 610 "Contents of struct2: " \ 611 "" \ 612 " 42 0" \ 613 "Contents of struct3: " \ 614 "" \ 615 " 62 0" \ 616 ] 617} 618 619if ![gdb_skip_stdio_test "print print_one_large_struct(...)"] { 620 gdb_test_stdio "print print_one_large_struct(*list1)" \ 621 " 4 1" 622} 623 624set timeout $oldtimeout 625return 626 627