File: mips-fpregset-core.exp

package info (click to toggle)
gdb-doc 16.3-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid, trixie
  • size: 244,264 kB
  • sloc: ansic: 2,134,731; asm: 375,582; exp: 206,875; cpp: 73,639; makefile: 70,232; sh: 26,038; python: 13,697; yacc: 11,341; ada: 7,358; xml: 6,098; perl: 5,077; pascal: 3,389; tcl: 2,986; f90: 2,764; lisp: 1,984; cs: 879; lex: 738; sed: 228; awk: 181; objc: 137; fortran: 57
file content (151 lines) | stat: -rw-r--r-- 4,002 bytes parent folder | download | duplicates (6)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Copyright 2018-2024 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/>.

# Test MIPS Floating Point General Register handling in core files.

require {istarget "mips*-*-*"}

standard_testfile

if { [prepare_for_testing "failed to prepare" ${testfile}] } {
    return
}

# Procedure to get current content of all floating-point registers.
proc mips_fpregset_core_fetch_float_registers { test } {
    global gdb_prompt

    set all_registers_lines {}
    set bad -1
    # Former trailing `\[\r\n\]+' may eat just \r leaving \n in the buffer
    # corrupting the next matches.
    if { [gdb_test_multiple "info registers float" $test {
	-re "info registers float\r\n" {
	    exp_continue
	}
	-ex "The program has no registers now" {
	    set bad 1
	    exp_continue
	}
	-re "^\(?:fcsr\|fir\):\[ \t\]+\[^\r\n\]+\r\n" {
	    # Filter out control registers.  They may or may not be a part
	    # of the float group depending on whether XML descriptions are
	    # used or not.
	    exp_continue
	}
	-re "^\[^ \t\]+\[ \t\]+\[^\r\n\]+\r\n" {
	    lappend all_registers_lines $expect_out(0,string)
	    exp_continue
	}
	-re "$gdb_prompt $" {
	    incr bad
	}
	-re "^\[^\r\n\]+\r\n" {
	    if { !$bad } {
		warning "Unrecognized output: $expect_out(0,string)"
		set bad 1
	    }
	    exp_continue
	}
    }] != 0 } {
	return {}
    }

    if { $bad } {
	fail $test
	return {}
    }

    pass $test
    return $all_registers_lines
}

# Generate a native core file.

set corefile [core_find $binfile]
set core_supported [expr {$corefile != ""}]

# Generate a core file with "gcore".

clean_restart ${binfile}

runto break_here

# Check if we have an FPU available.
gdb_test_multiple "show mipsfpu" "check for MIPS floating-point coprocessor" {
    -re "The MIPS floating-point coprocessor\
	 .*\(absent\|unknown\).*$gdb_prompt $" {
        unsupported "no MIPS floating-point coprocessor in the processor"
        return
    }
    -re "The MIPS floating-point coprocessor .*$gdb_prompt $" {
        verbose "MIPS floating-point coprocessor check successful."
    }
    default {
        fail
        return
    }
}

# Save live FGR register contents.
set live_fgr_contents [mips_fpregset_core_fetch_float_registers \
    "retrieve live FGR register contents"]

set gcorefile [standard_output_file gcore.test]
set gcore_supported [gdb_gcore_cmd "$gcorefile" "gcore"]

# Restart gdb and load COREFILE as a core file.  SUPPORTED is true iff
# the core was generated successfully; otherwise, the tests are marked
# unsupported.
#
proc mips_fpregset_core_test { supported corefile } {
    upvar live_fgr_contents live_fgr_contents
    upvar target_triplet target_triplet
    upvar host_triplet host_triplet
    upvar binfile binfile

    clean_restart ${binfile}

    set test "load core file"
    if { $supported } {
	set core_loaded [gdb_core_cmd $corefile $test]
    } else {
	set core_loaded 0
	unsupported $test
    }

    if { $core_loaded == 1 } {
	set test "core file FGR register contents"
	set core_fgr_contents \
	    [mips_fpregset_core_fetch_float_registers "retrieve $test"]
	if {$core_fgr_contents == $live_fgr_contents} {
	    pass $test
	} else {
	    fail $test
	}
    } else {
	unsupported $test
    }
}

with_test_prefix "native" {
    mips_fpregset_core_test $core_supported $corefile
}

with_test_prefix "gcore" {
    mips_fpregset_core_test $gcore_supported $gcorefile
}

gdb_exit