diff options
author | Michael Snyder <msnyder@vmware.com> | 2009-12-10 19:36:20 +0000 |
---|---|---|
committer | Michael Snyder <msnyder@vmware.com> | 2009-12-10 19:36:20 +0000 |
commit | 0fa6cf1b45216a678549ff81c211b2a1172793bd (patch) | |
tree | 4794139ee23a2bb833100c425f9d8309a660f530 /gdb | |
parent | 0289bdd781492ea4bb4e8da868fb6c4fb85d70ae (diff) | |
download | gdb-0fa6cf1b45216a678549ff81c211b2a1172793bd.zip gdb-0fa6cf1b45216a678549ff81c211b2a1172793bd.tar.gz gdb-0fa6cf1b45216a678549ff81c211b2a1172793bd.tar.bz2 |
2009-12-10 Oza Pawandeep (paawan1982@yahoo.com
* gdb.reverse/i387-env-reverse.c: New file.
* gdb.reverse/i387-env-reverse.exp: New file.
* gdb.reverse/i387-stack-reverse.c: New file.
* gdb.reverse/i387-stack-reverse.exp: New file.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.reverse/i387-env-reverse.c | 60 | ||||
-rw-r--r-- | gdb/testsuite/gdb.reverse/i387-env-reverse.exp | 147 | ||||
-rw-r--r-- | gdb/testsuite/gdb.reverse/i387-stack-reverse.c | 38 | ||||
-rw-r--r-- | gdb/testsuite/gdb.reverse/i387-stack-reverse.exp | 177 |
5 files changed, 429 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 069280c..751df31 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2009-12-10 Oza Pawandeep (paawan1982@yahoo.com + + * gdb.reverse/i387-env-reverse.c: New file. + * gdb.reverse/i387-env-reverse.exp: New file. + * gdb.reverse/i387-stack-reverse.c: New file. + * gdb.reverse/i387-stack-reverse.exp: New file. + 2009-12-08 Phil Muldoon <pmuldoon@redhat.com> * gdb.python/py-type.exp (test_range): New test. diff --git a/gdb/testsuite/gdb.reverse/i387-env-reverse.c b/gdb/testsuite/gdb.reverse/i387-env-reverse.c new file mode 100644 index 0000000..c346879 --- /dev/null +++ b/gdb/testsuite/gdb.reverse/i387-env-reverse.c @@ -0,0 +1,60 @@ +#include <stdio.h> +#include <math.h> +#include <stdlib.h> + + +float no1,no2,no3,no4,no5,no6,no7; +float result,resultd,resultld; +float *float_memory; +long double ldx = 88888888888888888888.88, ldy = 9999999999999999999.99; +double x = 100.345, y = 25.7789; +/* marks FPU stack as empty */ +void empty_fpu_stack() +{ + asm ("ffree %st(1) \n\t" + "ffree %st(2) \n\t" + "ffree %st(3) \n\t" + "ffree %st(4) \n\t" + "ffree %st(5) \n\t" + "ffree %st(6) \n\t" + "ffree %st(7)"); +} + +/* initialization of floats */ +void init_floats() +{ + no1 = 10.45; + no2 = 20.77; + no3 = 156.89874646; + no4 = 14.56; + no5 = 11.11; + no6 = 66.77; + no7 = 88.88; + float_memory = malloc(sizeof(float) * 4); + *float_memory = 256.256; + *(float_memory + 1) = 356.356; + *(float_memory + 2) = 456.456; + *(float_memory + 3) = 556.556; +} + +int main() +{ + init_floats(); + empty_fpu_stack(); /* BEGIN I387-FLOAT-REVERSE */ + + asm("nop"); /* TEST ENV */ + asm ("fsave %0" : "=m"(*float_memory) : ); + asm ("frstor %0" : : "m"(*float_memory)); + asm ("fstsw %ax"); /* test eax register */ + + asm ("fld1"); + asm ("fldl2t"); + asm ("fldl2e"); + asm ("fldpi"); + asm ("fldlg2"); + asm ("fldln2"); + asm ("fldz"); + asm ("nop"); + + return 1; /* END I387-FLOAT-REVERSE */ +} diff --git a/gdb/testsuite/gdb.reverse/i387-env-reverse.exp b/gdb/testsuite/gdb.reverse/i387-env-reverse.exp new file mode 100644 index 0000000..985675b --- /dev/null +++ b/gdb/testsuite/gdb.reverse/i387-env-reverse.exp @@ -0,0 +1,147 @@ +# Copyright 2009 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. + +if $tracelevel { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +if ![istarget "i?86-*linux*"] then { + verbose "Skipping i387 reverse float tests." + return +} + +set testfile "i387-env-reverse" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +# some targets have leading underscores on assembly symbols. +# TODO: detect this automatically +set additional_flags "" +if [istarget "i?86-*-cygwin*"] then { + set additional_flags "additional_flags=-DSYMBOL_PREFIX=\"_\"" +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } { + untested i387-float-reverse + return -1 +} + +# Get things started. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} +runto main + +# Record to end of main + +set location [gdb_get_line_number "END I387-FLOAT-REVERSE"] +gdb_test "record" "" "Turn on process record" +gdb_test "until $location" ".*/$srcfile:$location.*" \ + "record to end of main" + +# Now rewind to beginning so we can begin testing. + +set location [gdb_get_line_number "BEGIN I387-FLOAT-REVERSE"] +gdb_test "set exec-dir reverse" "" "set reverse direction" +gdb_test "until $location" ".*/$srcfile:$location.*" \ + "rewind to beginning of main" +gdb_test "set exec-dir forward" "" "set forward direction" + +# Test FPU env particularly ftag and fstatus reigters. + +set location [gdb_get_line_number "TEST ENV"] +gdb_test "until $location" ".*/$srcfile:$location.*asm.*nop.*" \ + "begin testing fpu env" + +gdb_test "n" "asm.*fsave.*" "save FPU env in memory" +gdb_test "n" "asm.*frstor.*" "restore FPU env" +gdb_test "n" "asm.*fstsw.*" "store status word in EAX" +gdb_test "n" "asm.*fld1.*" "push st0" + +gdb_test "info register eax" "eax *0x8040000.*\t.*" "verify eax == 0x8040000" +gdb_test "info register fstat" "fstat *0.*\t.*" "verify fstat == 0" +gdb_test "info register ftag" "ftag *0xffff.*\t.*" "verify ftag == 0xffff" + +gdb_test "stepi" "asm.*fldl2t.*" "push st0" +gdb_test "info register fstat" "fstat *0x3800.*\t.*" "verify fstat == 0x3800" +gdb_test "info register ftag" "ftag *0x3fff.*\t.*" "verify ftag == 0x3fff" + +gdb_test "stepi" "asm.*fldl2e.*" "push st0" +gdb_test "info register fstat" "fstat *0x3000.*\t.*" "verify fstat == 0x3000" +gdb_test "info register ftag" "ftag *0xfff.*\t.*" "verify ftag == 0xfff" + +gdb_test "stepi" "asm.*fldpi.*" "push st0" +gdb_test "info register fstat" "fstat *0x2800.*\t.*" "verify fstat == 0x2800" +gdb_test "info register ftag" "ftag *0x3ff.*\t.*" "verify ftag == 0x3ff" + +gdb_test "stepi" "asm.*fldlg2.*" "push st0" +gdb_test "info register fstat" "fstat *0x2000.*\t.*" "verify fstat == 0x2000" +gdb_test "info register ftag" "ftag *0xff.*\t.*" "verify ftag == 0xff" + +gdb_test "stepi" "asm.*fldln2.*" "push st0" +gdb_test "info register fstat" "fstat *0x1800.*\t.*" "verify fstat == 0x1800" +gdb_test "info register ftag" "ftag *0x3f.*\t.*" "verify ftag == 0x3f" + +gdb_test "stepi" "asm.*fldz.*" "push st0" +gdb_test "info register fstat" "fstat *0x1000.*\t.*" "verify fstat == 0x1000" +gdb_test "info register ftag" "ftag *0xf.*\t.*" "verify ftag == 0xf" + +gdb_test "stepi" "asm.*nop.*" "push st0" +gdb_test "info register fstat" "fstat *0x800.*\t.*" "verify fstat == 0x800" +gdb_test "info register ftag" "ftag *0x7.*\t.*" "verify ftag == 0x7" + + +# move backward and ehck we get the same registers back. + +gdb_test "reverse-stepi" "asm.*fldz.*" "push st0" +gdb_test "info register fstat" "fstat *0x1000.*\t.*" "verify fstat == 0x1000" +gdb_test "info register ftag" "ftag *0xf.*\t.*" "verify ftag == 0xf" + +gdb_test "reverse-stepi" "asm.*fldln2.*" "push st0" +gdb_test "info register fstat" "fstat *0x1800.*\t.*" "verify fstat == 0x1800" +gdb_test "info register ftag" "ftag *0x3f.*\t.*" "verify ftag == 0x3f" + +gdb_test "reverse-stepi" "asm.*fldlg2.*" "push st0" +gdb_test "info register fstat" "fstat *0x2000.*\t.*" "verify fstat == 0x2000" +gdb_test "info register ftag" "ftag *0xff.*\t.*" "verify ftag == 0xff" + +gdb_test "reverse-stepi" "asm.*fldpi.*" "push st0" +gdb_test "info register fstat" "fstat *0x2800.*\t.*" "verify fstat == 0x2800" +gdb_test "info register ftag" "ftag *0x3ff.*\t.*" "verify ftag == 0x3ff" + +gdb_test "reverse-stepi" "asm.*fldl2e.*" "push st0" +gdb_test "info register fstat" "fstat *0x3000.*\t.*" "verify fstat == 0x3000" +gdb_test "info register ftag" "ftag *0xfff.*\t.*" "verify ftag == 0xfff" + +gdb_test "reverse-stepi" "asm.*fldl2t.*" "push st0" +gdb_test "info register fstat" "fstat *0x3800.*\t.*" "verify fstat == 0x3800" +gdb_test "info register ftag" "ftag *0x3fff.*\t.*" "verify ftag == 0x3fff" + +gdb_test "reverse-stepi" "asm.*fld1.*" "push st0" +gdb_test "info register fstat" "fstat *0.*\t.*" "verify fstat == 0" +gdb_test "info register ftag" "ftag *0xffff.*\t.*" "verify ftag == 0xffff" + + + + + + diff --git a/gdb/testsuite/gdb.reverse/i387-stack-reverse.c b/gdb/testsuite/gdb.reverse/i387-stack-reverse.c new file mode 100644 index 0000000..8c690f7 --- /dev/null +++ b/gdb/testsuite/gdb.reverse/i387-stack-reverse.c @@ -0,0 +1,38 @@ +#include <stdio.h> +#include <math.h> +#include <stdlib.h> + +/* marks FPU stack as empty */ +void empty_fpu_stack() +{ + asm ("ffree %st(1) \n\t" + "ffree %st(2) \n\t" + "ffree %st(3) \n\t" + "ffree %st(4) \n\t" + "ffree %st(5) \n\t" + "ffree %st(6) \n\t" + "ffree %st(7)"); +} + +/* tests floating point arithmatic */ +void test_arith_floats() +{ + +} + +int main() +{ + empty_fpu_stack(); /* BEGIN I387-FLOAT-REVERSE */ + + asm ("fld1"); /* test st0 register */ + asm ("fldl2t"); /* test st0, st1 */ + asm ("fldl2e"); /* test st0, st1, st2 */ + asm ("fldpi"); /* test st0, st1, st2, st3 */ + asm ("fldlg2"); /* test st0, st1, st2, st3, st4 */ + asm ("fldln2"); /* test st0, st1, st2, st3, st4, st5 */ + asm ("fldz"); /* test st0, st1, st2, st3, st4, st5, st6 */ + asm ("fld1"); /* test st0, st1, st2, st3, st4, st5, st6, st7 */ + asm ("nop"); + + return 1; /* END I387-FLOAT-REVERSE */ +} diff --git a/gdb/testsuite/gdb.reverse/i387-stack-reverse.exp b/gdb/testsuite/gdb.reverse/i387-stack-reverse.exp new file mode 100644 index 0000000..bb38e59 --- /dev/null +++ b/gdb/testsuite/gdb.reverse/i387-stack-reverse.exp @@ -0,0 +1,177 @@ +# Copyright 2009 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. + +if $tracelevel { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +if ![istarget "i?86-*linux*"] then { + verbose "Skipping i387 reverse float tests." + return +} + +set testfile "i387-stack-reverse" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +# some targets have leading underscores on assembly symbols. +# TODO: detect this automatically +set additional_flags "" +if [istarget "i?86-*-cygwin*"] then { + set additional_flags "additional_flags=-DSYMBOL_PREFIX=\"_\"" +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } { + untested i387-float-reverse + return -1 +} + +# Get things started. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} +runto main + +# Record to end of main + +set location [gdb_get_line_number "END I387-FLOAT-REVERSE"] +gdb_test "record" "" "Turn on process record" +gdb_test "until $location" ".*/$srcfile:$location.*" \ + "record to end of main" + +# Now rewind to beginning so we can begin testing. + +set location [gdb_get_line_number "BEGIN I387-FLOAT-REVERSE"] +gdb_test "set exec-dir reverse" "" "set reverse direction" +gdb_test "until $location" ".*/$srcfile:$location.*" \ + "rewind to beginning of main" +gdb_test "set exec-dir forward" "" "set forward direction" + +# Test FPU stack. FPU stack includes st0, st1, st2, st3, st4, +# st5, st6, st7. We push 8 values to FPU stack in record mode +# and see whether all are getting recorded. + +set location [gdb_get_line_number "test st0 register"] +gdb_test "until $location" ".*/$srcfile:$location.*asm.*fld1.*" \ + "begin test st0" +gdb_test "stepi" "asm.*fldl2t.*" "push st0 == 1" +gdb_test "info register st0" "st0 *1\t.*" "verify st0 == 1" + + +gdb_test "stepi" "asm.*fldl2e.*" "push st0 == 3.3219280948*" +gdb_test "info register st0" "st0 *3.32192.*\t.*" "verify st0 == 3.321928094*" +gdb_test "info register st1" "st1 *1\t.*" "verify st1 == 1" + +gdb_test "stepi" "asm.*fldpi.*" "push st0 == 1.4426950406*" +gdb_test "info register st0" "st0 *1.44269.*\t.*" "verify st0 == 1.442695040*" +gdb_test "info register st1" "st1 *3.32192.*\t.*" "verify st1 == 3.3219280948*" +gdb_test "info register st2" "st2 *1\t.*" "verify st2 == 1" + +gdb_test "stepi" "asm.*fldlg2.*" "push st0 == 3.14159265*" +gdb_test "info register st0" "st0 *3.14159.*\t.*" "verify st0 == 3.14159265*" +gdb_test "info register st1" "st1 *1.44269.*\t.*" "verify st1 == 1.4426950*" +gdb_test "info register st2" "st2 *3.32192.*\t.*" "verify st2 == 3.3219280*" +gdb_test "info register st3" "st3 *1\t.*" "verify st3 == 1" + +gdb_test "stepi" "asm.*fldln2.*" "push st0 == 0.301029*" +gdb_test "info register st0" "st0 *0.30102.*\t.*" "verify st0 == 0.301029*" +gdb_test "info register st1" "st1 *3.14159.*\t.*" "verify st1 == 3.14159265*" +gdb_test "info register st2" "st2 *1.44269.*\t.*" "verify st2 == 1.44269506*" +gdb_test "info register st3" "st3 *3.32192.*\t.*" "verify st3 == 3.3219280948*" +gdb_test "info register st4" "st4 *1\t.*" "verify st4 == 1" + +gdb_test "stepi" "asm.*fldz.*" "push st0 == 0.69314*" +gdb_test "info register st0" "st0 *0.69314.*\t.*" "verify st0 == 0.69314*" +gdb_test "info register st1" "st1 *0.30102.*\t.*" "verify st1 == 0.301029*" +gdb_test "info register st2" "st2 *3.14159.*\t.*" "verify st2 == 3.14159265*" +gdb_test "info register st3" "st3 *1.44269.*\t.*" "verify st3 == 1.442695040*" +gdb_test "info register st4" "st4 *3.32192.*\t.*" "verify st4 == 3.3219280948*" +gdb_test "info register st5" "st5 *1\t.*" "verify st5 == 1" + +gdb_test "stepi" "asm.*fld1.*" "push st0 == 0" +gdb_test "info register st0" "st0 *0\t.*" "verify st0 == 0" +gdb_test "info register st1" "st1 *0.69314.*\t.*" "verify st1 == 0.69314*" +gdb_test "info register st2" "st2 *0.30102.*\t.*" "verify st2 == 0.301029*" +gdb_test "info register st3" "st3 *3.14159.*\t.*" "verify st3 == 3.14159265*" +gdb_test "info register st4" "st4 *1.44269.*\t.*" "verify st4 == 1.442695040*" +gdb_test "info register st5" "st5 *3.32192.*\t.*" "verify st5 == 3.32192809*" +gdb_test "info register st6" "st6 *1\t.*" "verify st6 == 1" + +gdb_test "stepi" "asm.*nop.*" "push st0 == 0" +gdb_test "info register st0" "st0 *1\t.*" "verify st0 == 1" +gdb_test "info register st1" "st1 *0\t.*" "verify st1 == 0" +gdb_test "info register st2" "st2 *0.69314.*\t.*" "verify st2 == 0.69314*" +gdb_test "info register st3" "st3 *0.30102.*\t.*" "verify st3 == 0.301029*" +gdb_test "info register st4" "st4 *3.14159.*\t.*" "verify st4 == 3.14159265*" +gdb_test "info register st5" "st5 *1.44269.*\t.*" "verify st5 == 1.44269504*" +gdb_test "info register st6" "st6 *3.32192.*\t.*" "verify st6 == 3.3219280948*" +gdb_test "info register st7" "st7 *1.*" "verify st7 == 1" + +# Now step backward, and check that st0 value reverts to zero. + +gdb_test "reverse-stepi" "asm.*fld1.*" "undo registers, st0-st7" +gdb_test "info register st0" "st0 *0\t.*" "verify st0 == 0" +gdb_test "info register st1" "st1 *0.69314.*\t.*" "verify st1 == 0.69314*" +gdb_test "info register st2" "st2 *0.30102.*\t.*" "verify st2 == 0.301029*" +gdb_test "info register st3" "st3 *3.14159.*\t.*" "verify st3 == 3.14159265*" +gdb_test "info register st4" "st4 *1.44269.*\t.*" "verify st4 == 1.442695040*" +gdb_test "info register st5" "st5 *3.32192.*\t.*" "verify st5 == 3.3219280948*" +gdb_test "info register st6" "st6 *1\t.*" "verify st6 == 1" + +gdb_test "reverse-stepi" "asm.*fldz.*" "push st0 == 0.69314*" +gdb_test "info register st0" "st0 *0.69314.*\t.*" "verify st0 == 0.69314*" +gdb_test "info register st1" "st1 *0.30102.*\t.*" "verify st1 == 0.301029*" +gdb_test "info register st2" "st2 *3.14159.*\t.*" "verify st2 == 3.14159265*" +gdb_test "info register st3" "st3 *1.44269.*\t.*" "verify st3 == 1.442695040*" +gdb_test "info register st4" "st4 *3.32192.*\t.*" "verify st4 == 3.3219280948*" +gdb_test "info register st5" "st5 *1\t.*" "verify st5 == 1" + +gdb_test "reverse-stepi" "asm.*fldln2.*" "push st0 == 0.301029*" +gdb_test "info register st0" "st0 *0.30102.*\t.*" "verify st0 == 0.301029*" +gdb_test "info register st1" "st1 *3.14159.*\t.*" "verify st1 == 3.14159265*" +gdb_test "info register st2" "st2 *1.44269.*\t.*" "verify st2 == 1.442695040*" +gdb_test "info register st3" "st3 *3.32192.*\t.*" "verify st3 == 3.3219280948*" +gdb_test "info register st4" "st4 *1\t.*" "verify st4 == 1" + +gdb_test "reverse-stepi" "asm.*fldlg2.*" "push st0 == 3.14159265*" +gdb_test "info register st0" "st0 *3.14159.*\t.*" "verify st0 == 3.14159265*" +gdb_test "info register st1" "st1 *1.44269.*\t.*" "verify st1 == 1.442695040*" +gdb_test "info register st2" "st2 *3.32192.*\t.*" "verify st2 == 3.3219280948*" +gdb_test "info register st3" "st3 *1\t.*" "verify st3 == 1" + +gdb_test "reverse-stepi" "asm.*fldpi.*" "push st0 == 1.44269504088*" +gdb_test "info register st0" "st0 *1.44269.*\t.*" "verify st0 == 1.442695040*" +gdb_test "info register st1" "st1 *3.32192.*\t.*" "verify st1 == 3.3219280948*" +gdb_test "info register st2" "st2 *1\t.*" "verify st2 == 1" + + +gdb_test "reverse-stepi" "asm.*fldl2e.*" "push st0 == 3.3219280948*" +gdb_test "info register st0" "st0 *3.32192.*\t.*" "verify st0 == 3.3219280948*" +gdb_test "info register st1" "st1 *1\t.*" "verify st1 == 1" + +gdb_test "reverse-stepi" "asm.*fldl2t.*" "push st0 == 1" +gdb_test "info register st0" "st0 *1\t.*" "verify st0 == 1" + + + + + |