aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch/aarch64-fp.exp
blob: c851447bb45feffd18ac4047c0be2a6e1bd0f118 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Copyright 2008-2023 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 <http://www.gnu.org/licenses/>.
#
# This file is part of the gdb testsuite.

# PR server/17457
# Test aarch64 floating point registers q0, q1, v0, v1, fpsr, fpcr

require is_aarch64_target

standard_testfile
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
    return -1
}

if ![runto_main] {
    return -1
}

set endianness [get_endianness]

gdb_test "break ${srcfile}:[gdb_get_line_number "return"]" \
    "Breakpoint $decimal at 0x\[0-9a-fA-F\]+: file .*${srcfile}.*\\\." \
    "set the breakpoint after setting the fp registers"

gdb_test "continue" \
    "Continuing.*Breakpoint $decimal.*" \
    "continue until breakpoint"

if {$endianness == "little"} {
    set reg_value0 "0x1f1e1d1c1b1a19181716151413121110"
    set reg_value1 "0x2f2e2d2c2b2a29282726252423222120"
} else {
    set reg_value0 "0x101112131415161718191a1b1c1d1e1f"
    set reg_value1 "0x202122232425262728292a2b2c2d2e2f"
}

gdb_test "p/x \$q0" \
    "q0.*{u = $reg_value0, s = $reg_value0.*" \
    "check register q0 value"

gdb_test "p/x \$q1" \
    "q1.*{u = $reg_value1, s = $reg_value1.*" \
    "check register q1 value"

gdb_test "p/x \$v0" \
    "v0.*$reg_value0}}}" \
    "check register v0 value"

gdb_test "p/x \$v1" \
    "v1.*$reg_value1}}}" \
    "check register v1 value"

gdb_test "p/x \$fpsr" \
    "fpsr.*0x\[0-9a-fA-F\].*" \
    "check register fpsr value"

gdb_test "p/x \$fpcr" \
    "fpcr.*0x\[0-9a-fA-F\].*" \
    "check register fpcr value"

with_test_prefix "bfloat16" {
    gdb_test "set \$h0.bf = 1.185e-38" \
    ".*" \
    "set h0.bf to 129"

    gdb_test "p \$h0" \
    "h0.*{bf = 1.185e-38, f = 7.689e-06, u = 129, s = 129}" \
    "h0 fields are valid"

    gdb_test "set \$v0.h.bf\[0\] = 0" \
    "v0.* = 0" \
    "set v0.h.bf\[0\] to 0"

    gdb_test "p \$v0.h.s\[0\]" \
    "v0.* = 0" \
    "v0.h.s\[0\] is 0"

    gdb_test "set \$v0.h.bf\[0\] = 1.185e-38" \
    "v0.* = 1.185e-38" \
    "set v0.h.bf\[0\] to 129"

    gdb_test "p \$v0.h.s\[0\]" \
    "v0.* = 129" \
    "v0.h.s\[0\] is 129"
}