# Copyright 1998-2017 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# This file was written by Elena Zannoni (ezannoni@cygnus.com)
standard_testfile
# Some targets can't call functions, so don't even bother with this
# test.
if [target_info exists gdb,cannot_call_functions] {
unsupported "this target can not call functions"
continue
}
# Create and source the file that provides information about the compiler
# used to compile the test case.
if [get_compiler_info] {
return -1
}
set skip_float_test [gdb_skip_float_test]
if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
return -1
}
set oldtimeout $timeout
set timeout [expr "$timeout + 60"]
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set print address off"
gdb_test_no_output "set width 0"
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
get_debug_format
set stop_line [gdb_get_line_number "-tbreak1-"]
gdb_test "tbreak $stop_line" \
"Temporary breakpoint ${decimal}.*file.*$srcfile, line $stop_line.*" \
"tbreakpoint at tbreak1"
gdb_test continue \
"Continuing\\..*main \\(\\) at.*$srcfile:$stop_line.*" \
"run until breakpoint set at a line"
#call print_double_array(double_array)
if {!$skip_float_test && \
![gdb_skip_stdio_test "print print_double_array(double_array)"] } {
gdb_test_stdio "print print_double_array(double_array)" \
[multi_line \
"array_d :" \
"=========" \
"" \
"0.000000 *" \
"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\]"]
}
#call print_char_array(char_array)
set array_c_re \
[multi_line \
"array_c :" \
"=========" \
"" \
"Z" \
"aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ" \
"aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ" \
"aZaZaZaZaZaZaZaZaZa"]
if ![gdb_skip_stdio_test "print_char_array(char_array)"] {
gdb_test_stdio "print print_char_array(char_array)" $array_c_re
}
set stop_line [gdb_get_line_number "-tbreak2-"]
gdb_test "tbreak $stop_line" \
"Temporary breakpoint.*file.*$srcfile, line $stop_line.*" \
"tbreakpoint at tbreak2"
if ![gdb_skip_stdio_test "continue to tbreak2"] {
set gdb_re \
[multi_line \
"main.*at.*:\[0-9\]+" \
"\[0-9\]+.*print_double_array\\(double_array\\).*"]
gdb_test_stdio "continue" $array_c_re $gdb_re "continue to tbreak2"
} else {
gdb_test "continue" ".*" ""
}
# I am disabling this test, because it takes too long. I verified by
# hand that it works, feel free to check for yourself.
#call print_all_arrays(integer_array, char_array, float_array, double_array)
#send_gdb "print print_all_arrays(integer_array, char_array, float_array, double_array)\n"
#gdb_expect {
# -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 $" {
# pass "print print_all_arrays(integer_array, char_array, float_array, double_array)"
# }
# -re ".*$gdb_prompt $" { fail "print print_all_arrays(integer_array, char_array, float_array, double_array)" }
# timeout { fail "(timeout) print print_all_arrays(integer_array, char_array, float_array, double_array)" }
# }
#set timeout $oldtimeout
set stop_line [gdb_get_line_number "-tbreak3-"]
gdb_test "tbreak $stop_line" \
"Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \
"tbreakpoint at tbreak3"
if {!$skip_float_test && \
![gdb_skip_stdio_test "continuing to tbreak3"] } {
gdb_test_stdio "continue" \
[multi_line \
"array_d :" \
"=========" \
"" \
"0.000000 *" \
"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\]* *" \
"" \
"" \
"array_f :" \
".*" \
"student id :\[\t \]+.*YELLOW" \
"array_i :" \
] \
"main \\(\\) at .*call-ar-st.c:\[0-9\]+\[ \t\r\n\]+.*print_all_arrays\\(integer_array, char_array, float_array, double_array\\)..*" \
"continuing to tbreak3"
} else {
gdb_test "continue" ".*" ""
}
#step
set stop_line [gdb_get_line_number "-step1-"]
gdb_test "step" \
"print_all_arrays \\(array_i=, array_c= .ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa., array_f=, array_d=\\) at .*$srcfile:$stop_line\[ \t\r\n\]+$stop_line.*print_int_array\\(array_i\\);.*" \
"step inside print_all_arrays"
#step -over
if ![gdb_skip_stdio_test "next over print_int_array in print_all_arrays"] {
set stop_line [gdb_get_line_number "-next1-"]
gdb_test_stdio "next" \
"array_i :" \
"$stop_line.*print_char_array.*" \
"next over print_int_array in print-all_arrays"
} else {
gdb_test "next" ".*" ""
}
#call print_double_array(array_d)
if {!$skip_float_test && \
![gdb_skip_stdio_test "print print_double_array(array_d)"] } {
gdb_test_stdio "print print_double_array(array_d)" \
[multi_line \
"array_d :" \
"=========" \
"" \
"0.000000 *" \
"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\]*" \
]
}
set stop_line [gdb_get_line_number "-tbreak4-"]
gdb_test "tbreak $stop_line" \
"Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \
"tbreakpoint at tbreak4"
if {!$skip_float_test && \
![gdb_skip_stdio_test "continuing to tbreak4"] } {
gdb_test_stdio "continue" \
[multi_line \
"array_d :" \
"=========" \
"" \
"0.000000 *" \
"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\]*" \
] \
"" \
"continuing to tbreak4"
} else {
gdb_test "continue" ".*" ""
}
#call sum_array_print(10, *list1, *list2, *list3, *list4)
if ![gdb_skip_stdio_test "print sum_array_print(...)"] {
gdb_test_stdio "print sum_array_print(10, *list1, *list2, *list3, *list4)" \
[multi_line \
"Sum of 4 arrays, by element \\(add in seed as well\\): " \
"" \
"Seed: 10" \
"Element Index . Sum " \
"-------------------------" \
".*" \
"\[ \t\]+0\[ \t\]+52" \
"\[ \t\]+1\[ \t\]+60" \
"\[ \t\]+2\[ \t\]+68" \
"\[ \t\]+3\[ \t\]+76" \
"\[ \t\]+4\[ \t\]+84" \
"\[ \t\]+5\[ \t\]+92" \
"\[ \t\]+6\[ \t\]+100" \
"\[ \t\]+7\[ \t\]+108" \
"\[ \t\]+8\[ \t\]+116" \
"\[ \t\]+9\[ \t\]+124" \
]
}
#step over
set stop_line [gdb_get_line_number "-next2-"]
if ![gdb_skip_stdio_test "next to next2"] {
gdb_test_stdio "next" \
"BYE BYE FOR NOW" \
"$stop_line.*printf\\(.VERY GREEN GRASS.n.\\);.*" \
"next to next2"
} else {
gdb_test "next" ".*" ""
}
#call print_array_rep(\*list1, \*list2, \*list3)
if ![gdb_skip_stdio_test "print print_array_rep(...)"] {
gdb_test_stdio "print print_array_rep(\*list1, \*list2, \*list3)" \
"Contents of linked list3:"
}
set stop_line [gdb_get_line_number "-tbreak5-"]
gdb_test "tbreak $stop_line" \
"Temporary breakpoint..* file .*$srcfile, line $stop_line.*" \
"tbreakpoint at tbreak5"
gdb_test "continue" \
"main \\(\\) at .*$srcfile:$stop_line\r\n$stop_line\[\t \]+sum_array_print\\(10, \\*list1, \\*list2, \\*list3, \\*list4\\);.*" \
"continue to tbreak5"
# Run into sum_array_print, and verify that the arguments were passed
# accurately.
#
# Note that we shouldn't use a `step' here to get into
# sum_array_print; GCC may emit calls to memcpy to put the arguments
# in the right place, and a step may end up in memcpy instead. This
# may itself be a bug, but it's not the one we're trying to catch
# here. I've added something to step-test.exp for this.
gdb_test "break sum_array_print" \
".*Breakpoint ${decimal}: file .*$srcfile, line.*" \
"set breakpoint in sum_array_print"
gdb_test_no_output "set print frame-arguments all"
gdb_test "continue" \
".*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\\).*\\);.*" \
"check args of sum_array_print"
#call print_array_rep(linked_list1, linked_list2, linked_list3)
# this calls works from gdb without gdb_expect. But it does seem to hang
#from within gdb_expect.
#I comment this out
#send_gdb "print print_array_rep(linked_list1, linked_list2, linked_list3)\n"
#gdb_expect {
# -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 $" {
# pass "print print_array_rep(linked_list1, linked_list2, linked_list3)"
# }
# -re ".*$gdb_prompt $" { fail "print print_array_rep(linked_list1, linked_list2, linked_list3)" }
# timeout { fail "(timeout) print print_array_rep(linked_list1, linked_list2, linked_list3)" }
#}
set stop_line [gdb_get_line_number "-tbreak6-"]
gdb_test "tbreak $stop_line" \
"Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \
"tbreakpoint at tbreak6"
if ![gdb_skip_stdio_test "continuing to tbreak6"] {
gdb_test_stdio "continue" \
"Sum of 4 arrays.*Contents of linked list1.*Contents of two_floats_t" \
"main \\(\\) at .*$srcfile:$stop_line.*c = 0.*" \
"continue to tbreak6"
} else {
gdb_test "continue" ".*" ""
}
#call print_small_structs(*struct1, *struct2, *struct3, *struct4,
# *flags, *flags_combo, *three_char, *five_char,
# *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3)
if {!$skip_float_test && \
![gdb_skip_stdio_test "print print_small_structs(...)"] } {
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)" \
[multi_line \
"alpha" \
"gamma" \
"epsilon" \
"alpha" \
"gamma" \
"epsilon" \
"ch1: y\[ \t\]*ch2: n" \
"Contents of three_char_t: " \
"" \
"a\[ \t\]*b\[ \t\]*c" \
"Contents of five_char_t: " \
"" \
"l\[ \t\]*m\[ \t\]*n\[ \t\]*o\[ \t\]*p" \
"Contents of int_char_combo_t: " \
"" \
"123\[ \t\]*z" \
"Sum of the 4 struct values and seed : " \
"" \
"\[ \t\]*52" \
"Contents of struct1: " \
"" \
"\[ \t\]*6\[ \t\]*0" \
"Contents of struct2: " \
"" \
"\[ \t\]*10\[ \t\]*0" \
"Contents of struct3: " \
"" \
"\[ \t\]*12\[ \t\]*0" \
"Contents of one_double_t: " \
"" \
"10.500000" \
"Contents of one_double_t: " \
"" \
"-3.375000" \
"Contents of one_double_t: " \
"" \
"675.093750" \
"Contents of two_floats_t: " \
"" \
"\[ \t\]*45.234001\[ \t\]*43.599998" \
"Contents of two_floats_t: " \
"" \
"\[ \t\]*78.010002\[ \t\]*122.099998" \
"Contents of two_floats_t: " \
"" \
"-1232.344971\[ \t\]*-199.210007" \
] \
"" \
"print print_small_structs"
}
#call compute_with_small_structs(20)
gdb_test "print compute_with_small_structs(20)" \
"\[0-9\]+ = void" \
"print compute_with_small_structs(20)"
#call print_ten_doubles(123.456, 123.456, -0.12, -1.23, 343434.8, 89.098,
# 3.14, -5678.12345, -0.11111111, 216.97065)
if {!$skip_float_test && \
![gdb_skip_stdio_test "print print_ten_doubles(...)"]} {
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)" \
[multi_line \
"Two Doubles : 123.45\[0-9\]*.*123.45\[0-9\]*" \
"Two Doubles : -0.1200\[0-9\]*.*-1.2300\[0-9\]*" \
"Two Doubles : 343434.\[0-9\]*.*89.09\[0-9\]*" \
"Two Doubles : 3.1400\[0-9\]*.*-5678.123\[0-9\]*" \
"Two Doubles : -0.1111\[0-9\]*.*216.97\[0-9\]*" \
]
}
set stop_line [gdb_get_line_number "-tbreak7-"]
gdb_test "tbreak $stop_line" \
"Temporary breakpoint .* file .*$srcfile, line $stop_line.*" \
"tbreakpoint at tbreak7"
gdb_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"
set stop_line [gdb_get_line_number "-step2-"]
# We can't just assume that a "step" will get us into
# print_long_arg_list here,either.
gdb_test "tbreak print_long_arg_list" \
"Temporary breakpoint .* file .*$srcfile, line .*" \
"tbreak in print_long_arg_list after stepping into memcpy"
# The short match case below handles cases where a buffer
# overflows or something, and expect can't deal with the full
# line. Perhaps a more elegant solution exists... -sts 1999-08-17
if {!$skip_float_test} {
gdb_test_multiple "continue" "step into print_long_arg_list" {
-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 $" {
pass "step into print_long_arg_list"
}
-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 $" {
pass "step into print_long_arg_list (short match)"
}
}
} else {
# If skipping float tests, don't expect anything in arg list.
gdb_test "continue" \
"print_long_arg_list \\(.*\\).*" \
"step into print_long_arg_list"
}
set ws "\[\n\r\t \]+"
#call print_small_structs(struct1, struct2, struct3, struct4, flags,
# flags_combo, three_char, five_char, int_char_combo,
# d1, d2, d3, f1, f2, f3)
if {!$skip_float_test && \
![gdb_skip_stdio_test "print_small_structs from print_long_arg_list"] } {
# On 32-bit SPARC, some of the args are passed by ref, others by
# value, and GDB gets confused and says "Invalid cast" because it
# thinks it has to cast the structure into a pointer to structure.
if { [test_debug_format "stabs"] } then {
setup_kfail "gdb/1539" "sparc-*-*"
}
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)" \
[multi_line \
"alpha" \
"gamma" \
"epsilon" \
"alpha" \
"gamma" \
"epsilon" \
"ch1: y\[ \t\]*ch2: n" \
"Contents of three_char_t: " \
"" \
"a\[ \t\]*b\[ \t\]*c" \
"Contents of five_char_t: " \
"" \
"l\[ \t\]*m\[ \t\]*n\[ \t\]*o\[ \t\]*p" \
"Contents of int_char_combo_t: " \
"" \
"123\[ \t\]*z" \
"Sum of the 4 struct values and seed : " \
"" \
"\[ \t\]*52" \
"Contents of struct1: " \
"" \
"\[ \t\]*6\[ \t\]*0" \
"Contents of struct2: " \
"" \
"\[ \t\]*10\[ \t\]*0" \
"Contents of struct3: " \
"" \
"\[ \t\]*12\[ \t\]*0" \
"Contents of one_double_t: " \
"" \
"10.500000" \
"Contents of one_double_t: " \
"" \
"-3.375000" \
"Contents of one_double_t: " \
"" \
"675.093750" \
"Contents of two_floats_t: " \
"" \
"\[ \t\]*45.234001\[ \t\]*43.599998" \
"Contents of two_floats_t: " \
"" \
"\[ \t\]*78.010002\[ \t\]*122.099998" \
"Contents of two_floats_t: " \
"" \
"-1232.344971\[ \t\]*-199.210007" \
] \
"" \
"print print_small_structs from print_long_arg_list"
}
set stop_line [gdb_get_line_number "-tbreak8-"]
gdb_test "tbreak $stop_line" \
"Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \
"tbreakpoint at tbreak8"
if ![gdb_skip_stdio_test "continuing to tbreak8"] {
gdb_test_stdio "continue" \
"Contents of two_floats_t:" \
".*main \\(\\) at.*$srcfile:$stop_line.*$stop_line.*init_bit_flags_combo\\(flags_combo, \\(unsigned\\)1, \\(unsigned\\)0, .y.,.*" \
"continue to tbreak8"
} else {
gdb_test "continue" ".*" ""
}
#step
set stop_line [gdb_get_line_number "-step3-"]
gdb_test "step" \
"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;.*" \
"step into init_bit_flags_combo"
#call print_bit_flags_combo(*bit_flags_combo)
if ![gdb_skip_stdio_test "continuing at step3"] {
gdb_test_stdio "print print_bit_flags_combo(*bit_flags_combo)" \
"alpha.*gamma.*epsilon.*ch1: y.*ch2: n"
}
set stop_line [gdb_get_line_number "-tbreak9-"]
gdb_test "tbreak $stop_line" \
"Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \
"tbreakpoint at tbreak9"
gdb_test continue "Continuing\\..*main \\(\\) at .*$srcfile:$stop_line\[\r\n\t \]+$stop_line.*init_int_char_combo\\(int_char_combo, 13, .!.\\);.*" \
"continue to tbreak9"
#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)
if {!$skip_float_test && \
![gdb_skip_stdio_test "print print_long_arg_list"] } {
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)" \
[multi_line \
"double : 22.250000" \
"double : 33.375000" \
"int : 0" \
"int : -25" \
"int : 100" \
"int : 2345" \
"alpha" \
"gamma" \
"epsilon" \
"alpha" \
"gamma" \
"epsilon" \
"ch1: y\[ \t\]*ch2: n" \
"Contents of three_char_t: " \
"" \
"x\[ \t\]*y\[ \t\]*z" \
"Contents of five_char_t: " \
"" \
"h\[ \t\]*e\[ \t\]*l\[ \t\]*l\[ \t\]*o" \
"Contents of int_char_combo_t: " \
"" \
"123\[ \t\]*z" \
"Sum of the 4 struct values and seed : " \
"" \
"\[ \t\]*52" \
"Contents of struct1: " \
"" \
"\[ \t\]*6\[ \t\]*0" \
"Contents of struct2: " \
"" \
"\[ \t\]*10\[ \t\]*0" \
"Contents of struct3: " \
"" \
"\[ \t\]*12\[ \t\]*0" \
"Contents of one_double_t: " \
"" \
"1.111110" \
"Contents of one_double_t: " \
"" \
"-345.340000" \
"Contents of one_double_t: " \
"" \
"546464.200000" \
"Contents of two_floats_t: " \
"" \
"0.234000\[ \t\]*453.100006" \
"Contents of two_floats_t: " \
"" \
"78.345001\[ \t\]*23.090000" \
"Contents of two_floats_t: " \
"" \
"-2.345000\[ \t\]*1.000000" \
] \
"" \
"print print_long_arg_list"
}
set stop_line [gdb_get_line_number "-tbreak10-"]
gdb_test "tbreak $stop_line" \
"Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \
"tbreakpoint at tbreak10"
gdb_test continue "Continuing\\..*main \\(\\) at .*$srcfile:$stop_line\[ \t\n\r\]+$stop_line.*compute_with_small_structs\\(35\\);.*" \
"continue to tbreak10"
#call sum_struct_print(10, *struct1, *struct2, *struct3, *struct4)
if ![gdb_skip_stdio_test "print sum_struct_print(...)"] {
gdb_test_stdio "print sum_struct_print(10,*struct1,*struct2,*struct3,*struct4)" \
"Sum of the 4 struct values and seed :\[ \t\n\r\]+218"
}
#call print_struct_rep(*struct1, *struct2, *struct3)
if ![gdb_skip_stdio_test "print print_struct_rep(...)"] {
gdb_test_stdio "print print_struct_rep(*struct1, *struct2, *struct3)" \
[multi_line \
"Contents of struct1: " \
"" \
" 22 0" \
"Contents of struct2: " \
"" \
" 42 0" \
"Contents of struct3: " \
"" \
" 62 0" \
]
}
if ![gdb_skip_stdio_test "print print_one_large_struct(...)"] {
gdb_test_stdio "print print_one_large_struct(*list1)" \
" 4 1"
}
set timeout $oldtimeout
return