1 # Copyright 2003-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Please email any bugs, comments, and/or additions to this file to:
19 # This file is part of the gdb testsuite.
22 # Test floating-point related functionality.
26 if { [prepare_for_testing "failed to prepare" float float.c] } {
30 # Set it up at a breakpoint so we have its registers.
38 if {[is_aarch64_target]} {
39 gdb_test "info float" "d0.*d1.*d31.*s0.*s1.*s31.*"
40 } elseif {[istarget "alpha*-*-*"]} {
41 gdb_test "info float" "f0.*"
42 } elseif {[is_aarch32_target]} {
43 gdb_test_multiple "info float" "info float" {
44 -re "Software FPU type.*mask:.*flags:.*$gdb_prompt $" {
45 pass "info float (FPA)"
47 -re "fpscr.*s0.*s1.*s31.*$gdb_prompt $" {
48 # Only check for single precision; d0 might be a vector register
50 pass "info float (VFP)"
52 -re "No floating.point info available for this processor.*$gdb_prompt $" {
53 pass "info float (without FPU)"
56 } elseif {[istarget "i?86-*-*"] || [istarget "x86_64-*-*"]} {
57 gdb_test "info float" "R7:.*Status Word:.*Opcode:.*"
58 } elseif {[istarget "ia64-*-*"]} {
59 gdb_test "info float" "f0.*f1.*f127.*"
60 } elseif {[istarget "m68k-*-*"]} {
61 gdb_test_multiple "info float" "info_float" {
62 -re "fp0.*fp1.*fp7.*$gdb_prompt $" {
63 pass "info float (with FPU)"
65 -re "No floating.point info available for this processor.*$gdb_prompt $" {
66 pass "info float (without FPU)"
69 } elseif {[istarget "mips*-*-*"]} {
70 gdb_test_multiple "info float" "info float" {
71 -re "fpu type: none / unused\r\n$gdb_prompt $" {
72 pass "info float (without FPU)"
74 -re "fpu type:.*cause.*mask.*flags.*round.*flush.*f0:.*flt:.*dbl:.*$gdb_prompt $" {
75 pass "info float (with FPU)"
78 } elseif {[istarget "nds32*-*-*"]} {
79 gdb_test_multiple "info float" "info_float" {
80 -re "fd0.*fd3.*$gdb_prompt $" {
81 pass "info float (with FPU)"
83 -re "No floating.point info available for this processor.*$gdb_prompt $" {
84 pass "info float (without FPU)"
87 } elseif {[istarget "powerpc*-*-*"]} {
88 gdb_test_multiple "info float" "info_float" {
89 -re "f0.*f1.*f31.*fpscr.*$gdb_prompt $" {
90 pass "info float (with FPU)"
92 -re "No floating.point info available for this processor.*$gdb_prompt $" {
93 pass "info float (without FPU)"
96 } elseif {[istarget "s390*-*-*"]} {
97 gdb_test "info float" "fpc.*f0.*f1.*f15.*" "info float"
98 } elseif {[istarget "sh*-*"]} {
99 # SH may or may not have an FPU
100 gdb_test_multiple "info float" "info float" {
101 -re "fpul.*fr0.*fr1.*fr15.*$gdb_prompt $" {
102 pass "info float (with FPU)"
104 -re "No floating.point info available for this processor.*$gdb_prompt $" {
105 pass "info float (without FPU)"
108 } elseif {[istarget "hppa*-*"]} {
109 gdb_test "info float" "fr4.*fr4R.*fr31R.*" "info float"
110 } elseif {[istarget "sparc*-*-*"]} {
111 gdb_test "info float" "f0.*f1.*f31.*d0.*d30.*" "info float"
112 } elseif {[istarget "riscv*-*-*"]} {
113 # RISC-V may or may not have an FPU. Additionally, the order of
114 # fcsr relative to fflags and frm can change depending on whether
115 # the fflags and frm registers are implemented as real registers
116 # (supplied in the target description) or pseudo-registers
117 # (supplied by GDB as a view into fcsr).
118 gdb_test_multiple "info float" "info float" {
119 -re "ft0.*ft1.*ft11.*fflags.*frm.*fcsr.*$gdb_prompt $" {
120 pass "info float (with FPU)"
122 -re "ft0.*ft1.*ft11.*fcsr.*fflags.*frm.*$gdb_prompt $" {
123 pass "info float (with FPU)"
125 -re "No floating.point info available for this processor.*$gdb_prompt $" {
126 pass "info float (without FPU)"
129 } elseif {[istarget "loongarch*-*-*"]} {
130 gdb_test "info float" "f.*fcc0.*fcsr.*" "info float"
132 gdb_test "info float" "No floating.point info available for this processor." "info float (unknown target)"
136 gdb_test "finish" "Value returned is .* = (inf|nan).*"