1# Copyright 2016-2019 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 19standard_testfile .c 20 21proc do_compile { {opts {}} } { 22 global srcdir subdir srcfile binfile 23 set ccopts {debug quiet} 24 foreach opt $opts {lappend ccopts "additional_flags=$opt"} 25 gdb_compile "${srcdir}/${subdir}/${srcfile}" "$binfile" executable $ccopts 26} 27 28if { [do_compile] != "" && [do_compile {-mfloat128}] != "" } { 29 untested "compiler can't handle _FloatN/_FloatNx types?" 30 return -1 31} 32 33clean_restart ${binfile} 34 35if ![runto_main] then { 36 perror "couldn't run to breakpoint" 37 continue 38} 39 40# Run to the breakpoint at return. 41gdb_breakpoint [gdb_get_line_number "return"] 42gdb_continue_to_breakpoint "return" 43 44# Print the original values of f32, f64, f128, f32x, f64x. 45gdb_test "print f32" ".* = 1\\.5.*" "the original value of f32 is 1.5" 46gdb_test "print f64" ".* = 2\\.25.*" "the original value of f64 is 2.25" 47gdb_test "print f128" ".* = 3\\.375.*" "the original value of f128 is 3.375" 48gdb_test "print f32x" ".* = 10\\.5.*" "the original value of f32x is 10.5" 49gdb_test "print f64x" ".* = 20\\.25.*" "the original value of f64x is 20.25" 50 51# Test that gdb could correctly recognize float constant expression with a suffix. 52# FIXME: gdb does not yet recognize the suffix for _FloatN/_FloatNx types. 53gdb_test "print f32=-1.5" ".* = -1\\.5.*" "try to change f32 to -1.5 with 'print f32=-1.5'" 54gdb_test "print f64=-2.25" ".* = -2\\.25.*" "try to change f64 to -2.25 with 'print f64=-2.25'" 55gdb_test "print f128=-3.375" ".* = -3\\.375.*" "try to change f128 to -3.375 with 'print f128=-3.375'" 56gdb_test "print f32x=-10.5" ".* = -10\\.5.*" "try to change f32x to -10.5 with 'print f32=-1.5x'" 57gdb_test "print f64x=-20.25" ".* = -20\\.25.*" "try to change f64x to -20.25 with 'print f64=-2.25x'" 58 59# Test that gdb could handle the above correctly with "set var" command. 60set test "set variable f32 = 10.5" 61gdb_test_multiple "set var f32=10.5" "$test" { 62 -re "$gdb_prompt $" { 63 pass "$test" 64 } 65 -re "Invalid number.*$gdb_prompt $" { 66 fail "$test (do not recognize 10.5)" 67 } 68} 69 70set test "set variable f64 = 20.25" 71gdb_test_multiple "set var f64=20.25" "$test" { 72 -re "$gdb_prompt $" { 73 pass "$test" 74 } 75 -re "Invalid number.*$gdb_prompt $" { 76 fail "$test (do not recognize 20.25)" 77 } 78} 79 80set test "set variable f128 = 30.375" 81gdb_test_multiple "set var f128=30.375" "$test" { 82 -re "$gdb_prompt $" { 83 pass "$test" 84 } 85 -re "Invalid number.*$gdb_prompt $" { 86 fail "$test (do not recognize 30.375)" 87 } 88} 89 90set test "set variable f32x = 100.5" 91gdb_test_multiple "set var f32x=100.5" "$test" { 92 -re "$gdb_prompt $" { 93 pass "$test" 94 } 95 -re "Invalid number.*$gdb_prompt $" { 96 fail "$test (do not recognize 100.5)" 97 } 98} 99 100set test "set variable f64x = 200.25" 101gdb_test_multiple "set var f64x=200.25" "$test" { 102 -re "$gdb_prompt $" { 103 pass "$test" 104 } 105 -re "Invalid number.*$gdb_prompt $" { 106 fail "$test (do not recognize 200.25)" 107 } 108} 109 110gdb_test "print f32" ".* = 10\\.5.*" "the value of f32 is changed to 10.5" 111gdb_test "print f64" ".* = 20\\.25.*" "the value of f64 is changed to 20.25" 112gdb_test "print f128" ".* = 30\\.375.*" "the value of f128 is changed to 30.375" 113gdb_test "print f32x" ".* = 100\\.5.*" "the value of f32x is changed to 100.5" 114gdb_test "print f64x" ".* = 200\\.25.*" "the value of f64x is changed to 200.25" 115 116# Print the original values of c32, c64, c128, c32x, c64x. 117gdb_test "print c32" ".* = 1\\.5 \\+ 1 \\* I.*" "the original value of c32 is 1.5 + 1 * I" 118gdb_test "print c64" ".* = 2\\.25 \\+ 1 \\* I.*" "the original value of c64 is 2.25 + 1 * I" 119gdb_test "print c128" ".* = 3\\.375 \\+ 1 \\* I.*" "the original value of c128 is 3.375 + 1 * I" 120gdb_test "print c32x" ".* = 10\\.5 \\+ 1 \\* I.*" "the original value of c32x is 10.5 + 1 * I" 121gdb_test "print c64x" ".* = 20\\.25 \\+ 1 \\* I.*" "the original value of c64x is 20.25 + 1 * I" 122 123# FIXME: GDB cannot parse non-trivial complex constants yet. 124 125