1 |
227 |
jeremybenn |
# Copyright 2009, 2010 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 .
|
15 |
|
|
|
16 |
|
|
# This file is part of the gdb testsuite.
|
17 |
|
|
|
18 |
|
|
if $tracelevel {
|
19 |
|
|
strace $tracelevel
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
set prms_id 0
|
23 |
|
|
set bug_id 0
|
24 |
|
|
|
25 |
|
|
if ![istarget "i?86-*linux*"] then {
|
26 |
|
|
verbose "Skipping i387 reverse float tests."
|
27 |
|
|
return
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
set testfile "i387-env-reverse"
|
31 |
|
|
set srcfile ${testfile}.c
|
32 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
33 |
|
|
|
34 |
|
|
# some targets have leading underscores on assembly symbols.
|
35 |
|
|
# TODO: detect this automatically
|
36 |
|
|
set additional_flags ""
|
37 |
|
|
if [istarget "i?86-*-cygwin*"] then {
|
38 |
|
|
set additional_flags "additional_flags=-DSYMBOL_PREFIX=\"_\""
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } {
|
42 |
|
|
untested i387-float-reverse
|
43 |
|
|
return -1
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
# Get things started.
|
47 |
|
|
|
48 |
|
|
gdb_exit
|
49 |
|
|
gdb_start
|
50 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
51 |
|
|
gdb_load ${binfile}
|
52 |
|
|
runto main
|
53 |
|
|
|
54 |
|
|
# Record to end of main
|
55 |
|
|
|
56 |
|
|
set location [gdb_get_line_number "END I387-FLOAT-REVERSE"]
|
57 |
|
|
gdb_test "record" "" "Turn on process record"
|
58 |
|
|
gdb_test "until $location" ".*/$srcfile:$location.*" \
|
59 |
|
|
"record to end of main"
|
60 |
|
|
|
61 |
|
|
# Now rewind to beginning so we can begin testing.
|
62 |
|
|
|
63 |
|
|
set location [gdb_get_line_number "BEGIN I387-FLOAT-REVERSE"]
|
64 |
|
|
gdb_test "set exec-dir reverse" "" "set reverse direction"
|
65 |
|
|
gdb_test "until $location" ".*/$srcfile:$location.*" \
|
66 |
|
|
"rewind to beginning of main"
|
67 |
|
|
gdb_test "set exec-dir forward" "" "set forward direction"
|
68 |
|
|
|
69 |
|
|
# Test FPU env particularly ftag and fstatus reigters.
|
70 |
|
|
|
71 |
|
|
set location [gdb_get_line_number "TEST ENV"]
|
72 |
|
|
gdb_test "until $location" ".*/$srcfile:$location.*asm.*nop.*" \
|
73 |
|
|
"begin testing fpu env"
|
74 |
|
|
|
75 |
|
|
gdb_test "n" "asm.*fsave.*" "save FPU env in memory"
|
76 |
|
|
gdb_test "n" "asm.*frstor.*" "restore FPU env"
|
77 |
|
|
gdb_test "n" "asm.*fstsw.*" "store status word in EAX"
|
78 |
|
|
gdb_test "n" "asm.*fld1.*" "push st0"
|
79 |
|
|
|
80 |
|
|
gdb_test "info register eax" "eax *0x8040000.*\t.*" "verify eax == 0x8040000"
|
81 |
|
|
gdb_test "info register fstat" "fstat *0.*\t.*" "verify fstat == 0"
|
82 |
|
|
gdb_test "info register ftag" "ftag *0xffff.*\t.*" "verify ftag == 0xffff"
|
83 |
|
|
|
84 |
|
|
gdb_test "stepi" "asm.*fldl2t.*" "push st0"
|
85 |
|
|
gdb_test "info register fstat" "fstat *0x3800.*\t.*" "verify fstat == 0x3800"
|
86 |
|
|
gdb_test "info register ftag" "ftag *0x3fff.*\t.*" "verify ftag == 0x3fff"
|
87 |
|
|
|
88 |
|
|
gdb_test "stepi" "asm.*fldl2e.*" "push st0"
|
89 |
|
|
gdb_test "info register fstat" "fstat *0x3000.*\t.*" "verify fstat == 0x3000"
|
90 |
|
|
gdb_test "info register ftag" "ftag *0xfff.*\t.*" "verify ftag == 0xfff"
|
91 |
|
|
|
92 |
|
|
gdb_test "stepi" "asm.*fldpi.*" "push st0"
|
93 |
|
|
gdb_test "info register fstat" "fstat *0x2800.*\t.*" "verify fstat == 0x2800"
|
94 |
|
|
gdb_test "info register ftag" "ftag *0x3ff.*\t.*" "verify ftag == 0x3ff"
|
95 |
|
|
|
96 |
|
|
gdb_test "stepi" "asm.*fldlg2.*" "push st0"
|
97 |
|
|
gdb_test "info register fstat" "fstat *0x2000.*\t.*" "verify fstat == 0x2000"
|
98 |
|
|
gdb_test "info register ftag" "ftag *0xff.*\t.*" "verify ftag == 0xff"
|
99 |
|
|
|
100 |
|
|
gdb_test "stepi" "asm.*fldln2.*" "push st0"
|
101 |
|
|
gdb_test "info register fstat" "fstat *0x1800.*\t.*" "verify fstat == 0x1800"
|
102 |
|
|
gdb_test "info register ftag" "ftag *0x3f.*\t.*" "verify ftag == 0x3f"
|
103 |
|
|
|
104 |
|
|
gdb_test "stepi" "asm.*fldz.*" "push st0"
|
105 |
|
|
gdb_test "info register fstat" "fstat *0x1000.*\t.*" "verify fstat == 0x1000"
|
106 |
|
|
gdb_test "info register ftag" "ftag *0xf.*\t.*" "verify ftag == 0xf"
|
107 |
|
|
|
108 |
|
|
gdb_test "stepi" "asm.*nop.*" "push st0"
|
109 |
|
|
gdb_test "info register fstat" "fstat *0x800.*\t.*" "verify fstat == 0x800"
|
110 |
|
|
gdb_test "info register ftag" "ftag *0x7.*\t.*" "verify ftag == 0x7"
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
# move backward and ehck we get the same registers back.
|
114 |
|
|
|
115 |
|
|
gdb_test "reverse-stepi" "asm.*fldz.*" "push st0"
|
116 |
|
|
gdb_test "info register fstat" "fstat *0x1000.*\t.*" "verify fstat == 0x1000"
|
117 |
|
|
gdb_test "info register ftag" "ftag *0xf.*\t.*" "verify ftag == 0xf"
|
118 |
|
|
|
119 |
|
|
gdb_test "reverse-stepi" "asm.*fldln2.*" "push st0"
|
120 |
|
|
gdb_test "info register fstat" "fstat *0x1800.*\t.*" "verify fstat == 0x1800"
|
121 |
|
|
gdb_test "info register ftag" "ftag *0x3f.*\t.*" "verify ftag == 0x3f"
|
122 |
|
|
|
123 |
|
|
gdb_test "reverse-stepi" "asm.*fldlg2.*" "push st0"
|
124 |
|
|
gdb_test "info register fstat" "fstat *0x2000.*\t.*" "verify fstat == 0x2000"
|
125 |
|
|
gdb_test "info register ftag" "ftag *0xff.*\t.*" "verify ftag == 0xff"
|
126 |
|
|
|
127 |
|
|
gdb_test "reverse-stepi" "asm.*fldpi.*" "push st0"
|
128 |
|
|
gdb_test "info register fstat" "fstat *0x2800.*\t.*" "verify fstat == 0x2800"
|
129 |
|
|
gdb_test "info register ftag" "ftag *0x3ff.*\t.*" "verify ftag == 0x3ff"
|
130 |
|
|
|
131 |
|
|
gdb_test "reverse-stepi" "asm.*fldl2e.*" "push st0"
|
132 |
|
|
gdb_test "info register fstat" "fstat *0x3000.*\t.*" "verify fstat == 0x3000"
|
133 |
|
|
gdb_test "info register ftag" "ftag *0xfff.*\t.*" "verify ftag == 0xfff"
|
134 |
|
|
|
135 |
|
|
gdb_test "reverse-stepi" "asm.*fldl2t.*" "push st0"
|
136 |
|
|
gdb_test "info register fstat" "fstat *0x3800.*\t.*" "verify fstat == 0x3800"
|
137 |
|
|
gdb_test "info register ftag" "ftag *0x3fff.*\t.*" "verify ftag == 0x3fff"
|
138 |
|
|
|
139 |
|
|
gdb_test "reverse-stepi" "asm.*fld1.*" "push st0"
|
140 |
|
|
gdb_test "info register fstat" "fstat *0.*\t.*" "verify fstat == 0"
|
141 |
|
|
gdb_test "info register ftag" "ftag *0xffff.*\t.*" "verify ftag == 0xffff"
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
|