1# Copyright 2005-2013 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 is part of the gdb testsuite. It is intended to test that 17# gdb could correctly handle floating point constant with a suffix. 18 19set testfile "bfp-test" 20set srcfile ${testfile}.c 21set binfile ${objdir}/${subdir}/${testfile} 22if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { 23 untested "Couldn't compile ${srcfile}" 24 return -1 25} 26 27gdb_exit 28gdb_start 29gdb_reinitialize_dir $srcdir/$subdir 30gdb_load ${binfile} 31 32if ![runto_main] then { 33 perror "couldn't run to breakpoint" 34 continue 35} 36 37# Run to the breakpoint at return. 38gdb_breakpoint [gdb_get_line_number "return"] 39gdb_continue_to_breakpoint "return" 40 41# Print the original value of b32, b64 and b128. 42gdb_test "print b32" ".*1 = 1\.5.*" "The original value of b32 is 1.5" 43gdb_test "print b64" ".*2 = 2\.25.*" "The original value of b64 is 2.25" 44gdb_test "print b128" ".*3 = 3\.375.*" "The original value of b128 is 3.375" 45 46# Test that gdb could correctly recognize float constant expression with a suffix. 47gdb_test "print b32=-1.5f" ".*4 = -1\.5.*" "Try to change b32 to -1.5 with 'print b32=-1.5f'" 48gdb_test "print b64=-2.25f" ".*5 = -2\.25.*" "Try to change b64 to -2.25 with 'print b64=-2.25f'" 49gdb_test "print b128=-3.375l" ".*6 = -3\.375.*" "Try to change b128 to -3.375 with 'print b128=-3.375l'" 50 51# Test that gdb could handle the above correctly with "set var" command. 52set test "set variable b32 = 10.5f" 53gdb_test_multiple "set var b32=10.5f" "$test" { 54 -re "$gdb_prompt $" { 55 pass "$test" 56 } 57 -re "Invalid number.*$gdb_prompt $" { 58 fail "$test (do not recognize 10.5f)" 59 } 60} 61 62set test "set variable b64 = 20.25f" 63gdb_test_multiple "set var b64=20.25f" "$test" { 64 -re "$gdb_prompt $" { 65 pass "$test" 66 } 67 -re "Invalid number.*$gdb_prompt $" { 68 fail "$test (do not recognize 20.25f)" 69 } 70} 71 72set test "set variable b128 = 30.375l" 73gdb_test_multiple "set var b128=30.375l" "$test" { 74 -re "$gdb_prompt $" { 75 pass "$test" 76 } 77 -re "Invalid number.*$gdb_prompt $" { 78 fail "$test (do not recognize 30.375l)" 79 } 80} 81 82gdb_test "print b32" ".*7 = 10\.5.*" "The value of b32 is changed to 10.5" 83gdb_test "print b64" ".*8 = 20\.25.*" "The value of b64 is changed to 20.25" 84gdb_test "print b128" ".*9 = 30\.375.*" "The value of b128 is changed to 30.375" 85 86# Test that gdb could handle invalid suffix correctly. 87 88set test "set variable b32 = 100.5a" 89gdb_test_multiple "set var b32=100.5a" "$test" { 90 -re "Invalid number.*$gdb_prompt $" { 91 pass "$test" 92 } 93 -re "$gdb_prompt $" { 94 fail "$test (do not report error on invalid suffix)" 95 } 96} 97 98set test "set variable b64 = 200.25x" 99gdb_test_multiple "set var b64=200.25x" "$test" { 100 -re "Invalid number.*$gdb_prompt $" { 101 pass "$test" 102 } 103 -re "$gdb_prompt $" { 104 fail "$test (do not report error on invalid suffix)" 105 } 106} 107 108set test "set variable b128 = 300.375fl" 109gdb_test_multiple "set var b128=300.375fl" "$test" { 110 -re "Invalid number.*$gdb_prompt $" { 111 pass "$test" 112 } 113 -re "$gdb_prompt $" { 114 fail "$test (do not report error on invalid suffix)" 115 } 116} 117 118set test "set variable b128 = 300.375fff" 119gdb_test_multiple "set var b128=300.375fff" "$test" { 120 -re "Invalid number.*$gdb_prompt $" { 121 pass "$test" 122 } 123 -re "$gdb_prompt $" { 124 fail "$test (do not report error on invalid suffix)" 125 } 126} 127