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