1 # Copyright
2018-2019 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 # Test MIPS Floating Point General Register handling in core files.
18 if { ![istarget
"mips*-*-*"] } then {
19 verbose
"Skipping MIPS Floating Point General Register tests."
25 if { [prepare_for_testing
"failed to prepare" ${testfile}] } {
29 # Procedure to
get current content of all floating
-point registers.
30 proc mips_fpregset_core_fetch_float_registers
{ test
} {
33 set all_registers_lines
{}
35 # Former trailing `\
[\r\n\
]+' may eat just \r leaving \n in the buffer
36 # corrupting the next matches.
37 if { [gdb_test_multiple "info registers float" $test {
38 -re "info registers float\r\n" {
41 -ex "The program has no registers now" {
45 -re "^\(?:fcsr\|fir\):\[ \t\]+\[^\r\n\]+\r\n" {
46 # Filter out control registers. They may or may not be a part
47 # of the float group depending on whether XML descriptions are
51 -re "^\[^ \t\]+\[ \t\]+\[^\r\n\]+\r\n" {
52 lappend all_registers_lines $expect_out(0,string)
58 -re "^\[^\r\n\]+\r\n" {
60 warning "Unrecognized output: $expect_out(0,string)"
75 return $all_registers_lines
78 # Generate a native core file.
80 set corefile [core_find $binfile]
81 set core_supported [expr {$corefile != ""}]
83 # Generate a core file with "gcore".
85 clean_restart ${binfile}
89 # Check if we have an FPU available.
90 gdb_test_multiple "show mipsfpu" "check for MIPS floating-point coprocessor" {
91 -re "The MIPS floating-point coprocessor\
92 .*\(absent\|unknown\).*$gdb_prompt $" {
93 unsupported "no MIPS floating-point coprocessor in the processor"
96 -re "The MIPS floating-point coprocessor .*$gdb_prompt $" {
97 verbose "MIPS floating-point coprocessor check successful."
105 # Save live FGR register contents.
106 set live_fgr_contents [mips_fpregset_core_fetch_float_registers \
107 "retrieve live FGR register contents"]
109 set gcorefile [standard_output_file gcore.test]
110 set gcore_supported [gdb_gcore_cmd "$gcorefile" "gcore"]
112 # Restart gdb and load COREFILE as a core file. SUPPORTED is true iff
113 # the core was generated successfully; otherwise, the tests are marked
116 proc mips_fpregset_core_test { supported corefile } {
117 upvar live_fgr_contents live_fgr_contents
118 upvar target_triplet target_triplet
119 upvar host_triplet host_triplet
120 upvar binfile binfile
122 clean_restart ${binfile}
124 set test "load core file"
126 set core_loaded [gdb_core_cmd $corefile $test]
132 if { $core_loaded == 1 } {
133 set test "core file FGR register contents"
134 set core_fgr_contents \
135 [mips_fpregset_core_fetch_float_registers "retrieve $test"]
136 if { $core_fgr_contents == $live_fgr_contents } then {
146 with_test_prefix "native" {
147 mips_fpregset_core_test $core_supported $corefile
150 with_test_prefix "gcore" {
151 mips_fpregset_core_test $gcore_supported $gcorefile