* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-07-03 18:55 paawan oza
2009-07-03 21:52 ` Michael Snyder
0 siblings, 1 reply; 40+ messages in thread
From: paawan oza @ 2009-07-03 18:55 UTC (permalink / raw)
To: Mark Kettenis; +Cc: pedro, msnyder, teawater, gdb-patches
Hi,
In My understanding the point was like below.
in the patch there were following register extended in enumeration in
i386-tdep.h
I386_FSTAT,
I386_FTAG,
I386_FISEG,
I386_FIOFF,
I386_FOSEG,
I386_FOOFF,
I386_FOP
According to Hui in some of his previous mails...his idea was
> FCTRL, FOP and so on are the fp reg of amd64. For now, prec is still
> not support amd64 And amd64's support are in amd64-tedp.... files. >Change i386_regnum is not a good idea. I suggest you divide fp patch to 2 >parts. One is for i386, the other for amd64. For now, just send i386 patch >for review. And send amd64 patch when prec support amd64"
while, my idea/understanding is:
FCTRL, FOP registers are not only a part of amd64, but also part of i386 (x87 FPU unit) also.
so according to me these registers are part of i386 also and it needed to be also in i386-tdep.h.
Regards,
Oza.
--- On Wed, 7/1/09, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> From: Mark Kettenis <mark.kettenis@xs4all.nl>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: paawan1982@yahoo.com
> Cc: pedro@codesourcery.com, msnyder@vmware.com, teawater@gmail.com, gdb-patches@sourceware.org
> Date: Wednesday, July 1, 2009, 9:42 PM
> > Date: Wed, 1 Jul 2009 09:02:17
> -0700 (PDT)
> > From: paawan oza <paawan1982@yahoo.com>
> >
> > Can somebody please help with this open point ?
>
> Sorry, I don't understand what point.
>
> > --- On Wed, 7/1/09, paawan oza <paawan1982@yahoo.com>
> wrote:
> >
> > > From: paawan oza <paawan1982@yahoo.com>
> > > Subject: Re: i386.record.floating.point.patch :
> with more testing and assurity
> > > To: "Pedro Alves" <pedro@codesourcery.com>,
> "Mark Kettenis" <mark.kettenis@xs4all.nl>,
> "Michael Snyder" <msnyder@vmware.com>,
> "Hui Zhu" <teawater@gmail.com>
> > > Cc: gdb-patches@sourceware.org
> > > Date: Wednesday, July 1, 2009, 9:30 PM
> > > Hi Hui,
> > >
> > > As I clarified earlier,
> > > these registers are already supported and
> extended by gdb
> > > much before this patch.
> > > all floating point registers are already
> supported by gdb
> > > (info floats/info all-registers command gives
> it)
> > >
> > > My aim is : only to make sure that whenever any
> floating
> > > point insn gets executed, we record the registers
>
> > > (no matter whether it is %st(n) or FCTRL or FTAG
> or
> > > FSTATUS)
> > > there are insns
> > > e.g. 'ffree' changes FTAG register, so we must
> record it.
> > >
> > > Do you mean to say that we should remove it from
> just
> > > enumaration ?
> > > but anyway we need to record those registers.
> > >
> > > Regards,
> > > Oza.
> > >
> > > --- On Wed, 7/1/09, Hui Zhu <teawater@gmail.com>
> > > wrote:
> > >
> > > > From: Hui Zhu <teawater@gmail.com>
> > > > Subject: Re:
> i386.record.floating.point.patch : with
> > > more testing and assurity
> > > > To: "paawan oza" <paawan1982@yahoo.com>,
> > > "Pedro Alves" <pedro@codesourcery.com>,
> > > "Mark Kettenis" <mark.kettenis@xs4all.nl>,
> > > "Michael Snyder" <msnyder@vmware.com>
> > > > Cc: gdb-patches@sourceware.org
> > > > Date: Wednesday, July 1, 2009, 11:23 AM
> > > > About this patch, I say my idea
> > > > again, I told in
> > > > http://sourceware.org/ml/gdb-patches/2009-06/msg00014.html
> > > > @@ -145,7 +145,22 @@
> > > > I386_ES_REGNUM,
> > > > /* %es */
> > > > I386_FS_REGNUM,
> > > > /* %fs */
> > > > I386_GS_REGNUM,
> > > > /* %gs */
> > > > - I386_ST0_REGNUM
> > > > /* %st(0) */
> > > > + I386_ST0_REGNUM,
> > > > /* %st(0) */
> > > > + I386_ST1_REGNUM,
> > > > /* %st(1) */
> > > > + I386_ST2_REGNUM,
> > > > /* %st(2) */
> > > > + I386_ST3_REGNUM,
> > > > /* %st(3) */
> > > > + I386_ST4_REGNUM,
> > > > /* %st(4) */
> > > > + I386_ST5_REGNUM,
> > > > /* %st(5) */
> > > > + I386_ST6_REGNUM,
> > > > /* %st(6) */
> > > > + I386_ST7_REGNUM,
> > > > /* %st(7) */
> > > > + I386_FCTRL,
> > > > /* floating point env regs :
> FCTRL-FOP
> > > > */
> > > > + I386_FSTAT,
> > > > + I386_FTAG,
> > > >
> > > > + I386_FISEG,
> > > > + I386_FIOFF,
> > > > + I386_FOSEG,
> > > > + I386_FOOFF,
> > > > + I386_FOP
> > > > };
> > > >
> > > > You are working on make prec x86 support fp
> insn, not
> > > to
> > > > extend the fp
> > > > function of i386 (If you want, you can make
> a special
> > > patch
> > > > for it).
> > > >
> > > > Hui
> > > >
> > > > On Tue, Jun 30, 2009 at 23:05, paawan
> oza<paawan1982@yahoo.com>
> > > > wrote:
> > > > >
> > > > > Hi,
> > > > > As I am submitting the patch for the
> first time,
> > > I am
> > > > not much aware of gdb test suite.
> > > > > would you please guide me about how I
> can put
> > > the
> > > > things in the testsuite ?
> > > > > is it the testsuite which comes along
> with the
> > > gdb
> > > > source ?
> > > > > gdb\testsuite\gdb.base ??
> > > > > Regards,
> > > > > Oza.
> > > > >
> > > > > --- On Tue, 6/30/09, Pedro Alves <pedro@codesourcery.com>
> > > > wrote:
> > > > >
> > > > >> From: Pedro Alves <pedro@codesourcery.com>
> > > > >> Subject: Re:
> i386.record.floating.point.patch
> > > :
> > > > with more testing and assurity
> > > > >> To: gdb-patches@sourceware.org
> > > > >> Cc: "paawan oza" <paawan1982@yahoo.com>,
> > > > teawater@gmail.com
> > > > >> Date: Tuesday, June 30, 2009, 7:09
> PM
> > > > >> On Tuesday 30 June 2009 14:23:30,
> > > > >> paawan oza wrote:
> > > > >> >
> > > > >> > > As suggested by Hui,
> > > > >> > > I have come up with more
> detailed
> > > and
> > > > granular
> > > > >> test case
> > > > >> > > for the patch which I had
> submitted
> > > last
> > > > week.
> > > > >>
> > > > >> Could you please consider migrating
> that test
> > > into
> > > > the
> > > > >> testsuite?
> > > > >> You've gone through the trouble of
> writing
> > > tests
> > > > to make
> > > > >> sure
> > > > >> the features work now --- putting
> it in the
> > > > testsuite means
> > > > >> we
> > > > >> have an automatic-ish means to
> check that it
> > > > doesn't get
> > > > >> inadvertently broken in the
> future. The way
> > > it
> > > > is,
> > > > >> when your
> > > > >> code gets in, the test will
> probably end up
> > > lost
> > > > in the
> > > > >> archives.
> > > > >> We wouldn't want that, would we?
> :-)
> > > Having
> > > > >> auto-tests, also helps
> > > > >> the person doing the review in
> confirming
> > > things
> > > > work as
> > > > >> expected (without much effort).
> > > > >>
> > > > >> --
> > > > >> Pedro Alves
> > > > >>
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-03 18:55 i386.record.floating.point.patch : with more testing and assurity paawan oza
@ 2009-07-03 21:52 ` Michael Snyder
0 siblings, 0 replies; 40+ messages in thread
From: Michael Snyder @ 2009-07-03 21:52 UTC (permalink / raw)
To: paawan oza; +Cc: Mark Kettenis, pedro, teawater, gdb-patches
paawan oza wrote:
> Hi,
>
> In My understanding the point was like below.
> in the patch there were following register extended in enumeration in
> i386-tdep.h
>
> I386_FSTAT,
> I386_FTAG,
> I386_FISEG,
> I386_FIOFF,
> I386_FOSEG,
> I386_FOOFF,
> I386_FOP
>
>
> According to Hui in some of his previous mails...his idea was
>> FCTRL, FOP and so on are the fp reg of amd64. For now, prec is still
>> not support amd64 And amd64's support are in amd64-tedp.... files. >Change i386_regnum is not a good idea. I suggest you divide fp patch to 2 >parts. One is for i386, the other for amd64. For now, just send i386 patch >for review. And send amd64 patch when prec support amd64"
>
>
> while, my idea/understanding is:
> FCTRL, FOP registers are not only a part of amd64, but also part of i386 (x87 FPU unit) also.
> so according to me these registers are part of i386 also and it needed to be also in i386-tdep.h.
>
> Regards,
> Oza.
I'm not sure why you want to add those constants to i386-tdep.h,
when the rest of your patch does not seem to use them.
^ permalink raw reply [flat|nested] 40+ messages in thread
[parent not found: <992589.56162.qm@web112513.mail.gq1.yahoo.com>]
* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-07-26 14:27 paawan oza
2009-07-26 22:51 ` Michael Snyder
` (2 more replies)
0 siblings, 3 replies; 40+ messages in thread
From: paawan oza @ 2009-07-26 14:27 UTC (permalink / raw)
To: Michael Snyder; +Cc: Hui Zhu, Mark Kettenis, pedro, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1205 bytes --]
Hi All,
I have worked on formatting part of the patch as per Michael and Hui's comments.
there is one problem I have been observing.
when I edit with emac and make everything correct....
still the command 'diff -bwEurN' gives some unaligned formatting at some lines.
but now things are much improved as far as far as formatting is concerned.
please find the files attached.
1) i386-tdep.c : this looks perfectly okay as per comments and formatting as per open source standard.
2) i386-tdep.orig.c : original file.
3) patch : when you edit this patch it has still some formatting problem
, but when you apply on linux, the resulting file looks okay.
please extract the attached package, you will find above contents
when I take the patch on windows and try to mail,
again format changes....and I have no clue (I tried to remove tabs, dos2unix etc....)
but still it is the same....
please help.
(please try take difference with attached files and see the 'diff' result, it is strange, if you take the patch on windows it gets even more worse with formatting)
please let me know where and how can I take the difference between new and original file (attached with mail)....
Regards,
Oza.
[-- Attachment #2: package.rar --]
[-- Type: application/octet-stream, Size: 60747 bytes --]
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-26 14:27 paawan oza
@ 2009-07-26 22:51 ` Michael Snyder
2009-07-27 1:09 ` Michael Snyder
2009-07-27 2:33 ` Samuel Bronson
2 siblings, 0 replies; 40+ messages in thread
From: Michael Snyder @ 2009-07-26 22:51 UTC (permalink / raw)
To: paawan oza; +Cc: Hui Zhu, Mark Kettenis, pedro, gdb-patches
paawan oza wrote:
> Hi All,
>
> I have worked on formatting part of the patch as per Michael and Hui's comments.
>
>
> there is one problem I have been observing.
> when I edit with emac and make everything correct....
> still the command 'diff -bwEurN' gives some unaligned formatting at some lines.
Unfortunately, the formatting (indent) issues are confusing:
1) Some are artifacts of the combination of spaces and tabs.
These can be ignored.
2) But some are still mis-indentations. I'll point some out.
> but now things are much improved as far as far as formatting is concerned.
>
> please find the files attached.
>
> 1) i386-tdep.c : this looks perfectly okay as per comments and formatting as per open source standard.
Well, much closer anyway. ;-)
> 2) i386-tdep.orig.c : original file.
And here's another issue. Your "orig" file is only up to date
as of July 9. There have been several cvs changes since then.
You need to always update and merge your files before submitting a diff.
> 3) patch : when you edit this patch it has still some formatting problem
> , but when you apply on linux, the resulting file looks okay.
>
> please extract the attached package, you will find above contents
>
> when I take the patch on windows and try to mail,
> again format changes....and I have no clue (I tried to remove tabs, dos2unix etc....)
> but still it is the same....
>
> please help.
> (please try take difference with attached files and see the 'diff' result, it is strange, if you take the patch on windows it gets even more worse with formatting)
>
> please let me know where and how can I take the difference between new and original file (attached with mail)....
Have you tried doing your diffs and your email from a linux machine?
I'll send diff comments in a separate email.
Michael
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-26 14:27 paawan oza
2009-07-26 22:51 ` Michael Snyder
@ 2009-07-27 1:09 ` Michael Snyder
2009-07-27 2:33 ` Samuel Bronson
2 siblings, 0 replies; 40+ messages in thread
From: Michael Snyder @ 2009-07-27 1:09 UTC (permalink / raw)
To: paawan oza; +Cc: Hui Zhu, Mark Kettenis, pedro, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 264 bytes --]
paawan oza wrote:
> (please try take difference with attached files and see the 'diff' result, it is strange, if you take the patch on windows it gets even more worse with formatting)
OK, I've done as you suggested. Here are my comments
(search for "msnyder):
[-- Attachment #2: reply.txt --]
[-- Type: text/plain, Size: 20382 bytes --]
--- i386-tdep.0726.c 2009-07-26 10:55:37.000013000 -0700
+++ i386-tdep.c 2009-07-26 11:00:19.001044000 -0700
@@ -3139,6 +3139,66 @@
return 0;
}
+
+/* Defines contents to record. */
+#define I386_SAVE_FPU_REGS 0xfffd
+#define I386_SAVE_FPU_ENV 0xfffe
+#define I386_SAVE_FPU_ENV_REG_STACK 0xffff
+
+/* Record the value of floating point registers which will be changed by the
+ current instruction to "record_arch_list". Return -1 if something is wrong.
+*/
+
+static int i386_record_floats (struct gdbarch *gdbarch,
+ struct i386_record_s *ir,
+ uint32_t iregnum)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ int i;
+
+ /* Oza:Because of floating point insn push/pop of fpu stack is going to
msnyder: "Oza: Because"
+ happen. Currently we store st0-st7 registers, but we need not store all
+ registers all the time, in future we use ftag register and record only
+ those who are not marked as an empty.
+ */
+ if (I386_SAVE_FPU_REGS == iregnum)
+ {
+ for (i = I387_ST0_REGNUM (tdep);i <= I387_ST0_REGNUM (tdep) + 7;i++)
msynder:
for (i = I387_ST0_REGNUM (tdep); i <= I387_ST0_REGNUM (tdep) + 7; i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache, i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV == iregnum)
+ {
+ for (i = I387_FCTRL_REGNUM (tdep);i <= I387_FOP_REGNUM (tdep);i++)
msnyder:
for (i = I387_FCTRL_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+ {
msnyder: indent { to the right by two spaces after "for".
+ if (record_arch_list_add_reg (ir->regcache, i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+ {
+ for (i = I387_ST0_REGNUM (tdep);i <= I387_FOP_REGNUM (tdep);i++)
msnyder:
for (i = I387_ST0_REGNUM (tdep); i <= I387_FOP_REGNUM (tdep); i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache, i))
+ return -1;
+ }
+ }
+ else if ((iregnum >= I387_ST0_REGNUM (tdep)) &&
+ (iregnum <= I387_FOP_REGNUM (tdep)))
+ {
+ if (record_arch_list_add_reg (ir->regcache,iregnum))
+ return -1;
+ }
+ else
+ {
+ /* Parameter error. */
+ return -1;
+ }
+ return 0;
+}
+
/* Parse the current instruction and record the values of the registers and
memory that will be changed in current instruction to "record_arch_list".
Return -1 if something wrong. */
@@ -3153,6 +3213,7 @@
uint32_t tmpu32;
uint32_t opcode;
struct i386_record_s ir;
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
memset (&ir, 0, sizeof (struct i386_record_s));
ir.regcache = regcache;
@@ -4188,8 +4249,7 @@
}
break;
- /* floats */
- /* It just record the memory change of instrcution. */
+ /* Floats. */
case 0xd8:
case 0xd9:
case 0xda:
@@ -4203,45 +4263,56 @@
ir.reg |= ((opcode & 7) << 3);
if (ir.mod != 3)
{
- /* memory */
+ /* Memory. */
uint32_t addr;
if (i386_record_lea_modrm_addr (&ir, &addr))
return -1;
switch (ir.reg)
{
- case 0x00:
- case 0x01:
case 0x02:
+ case 0x12:
+ case 0x22:
+ case 0x32:
+ /* For fcom, ficom nothing to do. */
+ break;
case 0x03:
+ case 0x13:
+ case 0x23:
+ case 0x33:
+ /* For fcomp, ficomp pop FPU stack, store all. */
+ if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0x00:
+ case 0x01:
case 0x04:
case 0x05:
case 0x06:
case 0x07:
case 0x10:
case 0x11:
- case 0x12:
- case 0x13:
case 0x14:
case 0x15:
case 0x16:
case 0x17:
case 0x20:
case 0x21:
- case 0x22:
- case 0x23:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x30:
case 0x31:
- case 0x32:
- case 0x33:
case 0x34:
case 0x35:
case 0x36:
case 0x37:
+ /* For fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul,
+ fisub, fisubr, fidiv, fidivr, modR/M.reg is an extension of code,
+ always affects st(0) register. */
+ if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+ return -1;
break;
case 0x08:
case 0x0a:
@@ -4250,6 +4321,7 @@
case 0x19:
case 0x1a:
case 0x1b:
+ case 0x1d:
case 0x28:
case 0x29:
case 0x2a:
@@ -4258,9 +4330,14 @@
case 0x39:
case 0x3a:
case 0x3b:
+ case 0x3c:
+ case 0x3d:
switch (ir.reg & 7)
{
case 0:
+ /* Handling fld, fild. */
+ if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
msnyder: indented too far (two spaces extra):
/* Handling fld, fild. */
if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
return -1;
break;
case 1:
switch (ir.reg >> 4)
@@ -4274,6 +4351,7 @@
return -1;
break;
case 3:
+ break;
msnyder: indented too far:
break;
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4284,15 +4362,49 @@
switch (ir.reg >> 4)
{
case 0:
+ if (record_arch_list_add_mem (addr, 4))
+ return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* For fstp m32fp. */
+ if (i386_record_floats (gdbarch, &ir,
+ I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
msnyder: indented four extra spaces too far.
case 1:
if (record_arch_list_add_mem (addr, 4))
return -1;
+ if ((3 == (ir.reg & 7)) \
+ || (5 == (ir.reg & 7)) \
+ || (7 == (ir.reg & 7)))
msnyder: remove '\' from end of lines:
if ((3 == (ir.reg & 7))
|| (5 == (ir.reg & 7))
|| (7 == (ir.reg & 7)))
+ {
+ /* For fstp insn. */
+ if (i386_record_floats (gdbarch, &ir,
+ I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 2:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* For fstp m64fp. */
+ if (i386_record_floats (gdbarch, &ir,
+ I386_SAVE_FPU_REGS))
+ return -1;
+ }
msnyder: indented too far.
break;
case 3:
+ if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+ {
+ /* For fistp, fbld, fild, fbstp. */
+ if (i386_record_floats (gdbarch, &ir,
+ I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ /*Fall through */
msnyder: indented too far.
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4302,11 +4414,21 @@
}
break;
case 0x0c:
+ /* Insn fldenv. */
+ if (i386_record_floats (gdbarch, &ir,
+ I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
case 0x0d:
- case 0x1d:
+ /* Insn fldcw. */
+ if (i386_record_floats (gdbarch, &ir, I387_FCTRL_REGNUM (tdep)))
+ return -1;
+ break;
case 0x2c:
- case 0x3c:
- case 0x3d:
+ /* Insn frstor. */
+ if (i386_record_floats (gdbarch, &ir,
+ I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
break;
case 0x0e:
if (ir.dflag)
@@ -4329,6 +4451,9 @@
case 0x3e:
if (record_arch_list_add_mem (addr, 10))
return -1;
+ /* Insn fstp, fbstp. */
+ if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
case 0x2e:
if (ir.dflag)
@@ -4345,10 +4470,17 @@
}
if (record_arch_list_add_mem (addr, 80))
return -1;
+ /* Insn fsave. */
+ if (i386_record_floats (gdbarch, &ir,
+ I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
break;
case 0x3f:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ /* Ins fistp. */
+ if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
default:
ir.addr -= 2;
@@ -4357,8 +4489,205 @@
break;
}
}
+ /* Opcode is an extension of modR/M byte. */
+ else
msnyder: above, indentation level minus two after }
/* Opcode is an extension of modR/M byte. */
else
+ {
+ switch (opcode)
msnyder: above, indentation level plus two after {
switch (opcode)
And then everything below this point needs to be re-indented to the right.
+ {
+ case 0xd8:
+ if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+ return -1;
+ break;
+ case 0xd9:
+ if (0x0c == (ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
msnyder: missing a right-indent.
+ }
+ else
+ {
+ if (i386_record_floats (gdbarch, &ir,
+ I387_ST0_REGNUM (tdep)))
msnyder: missing a right-indent.
+ return -1;
+ /* If only st(0) is changing, then we have already recorded. */
+ if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats (gdbarch, &ir,
msnyder: missing a right-indent.
+ I387_ST0_REGNUM (tdep) + \
msnyder: no \ at end of line.
I387_ST0_REGNUM (tdep) +
+ ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ }
+ else
+ {
msnyder: indentation.
+ switch(ir.modrm)
msnyder: "switch ("
+ {
+ case 0xe0:
+ case 0xe1:
+ case 0xf0:
+ case 0xf5:
+ case 0xf8:
+ case 0xfa:
+ case 0xfc:
+ case 0xfe:
+ case 0xff:
+ if (i386_record_floats (gdbarch, &ir,
+ I387_ST0_REGNUM (tdep)))
+ return -1;
+ break;
+ case 0xf1:
+ case 0xf2:
+ case 0xf3:
+ case 0xf4:
+ case 0xf6:
+ case 0xf7:
+ case 0xe8:
+ case 0xe9:
+ case 0xea:
+ case 0xeb:
+ case 0xec:
+ case 0xed:
+ case 0xee:
+ case 0xf9:
+ case 0xfb:
+ if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0xfd:
+ if (i386_record_floats (gdbarch, &ir,
+ I387_ST0_REGNUM (tdep)))
+ return -1;
+ if (i386_record_floats (gdbarch, &ir,
+ I387_ST0_REGNUM (tdep) + 1))
+ return -1;
+ break;
+ }
+ }
+ break;
+ case 0xda:
+ if (0xe9 == ir.modrm)
+ {
+ if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
msnyder: indentation after {
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
msnyder: indentation after {
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats (gdbarch, &ir,
msnyder: indentation after {
+ I387_ST0_REGNUM (tdep) +
+ (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats (gdbarch, &ir,
+ I387_ST0_REGNUM (tdep) + \
msnyder: no \ at end of line.
I387_ST0_REGNUM (tdep) +
+ ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdb:
+ if (0xe3 == ir.modrm)
+ {
+ if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_ENV))
msnyder: indentation after {
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats (gdbarch, &ir, I387_ST0_REGNUM (tdep)))
msnyder: indentation after {
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats (gdbarch, &ir,
msnyder: indentation after {
+ I387_ST0_REGNUM (tdep) + \
msnyder: no \ at end of line.
I387_ST0_REGNUM (tdep) +
+ (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats (gdbarch, &ir,
msnyder: indentation after {
+ I387_ST0_REGNUM (tdep) + \
msnyder: no \ at end of line.
I387_ST0_REGNUM (tdep) +
+ ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdc:
+ if ((0x0c == ir.modrm >> 4) \
+ || (0x0d == ir.modrm >> 4) \
+ || (0x0f == ir.modrm >> 4))
msnyder: no \ at end of line.
if ((0x0c == ir.modrm >> 4)
|| (0x0d == ir.modrm >> 4)
|| (0x0f == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats (gdbarch, &ir,
+ I387_ST0_REGNUM (tdep) + \
msnyder: no \ at end of line.
I387_ST0_REGNUM (tdep) +
+ (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats (gdbarch, &ir,
+ I387_ST0_REGNUM (tdep) + \
msnyder: no \ at end of line.
I387_ST0_REGNUM (tdep) +
+ ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdd:
+ if (0x0c == ir.modrm >> 4)
+ {
+ if (i386_record_floats (gdbarch, &ir,
+ I387_FTAG_REGNUM (tdep)))
+ return -1;
+ }
+ else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats (gdbarch, &ir,
+ I387_ST0_REGNUM (tdep) + \
msnyder: no \ at end of line.
I387_ST0_REGNUM (tdep) +
+ (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ }
+ break;
+ case 0xde:
+ if ((0x0c == ir.modrm >> 4) \
+ || (0x0e == ir.modrm >> 4) \
+ || (0x0f == ir.modrm >> 4) \
+ || (0xd9 == ir.modrm))
msnyder: no \ at end of line.
if ((0x0c == ir.modrm >> 4)
|| (0x0e == ir.modrm >> 4)
|| (0x0f == ir.modrm >> 4)
|| (0xd9 == ir.modrm))
+ {
+ if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ case 0xdf:
+ if (0xe0 == ir.modrm)
+ {
+ if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+ return -1;
+ }
+ else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if (i386_record_floats (gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ }
+ }
break;
-
/* string ops */
/* movsS */
case 0xa4:
@@ -4777,10 +5106,17 @@
/* fwait */
/* XXX */
case 0x9b:
- printf_unfiltered (_("Process record doesn't support instruction "
- "fwait.\n"));
- ir.addr -= 1;
- goto no_support;
+ if (target_read_memory (ir.addr, &tmpu8, 1))
+ {
+ if (record_debug)
+ printf_unfiltered (_("Process record: error reading memory at "
+ "addr 0x%s len = 1.\n"),
+ paddress (gdbarch, ir.addr));
msnyder: indentation
printf_unfiltered (_("Process record: error reading memory at "
"addr 0x%s len = 1.\n"),
paddress (gdbarch, ir.addr));
+ return -1;
+ }
+ opcode = (uint32_t) tmpu8;
+ ir.addr++;
+ goto reswitch;
break;
/* int3 */
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-26 14:27 paawan oza
2009-07-26 22:51 ` Michael Snyder
2009-07-27 1:09 ` Michael Snyder
@ 2009-07-27 2:33 ` Samuel Bronson
2 siblings, 0 replies; 40+ messages in thread
From: Samuel Bronson @ 2009-07-27 2:33 UTC (permalink / raw)
To: paawan oza; +Cc: Michael Snyder, Hui Zhu, Mark Kettenis, pedro, gdb-patches
Why a "rar" archive? "zip" would be much more likely to be accessbile
to others, and then again why not just attach each file individually?
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-07-06 19:09 paawan oza
0 siblings, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-07-06 19:09 UTC (permalink / raw)
To: Hui Zhu; +Cc: Michael Snyder, Mark Kettenis, pedro, gdb-patches
Hi,
I am not sure why the text looks little unformatted in the mail.
(but it is not)
but when I copy the patch and patch it on Linux, the code looks perfectly formatted.
Regards,
Oza.
--- On Tue, 7/7/09, paawan oza <paawan1982@yahoo.com> wrote:
> From: paawan oza <paawan1982@yahoo.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: "Hui Zhu" <teawater@gmail.com>
> Cc: "Michael Snyder" <msnyder@vmware.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "pedro@codesourcery.com" <pedro@codesourcery.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Tuesday, July 7, 2009, 12:34 AM
> Hi,
>
> please find the latest patch and ChangeLog as follows.
>
> ********************
> ChangeLog
> ********************
> Current: gdb-6.8.50.20090706
> 2009-07-06 Oza <paawan1982@yahoo.com>
>
> * i386-tdep.c: Support for
> floating point recording.
>
>
> ***************************
> i386.records.floats.patch
> ***************************
>
>
> diff -urN ./gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
> --- ./gdb.orig/i386-tdep.c 2009-07-02
> 13:25:54.000000000 -0400
> +++ gdb.new/i386-tdep.c 2009-07-06
> 23:44:07.000000000 -0400
> @@ -3056,6 +3056,66 @@
> return 0;
> }
>
> +
> +/* Defines contents to record. */
> +#define I386_SAVE_FPU_REGS
> 0xfffd
> +#define I386_SAVE_FPU_ENV
> 0xfffe
> +#define I386_SAVE_FPU_ENV_REG_STACK
> 0xffff
> +
> +/* Record the value of floating point registers which will
> be changed by the
> + Current instruction to
> "record_arch_list".
> + Return -1 if something is wrong.
> */
> +
> +static int i386_record_floats(struct gdbarch *gdbarch,
> +
> struct
> i386_record_s *ir,
> +
> uint32_t
> iregnum)
> +{
> + struct gdbarch_tdep *tdep = gdbarch_tdep
> (gdbarch);
> + int i;
> +
> + /* Oza : because of floating point insn push/pop of
> fpu stack
> + Is going to happen. currently we store st0-st7
> registers,
> + But we need not store all registers all the time,
> In future
> + We use ftag register and record only those who are
> not marked as an empty.
> + */
> + if (I386_SAVE_FPU_REGS == iregnum)
> + {
> + for (i = I387_ST0_REGNUM (tdep);i
> <= I387_ST0_REGNUM (tdep) + 7;i++)
> + {
> + if
> (record_arch_list_add_reg (ir->regcache,i))
> + return -1;
> + }
> + }
> + else if (I386_SAVE_FPU_ENV == iregnum)
> + {
> + for (i = I387_FCTRL_REGNUM(tdep);i
> <= I387_FOP_REGNUM(tdep);i++)
> + {
> + if (record_arch_list_add_reg
> (ir->regcache,i))
> + return -1;
> + }
> + }
> + else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
> + {
> + for (i = I387_ST0_REGNUM (tdep);i
> <= I387_FOP_REGNUM(tdep);i++)
> + {
> + if (record_arch_list_add_reg
> (ir->regcache,i))
> + return -1;
>
> + }
> + }
> + else if ((iregnum >= I387_ST0_REGNUM (tdep))
> &&
> + (iregnum
> <= I387_FOP_REGNUM(tdep)))
> + {
> + if (record_arch_list_add_reg
> (ir->regcache,iregnum))
> + return -1;
> + }
> + else
> + {
> + /* Parameter error. */
> + return -1;
> + }
> + return 0;
> +}
> +
> /* Parse the current instruction and record the values of
> the registers and
> memory that will be changed in current
> instruction to "record_arch_list".
> Return -1 if something wrong. */
> @@ -3070,6 +3130,7 @@
> uint32_t tmpu32;
> uint32_t opcode;
> struct i386_record_s ir;
> + struct gdbarch_tdep *tdep = gdbarch_tdep
> (gdbarch);
>
> memset (&ir, 0, sizeof (struct
> i386_record_s));
> ir.regcache = regcache;
> @@ -4105,8 +4166,7 @@
> }
> break;
>
> - /* floats */
> - /* It just record the memory change
> of instrcution. */
> + /* Floats. */
> case 0xd8:
> case 0xd9:
> case 0xda:
> @@ -4120,46 +4180,57 @@
> ir.reg |= ((opcode & 7)
> << 3);
> if (ir.mod != 3)
> {
> - /* memory */
> + /* Memory. */
> uint32_t addr;
>
> if (i386_record_lea_modrm_addr
> (&ir, &addr))
> return -1;
> switch (ir.reg)
> {
> - case 0x00:
> - case 0x01:
> case 0x02:
> - case 0x03:
> + case 0x12:
> + case 0x22:
> + case 0x32:
> + /* For fcom, ficom
> nothing to do. */
> + break;
> + case 0x03:
> + case 0x13:
> + case 0x23:
> + case 0x33:
> + /* For
> fcomp, ficomp pop FPU stack, store all. */
> + if
> (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> +
> return -1;
> + break;
> + case 0x00:
> + case
> 0x01:
> case 0x04:
> case 0x05:
> case 0x06:
> case 0x07:
> case 0x10:
> - case 0x11:
> - case 0x12:
> - case 0x13:
> + case
> 0x11:
> case 0x14:
> case 0x15:
> case 0x16:
> case 0x17:
> case 0x20:
> case 0x21:
> - case 0x22:
> - case 0x23:
> case 0x24:
> case 0x25:
> case 0x26:
> case 0x27:
> case 0x30:
> case 0x31:
> - case 0x32:
> - case 0x33:
> case 0x34:
> case 0x35:
> case 0x36:
> case 0x37:
> - break;
> + /* For fadd, fmul,
> fsub, fsubr, fdiv, fdivr, fiadd, fimul,
> +
> fisub, fisubr, fidiv, fidivr, modR/M.reg
> is an extension of code,
> +
> Always affects st(0) register. */
> + if
> (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM
> (tdep)))
> +
> return -1;
> +
> break;
>
>
> case 0x08:
> case 0x0a:
> case 0x0b:
> @@ -4167,6 +4238,7 @@
> case 0x19:
> case 0x1a:
> case 0x1b:
> + case 0x1d:
> case 0x28:
> case 0x29:
> case 0x2a:
> @@ -4174,11 +4246,16 @@
> case 0x38:
> case 0x39:
> case 0x3a:
> - case 0x3b:
> + case
> 0x3b:
> + case 0x3c:
> + case 0x3d:
> switch (ir.reg
> & 7)
> {
> case 0:
> - break;
> + /* Handling
> fld, fild. */
> + if
> (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> +
> return -1;
> +
> break;
> case 1:
> switch
> (ir.reg >> 4)
> {
> @@ -4191,6 +4268,7 @@
>
> return -1;
>
> break;
> case
> 3:
> +
> break;
>
> default:
>
> if (record_arch_list_add_mem (addr, 2))
>
> return -1;
> @@ -4201,15 +4279,48 @@
> switch
> (ir.reg >> 4)
> {
> case
> 0:
> +
> if (record_arch_list_add_mem (addr, 4))
> +
> return -1;
> +
> if (3 == (ir.reg & 7))
> +
> {
> +
> /* For fstp m32fp */
> +
> if (i386_record_floats(gdbarch, &ir, \
> +
>
>
> I386_SAVE_FPU_REGS))
> +
> return -1;
>
> +
> }
> +
> break;
> case
> 1:
>
> if (record_arch_list_add_mem (addr, 4))
>
> return -1;
> +
> if ((3 == (ir.reg & 7)) \
> +
> || (5 == (ir.reg
> & 7)) \
> +
> || (7 == (ir.reg
> & 7)))
> +
> {
> +
> /* For fstp insn */
> +
> if (i386_record_floats(gdbarch, &ir, \
> +
>
>
> I386_SAVE_FPU_REGS))
> +
> return -1;
>
> +
> }
>
> break;
> case
> 2:
>
> if (record_arch_list_add_mem (addr, 8))
>
> return -1;
> +
> if (3 == (ir.reg & 7))
> +
> {
> +
> /* For fstp m64fp */
> +
> if (i386_record_floats(gdbarch, &ir, \
> +
>
>
> I386_SAVE_FPU_REGS))
> +
> return -1;
>
> +
> }
>
> break;
> case
> 3:
> +
> if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg
> & 7)))
> +
> {
> +
> /* For fistp, fbld, fild,
> fbstp. */
> +
> if (i386_record_floats(gdbarch, &ir, \
> +
>
>
> I386_SAVE_FPU_REGS))
> +
> return -1;
>
> +
> }
>
>
> default:
>
> if (record_arch_list_add_mem (addr, 2))
>
> return -1;
> @@ -4218,54 +4329,74 @@
> break;
> }
> break;
> - case 0x0c:
> - case 0x0d:
> - case 0x1d:
> - case 0x2c:
> - case 0x3c:
> - case 0x3d:
> - break;
> - case 0x0e:
> + case
> 0x0c:
> + /* Insn
> fldenv. */
> + if
> (i386_record_floats(gdbarch, &ir, \
> +
>
> I386_SAVE_FPU_ENV_REG_STACK))
> + return
> -1;
> + break;
> + case 0x0d:
> + /* Insn
> fldcw. */
> + if
> (i386_record_floats(gdbarch, &ir, I387_FCTRL_REGNUM
> (tdep)))
> + return
> -1;
> + break;
> + case 0x2c:
> + /* Insn
> frstor. */
> + if
> (i386_record_floats(gdbarch, &ir, \
> +
>
> I386_SAVE_FPU_ENV_REG_STACK))
> + return
> -1;
> + break;
> + case 0x0e:
> if (ir.dflag)
> {
> - if
> (record_arch_list_add_mem (addr, 28))
> - return
> -1;
> + if
> (record_arch_list_add_mem (addr, 28))
> + return -1;
> }
> else
> {
> - if
> (record_arch_list_add_mem (addr, 14))
> - return
> -1;
> + if
> (record_arch_list_add_mem (addr, 14))
> + return -1;
> }
> break;
> - case 0x0f:
> - case 0x2f:
> + case 0x0f:
> + case 0x2f:
> if
> (record_arch_list_add_mem (addr, 2))
> return -1;
> break;
> - case 0x1f:
> - case 0x3e:
> + case 0x1f:
> + case 0x3e:
> if
> (record_arch_list_add_mem (addr, 10))
> return -1;
> + /* Insn
> fstp, fbstp. */
> + if
> (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> + return
> -1;
>
>
> break;
> - case 0x2e:
> + case 0x2e:
> if (ir.dflag)
> {
> - if
> (record_arch_list_add_mem (addr, 28))
> - return
> -1;
> - addr += 28;
> + if
> (record_arch_list_add_mem (addr, 28))
> + return -1;
> + addr += 28;
> }
> else
> {
> - if
> (record_arch_list_add_mem (addr, 14))
> - return
> -1;
> - addr += 14;
> + if
> (record_arch_list_add_mem (addr, 14))
> + return -1;
> + addr += 14;
> }
> if
> (record_arch_list_add_mem (addr, 80))
> return -1;
> + /* Insn
> fsave. */
> + if
> (i386_record_floats(gdbarch, &ir, \
> +
>
> I386_SAVE_FPU_ENV_REG_STACK))
> + return
> -1;
> break;
> - case 0x3f:
> + case 0x3f:
> if
> (record_arch_list_add_mem (addr, 8))
> return -1;
> + /* Ins fistp.
> */
> + if
> (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> + return
> -1;
> break;
> default:
> ir.addr -= 2;
> @@ -4273,9 +4404,198 @@
> goto no_support;
> break;
> }
> - }
> + }
> + /* Opcode is an extension of
> modR/M byte. */
> + else
> + {
> + switch (opcode)
> + {
> + case 0xd8:
> + if
> (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM
> (tdep)))
> +
> return -1;
> + break;
> + case 0xd9:
>
> + if (0x0c
> == (ir.modrm >> 4))
> + {
> +
> if ((ir.modrm & 0x0f) <= 7)
> +
> {
> +
> if (i386_record_floats(gdbarch, &ir,
> I386_SAVE_FPU_REGS))
> +
> return -1;
> +
> }
> +
> else
> +
> {
> +
> if (i386_record_floats(gdbarch, &ir,
> \
> +
>
>
> I387_ST0_REGNUM (tdep)))
> +
> return -1;
> +
> /* If only st(0) is changing, then we have
> already recorded */
> +
> if ((ir.modrm & 0x0f) - 0x08)
> +
> {
> +
> if (i386_record_floats(gdbarch,
> &ir, \
> +
> I387_ST0_REGNUM (tdep) +
> ((ir.modrm & 0x0f) - 0x08)))
> +
> return -1;
>
>
> +
> }
> +
> }
> + }
> + else
> + {
> +
> switch(ir.modrm)
> +
> {
> +
> case 0xe0:
> +
> case 0xe1:
> +
> case 0xf0:
> +
> case 0xf5:
> +
> case 0xf8:
> +
> case 0xfa:
> +
> case 0xfc:
> +
> case 0xfe:
> +
> case 0xff:
> +
> if (i386_record_floats(gdbarch, &ir,
> \
> +
>
>
> I387_ST0_REGNUM (tdep)))
> +
> return -1;
> +
> break;
>
> +
> case 0xf1:
> +
> case 0xf2:
> +
> case 0xf3:
> +
> case 0xf4:
> + case 0xf6:
> +
> case 0xf7:
> +
> case 0xe8:
> +
> case 0xe9:
> +
> case 0xea:
> +
> case 0xeb:
> +
> case 0xec:
> +
> case 0xed:
> +
> case 0xee:
> +
> case 0xf9:
> +
> case 0xfb:
> +
> if (i386_record_floats(gdbarch, &ir,
> I386_SAVE_FPU_REGS))
> +
> return -1;
> +
> break;
> +
> case 0xfd:
> +
> if (i386_record_floats(gdbarch, &ir,
> \
> +
>
>
> I387_ST0_REGNUM (tdep)))
> +
> return -1;
> +
> if (i386_record_floats(gdbarch, &ir,
> \
> +
>
>
> I387_ST0_REGNUM (tdep) + 1))
> +
> return -1;
> +
> break;
> +
> }
> + }
> + break;
> + case 0xda:
> + if (0xe9
> == ir.modrm)
> + {
> + if
> (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> +
> return -1;
>
> + }
> + else if
> ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >>
> 4))
> + {
> + if
> (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM
> (tdep)))
> +
> return -1;
>
> + if
> (((ir.modrm & 0x0f) > 0) && ((ir.modrm &
> 0x0f) <= 7))
> +
> {
> +
> if (i386_record_floats(gdbarch, &ir, \
> +
> I387_ST0_REGNUM (tdep) + (ir.modrm
> & 0x0f)))
> +
> return -1;
>
>
> +
> }
> +
> else if ((ir.modrm & 0x0f) - 0x08)
> +
> {
> + if
> (i386_record_floats(gdbarch, &ir, \
> +
> I387_ST0_REGNUM (tdep) + ((ir.modrm
> & 0x0f) - 0x08)))
> +
> return -1;
> +
> }
> +
> }
> + break;
> + case 0xdb:
> + if (0xe3
> == ir.modrm)
> + {
> + if
> (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_ENV))
> +
> return -1;
>
> + }
> + else if
> ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >>
> 4))
> + {
> + if
> (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM
> (tdep)))
> +
> return -1;
>
> + if
> (((ir.modrm & 0x0f) > 0) && ((ir.modrm &
> 0x0f) <= 7))
> +
> {
> +
> if (i386_record_floats(gdbarch, &ir, \
> +
> I387_ST0_REGNUM (tdep) + (ir.modrm
> & 0x0f)))
> +
> return -1;
>
>
> +
> }
> +
> else if ((ir.modrm & 0x0f) - 0x08)
> +
> {
> + if
> (i386_record_floats(gdbarch, &ir, \
> +
> I387_ST0_REGNUM (tdep) + ((ir.modrm
> & 0x0f) - 0x08)))
> +
> return -1;
> +
> }
> +
> }
> + break;
> + case 0xdc:
> + if
> ( (0x0c == ir.modrm >> 4) \
> +
> || (0x0d == ir.modrm >> 4) \
> +
> || (0x0f == ir.modrm >> 4))
> + {
> + if
> ((ir.modrm & 0x0f) <= 7)
> +
> {
> +
> if (i386_record_floats(gdbarch, &ir, \
> +
> I387_ST0_REGNUM (tdep) + (ir.modrm
> & 0x0f)))
> +
> return -1;
>
>
> +
> }
> +
> else
> +
> {
> + if
> (i386_record_floats(gdbarch, &ir, \
> +
> I387_ST0_REGNUM (tdep) + ((ir.modrm
> & 0x0f) - 0x08)))
> +
> return -1;
> +
> }
> +
> }
> +
> break;
> + case 0xdd:
>
> + if (0x0c
> == ir.modrm >> 4)
> + {
> +
> if (i386_record_floats(gdbarch, &ir, \
> +
>
> I387_FTAG_REGNUM
> (tdep)))
> +
> return -1;
> + }
> + else if
> ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >>
> 4))
> + {
>
> +
> if ((ir.modrm & 0x0f) <= 7)
> +
> {
> +
> if (i386_record_floats(gdbarch,
> &ir, \
> +
> I387_ST0_REGNUM (tdep) +
> (ir.modrm & 0x0f)))
> +
> return
> -1;
> +
> }
> +
> else
> +
> {
> +
> if (i386_record_floats(gdbarch,
> &ir, I386_SAVE_FPU_REGS))
> +
> return -1;
> +
> }
> +
> }
> + break;
> + case 0xde:
> + if ((0x0c
> == ir.modrm >> 4) \
> +
> || (0x0e == ir.modrm >> 4) \
> +
> || (0x0f == ir.modrm >> 4) \
> +
> || (0xd9 == ir.modrm))
> +
> {
>
> +
> if (i386_record_floats(gdbarch, &ir,
> I386_SAVE_FPU_REGS))
> +
> return -1;
> +
> }
> + break;
> + case 0xdf:
> + if (0xe0 ==
> ir.modrm)
> + {
> +
> if (record_arch_list_add_reg (ir.regcache,
> I386_EAX_REGNUM))
> +
> return -1;
> + }
> + else if
> ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >>
> 4))
> + {
>
> +
> if (i386_record_floats(gdbarch, &ir,
> I386_SAVE_FPU_REGS))
> +
> return -1;
> + }
>
> + break;
> + }
>
> + }
>
> break;
> -
> /* string ops */
> /* movsS */
> case 0xa4:
> @@ -4694,10 +5014,17 @@
> /* fwait */
> /* XXX */
> case 0x9b:
> - printf_unfiltered (_("Process record
> doesn't support instruction "
> -
> "fwait.\n"));
> - ir.addr -= 1;
> - goto no_support;
> + if (target_read_memory (ir.addr,
> &tmpu8, 1))
> + {
> + if (record_debug)
> + printf_unfiltered
> (_("Process record: error reading memory at "
> +
> "addr 0x%s len = 1.\n"),
> +
> paddress (gdbarch,
> ir.addr));
> + return -1;
> + }
> + opcode = (uint32_t) tmpu8;
> + ir.addr++;
> + goto reswitch;
>
> break;
>
> /* int3 */
>
>
>
>
>
>
> --- On Sun, 7/5/09, Hui Zhu <teawater@gmail.com>
> wrote:
>
> > From: Hui Zhu <teawater@gmail.com>
> > Subject: Re: i386.record.floating.point.patch : with
> more testing and assurity
> > To: "paawan oza" <paawan1982@yahoo.com>
> > Cc: "Michael Snyder" <msnyder@vmware.com>,
> "Mark Kettenis" <mark.kettenis@xs4all.nl>,
> "pedro@codesourcery.com"
> <pedro@codesourcery.com>,
> "gdb-patches@sourceware.org"
> <gdb-patches@sourceware.org>
> > Date: Sunday, July 5, 2009, 3:45 PM
> > Hi Paawan,
> >
> > 1. gcc -g -O2 -I. -I../../src/gdb
> > -I../../src/gdb/common
> > -I../../src/gdb/config
> > -DLOCALEDIR="\"/usr/local/share/locale\""
> > -DHAVE_CONFIG_H -I../../src/gdb/../include/opcode
> > -I../../src/gdb/../readline/.. -I../bfd
> > -I../../src/gdb/../bfd
> > -I../../src/gdb/../include -I../libdecnumber
> > -I../../src/gdb/../libdecnumber
> > -I../../src/gdb/gnulib -Ignulib
> > -DMI_OUT=1 -DTUI=1 -Wall
> > -Wdeclaration-after-statement
> > -Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign
> > -Wno-unused
> > -Wno-switch -Wno-char-subscripts -Werror -c -o
> i386-tdep.o
> > -MT
> > i386-tdep.o -MMD -MP -MF .deps/i386-tdep.Tpo
> > ../../src/gdb/i386-tdep.c
> > cc1: warnings being treated as errors
> > ../../src/gdb/i386-tdep.c: In function
> > 'i386_process_record':
> > ../../src/gdb/i386-tdep.c:4985: warning: implicit
> > declaration of
> > function 'paddr_nz'
> > ../../src/gdb/i386-tdep.c:4985: warning: format '%s'
> > expects type
> > 'char *', but argument 2 has type 'int'
> > make[2]: *** [i386-tdep.o] Error 1
> > make[2]: Leaving directory `/media/disk/gdb/bgdb/gdb'
> > make[1]: *** [all-gdb] Error 2
> > make[1]: Leaving directory `/media/disk/gdb/bgdb'
> > make: *** [all] Error 2
> >
> > paddr_nz was removed. Please update your patch
> follow
> > cvs-head.
> >
> > 2. +#define I386_SAVE_FPU_REGS
> > 0xFFFD
> > +#define I386_SAVE_FPU_ENV
> > 0xFFFE
> > +#define I386_SAVE_FPU_ENV_REG_STACK
> > 0xFFFF
> >
> > They just used in prec right? Maybe you can move
> them
> > close to record
> > code in i386-tedp.c.
> >
> > 3. +static int i386_record_floats(struct i386_record_s
> *ir,
> > uint32_t iregnum)
> > +{
> > + int i;
> > +
> > + /* Oza : push/pop of fpu stack is going to happen
> > + currently we store st0-st7
> > registers, but we need not store all
> > registers all the time.
> > + using fstatus, we use 11-13 bits
> > which gives us stack top and
> > hence we optimize our storage.
> > + alternatively we can use ftag
> > register too */
> > + if (I386_SAVE_FPU_REGS == iregnum)
> > + {
> > + for
> > (i=I386_ST0_REGNUM;i<=I386_ST0_REGNUM+7;i++)
> > + {
> > + if
> > (record_arch_list_add_reg (ir->regcache,i))
> > + return -1;
> > + }
> > + }
> > About the number of fp regs. Please use the code:
> > #define I387_ST0_REGNUM(tdep) ((tdep)->st0_regnum)
> > #define I387_NUM_XMM_REGS(tdep)
> ((tdep)->num_xmm_regs)
> > #define I387_MM0_REGNUM(tdep) ((tdep)->mm0_regnum)
> >
> > #define I387_FCTRL_REGNUM(tdep) (I387_ST0_REGNUM
> (tdep) +
> > 8)
> > #define I387_FSTAT_REGNUM(tdep) (I387_FCTRL_REGNUM
> (tdep) +
> > 1)
> > #define I387_FTAG_REGNUM(tdep) (I387_FCTRL_REGNUM
> (tdep) +
> > 2)
> > #define I387_FISEG_REGNUM(tdep) (I387_FCTRL_REGNUM
> (tdep) +
> > 3)
> > #define I387_FIOFF_REGNUM(tdep) (I387_FCTRL_REGNUM
> (tdep) +
> > 4)
> > #define I387_FOSEG_REGNUM(tdep) (I387_FCTRL_REGNUM
> (tdep) +
> > 5)
> > #define I387_FOOFF_REGNUM(tdep) (I387_FCTRL_REGNUM
> (tdep) +
> > 6)
> > #define I387_FOP_REGNUM(tdep) (I387_FCTRL_REGNUM
> (tdep) +
> > 7)
> > #define I387_XMM0_REGNUM(tdep) (I387_ST0_REGNUM (tdep)
> +
> > 16)
> > #define I387_MXCSR_REGNUM(tdep) \
> > (I387_XMM0_REGNUM (tdep) + I387_NUM_XMM_REGS
> > (tdep))
> >
> > They are in i387-tdep.h.
> >
> > And maybe you can try function i387_supply_fsave and
> > i387_collect_fsave.
> >
> >
> > 4. Your code's format is not very well. Please
> > make it like the code in cvs.
> >
> >
> >
> > Thanks,
> > Hui
> >
> >
> >
> >
> > On Sat, Jul 4, 2009 at 13:19, paawan oza<paawan1982@yahoo.com>
> > wrote:
> > >
> > > Hi,
> > >
> > > Actually, the initial patch which I submitted
> were
> > using them.
> > > but as I have incorporated Hui's comments I have
> > removed those constants completely.
> > > in the sense I have no longer extended the
> > enumration.
> > >
> > > but of course, those registers are recorded as
> and
> > when required.
> > > e.g. (ffree insn changes FTAG register, so we
> record
> > it)
> > >
> > > Regards,
> > > Oza.
> > >
> > > --- On Sat, 7/4/09, Michael Snyder <msnyder@vmware.com>
> > wrote:
> > >
> > >> From: Michael Snyder <msnyder@vmware.com>
> > >> Subject: Re: i386.record.floating.point.patch
> :
> > with more testing and assurity
> > >> To: "paawan oza" <paawan1982@yahoo.com>
> > >> Cc: "Mark Kettenis" <mark.kettenis@xs4all.nl>,
> > "pedro@codesourcery.com"
> > <pedro@codesourcery.com>,
> > "teawater@gmail.com"
> > <teawater@gmail.com>,
> > "gdb-patches@sourceware.org"
> > <gdb-patches@sourceware.org>
> > >> Date: Saturday, July 4, 2009, 3:19 AM
> > >> paawan oza wrote:
> > >> > Hi,
> > >> >
> > >> > In My understanding the point was like
> > below.
> > >> > in the patch there were following
> register
> > extended in
> > >> enumeration in i386-tdep.h
> > >> >
> > >> > I386_FSTAT,
> > >> > I386_FTAG, I386_FISEG,
> > >> > I386_FIOFF,
> > >> > I386_FOSEG,
> > >> > I386_FOOFF,
> > >> > I386_FOP
> > >> >
> > >> >
> > >> > According to Hui in some of his
> previous
> > mails...his
> > >> idea was
> > >> >> FCTRL, FOP and so on are the fp reg
> of
> > >> amd64. For now, prec is still
> > >> >> not support amd64 And amd64's
> support are
> > in
> > >> amd64-tedp.... files. >Change
> i386_regnum is
> > not a
> > >> good idea. I suggest you divide fp patch to
> 2
> > >parts. One
> > >> is for i386, the other for amd64. For now,
> just
> > send i386
> > >> patch >for review. And send amd64 patch
> when
> > prec
> > >> support amd64"
> > >> >
> > >> >
> > >> > while, my idea/understanding is:
> > >> > FCTRL, FOP registers are not only a part
> of
> > amd64, but
> > >> also part of i386 (x87 FPU unit) also.
> > >> > so according to me these registers are
> part
> > of i386
> > >> also and it needed to be also in
> i386-tdep.h.
> > >> >
> > >> > Regards,
> > >> > Oza.
> > >>
> > >> I'm not sure why you want to add those
> constants
> > to
> > >> i386-tdep.h,
> > >> when the rest of your patch does not seem to
> use
> > them.
> > >>
> > >>
> > >
> > >
> > >
> > >
> >
>
>
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-07-06 19:05 paawan oza
2009-07-08 9:00 ` Hui Zhu
2009-07-12 9:52 ` Michael Snyder
0 siblings, 2 replies; 40+ messages in thread
From: paawan oza @ 2009-07-06 19:05 UTC (permalink / raw)
To: Hui Zhu; +Cc: Michael Snyder, Mark Kettenis, pedro, gdb-patches
Hi,
please find the latest patch and ChangeLog as follows.
********************
ChangeLog
********************
Current: gdb-6.8.50.20090706
2009-07-06 Oza <paawan1982@yahoo.com>
* i386-tdep.c: Support for floating point recording.
***************************
i386.records.floats.patch
***************************
diff -urN ./gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
--- ./gdb.orig/i386-tdep.c 2009-07-02 13:25:54.000000000 -0400
+++ gdb.new/i386-tdep.c 2009-07-06 23:44:07.000000000 -0400
@@ -3056,6 +3056,66 @@
return 0;
}
+
+/* Defines contents to record. */
+#define I386_SAVE_FPU_REGS 0xfffd
+#define I386_SAVE_FPU_ENV 0xfffe
+#define I386_SAVE_FPU_ENV_REG_STACK 0xffff
+
+/* Record the value of floating point registers which will be changed by the
+ Current instruction to "record_arch_list".
+ Return -1 if something is wrong. */
+
+static int i386_record_floats(struct gdbarch *gdbarch,
+ struct i386_record_s *ir,
+ uint32_t iregnum)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ int i;
+
+ /* Oza : because of floating point insn push/pop of fpu stack
+ Is going to happen. currently we store st0-st7 registers,
+ But we need not store all registers all the time, In future
+ We use ftag register and record only those who are not marked as an empty.
+ */
+ if (I386_SAVE_FPU_REGS == iregnum)
+ {
+ for (i = I387_ST0_REGNUM (tdep);i <= I387_ST0_REGNUM (tdep) + 7;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV == iregnum)
+ {
+ for (i = I387_FCTRL_REGNUM(tdep);i <= I387_FOP_REGNUM(tdep);i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+ {
+ for (i = I387_ST0_REGNUM (tdep);i <= I387_FOP_REGNUM(tdep);i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if ((iregnum >= I387_ST0_REGNUM (tdep)) &&
+ (iregnum <= I387_FOP_REGNUM(tdep)))
+ {
+ if (record_arch_list_add_reg (ir->regcache,iregnum))
+ return -1;
+ }
+ else
+ {
+ /* Parameter error. */
+ return -1;
+ }
+ return 0;
+}
+
/* Parse the current instruction and record the values of the registers and
memory that will be changed in current instruction to "record_arch_list".
Return -1 if something wrong. */
@@ -3070,6 +3130,7 @@
uint32_t tmpu32;
uint32_t opcode;
struct i386_record_s ir;
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
memset (&ir, 0, sizeof (struct i386_record_s));
ir.regcache = regcache;
@@ -4105,8 +4166,7 @@
}
break;
- /* floats */
- /* It just record the memory change of instrcution. */
+ /* Floats. */
case 0xd8:
case 0xd9:
case 0xda:
@@ -4120,46 +4180,57 @@
ir.reg |= ((opcode & 7) << 3);
if (ir.mod != 3)
{
- /* memory */
+ /* Memory. */
uint32_t addr;
if (i386_record_lea_modrm_addr (&ir, &addr))
return -1;
switch (ir.reg)
{
- case 0x00:
- case 0x01:
case 0x02:
- case 0x03:
+ case 0x12:
+ case 0x22:
+ case 0x32:
+ /* For fcom, ficom nothing to do. */
+ break;
+ case 0x03:
+ case 0x13:
+ case 0x23:
+ case 0x33:
+ /* For fcomp, ficomp pop FPU stack, store all. */
+ if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0x00:
+ case 0x01:
case 0x04:
case 0x05:
case 0x06:
case 0x07:
case 0x10:
- case 0x11:
- case 0x12:
- case 0x13:
+ case 0x11:
case 0x14:
case 0x15:
case 0x16:
case 0x17:
case 0x20:
case 0x21:
- case 0x22:
- case 0x23:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x30:
case 0x31:
- case 0x32:
- case 0x33:
case 0x34:
case 0x35:
case 0x36:
case 0x37:
- break;
+ /* For fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul,
+ fisub, fisubr, fidiv, fidivr, modR/M.reg is an extension of code,
+ Always affects st(0) register. */
+ if (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+ return -1;
+ break;
case 0x08:
case 0x0a:
case 0x0b:
@@ -4167,6 +4238,7 @@
case 0x19:
case 0x1a:
case 0x1b:
+ case 0x1d:
case 0x28:
case 0x29:
case 0x2a:
@@ -4174,11 +4246,16 @@
case 0x38:
case 0x39:
case 0x3a:
- case 0x3b:
+ case 0x3b:
+ case 0x3c:
+ case 0x3d:
switch (ir.reg & 7)
{
case 0:
- break;
+ /* Handling fld, fild. */
+ if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
case 1:
switch (ir.reg >> 4)
{
@@ -4191,6 +4268,7 @@
return -1;
break;
case 3:
+ break;
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4201,15 +4279,48 @@
switch (ir.reg >> 4)
{
case 0:
+ if (record_arch_list_add_mem (addr, 4))
+ return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* For fstp m32fp */
+ if (i386_record_floats(gdbarch, &ir, \
+ I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
case 1:
if (record_arch_list_add_mem (addr, 4))
return -1;
+ if ((3 == (ir.reg & 7)) \
+ || (5 == (ir.reg & 7)) \
+ || (7 == (ir.reg & 7)))
+ {
+ /* For fstp insn */
+ if (i386_record_floats(gdbarch, &ir, \
+ I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 2:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* For fstp m64fp */
+ if (i386_record_floats(gdbarch, &ir, \
+ I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 3:
+ if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+ {
+ /* For fistp, fbld, fild, fbstp. */
+ if (i386_record_floats(gdbarch, &ir, \
+ I386_SAVE_FPU_REGS))
+ return -1;
+ }
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4218,54 +4329,74 @@
break;
}
break;
- case 0x0c:
- case 0x0d:
- case 0x1d:
- case 0x2c:
- case 0x3c:
- case 0x3d:
- break;
- case 0x0e:
+ case 0x0c:
+ /* Insn fldenv. */
+ if (i386_record_floats(gdbarch, &ir, \
+ I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
+ case 0x0d:
+ /* Insn fldcw. */
+ if (i386_record_floats(gdbarch, &ir, I387_FCTRL_REGNUM (tdep)))
+ return -1;
+ break;
+ case 0x2c:
+ /* Insn frstor. */
+ if (i386_record_floats(gdbarch, &ir, \
+ I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
+ case 0x0e:
if (ir.dflag)
{
- if (record_arch_list_add_mem (addr, 28))
- return -1;
+ if (record_arch_list_add_mem (addr, 28))
+ return -1;
}
else
{
- if (record_arch_list_add_mem (addr, 14))
- return -1;
+ if (record_arch_list_add_mem (addr, 14))
+ return -1;
}
break;
- case 0x0f:
- case 0x2f:
+ case 0x0f:
+ case 0x2f:
if (record_arch_list_add_mem (addr, 2))
return -1;
break;
- case 0x1f:
- case 0x3e:
+ case 0x1f:
+ case 0x3e:
if (record_arch_list_add_mem (addr, 10))
return -1;
+ /* Insn fstp, fbstp. */
+ if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
- case 0x2e:
+ case 0x2e:
if (ir.dflag)
{
- if (record_arch_list_add_mem (addr, 28))
- return -1;
- addr += 28;
+ if (record_arch_list_add_mem (addr, 28))
+ return -1;
+ addr += 28;
}
else
{
- if (record_arch_list_add_mem (addr, 14))
- return -1;
- addr += 14;
+ if (record_arch_list_add_mem (addr, 14))
+ return -1;
+ addr += 14;
}
if (record_arch_list_add_mem (addr, 80))
return -1;
+ /* Insn fsave. */
+ if (i386_record_floats(gdbarch, &ir, \
+ I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
break;
- case 0x3f:
+ case 0x3f:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ /* Ins fistp. */
+ if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
default:
ir.addr -= 2;
@@ -4273,9 +4404,198 @@
goto no_support;
break;
}
- }
+ }
+ /* Opcode is an extension of modR/M byte. */
+ else
+ {
+ switch (opcode)
+ {
+ case 0xd8:
+ if (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+ return -1;
+ break;
+ case 0xd9:
+ if (0x0c == (ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(gdbarch, &ir, \
+ I387_ST0_REGNUM (tdep)))
+ return -1;
+ /* If only st(0) is changing, then we have already recorded */
+ if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(gdbarch, &ir, \
+ I387_ST0_REGNUM (tdep) + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ }
+ else
+ {
+ switch(ir.modrm)
+ {
+ case 0xe0:
+ case 0xe1:
+ case 0xf0:
+ case 0xf5:
+ case 0xf8:
+ case 0xfa:
+ case 0xfc:
+ case 0xfe:
+ case 0xff:
+ if (i386_record_floats(gdbarch, &ir, \
+ I387_ST0_REGNUM (tdep)))
+ return -1;
+ break;
+ case 0xf1:
+ case 0xf2:
+ case 0xf3:
+ case 0xf4:
+ case 0xf6:
+ case 0xf7:
+ case 0xe8:
+ case 0xe9:
+ case 0xea:
+ case 0xeb:
+ case 0xec:
+ case 0xed:
+ case 0xee:
+ case 0xf9:
+ case 0xfb:
+ if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0xfd:
+ if (i386_record_floats(gdbarch, &ir, \
+ I387_ST0_REGNUM (tdep)))
+ return -1;
+ if (i386_record_floats(gdbarch, &ir, \
+ I387_ST0_REGNUM (tdep) + 1))
+ return -1;
+ break;
+ }
+ }
+ break;
+ case 0xda:
+ if (0xe9 == ir.modrm)
+ {
+ if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats(gdbarch, &ir, \
+ I387_ST0_REGNUM (tdep) + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(gdbarch, &ir, \
+ I387_ST0_REGNUM (tdep) + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdb:
+ if (0xe3 == ir.modrm)
+ {
+ if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_ENV))
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM (tdep)))
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats(gdbarch, &ir, \
+ I387_ST0_REGNUM (tdep) + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(gdbarch, &ir, \
+ I387_ST0_REGNUM (tdep) + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdc:
+ if ( (0x0c == ir.modrm >> 4) \
+ || (0x0d == ir.modrm >> 4) \
+ || (0x0f == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(gdbarch, &ir, \
+ I387_ST0_REGNUM (tdep) + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(gdbarch, &ir, \
+ I387_ST0_REGNUM (tdep) + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdd:
+ if (0x0c == ir.modrm >> 4)
+ {
+ if (i386_record_floats(gdbarch, &ir, \
+ I387_FTAG_REGNUM (tdep)))
+ return -1;
+ }
+ else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(gdbarch, &ir, \
+ I387_ST0_REGNUM (tdep) + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ }
+ break;
+ case 0xde:
+ if ((0x0c == ir.modrm >> 4) \
+ || (0x0e == ir.modrm >> 4) \
+ || (0x0f == ir.modrm >> 4) \
+ || (0xd9 == ir.modrm))
+ {
+ if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ case 0xdf:
+ if (0xe0 == ir.modrm)
+ {
+ if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+ return -1;
+ }
+ else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ }
+ }
break;
-
/* string ops */
/* movsS */
case 0xa4:
@@ -4694,10 +5014,17 @@
/* fwait */
/* XXX */
case 0x9b:
- printf_unfiltered (_("Process record doesn't support instruction "
- "fwait.\n"));
- ir.addr -= 1;
- goto no_support;
+ if (target_read_memory (ir.addr, &tmpu8, 1))
+ {
+ if (record_debug)
+ printf_unfiltered (_("Process record: error reading memory at "
+ "addr 0x%s len = 1.\n"),
+ paddress (gdbarch, ir.addr));
+ return -1;
+ }
+ opcode = (uint32_t) tmpu8;
+ ir.addr++;
+ goto reswitch;
break;
/* int3 */
--- On Sun, 7/5/09, Hui Zhu <teawater@gmail.com> wrote:
> From: Hui Zhu <teawater@gmail.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Michael Snyder" <msnyder@vmware.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "pedro@codesourcery.com" <pedro@codesourcery.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Sunday, July 5, 2009, 3:45 PM
> Hi Paawan,
>
> 1. gcc -g -O2 -I. -I../../src/gdb
> -I../../src/gdb/common
> -I../../src/gdb/config
> -DLOCALEDIR="\"/usr/local/share/locale\""
> -DHAVE_CONFIG_H -I../../src/gdb/../include/opcode
> -I../../src/gdb/../readline/.. -I../bfd
> -I../../src/gdb/../bfd
> -I../../src/gdb/../include -I../libdecnumber
> -I../../src/gdb/../libdecnumber
> -I../../src/gdb/gnulib -Ignulib
> -DMI_OUT=1 -DTUI=1 -Wall
> -Wdeclaration-after-statement
> -Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign
> -Wno-unused
> -Wno-switch -Wno-char-subscripts -Werror -c -o i386-tdep.o
> -MT
> i386-tdep.o -MMD -MP -MF .deps/i386-tdep.Tpo
> ../../src/gdb/i386-tdep.c
> cc1: warnings being treated as errors
> ../../src/gdb/i386-tdep.c: In function
> 'i386_process_record':
> ../../src/gdb/i386-tdep.c:4985: warning: implicit
> declaration of
> function 'paddr_nz'
> ../../src/gdb/i386-tdep.c:4985: warning: format '%s'
> expects type
> 'char *', but argument 2 has type 'int'
> make[2]: *** [i386-tdep.o] Error 1
> make[2]: Leaving directory `/media/disk/gdb/bgdb/gdb'
> make[1]: *** [all-gdb] Error 2
> make[1]: Leaving directory `/media/disk/gdb/bgdb'
> make: *** [all] Error 2
>
> paddr_nz was removed. Please update your patch follow
> cvs-head.
>
> 2. +#define I386_SAVE_FPU_REGS
> 0xFFFD
> +#define I386_SAVE_FPU_ENV
> 0xFFFE
> +#define I386_SAVE_FPU_ENV_REG_STACK
> 0xFFFF
>
> They just used in prec right? Maybe you can move them
> close to record
> code in i386-tedp.c.
>
> 3. +static int i386_record_floats(struct i386_record_s *ir,
> uint32_t iregnum)
> +{
> + int i;
> +
> + /* Oza : push/pop of fpu stack is going to happen
> + currently we store st0-st7
> registers, but we need not store all
> registers all the time.
> + using fstatus, we use 11-13 bits
> which gives us stack top and
> hence we optimize our storage.
> + alternatively we can use ftag
> register too */
> + if (I386_SAVE_FPU_REGS == iregnum)
> + {
> + for
> (i=I386_ST0_REGNUM;i<=I386_ST0_REGNUM+7;i++)
> + {
> + if
> (record_arch_list_add_reg (ir->regcache,i))
> + return -1;
> + }
> + }
> About the number of fp regs. Please use the code:
> #define I387_ST0_REGNUM(tdep) ((tdep)->st0_regnum)
> #define I387_NUM_XMM_REGS(tdep) ((tdep)->num_xmm_regs)
> #define I387_MM0_REGNUM(tdep) ((tdep)->mm0_regnum)
>
> #define I387_FCTRL_REGNUM(tdep) (I387_ST0_REGNUM (tdep) +
> 8)
> #define I387_FSTAT_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
> 1)
> #define I387_FTAG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
> 2)
> #define I387_FISEG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
> 3)
> #define I387_FIOFF_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
> 4)
> #define I387_FOSEG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
> 5)
> #define I387_FOOFF_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
> 6)
> #define I387_FOP_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
> 7)
> #define I387_XMM0_REGNUM(tdep) (I387_ST0_REGNUM (tdep) +
> 16)
> #define I387_MXCSR_REGNUM(tdep) \
> (I387_XMM0_REGNUM (tdep) + I387_NUM_XMM_REGS
> (tdep))
>
> They are in i387-tdep.h.
>
> And maybe you can try function i387_supply_fsave and
> i387_collect_fsave.
>
>
> 4. Your code's format is not very well. Please
> make it like the code in cvs.
>
>
>
> Thanks,
> Hui
>
>
>
>
> On Sat, Jul 4, 2009 at 13:19, paawan oza<paawan1982@yahoo.com>
> wrote:
> >
> > Hi,
> >
> > Actually, the initial patch which I submitted were
> using them.
> > but as I have incorporated Hui's comments I have
> removed those constants completely.
> > in the sense I have no longer extended the
> enumration.
> >
> > but of course, those registers are recorded as and
> when required.
> > e.g. (ffree insn changes FTAG register, so we record
> it)
> >
> > Regards,
> > Oza.
> >
> > --- On Sat, 7/4/09, Michael Snyder <msnyder@vmware.com>
> wrote:
> >
> >> From: Michael Snyder <msnyder@vmware.com>
> >> Subject: Re: i386.record.floating.point.patch :
> with more testing and assurity
> >> To: "paawan oza" <paawan1982@yahoo.com>
> >> Cc: "Mark Kettenis" <mark.kettenis@xs4all.nl>,
> "pedro@codesourcery.com"
> <pedro@codesourcery.com>,
> "teawater@gmail.com"
> <teawater@gmail.com>,
> "gdb-patches@sourceware.org"
> <gdb-patches@sourceware.org>
> >> Date: Saturday, July 4, 2009, 3:19 AM
> >> paawan oza wrote:
> >> > Hi,
> >> >
> >> > In My understanding the point was like
> below.
> >> > in the patch there were following register
> extended in
> >> enumeration in i386-tdep.h
> >> >
> >> > I386_FSTAT,
> >> > I386_FTAG, I386_FISEG,
> >> > I386_FIOFF,
> >> > I386_FOSEG,
> >> > I386_FOOFF,
> >> > I386_FOP
> >> >
> >> >
> >> > According to Hui in some of his previous
> mails...his
> >> idea was
> >> >> FCTRL, FOP and so on are the fp reg of
> >> amd64. For now, prec is still
> >> >> not support amd64 And amd64's support are
> in
> >> amd64-tedp.... files. >Change i386_regnum is
> not a
> >> good idea. I suggest you divide fp patch to 2
> >parts. One
> >> is for i386, the other for amd64. For now, just
> send i386
> >> patch >for review. And send amd64 patch when
> prec
> >> support amd64"
> >> >
> >> >
> >> > while, my idea/understanding is:
> >> > FCTRL, FOP registers are not only a part of
> amd64, but
> >> also part of i386 (x87 FPU unit) also.
> >> > so according to me these registers are part
> of i386
> >> also and it needed to be also in i386-tdep.h.
> >> >
> >> > Regards,
> >> > Oza.
> >>
> >> I'm not sure why you want to add those constants
> to
> >> i386-tdep.h,
> >> when the rest of your patch does not seem to use
> them.
> >>
> >>
> >
> >
> >
> >
>
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-06 19:05 paawan oza
@ 2009-07-08 9:00 ` Hui Zhu
2009-07-12 9:52 ` Michael Snyder
1 sibling, 0 replies; 40+ messages in thread
From: Hui Zhu @ 2009-07-08 9:00 UTC (permalink / raw)
To: paawan oza; +Cc: Michael Snyder, Mark Kettenis, pedro, gdb-patches
This version still have some format issue:
1. A lot of spaces follow the code.
2. Some line size biger than 80.
3. Some indent error.
And maybe you can make a testsuite to test the fp insn or write clear
how to use the test code that you post (post your behavior with it).
Thanks,
Hui
On Tue, Jul 7, 2009 at 03:04, paawan oza<paawan1982@yahoo.com> wrote:
>
> Hi,
>
> please find the latest patch and ChangeLog as follows.
>
> ********************
> ChangeLog
> ********************
> Current: gdb-6.8.50.20090706
> 2009-07-06 Oza <paawan1982@yahoo.com>
>
> * i386-tdep.c: Support for floating point recording.
>
>
> ***************************
> i386.records.floats.patch
> ***************************
>
>
> diff -urN ./gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
> --- ./gdb.orig/i386-tdep.c 2009-07-02 13:25:54.000000000 -0400
> +++ gdb.new/i386-tdep.c 2009-07-06 23:44:07.000000000 -0400
> @@ -3056,6 +3056,66 @@
> return 0;
> }
>
> +
> +/* Defines contents to record. */
> +#define I386_SAVE_FPU_REGS 0xfffd
> +#define I386_SAVE_FPU_ENV 0xfffe
> +#define I386_SAVE_FPU_ENV_REG_STACK 0xffff
> +
> +/* Record the value of floating point registers which will be changed by the
> + Current instruction to "record_arch_list".
> + Return -1 if something is wrong. */
> +
> +static int i386_record_floats(struct gdbarch *gdbarch,
> + struct i386_record_s *ir,
> + uint32_t iregnum)
> +{
> + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
> + int i;
> +
> + /* Oza : because of floating point insn push/pop of fpu stack
> + Is going to happen. currently we store st0-st7 registers,
> + But we need not store all registers all the time, In future
> + We use ftag register and record only those who are not marked as an empty.
> + */
> + if (I386_SAVE_FPU_REGS == iregnum)
> + {
> + for (i = I387_ST0_REGNUM (tdep);i <= I387_ST0_REGNUM (tdep) + 7;i++)
> + {
> + if (record_arch_list_add_reg (ir->regcache,i))
> + return -1;
> + }
> + }
> + else if (I386_SAVE_FPU_ENV == iregnum)
> + {
> + for (i = I387_FCTRL_REGNUM(tdep);i <= I387_FOP_REGNUM(tdep);i++)
> + {
> + if (record_arch_list_add_reg (ir->regcache,i))
> + return -1;
> + }
> + }
> + else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
> + {
> + for (i = I387_ST0_REGNUM (tdep);i <= I387_FOP_REGNUM(tdep);i++)
> + {
> + if (record_arch_list_add_reg (ir->regcache,i))
> + return -1;
> + }
> + }
> + else if ((iregnum >= I387_ST0_REGNUM (tdep)) &&
> + (iregnum <= I387_FOP_REGNUM(tdep)))
> + {
> + if (record_arch_list_add_reg (ir->regcache,iregnum))
> + return -1;
> + }
> + else
> + {
> + /* Parameter error. */
> + return -1;
> + }
> + return 0;
> +}
> +
> /* Parse the current instruction and record the values of the registers and
> memory that will be changed in current instruction to "record_arch_list".
> Return -1 if something wrong. */
> @@ -3070,6 +3130,7 @@
> uint32_t tmpu32;
> uint32_t opcode;
> struct i386_record_s ir;
> + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
>
> memset (&ir, 0, sizeof (struct i386_record_s));
> ir.regcache = regcache;
> @@ -4105,8 +4166,7 @@
> }
> break;
>
> - /* floats */
> - /* It just record the memory change of instrcution. */
> + /* Floats. */
> case 0xd8:
> case 0xd9:
> case 0xda:
> @@ -4120,46 +4180,57 @@
> ir.reg |= ((opcode & 7) << 3);
> if (ir.mod != 3)
> {
> - /* memory */
> + /* Memory. */
> uint32_t addr;
>
> if (i386_record_lea_modrm_addr (&ir, &addr))
> return -1;
> switch (ir.reg)
> {
> - case 0x00:
> - case 0x01:
> case 0x02:
> - case 0x03:
> + case 0x12:
> + case 0x22:
> + case 0x32:
> + /* For fcom, ficom nothing to do. */
> + break;
> + case 0x03:
> + case 0x13:
> + case 0x23:
> + case 0x33:
> + /* For fcomp, ficomp pop FPU stack, store all. */
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> + return -1;
> + break;
> + case 0x00:
> + case 0x01:
> case 0x04:
> case 0x05:
> case 0x06:
> case 0x07:
> case 0x10:
> - case 0x11:
> - case 0x12:
> - case 0x13:
> + case 0x11:
> case 0x14:
> case 0x15:
> case 0x16:
> case 0x17:
> case 0x20:
> case 0x21:
> - case 0x22:
> - case 0x23:
> case 0x24:
> case 0x25:
> case 0x26:
> case 0x27:
> case 0x30:
> case 0x31:
> - case 0x32:
> - case 0x33:
> case 0x34:
> case 0x35:
> case 0x36:
> case 0x37:
> - break;
> + /* For fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul,
> + fisub, fisubr, fidiv, fidivr, modR/M.reg is an extension of code,
> + Always affects st(0) register. */
> + if (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM (tdep)))
> + return -1;
> + break;
> case 0x08:
> case 0x0a:
> case 0x0b:
> @@ -4167,6 +4238,7 @@
> case 0x19:
> case 0x1a:
> case 0x1b:
> + case 0x1d:
> case 0x28:
> case 0x29:
> case 0x2a:
> @@ -4174,11 +4246,16 @@
> case 0x38:
> case 0x39:
> case 0x3a:
> - case 0x3b:
> + case 0x3b:
> + case 0x3c:
> + case 0x3d:
> switch (ir.reg & 7)
> {
> case 0:
> - break;
> + /* Handling fld, fild. */
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> + return -1;
> + break;
> case 1:
> switch (ir.reg >> 4)
> {
> @@ -4191,6 +4268,7 @@
> return -1;
> break;
> case 3:
> + break;
> default:
> if (record_arch_list_add_mem (addr, 2))
> return -1;
> @@ -4201,15 +4279,48 @@
> switch (ir.reg >> 4)
> {
> case 0:
> + if (record_arch_list_add_mem (addr, 4))
> + return -1;
> + if (3 == (ir.reg & 7))
> + {
> + /* For fstp m32fp */
> + if (i386_record_floats(gdbarch, &ir, \
> + I386_SAVE_FPU_REGS))
> + return -1;
> + }
> + break;
> case 1:
> if (record_arch_list_add_mem (addr, 4))
> return -1;
> + if ((3 == (ir.reg & 7)) \
> + || (5 == (ir.reg & 7)) \
> + || (7 == (ir.reg & 7)))
> + {
> + /* For fstp insn */
> + if (i386_record_floats(gdbarch, &ir, \
> + I386_SAVE_FPU_REGS))
> + return -1;
> + }
> break;
> case 2:
> if (record_arch_list_add_mem (addr, 8))
> return -1;
> + if (3 == (ir.reg & 7))
> + {
> + /* For fstp m64fp */
> + if (i386_record_floats(gdbarch, &ir, \
> + I386_SAVE_FPU_REGS))
> + return -1;
> + }
> break;
> case 3:
> + if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
> + {
> + /* For fistp, fbld, fild, fbstp. */
> + if (i386_record_floats(gdbarch, &ir, \
> + I386_SAVE_FPU_REGS))
> + return -1;
> + }
> default:
> if (record_arch_list_add_mem (addr, 2))
> return -1;
> @@ -4218,54 +4329,74 @@
> break;
> }
> break;
> - case 0x0c:
> - case 0x0d:
> - case 0x1d:
> - case 0x2c:
> - case 0x3c:
> - case 0x3d:
> - break;
> - case 0x0e:
> + case 0x0c:
> + /* Insn fldenv. */
> + if (i386_record_floats(gdbarch, &ir, \
> + I386_SAVE_FPU_ENV_REG_STACK))
> + return -1;
> + break;
> + case 0x0d:
> + /* Insn fldcw. */
> + if (i386_record_floats(gdbarch, &ir, I387_FCTRL_REGNUM (tdep)))
> + return -1;
> + break;
> + case 0x2c:
> + /* Insn frstor. */
> + if (i386_record_floats(gdbarch, &ir, \
> + I386_SAVE_FPU_ENV_REG_STACK))
> + return -1;
> + break;
> + case 0x0e:
> if (ir.dflag)
> {
> - if (record_arch_list_add_mem (addr, 28))
> - return -1;
> + if (record_arch_list_add_mem (addr, 28))
> + return -1;
> }
> else
> {
> - if (record_arch_list_add_mem (addr, 14))
> - return -1;
> + if (record_arch_list_add_mem (addr, 14))
> + return -1;
> }
> break;
> - case 0x0f:
> - case 0x2f:
> + case 0x0f:
> + case 0x2f:
> if (record_arch_list_add_mem (addr, 2))
> return -1;
> break;
> - case 0x1f:
> - case 0x3e:
> + case 0x1f:
> + case 0x3e:
> if (record_arch_list_add_mem (addr, 10))
> return -1;
> + /* Insn fstp, fbstp. */
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> + return -1;
> break;
> - case 0x2e:
> + case 0x2e:
> if (ir.dflag)
> {
> - if (record_arch_list_add_mem (addr, 28))
> - return -1;
> - addr += 28;
> + if (record_arch_list_add_mem (addr, 28))
> + return -1;
> + addr += 28;
> }
> else
> {
> - if (record_arch_list_add_mem (addr, 14))
> - return -1;
> - addr += 14;
> + if (record_arch_list_add_mem (addr, 14))
> + return -1;
> + addr += 14;
> }
> if (record_arch_list_add_mem (addr, 80))
> return -1;
> + /* Insn fsave. */
> + if (i386_record_floats(gdbarch, &ir, \
> + I386_SAVE_FPU_ENV_REG_STACK))
> + return -1;
> break;
> - case 0x3f:
> + case 0x3f:
> if (record_arch_list_add_mem (addr, 8))
> return -1;
> + /* Ins fistp. */
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> + return -1;
> break;
> default:
> ir.addr -= 2;
> @@ -4273,9 +4404,198 @@
> goto no_support;
> break;
> }
> - }
> + }
> + /* Opcode is an extension of modR/M byte. */
> + else
> + {
> + switch (opcode)
> + {
> + case 0xd8:
> + if (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM (tdep)))
> + return -1;
> + break;
> + case 0xd9:
> + if (0x0c == (ir.modrm >> 4))
> + {
> + if ((ir.modrm & 0x0f) <= 7)
> + {
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> + return -1;
> + }
> + else
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep)))
> + return -1;
> + /* If only st(0) is changing, then we have already recorded */
> + if ((ir.modrm & 0x0f) - 0x08)
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + ((ir.modrm & 0x0f) - 0x08)))
> + return -1;
> + }
> + }
> + }
> + else
> + {
> + switch(ir.modrm)
> + {
> + case 0xe0:
> + case 0xe1:
> + case 0xf0:
> + case 0xf5:
> + case 0xf8:
> + case 0xfa:
> + case 0xfc:
> + case 0xfe:
> + case 0xff:
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep)))
> + return -1;
> + break;
> + case 0xf1:
> + case 0xf2:
> + case 0xf3:
> + case 0xf4:
> + case 0xf6:
> + case 0xf7:
> + case 0xe8:
> + case 0xe9:
> + case 0xea:
> + case 0xeb:
> + case 0xec:
> + case 0xed:
> + case 0xee:
> + case 0xf9:
> + case 0xfb:
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> + return -1;
> + break;
> + case 0xfd:
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep)))
> + return -1;
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + 1))
> + return -1;
> + break;
> + }
> + }
> + break;
> + case 0xda:
> + if (0xe9 == ir.modrm)
> + {
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> + return -1;
> + }
> + else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
> + {
> + if (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM (tdep)))
> + return -1;
> + if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + (ir.modrm & 0x0f)))
> + return -1;
> + }
> + else if ((ir.modrm & 0x0f) - 0x08)
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + ((ir.modrm & 0x0f) - 0x08)))
> + return -1;
> + }
> + }
> + break;
> + case 0xdb:
> + if (0xe3 == ir.modrm)
> + {
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_ENV))
> + return -1;
> + }
> + else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
> + {
> + if (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM (tdep)))
> + return -1;
> + if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + (ir.modrm & 0x0f)))
> + return -1;
> + }
> + else if ((ir.modrm & 0x0f) - 0x08)
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + ((ir.modrm & 0x0f) - 0x08)))
> + return -1;
> + }
> + }
> + break;
> + case 0xdc:
> + if ( (0x0c == ir.modrm >> 4) \
> + || (0x0d == ir.modrm >> 4) \
> + || (0x0f == ir.modrm >> 4))
> + {
> + if ((ir.modrm & 0x0f) <= 7)
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + (ir.modrm & 0x0f)))
> + return -1;
> + }
> + else
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + ((ir.modrm & 0x0f) - 0x08)))
> + return -1;
> + }
> + }
> + break;
> + case 0xdd:
> + if (0x0c == ir.modrm >> 4)
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_FTAG_REGNUM (tdep)))
> + return -1;
> + }
> + else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
> + {
> + if ((ir.modrm & 0x0f) <= 7)
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + (ir.modrm & 0x0f)))
> + return -1;
> + }
> + else
> + {
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> + return -1;
> + }
> + }
> + break;
> + case 0xde:
> + if ((0x0c == ir.modrm >> 4) \
> + || (0x0e == ir.modrm >> 4) \
> + || (0x0f == ir.modrm >> 4) \
> + || (0xd9 == ir.modrm))
> + {
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> + return -1;
> + }
> + break;
> + case 0xdf:
> + if (0xe0 == ir.modrm)
> + {
> + if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
> + return -1;
> + }
> + else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
> + {
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> + return -1;
> + }
> + break;
> + }
> + }
> break;
> -
> /* string ops */
> /* movsS */
> case 0xa4:
> @@ -4694,10 +5014,17 @@
> /* fwait */
> /* XXX */
> case 0x9b:
> - printf_unfiltered (_("Process record doesn't support instruction "
> - "fwait.\n"));
> - ir.addr -= 1;
> - goto no_support;
> + if (target_read_memory (ir.addr, &tmpu8, 1))
> + {
> + if (record_debug)
> + printf_unfiltered (_("Process record: error reading memory at "
> + "addr 0x%s len = 1.\n"),
> + paddress (gdbarch, ir.addr));
> + return -1;
> + }
> + opcode = (uint32_t) tmpu8;
> + ir.addr++;
> + goto reswitch;
> break;
>
> /* int3 */
>
>
>
>
>
>
> --- On Sun, 7/5/09, Hui Zhu <teawater@gmail.com> wrote:
>
>> From: Hui Zhu <teawater@gmail.com>
>> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
>> To: "paawan oza" <paawan1982@yahoo.com>
>> Cc: "Michael Snyder" <msnyder@vmware.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "pedro@codesourcery.com" <pedro@codesourcery.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
>> Date: Sunday, July 5, 2009, 3:45 PM
>> Hi Paawan,
>>
>> 1. gcc -g -O2 -I. -I../../src/gdb
>> -I../../src/gdb/common
>> -I../../src/gdb/config
>> -DLOCALEDIR="\"/usr/local/share/locale\""
>> -DHAVE_CONFIG_H -I../../src/gdb/../include/opcode
>> -I../../src/gdb/../readline/.. -I../bfd
>> -I../../src/gdb/../bfd
>> -I../../src/gdb/../include -I../libdecnumber
>> -I../../src/gdb/../libdecnumber
>> -I../../src/gdb/gnulib -Ignulib
>> -DMI_OUT=1 -DTUI=1 -Wall
>> -Wdeclaration-after-statement
>> -Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign
>> -Wno-unused
>> -Wno-switch -Wno-char-subscripts -Werror -c -o i386-tdep.o
>> -MT
>> i386-tdep.o -MMD -MP -MF .deps/i386-tdep.Tpo
>> ../../src/gdb/i386-tdep.c
>> cc1: warnings being treated as errors
>> ../../src/gdb/i386-tdep.c: In function
>> 'i386_process_record':
>> ../../src/gdb/i386-tdep.c:4985: warning: implicit
>> declaration of
>> function 'paddr_nz'
>> ../../src/gdb/i386-tdep.c:4985: warning: format '%s'
>> expects type
>> 'char *', but argument 2 has type 'int'
>> make[2]: *** [i386-tdep.o] Error 1
>> make[2]: Leaving directory `/media/disk/gdb/bgdb/gdb'
>> make[1]: *** [all-gdb] Error 2
>> make[1]: Leaving directory `/media/disk/gdb/bgdb'
>> make: *** [all] Error 2
>>
>> paddr_nz was removed. Please update your patch follow
>> cvs-head.
>>
>> 2. +#define I386_SAVE_FPU_REGS
>> 0xFFFD
>> +#define I386_SAVE_FPU_ENV
>> 0xFFFE
>> +#define I386_SAVE_FPU_ENV_REG_STACK
>> 0xFFFF
>>
>> They just used in prec right? Maybe you can move them
>> close to record
>> code in i386-tedp.c.
>>
>> 3. +static int i386_record_floats(struct i386_record_s *ir,
>> uint32_t iregnum)
>> +{
>> + int i;
>> +
>> + /* Oza : push/pop of fpu stack is going to happen
>> + currently we store st0-st7
>> registers, but we need not store all
>> registers all the time.
>> + using fstatus, we use 11-13 bits
>> which gives us stack top and
>> hence we optimize our storage.
>> + alternatively we can use ftag
>> register too */
>> + if (I386_SAVE_FPU_REGS == iregnum)
>> + {
>> + for
>> (i=I386_ST0_REGNUM;i<=I386_ST0_REGNUM+7;i++)
>> + {
>> + if
>> (record_arch_list_add_reg (ir->regcache,i))
>> + return -1;
>> + }
>> + }
>> About the number of fp regs. Please use the code:
>> #define I387_ST0_REGNUM(tdep) ((tdep)->st0_regnum)
>> #define I387_NUM_XMM_REGS(tdep) ((tdep)->num_xmm_regs)
>> #define I387_MM0_REGNUM(tdep) ((tdep)->mm0_regnum)
>>
>> #define I387_FCTRL_REGNUM(tdep) (I387_ST0_REGNUM (tdep) +
>> 8)
>> #define I387_FSTAT_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
>> 1)
>> #define I387_FTAG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
>> 2)
>> #define I387_FISEG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
>> 3)
>> #define I387_FIOFF_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
>> 4)
>> #define I387_FOSEG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
>> 5)
>> #define I387_FOOFF_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
>> 6)
>> #define I387_FOP_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
>> 7)
>> #define I387_XMM0_REGNUM(tdep) (I387_ST0_REGNUM (tdep) +
>> 16)
>> #define I387_MXCSR_REGNUM(tdep) \
>> (I387_XMM0_REGNUM (tdep) + I387_NUM_XMM_REGS
>> (tdep))
>>
>> They are in i387-tdep.h.
>>
>> And maybe you can try function i387_supply_fsave and
>> i387_collect_fsave.
>>
>>
>> 4. Your code's format is not very well. Please
>> make it like the code in cvs.
>>
>>
>>
>> Thanks,
>> Hui
>>
>>
>>
>>
>> On Sat, Jul 4, 2009 at 13:19, paawan oza<paawan1982@yahoo.com>
>> wrote:
>> >
>> > Hi,
>> >
>> > Actually, the initial patch which I submitted were
>> using them.
>> > but as I have incorporated Hui's comments I have
>> removed those constants completely.
>> > in the sense I have no longer extended the
>> enumration.
>> >
>> > but of course, those registers are recorded as and
>> when required.
>> > e.g. (ffree insn changes FTAG register, so we record
>> it)
>> >
>> > Regards,
>> > Oza.
>> >
>> > --- On Sat, 7/4/09, Michael Snyder <msnyder@vmware.com>
>> wrote:
>> >
>> >> From: Michael Snyder <msnyder@vmware.com>
>> >> Subject: Re: i386.record.floating.point.patch :
>> with more testing and assurity
>> >> To: "paawan oza" <paawan1982@yahoo.com>
>> >> Cc: "Mark Kettenis" <mark.kettenis@xs4all.nl>,
>> "pedro@codesourcery.com"
>> <pedro@codesourcery.com>,
>> "teawater@gmail.com"
>> <teawater@gmail.com>,
>> "gdb-patches@sourceware.org"
>> <gdb-patches@sourceware.org>
>> >> Date: Saturday, July 4, 2009, 3:19 AM
>> >> paawan oza wrote:
>> >> > Hi,
>> >> >
>> >> > In My understanding the point was like
>> below.
>> >> > in the patch there were following register
>> extended in
>> >> enumeration in i386-tdep.h
>> >> >
>> >> > I386_FSTAT,
>> >> > I386_FTAG, I386_FISEG,
>> >> > I386_FIOFF,
>> >> > I386_FOSEG,
>> >> > I386_FOOFF,
>> >> > I386_FOP
>> >> >
>> >> >
>> >> > According to Hui in some of his previous
>> mails...his
>> >> idea was
>> >> >> FCTRL, FOP and so on are the fp reg of
>> >> amd64. For now, prec is still
>> >> >> not support amd64 And amd64's support are
>> in
>> >> amd64-tedp.... files. >Change i386_regnum is
>> not a
>> >> good idea. I suggest you divide fp patch to 2
>> >parts. One
>> >> is for i386, the other for amd64. For now, just
>> send i386
>> >> patch >for review. And send amd64 patch when
>> prec
>> >> support amd64"
>> >> >
>> >> >
>> >> > while, my idea/understanding is:
>> >> > FCTRL, FOP registers are not only a part of
>> amd64, but
>> >> also part of i386 (x87 FPU unit) also.
>> >> > so according to me these registers are part
>> of i386
>> >> also and it needed to be also in i386-tdep.h.
>> >> >
>> >> > Regards,
>> >> > Oza.
>> >>
>> >> I'm not sure why you want to add those constants
>> to
>> >> i386-tdep.h,
>> >> when the rest of your patch does not seem to use
>> them.
>> >>
>> >>
>> >
>> >
>> >
>> >
>>
>
>
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-06 19:05 paawan oza
2009-07-08 9:00 ` Hui Zhu
@ 2009-07-12 9:52 ` Michael Snyder
2009-07-12 18:12 ` Michael Snyder
1 sibling, 1 reply; 40+ messages in thread
From: Michael Snyder @ 2009-07-12 9:52 UTC (permalink / raw)
To: paawan oza; +Cc: Hui Zhu, Mark Kettenis, pedro, gdb-patches
paawan oza wrote:
> Hi,
>
> please find the latest patch and ChangeLog as follows.
Hi Oza,
Thanks for all your work on this, particularly the revisions.
I think the patch has made a lot of progress.
I'm going to devote this review to text formatting and
white space. I know you've already made a lot of changes
in that area, but there are still some issues, and once
we get them taken care of we'll have an easier time.
I'll write about testing and your testcase in a separate message.
I'm afraid some of my comments might seem nit-picky. In particular,
I don't know whether English is your first language, so please don't
be offended if I correct your grammar and punctuation.
> ********************
> ChangeLog
> ********************
> Current: gdb-6.8.50.20090706
> 2009-07-06 Oza <paawan1982@yahoo.com>
>
> * i386-tdep.c: Support for floating point recording.
>
>
> ***************************
> i386.records.floats.patch
> ***************************
>
>
> diff -urN ./gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
> --- ./gdb.orig/i386-tdep.c 2009-07-02 13:25:54.000000000 -0400
> +++ gdb.new/i386-tdep.c 2009-07-06 23:44:07.000000000 -0400
> @@ -3056,6 +3056,66 @@
> return 0;
> }
>
> +
> +/* Defines contents to record. */
> +#define I386_SAVE_FPU_REGS 0xfffd
> +#define I386_SAVE_FPU_ENV 0xfffe
> +#define I386_SAVE_FPU_ENV_REG_STACK 0xffff
> +
> +/* Record the value of floating point registers which will be changed by the
> + Current instruction to "record_arch_list".
"Current" shouldn't be capitalized - it does not begin a sentence.
Also it would be nice to shorten the longest line by moving a couple
of words down to the next line.
> + Return -1 if something is wrong. */
> +
> +static int i386_record_floats(struct gdbarch *gdbarch,
Always one space between a function name and the parenthesis.
> + struct i386_record_s *ir,
> + uint32_t iregnum)
And then the arguments will need one more space too, to line up.
I don't know whether you use emacs, but if you do, emacs will
help you with this indenting.
> +{
> + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
> + int i;
> +
> + /* Oza : because of floating point insn push/pop of fpu stack
> + Is going to happen. currently we store st0-st7 registers,
Several things here.
1) Capitalization. First word in a sentence should be capitalized,
not the first word on a line. So, "Is" should not be capitalized,
but "Currently" should.
2) Periods that end a sentence should be followed by two spaces.
3) Indentation. The word "is" should be indented to align with
the word "Oza" above it. See the comment at the beginning of
i386-tdep.c for an example.
4) No space before a colon (":").
> + But we need not store all registers all the time, In future
> + We use ftag register and record only those who are not marked as an empty.
"But" and "We" should not be capitalized. Sentence ends with the
words "all the time", should be followed by a period and two spaces.
> + */
> + if (I386_SAVE_FPU_REGS == iregnum)
> + {
> + for (i = I387_ST0_REGNUM (tdep);i <= I387_ST0_REGNUM (tdep) + 7;i++)
One space after every c operator, semicolon (";") in this case.
Except at the end of a line.
> + {
> + if (record_arch_list_add_reg (ir->regcache,i))
One space after comma.
> + return -1;
> + }
> + }
> + else if (I386_SAVE_FPU_ENV == iregnum)
> + {
> + for (i = I387_FCTRL_REGNUM(tdep);i <= I387_FOP_REGNUM(tdep);i++)
One space after semicolon. One space between macro name and paren.
> + {
> + if (record_arch_list_add_reg (ir->regcache,i))
Space after comma.
> + return -1;
> + }
> + }
> + else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
> + {
> + for (i = I387_ST0_REGNUM (tdep);i <= I387_FOP_REGNUM(tdep);i++)
> + {
> + if (record_arch_list_add_reg (ir->regcache,i))
Space after semicolons, space after comma.
> + return -1;
> + }
> + }
> + else if ((iregnum >= I387_ST0_REGNUM (tdep)) &&
> + (iregnum <= I387_FOP_REGNUM(tdep)))
> + {
> + if (record_arch_list_add_reg (ir->regcache,iregnum))
Space after comma.
> + return -1;
> + }
> + else
> + {
> + /* Parameter error. */
> + return -1;
> + }
> + return 0;
> +}
> +
> /* Parse the current instruction and record the values of the registers and
> memory that will be changed in current instruction to "record_arch_list".
> Return -1 if something wrong. */
> @@ -3070,6 +3130,7 @@
> uint32_t tmpu32;
> uint32_t opcode;
> struct i386_record_s ir;
> + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
>
> memset (&ir, 0, sizeof (struct i386_record_s));
> ir.regcache = regcache;
> @@ -4105,8 +4166,7 @@
> }
> break;
>
> - /* floats */
> - /* It just record the memory change of instrcution. */
> + /* Floats. */
> case 0xd8:
> case 0xd9:
> case 0xda:
> @@ -4120,46 +4180,57 @@
> ir.reg |= ((opcode & 7) << 3);
> if (ir.mod != 3)
> {
> - /* memory */
> + /* Memory. */
> uint32_t addr;
>
> if (i386_record_lea_modrm_addr (&ir, &addr))
> return -1;
> switch (ir.reg)
> {
> - case 0x00:
> - case 0x01:
> case 0x02:
> - case 0x03:
> + case 0x12:
> + case 0x22:
> + case 0x32:
> + /* For fcom, ficom nothing to do. */
> + break;
> + case 0x03:
> + case 0x13:
> + case 0x23:
> + case 0x33:
> + /* For fcomp, ficomp pop FPU stack, store all. */
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
> + return -1;
> + break;
> + case 0x00:
> + case 0x01:
> case 0x04:
> case 0x05:
> case 0x06:
> case 0x07:
> case 0x10:
> - case 0x11:
> - case 0x12:
> - case 0x13:
> + case 0x11:
Ok here, in the line for "case 0x11", the original source file
has a tab, but you've changed it to spaces. There are a lot
more cases like this below. This makes the diff greater than
it needs to be, and besides, we have an explicit rule against
gratuitous (unnecessary) white space changes mixed in with
other changes.
There is an easy way to fix this. Next time you make a diff
for submission, add -w and -b to your diff flags. That will
cause diff to ignore changes in white space.
> case 0x14:
> case 0x15:
> case 0x16:
> case 0x17:
> case 0x20:
> case 0x21:
> - case 0x22:
> - case 0x23:
> case 0x24:
> case 0x25:
> case 0x26:
> case 0x27:
> case 0x30:
> case 0x31:
> - case 0x32:
> - case 0x33:
> case 0x34:
> case 0x35:
> case 0x36:
> case 0x37:
> - break;
> + /* For fadd, fmul, fsub, fsubr, fdiv, fdivr, fiadd, fimul,
> + fisub, fisubr, fidiv, fidivr, modR/M.reg is an extension of code,
> + Always affects st(0) register. */
Sentence punctuation.
> + if (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM (tdep)))
One space between function name and paren.
> + return -1;
> + break;
> case 0x08:
> case 0x0a:
> case 0x0b:
> @@ -4167,6 +4238,7 @@
> case 0x19:
> case 0x1a:
> case 0x1b:
> + case 0x1d:
> case 0x28:
> case 0x29:
> case 0x2a:
> @@ -4174,11 +4246,16 @@
> case 0x38:
> case 0x39:
> case 0x3a:
> - case 0x3b:
> + case 0x3b:
> + case 0x3c:
> + case 0x3d:
> switch (ir.reg & 7)
> {
> case 0:
> - break;
> + /* Handling fld, fild. */
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
Space after function name.
> + return -1;
> + break;
> case 1:
> switch (ir.reg >> 4)
> {
> @@ -4191,6 +4268,7 @@
> return -1;
> break;
> case 3:
> + break;
> default:
> if (record_arch_list_add_mem (addr, 2))
> return -1;
> @@ -4201,15 +4279,48 @@
> switch (ir.reg >> 4)
> {
> case 0:
> + if (record_arch_list_add_mem (addr, 4))
> + return -1;
> + if (3 == (ir.reg & 7))
> + {
> + /* For fstp m32fp */
> + if (i386_record_floats(gdbarch, &ir, \
Space after function name.
Also I don't know whether you put that backward-slash
at the end of the line, or if the email software inserted it,
but it doesn't belong there.
> + I386_SAVE_FPU_REGS))
> + return -1;
> + }
> + break;
> case 1:
> if (record_arch_list_add_mem (addr, 4))
> return -1;
> + if ((3 == (ir.reg & 7)) \
> + || (5 == (ir.reg & 7)) \
> + || (7 == (ir.reg & 7)))
> + {
> + /* For fstp insn */
> + if (i386_record_floats(gdbarch, &ir, \
> + I386_SAVE_FPU_REGS))
Space after function name.
> + return -1;
> + }
> break;
> case 2:
> if (record_arch_list_add_mem (addr, 8))
> return -1;
> + if (3 == (ir.reg & 7))
> + {
> + /* For fstp m64fp */
> + if (i386_record_floats(gdbarch, &ir, \
> + I386_SAVE_FPU_REGS))
Space after function name.
> + return -1;
> + }
> break;
> case 3:
> + if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
> + {
> + /* For fistp, fbld, fild, fbstp. */
> + if (i386_record_floats(gdbarch, &ir, \
> + I386_SAVE_FPU_REGS))
Space after function name.
> + return -1;
> + }
> default:
> if (record_arch_list_add_mem (addr, 2))
> return -1;
> @@ -4218,54 +4329,74 @@
> break;
> }
> break;
> - case 0x0c:
> - case 0x0d:
> - case 0x1d:
> - case 0x2c:
> - case 0x3c:
> - case 0x3d:
> - break;
> - case 0x0e:
> + case 0x0c:
> + /* Insn fldenv. */
> + if (i386_record_floats(gdbarch, &ir, \
> + I386_SAVE_FPU_ENV_REG_STACK))
Space after function name. And no backward-slash.
> + return -1;
> + break;
> + case 0x0d:
> + /* Insn fldcw. */
> + if (i386_record_floats(gdbarch, &ir, I387_FCTRL_REGNUM (tdep)))
> + return -1;
> + break;
> + case 0x2c:
> + /* Insn frstor. */
> + if (i386_record_floats(gdbarch, &ir, \
> + I386_SAVE_FPU_ENV_REG_STACK))
Space after function name, and no backslash.
> + return -1;
> + break;
> + case 0x0e:
> if (ir.dflag)
> {
> - if (record_arch_list_add_mem (addr, 28))
> - return -1;
> + if (record_arch_list_add_mem (addr, 28))
> + return -1;
> }
> else
> {
> - if (record_arch_list_add_mem (addr, 14))
> - return -1;
> + if (record_arch_list_add_mem (addr, 14))
> + return -1;
> }
> break;
> - case 0x0f:
> - case 0x2f:
> + case 0x0f:
> + case 0x2f:
> if (record_arch_list_add_mem (addr, 2))
> return -1;
> break;
> - case 0x1f:
> - case 0x3e:
> + case 0x1f:
> + case 0x3e:
> if (record_arch_list_add_mem (addr, 10))
> return -1;
> + /* Insn fstp, fbstp. */
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
Space.
> + return -1;
> break;
> - case 0x2e:
> + case 0x2e:
> if (ir.dflag)
> {
> - if (record_arch_list_add_mem (addr, 28))
> - return -1;
> - addr += 28;
> + if (record_arch_list_add_mem (addr, 28))
> + return -1;
> + addr += 28;
> }
> else
> {
> - if (record_arch_list_add_mem (addr, 14))
> - return -1;
> - addr += 14;
> + if (record_arch_list_add_mem (addr, 14))
> + return -1;
> + addr += 14;
> }
> if (record_arch_list_add_mem (addr, 80))
> return -1;
> + /* Insn fsave. */
> + if (i386_record_floats(gdbarch, &ir, \
> + I386_SAVE_FPU_ENV_REG_STACK))
Space, and no backslash.
> + return -1;
> break;
> - case 0x3f:
> + case 0x3f:
> if (record_arch_list_add_mem (addr, 8))
> return -1;
> + /* Ins fistp. */
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
Space.
> + return -1;
> break;
> default:
> ir.addr -= 2;
> @@ -4273,9 +4404,198 @@
> goto no_support;
> break;
> }
> - }
> + }
> + /* Opcode is an extension of modR/M byte. */
> + else
> + {
> + switch (opcode)
> + {
> + case 0xd8:
> + if (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM (tdep)))
Space.
> + return -1;
> + break;
> + case 0xd9:
> + if (0x0c == (ir.modrm >> 4))
> + {
> + if ((ir.modrm & 0x0f) <= 7)
> + {
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
Space.
> + return -1;
> + }
> + else
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep)))
Space, and no backslash.
> + return -1;
> + /* If only st(0) is changing, then we have already recorded */
Period at end of sentence, and two spaces.
> + if ((ir.modrm & 0x0f) - 0x08)
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + ((ir.modrm & 0x0f) - 0x08)))
Space, no backslash, and the second line needs to be indented
so that "I387" is aligned with "gdbarch". And then of course
the line is unpleasantly long, so you can break it up into
several more lines if you wish.
> + return -1;
> + }
> + }
> + }
> + else
> + {
> + switch(ir.modrm)
> + {
> + case 0xe0:
> + case 0xe1:
> + case 0xf0:
> + case 0xf5:
> + case 0xf8:
> + case 0xfa:
> + case 0xfc:
> + case 0xfe:
> + case 0xff:
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep)))
Space, and no backslash.
> + return -1;
> + break;
> + case 0xf1:
> + case 0xf2:
> + case 0xf3:
> + case 0xf4:
> + case 0xf6:
> + case 0xf7:
> + case 0xe8:
> + case 0xe9:
> + case 0xea:
> + case 0xeb:
> + case 0xec:
> + case 0xed:
> + case 0xee:
> + case 0xf9:
> + case 0xfb:
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
Space, and no backslash.
> + return -1;
> + break;
> + case 0xfd:
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep)))
Space, and no backslash.
> + return -1;
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + 1))
Space, and no backslash.
> + return -1;
> + break;
> + }
> + }
> + break;
> + case 0xda:
> + if (0xe9 == ir.modrm)
> + {
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
Space.
> + return -1;
> + }
> + else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
> + {
> + if (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM (tdep)))
Space.
> + return -1;
> + if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + (ir.modrm & 0x0f)))
Space, no backslash, and indentation (see above).
> + return -1;
> + }
> + else if ((ir.modrm & 0x0f) - 0x08)
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + ((ir.modrm & 0x0f) - 0x08)))
Space, no backslash, and indentation (see above).
> + return -1;
> + }
> + }
> + break;
> + case 0xdb:
> + if (0xe3 == ir.modrm)
> + {
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_ENV))
Space.
> + return -1;
> + }
> + else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
> + {
> + if (i386_record_floats(gdbarch, &ir, I387_ST0_REGNUM (tdep)))
Space.
> + return -1;
> + if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + (ir.modrm & 0x0f)))
Space, no backslash, and indentation (see above).
> + return -1;
> + }
> + else if ((ir.modrm & 0x0f) - 0x08)
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + ((ir.modrm & 0x0f) - 0x08)))
Space, no backslash, and indentation (see above).
> + return -1;
> + }
> + }
> + break;
> + case 0xdc:
> + if ( (0x0c == ir.modrm >> 4) \
> + || (0x0d == ir.modrm >> 4) \
> + || (0x0f == ir.modrm >> 4))
> + {
> + if ((ir.modrm & 0x0f) <= 7)
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + (ir.modrm & 0x0f)))
Space, no backslash, and indentation (see above).
> + return -1;
> + }
> + else
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + ((ir.modrm & 0x0f) - 0x08)))
Space, no backslash, and indentation (see above).
> + return -1;
> + }
> + }
> + break;
> + case 0xdd:
> + if (0x0c == ir.modrm >> 4)
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_FTAG_REGNUM (tdep)))
Space, no backslash, and indentation (see above).
> + return -1;
> + }
> + else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
> + {
> + if ((ir.modrm & 0x0f) <= 7)
> + {
> + if (i386_record_floats(gdbarch, &ir, \
> + I387_ST0_REGNUM (tdep) + (ir.modrm & 0x0f)))
Space, no backslash, and indentation (see above).
> + return -1;
> + }
> + else
> + {
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
Space.
> + return -1;
> + }
> + }
> + break;
> + case 0xde:
> + if ((0x0c == ir.modrm >> 4) \
> + || (0x0e == ir.modrm >> 4) \
> + || (0x0f == ir.modrm >> 4) \
> + || (0xd9 == ir.modrm))
No backslashes.
> + {
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
Space.
> + return -1;
> + }
> + break;
> + case 0xdf:
> + if (0xe0 == ir.modrm)
> + {
> + if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
> + return -1;
> + }
> + else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
> + {
> + if (i386_record_floats(gdbarch, &ir, I386_SAVE_FPU_REGS))
Space.
> + return -1;
> + }
> + break;
> + }
> + }
> break;
> -
> /* string ops */
> /* movsS */
> case 0xa4:
> @@ -4694,10 +5014,17 @@
> /* fwait */
> /* XXX */
> case 0x9b:
> - printf_unfiltered (_("Process record doesn't support instruction "
> - "fwait.\n"));
> - ir.addr -= 1;
> - goto no_support;
> + if (target_read_memory (ir.addr, &tmpu8, 1))
> + {
> + if (record_debug)
> + printf_unfiltered (_("Process record: error reading memory at "
> + "addr 0x%s len = 1.\n"),
> + paddress (gdbarch, ir.addr));
> + return -1;
> + }
> + opcode = (uint32_t) tmpu8;
> + ir.addr++;
> + goto reswitch;
> break;
>
> /* int3 */
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-12 9:52 ` Michael Snyder
@ 2009-07-12 18:12 ` Michael Snyder
0 siblings, 0 replies; 40+ messages in thread
From: Michael Snyder @ 2009-07-12 18:12 UTC (permalink / raw)
To: Michael Snyder; +Cc: paawan oza, Hui Zhu, Mark Kettenis, pedro, gdb-patches
Two more things that I missed...
>> + return -1;
>> + }
>> + }
>> + else if ((iregnum >= I387_ST0_REGNUM (tdep)) &&
>> + (iregnum <= I387_FOP_REGNUM(tdep)))
Space here...
>> case 3:
>> + if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
>> + {
>> + /* For fistp, fbld, fild, fbstp. */
>> + if (i386_record_floats(gdbarch, &ir, \
>> + I386_SAVE_FPU_REGS))
>
> Space after function name.
>
>> + return -1;
>> + }
>> default:
>> if (record_arch_list_add_mem (addr, 2))
>> return -1;
And right here, is there supposed to be a break before default?
If not, ie. if case 3 is supposed to "fall through" into the
default case, we like to put a comment there, just to make sure
it is clear that the lack of a "break" is intentional.
Just like this:
/* Fall through. */
default:
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-07-06 19:03 paawan oza
0 siblings, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-07-06 19:03 UTC (permalink / raw)
To: Hui Zhu; +Cc: Michael Snyder, Mark Kettenis, pedro, gdb-patches
Hi Hui,
following comments are taken care.
1) paddr_nz is removed, now patch follows latest cvs head.
2) constants are moved close to prec code as you suggested.
3) for floating point register numbers, now I am using
I387_ST0_REGNUM(tdep) [gdbarch] struct.
4) I have tried my level best to make formatting better.
please find the latest patch in next mail.
Regards,
Oza.
--- On Sun, 7/5/09, Hui Zhu <teawater@gmail.com> wrote:
> From: Hui Zhu <teawater@gmail.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Michael Snyder" <msnyder@vmware.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "pedro@codesourcery.com" <pedro@codesourcery.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Sunday, July 5, 2009, 3:45 PM
> Hi Paawan,
>
> 1. gcc -g -O2 -I. -I../../src/gdb
> -I../../src/gdb/common
> -I../../src/gdb/config
> -DLOCALEDIR="\"/usr/local/share/locale\""
> -DHAVE_CONFIG_H -I../../src/gdb/../include/opcode
> -I../../src/gdb/../readline/.. -I../bfd
> -I../../src/gdb/../bfd
> -I../../src/gdb/../include -I../libdecnumber
> -I../../src/gdb/../libdecnumber
> -I../../src/gdb/gnulib -Ignulib
> -DMI_OUT=1 -DTUI=1 -Wall
> -Wdeclaration-after-statement
> -Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign
> -Wno-unused
> -Wno-switch -Wno-char-subscripts -Werror -c -o i386-tdep.o
> -MT
> i386-tdep.o -MMD -MP -MF .deps/i386-tdep.Tpo
> ../../src/gdb/i386-tdep.c
> cc1: warnings being treated as errors
> ../../src/gdb/i386-tdep.c: In function
> 'i386_process_record':
> ../../src/gdb/i386-tdep.c:4985: warning: implicit
> declaration of
> function 'paddr_nz'
> ../../src/gdb/i386-tdep.c:4985: warning: format '%s'
> expects type
> 'char *', but argument 2 has type 'int'
> make[2]: *** [i386-tdep.o] Error 1
> make[2]: Leaving directory `/media/disk/gdb/bgdb/gdb'
> make[1]: *** [all-gdb] Error 2
> make[1]: Leaving directory `/media/disk/gdb/bgdb'
> make: *** [all] Error 2
>
> paddr_nz was removed. Please update your patch follow
> cvs-head.
>
> 2. +#define I386_SAVE_FPU_REGS
> 0xFFFD
> +#define I386_SAVE_FPU_ENV
> 0xFFFE
> +#define I386_SAVE_FPU_ENV_REG_STACK
> 0xFFFF
>
> They just used in prec right? Maybe you can move them
> close to record
> code in i386-tedp.c.
>
> 3. +static int i386_record_floats(struct i386_record_s *ir,
> uint32_t iregnum)
> +{
> + int i;
> +
> + /* Oza : push/pop of fpu stack is going to happen
> + currently we store st0-st7
> registers, but we need not store all
> registers all the time.
> + using fstatus, we use 11-13 bits
> which gives us stack top and
> hence we optimize our storage.
> + alternatively we can use ftag
> register too */
> + if (I386_SAVE_FPU_REGS == iregnum)
> + {
> + for
> (i=I386_ST0_REGNUM;i<=I386_ST0_REGNUM+7;i++)
> + {
> + if
> (record_arch_list_add_reg (ir->regcache,i))
> + return -1;
> + }
> + }
> About the number of fp regs. Please use the code:
> #define I387_ST0_REGNUM(tdep) ((tdep)->st0_regnum)
> #define I387_NUM_XMM_REGS(tdep) ((tdep)->num_xmm_regs)
> #define I387_MM0_REGNUM(tdep) ((tdep)->mm0_regnum)
>
> #define I387_FCTRL_REGNUM(tdep) (I387_ST0_REGNUM (tdep) +
> 8)
> #define I387_FSTAT_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
> 1)
> #define I387_FTAG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
> 2)
> #define I387_FISEG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
> 3)
> #define I387_FIOFF_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
> 4)
> #define I387_FOSEG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
> 5)
> #define I387_FOOFF_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
> 6)
> #define I387_FOP_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) +
> 7)
> #define I387_XMM0_REGNUM(tdep) (I387_ST0_REGNUM (tdep) +
> 16)
> #define I387_MXCSR_REGNUM(tdep) \
> (I387_XMM0_REGNUM (tdep) + I387_NUM_XMM_REGS
> (tdep))
>
> They are in i387-tdep.h.
>
> And maybe you can try function i387_supply_fsave and
> i387_collect_fsave.
>
>
> 4. Your code's format is not very well. Please
> make it like the code in cvs.
>
>
>
> Thanks,
> Hui
>
>
>
>
> On Sat, Jul 4, 2009 at 13:19, paawan oza<paawan1982@yahoo.com>
> wrote:
> >
> > Hi,
> >
> > Actually, the initial patch which I submitted were
> using them.
> > but as I have incorporated Hui's comments I have
> removed those constants completely.
> > in the sense I have no longer extended the
> enumration.
> >
> > but of course, those registers are recorded as and
> when required.
> > e.g. (ffree insn changes FTAG register, so we record
> it)
> >
> > Regards,
> > Oza.
> >
> > --- On Sat, 7/4/09, Michael Snyder <msnyder@vmware.com>
> wrote:
> >
> >> From: Michael Snyder <msnyder@vmware.com>
> >> Subject: Re: i386.record.floating.point.patch :
> with more testing and assurity
> >> To: "paawan oza" <paawan1982@yahoo.com>
> >> Cc: "Mark Kettenis" <mark.kettenis@xs4all.nl>,
> "pedro@codesourcery.com"
> <pedro@codesourcery.com>,
> "teawater@gmail.com"
> <teawater@gmail.com>,
> "gdb-patches@sourceware.org"
> <gdb-patches@sourceware.org>
> >> Date: Saturday, July 4, 2009, 3:19 AM
> >> paawan oza wrote:
> >> > Hi,
> >> >
> >> > In My understanding the point was like
> below.
> >> > in the patch there were following register
> extended in
> >> enumeration in i386-tdep.h
> >> >
> >> > I386_FSTAT,
> >> > I386_FTAG, I386_FISEG,
> >> > I386_FIOFF,
> >> > I386_FOSEG,
> >> > I386_FOOFF,
> >> > I386_FOP
> >> >
> >> >
> >> > According to Hui in some of his previous
> mails...his
> >> idea was
> >> >> FCTRL, FOP and so on are the fp reg of
> >> amd64. For now, prec is still
> >> >> not support amd64 And amd64's support are
> in
> >> amd64-tedp.... files. >Change i386_regnum is
> not a
> >> good idea. I suggest you divide fp patch to 2
> >parts. One
> >> is for i386, the other for amd64. For now, just
> send i386
> >> patch >for review. And send amd64 patch when
> prec
> >> support amd64"
> >> >
> >> >
> >> > while, my idea/understanding is:
> >> > FCTRL, FOP registers are not only a part of
> amd64, but
> >> also part of i386 (x87 FPU unit) also.
> >> > so according to me these registers are part
> of i386
> >> also and it needed to be also in i386-tdep.h.
> >> >
> >> > Regards,
> >> > Oza.
> >>
> >> I'm not sure why you want to add those constants
> to
> >> i386-tdep.h,
> >> when the rest of your patch does not seem to use
> them.
> >>
> >>
> >
> >
> >
> >
>
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-07-06 19:01 paawan oza
0 siblings, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-07-06 19:01 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches, teawater
Hi,
All the comments by you are taken care. As far as possible I took care of spacing issues and commenting issues as suggested.
I will try to integrate test example with gdb testsuite.
I am sending a patch which includes yours and Hui's review comments.
Regards,
Oza.
--- On Mon, 7/6/09, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> From: Mark Kettenis <mark.kettenis@xs4all.nl>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: paawan1982@yahoo.com
> Cc: gdb-patches@sourceware.org, teawater@gmail.com
> Date: Monday, July 6, 2009, 12:03 AM
> > Date: Wed, 1 Jul 2009 09:17:41
> -0700 (PDT)
> > From: paawan oza <paawan1982@yahoo.com>
> >
> > Hi,
> >
> > For your review convenience, I am sending the patch in
> plain text as a part of email body.
> > please also refer to the previous mails, where a point
> is raised by Hui.
> > I provided justification for the same.
> > please help with the point to throw more light.
>
> Please review the GNU coding standards. Your new code
> has some
> formatting problems.
>
> > TEST_CASE
> > ****************************************************
> > test_float.c
> > ****************************************************
> > #include <stdio.h>
> > #include <math.h>
> > #include <stdlib.h>
> >
> > /* the test intends to test following insns.
> > flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp
> fsubrp fucomp fnstsw fsqrt
> > fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1
> fldl2t fldl2e FLDPI FLDLG2 FLDLN2
> > FLDZ fincstp ffree fptan fpatan fincstp fsincos
> frndint fscale fsin fcos fcmovb
> > fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor
> fstsw
> > */
> >
> > float no1,no2,no3,no4,no5,no6,no7;
> > double x = 100.345, y = 25.7789;
> > long double ldx = 88888888888888888888.88, ldy =
> 9999999999999999999.99;
> > float result,resultd,resultld;
> > float *float_memory;
> >
> > /* 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;
> > }
> >
> > /* 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()
> > {
> > result = no1 + no2 + no3 + no4 + no5
> + no6 + no7;
> > printf("result is %f\n",result);
> >
> > result = fmodf(no2,no1);
> > printf("result is %f\n",result);
> >
> > resultd = fmod(x,y);
> > printf("result is %f\n",resultd);
> >
> > resultld = fmodl(ldy,ldy);
> > printf("result is %f\n",resultld);
> >
> > result = fabsf(no1);
>
> > printf("result is %f\n",result);
> >
> > result = no3 / no4;
> > printf("result is %f\n",result);
> >
> > result = no1 * no2 * no3 * no4;
> > printf("result is %f\n",result);
> >
> > result = no1 - no2 - no3 - no4;
> > printf("result is %f\n",result);
> >
> >
> > asm ("fld %0" :
> :"m"(*float_memory));
> > asm ("fchs");
> >
> > /* test for f2xm1 */
> > asm ("fld %0" : :"m"(*float_memory));
>
> > asm ("f2xm1");
> >
> > asm ("fyl2x");
> >
> > asm ("fld %0" : :"m"(*float_memory));
>
> > asm ("fxtract");
> >
> > asm ("fld %0" : :"m"(*float_memory));
>
> > asm ("fprem1");
> >
> > /* decrement fpu stack pointer only
> status register should get affected */
> > asm ("fld %0" :
> :"m"(*float_memory));
> >
> > empty_fpu_stack();
> >
> > asm ("fld1");
> > asm ("fldl2t");
> > asm ("fldl2e");
> > asm ("fldpi");
> > asm ("fldlg2");
> > asm ("fldln2");
> > asm ("fldz");
> >
> > empty_fpu_stack();
> > /* finishing emptying the stack */
> >
> > result = sqrt(no3);
> > printf("result is %f\n",result);
> > }
> >
> > void test_log_exp_floats()
> > {
> > result = log10(no3);
> > printf("result is %f\n",result);
> >
> > result = log(no3);
> > printf("result is %f\n",result);
> >
> > result = exp10(no3);
> > printf("result is %f\n",result);
> >
> > result = exp(no3);
> > printf("result is %f\n",result);
> > }
> >
> > void test_trigo_floats()
> > {
> > result = sin(30);
> > printf("result is %f\n",result);
> >
> > result = cos(30);
> > printf("result is %f\n",result);
> >
> > result = tan(30);
> > printf("result is %f\n",result);
> >
> > result = atan(30);
> > printf("result is %f\n",result);
> >
> > asm ("fld %0" : :"m"(*float_memory));
>
> > asm ("fptan");
> >
> > /* changes st1 and popping register
> stack */
> > asm ("fpatan");
> >
> > asm("fincstp");
> > asm ("fld %0" : :"m"(float_memory));
>
> > asm ("fsincos");
> >
> > asm ("fld %0" : :"m"(*float_memory));
>
> > asm ("frndint");
> >
> > asm ("fld %0" :
> :"m"(*float_memory));
> > asm ("fld %0" :
> :"m"(*(float_memory+1)));
> > asm ("fscale");
> >
> > empty_fpu_stack();
> >
> > asm ("fld %0" : :"m"(*float_memory));
>
> > asm ("fsin");
> > asm ("fcos");
> >
> > /* currently we assume condition
> likely and always record the registers
> > code could be optimized only if the
> flag is set then record */
> > asm ("fld %0" :
> :"m"(*float_memory));
> > asm ("fld %0" :
> :"m"(*(float_memory+1)));
> > asm ("fcmovb %st(1), %st");
> > asm ("fcmovbe %st(1), %st");
> > asm ("fcmove %st(1), %st");
> > asm ("fcmovu %st(1), %st");
> > asm ("fcmovnb %st(1), %st");
> > asm ("fcmovnbe %st(1), %st");
> >
> > empty_fpu_stack();
> > /* finished emtyping the stack */
> > }
> >
> > void test_compare_floats()
> > {
> > ldy =
> 88888888888888888888.88;
> > if (ldx == ldy)
> > ldy =
> 7777777777777777777777777777.777;
> > else
> > ldy =
> 666666666666666666666666666.666;
> > }
> >
> > /* test loading and saving of FPU environment */
> > void test_fpu_env()
> > {
> > asm ("fsave %0" : "=m"(*float_memory)
> : );
> > asm ("frstor %0" : :
> "m"(*float_memory));
> > asm ("fstsw %ax");
> > }
> >
> > int main()
> > {
> > init_floats();
> > test_arith_floats();
> > test_log_exp_floats();
> > test_trigo_floats();
> > test_compare_floats();
> > test_fpu_env();
> > }
>
> As other already indicated, you should really turn this
> into something
> that is integrated in the GDB testsuite.
>
> > diff -urN gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
> > --- gdb.orig/i386-tdep.c 2009-05-29
> 17:08:40.000000000 -0400
> > +++ gdb.new/i386-tdep.c 2009-06-01
> 20:02:23.000000000 -0400
> > @@ -543,6 +543,9 @@
> > /* The maximum number of saved registers. This
> should include all
> > registers mentioned above, and
> %eip. */
> > #define I386_NUM_SAVED_REGS
> I386_NUM_GREGS
> > +#define I386_SAVE_FPU_REGS
> 0xFFFD
> > +#define I386_SAVE_FPU_ENV
> 0xFFFE
> > +#define I386_SAVE_FPU_ENV_REG_STACK
> 0xFFFF
>
> What are these constants used for? Do they have
> anything to do with
> the number of saved registers? Also, please use
> lowercase for
> hexadecimal constants.
>
> > struct i386_frame_cache
> > {
> > @@ -2985,6 +2988,54 @@
> > return 0;
> > }
> >
> > +/* Record the value of floating point registers which
> will be changed by the current instruction
> > + to "record_arch_list".
> > + return -1 if something is wrong.
> */
>
> Everey new sentence should start with a capital; everey
> full stop (.)
> should be followed by two spaces. Also please wrap
> your comments such
> that fit in a 80-column wide screen.
>
> > +
> > +static int i386_record_floats(struct i386_record_s
> *ir, uint32_t iregnum)
>
> static int
>
> > +{
> > + int i;
> > +
> > + /* Oza : push/pop of fpu stack is going to
> happen
> > + currently we store st0-st7
> registers, but we need not store all registers all the
> time.
> > + using fstatus, we use 11-13
> bits which gives us stack top and hence we optimize our
> storage. */
>
> Sorry, but I don't understand what you're saying here.
>
> > + if (I386_SAVE_FPU_REGS == iregnum)
> > + {
> > + for
> (i=I386_ST0_REGNUM;i<=I386_ST7_REGNUM;i++)
>
> Spacing problems.
>
> > + {
> > + if
> (record_arch_list_add_reg (ir->regcache,i))
> > + return
> -1;
> > + }
> > + }
> > + else if (I386_SAVE_FPU_ENV == iregnum)
> > + {
> > + for
> (i=I386_FCTRL;i<=I386_FOP;i++)
> > + {
> > + if
> (record_arch_list_add_reg (ir->regcache,i))
> > + return -1;
>
> > + }
> > + }
> > + else if (I386_SAVE_FPU_ENV_REG_STACK ==
> iregnum)
> > + {
> > + for
> (i=I386_ST0_REGNUM;i<=I386_FOP;i++)
> > + {
> > + if
> (record_arch_list_add_reg (ir->regcache,i))
> > + return -1;
>
> > + }
> > + }
> > + else if (iregnum >= I386_ST0_REGNUM
> && iregnum <= I386_FOP)
> > + {
> > + if (record_arch_list_add_reg
> (ir->regcache,iregnum))
> > + return -1;
> > + }
> > + else
> > + {
> > + /* param Error */
>
> Capitalization; missing full stop.
>
> > + return -1;
> > + }
> > + return 0;
> > +}
> > +
> > /* Parse the current instruction and record the values
> of the registers and
> > memory that will be changed in
> current instruction to "record_arch_list".
> > Return -1 if something wrong.
> */
> > @@ -4035,7 +4086,6 @@
> > break;
> >
> > /* floats */
> > - /* It just record the memory
> change of instrcution. */
> > case 0xd8:
> > case 0xd9:
> > case 0xda:
> > @@ -4056,39 +4106,49 @@
> > return -1;
> > switch (ir.reg)
> > {
> > - case 0x00:
> > - case 0x01:
> > case 0x02:
> > - case 0x03:
> > + case 0x12:
> > + case 0x22:
> > + case 0x32:
> > + /* for FCOM, FICOM
> nothing to do */
>
> Please use lowercase for assembler mnemonics.
>
> > +
> break;
> > + case 0x03:
> > + case 0x13:
> > + case 0x23:
> > + case 0x33:
> > + /* FCOMP,
> FICOMP pop FPU stack, store all */
> > + if
> (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> > +
> return -1;
> > +
> break;
> > + case 0x00:
> > +
> case 0x01:
> > case 0x04:
> > case 0x05:
> > case 0x06:
> > case 0x07:
> > case 0x10:
> > - case 0x11:
> > - case 0x12:
> > - case 0x13:
> > +
> case 0x11:
> > case 0x14:
> > case 0x15:
> > case 0x16:
> > case 0x17:
> > case 0x20:
> > case 0x21:
> > - case 0x22:
> > - case 0x23:
> > case 0x24:
> > case 0x25:
> > case 0x26:
> > case 0x27:
> > case 0x30:
> > case 0x31:
> > - case 0x32:
> > - case 0x33:
> > case 0x34:
> > case 0x35:
> > case 0x36:
> > case 0x37:
> > - break;
> > + /* FADD, FMUL,
> FSUB, FSUBR, FDIV, FDIVR, FIADD, FIMUL, FISUB, FISUBR,
> FIDIV, FIDIVR
> > +
> ModR/M.reg is an extension of code, always affects st(0)
> register */
> > + if
> (i386_record_floats(&ir, I386_ST0_REGNUM))
> > +
> return -1;
> > +
> break;
>
> > case 0x08:
> > case 0x0a:
> > case 0x0b:
> > @@ -4096,6 +4156,7 @@
> > case 0x19:
> > case 0x1a:
> > case 0x1b:
> > + case 0x1d:
> > case 0x28:
> > case 0x29:
> > case 0x2a:
> > @@ -4103,11 +4164,16 @@
> > case 0x38:
> > case 0x39:
> > case 0x3a:
> > - case 0x3b:
> > + case 0x3b:
>
> > + case 0x3c:
> > + case 0x3d:
> > switch
> (ir.reg & 7)
> > {
> > case 0:
> > - break;
> > + /* FLD, FILD */
> > + if
> (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> > +
> return -1;
> > +
> break;
> > case 1:
> > switch
> (ir.reg >> 4)
> > {
> > @@ -4120,6 +4186,7 @@
> >
> return -1;
> >
> break;
> >
> case 3:
> > +
> break;
> >
> default:
> >
> if (record_arch_list_add_mem (addr, 2))
> >
> return -1;
> > @@ -4130,15 +4197,42 @@
> > switch
> (ir.reg >> 4)
> > {
> >
> case 0:
> > + if
> (record_arch_list_add_mem (addr, 4))
> > + return -1;
> > + if
> (3 == (ir.reg & 7))
> > +
> {
> > +
> /* FSTP m32fp */
> > +
> if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> > +
> return -1;
>
> > +
> }
> > +
> break;
> >
> case 1:
> >
> if (record_arch_list_add_mem (addr, 4))
> >
> return -1;
> > + if
> ((3 == (ir.reg & 7)) || (5 == (ir.reg & 7)) || (7 ==
> (ir.reg & 7)))
> > +
> {
> > +
> /* FSTP */
> > +
> if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> > +
> return -1;
>
> > +
> }
> >
> break;
> >
> case 2:
> >
> if (record_arch_list_add_mem (addr, 8))
> >
> return -1;
> > + if
> (3 == (ir.reg & 7))
> > +
> {
> > +
> /* FSTP m64fp */
> > +
> if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> > +
> return -1;
>
> > +
> }
> >
> break;
> >
> case 3:
> > + if
> ((3 <= (ir.reg & 7)) && (6 <= (ir.reg
> & 7)))
> > +
> {
> > +
> /* FISTP, FBLD, FILD,
> FBSTP */
> > +
> if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> > +
> return -1;
>
> > +
> }
>
>
> >
> default:
> >
> if (record_arch_list_add_mem (addr, 2))
> >
> return -1;
> > @@ -4147,54 +4241,71 @@
> > break;
> > }
> > break;
> > - case 0x0c:
> > - case 0x0d:
> > - case 0x1d:
> > - case 0x2c:
> > - case 0x3c:
> > - case 0x3d:
> > - break;
> > - case 0x0e:
> > + case
> 0x0c:
> > + /* FLDENV */
> > + if
> (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
> > + return
> -1;
> > +
> break;
> > + case 0x0d:
> > + /*
> FLDCW */
> > + if
> (i386_record_floats(&ir, I386_FCTRL))
> > + return
> -1;
> > +
> break;
> > + case 0x2c:
> > + /*
> FRTSTOR */
> > + if
> (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
> > + return
> -1;
> > + break;
> > + case 0x0e:
> > if
> (ir.dflag)
> > {
> > - if
> (record_arch_list_add_mem (addr, 28))
> > - return -1;
> > + if
> (record_arch_list_add_mem (addr, 28))
> > + return -1;
> > }
> > else
> > {
> > - if
> (record_arch_list_add_mem (addr, 14))
> > - return -1;
> > + if
> (record_arch_list_add_mem (addr, 14))
> > + return -1;
> > }
> > break;
> > - case 0x0f:
> > - case 0x2f:
> > + case 0x0f:
> > + case 0x2f:
> > if
> (record_arch_list_add_mem (addr, 2))
> > return -1;
> > break;
> > - case 0x1f:
> > - case 0x3e:
> > + case 0x1f:
> > + case 0x3e:
> > if
> (record_arch_list_add_mem (addr, 10))
> > return -1;
> > + /*
> FSTP, FBSTP */
> > + if
> (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> > + return
> -1;
>
>
> > break;
> > - case 0x2e:
> > + case 0x2e:
> > if
> (ir.dflag)
> > {
> > - if
> (record_arch_list_add_mem (addr, 28))
> > - return -1;
> > - addr += 28;
> > + if
> (record_arch_list_add_mem (addr, 28))
> > + return -1;
> > + addr += 28;
> > }
> > else
> > {
> > - if
> (record_arch_list_add_mem (addr, 14))
> > - return -1;
> > - addr += 14;
> > + if
> (record_arch_list_add_mem (addr, 14))
> > + return -1;
> > + addr += 14;
> > }
> > if
> (record_arch_list_add_mem (addr, 80))
> > return -1;
> > + /*
> FSAVE */
> > + if
> (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
> > + return
> -1;
> > break;
> > - case 0x3f:
> > + case 0x3f:
> > if
> (record_arch_list_add_mem (addr, 8))
> > return -1;
> > + /* FISTP */
> > + if
> (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> > + return
> -1;
> > break;
> > default:
> > ir.addr
> -= 2;
> > @@ -4202,9 +4313,180 @@
> > goto
> no_support;
> > break;
> > }
> > - }
> > + }
> > + /* opcode is an extension
> of modR/M byte */
> > + else
> > + {
> > + switch (opcode)
> > + {
> > + case 0xd8:
> > + if
> (i386_record_floats(&ir, I386_ST0_REGNUM))
> > +
> return -1;
> > +
> break;
> > + case
> 0xd9:
> > + if
> (0x0c == (ir.modrm >> 4))
> > +
> {
> > +
> if ((ir.modrm & 0x0f) <= 7)
> > +
> {
> > +
> if (i386_record_floats(&ir,
> I386_SAVE_FPU_REGS))
> > +
> return -1;
> > +
> }
> > +
> else
> > +
> {
> > +
> if (i386_record_floats(&ir,
> I386_ST0_REGNUM))
> > +
> return -1;
> > +
> /* if only st(0) is changing, then we
> have already recorded */
> > +
> if ((ir.modrm & 0x0f) - 0x08)
> > +
> {
> > +
> if (i386_record_floats(&ir,
> I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
> > +
> return -1;
>
>
> > +
> }
> > +
> }
> > +
> }
> > +
> else
> > +
> {
> > +
> switch(ir.modrm)
> > +
> {
> > +
> case 0xe0:
> > +
> case 0xe1:
> > +
> case 0xf0:
> > +
> case 0xf5:
> > +
> case 0xf8:
> > +
> case 0xfa:
> > +
> case 0xfc:
> > +
> case 0xfe:
> > +
> case 0xff:
> > +
> if (i386_record_floats(&ir,
> I386_ST0_REGNUM))
> > +
> return -1;
> > +
> break;
>
> > +
> case 0xf1:
> > +
> case 0xf2:
> > +
> case 0xf3:
> > +
> case 0xf4:
> > +
> case 0xf6:
> > +
> case 0xf7:
> > +
> case 0xe8:
> > +
> case 0xe9:
> > +
> case 0xea:
> > +
> case 0xeb:
> > +
> case 0xec:
> > +
> case 0xed:
> > +
> case 0xee:
> > +
> case 0xf9:
> > +
> case 0xfb:
> > +
> if (i386_record_floats(&ir,
> I386_SAVE_FPU_REGS))
> > +
> return -1;
> > +
> break;
> > +
> case 0xfd:
> > +
> if (i386_record_floats(&ir,
> I386_ST0_REGNUM))
> > +
> return -1;
> > +
> if (i386_record_floats(&ir,
> I386_ST1_REGNUM))
> > +
> return -1;
> > +
> break;
> > +
> }
> > + }
> > +
> break;
> > + case 0xda:
> > + if
> (0xe9 == ir.modrm)
> > +
> {
> > + if
> (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> > +
> return -1;
>
> > +
> }
> > + else
> if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm
> >> 4))
> > +
> {
> > +
> if (i386_record_floats(&ir, I386_ST0_REGNUM))
> > +
> return -1;
>
> > +
> if (((ir.modrm & 0x0f) > 0) &&
> ((ir.modrm & 0x0f) <= 7))
> > +
> {
> > +
> if (i386_record_floats(&ir,
> I386_ST0_REGNUM + (ir.modrm & 0x0f)))
> > +
> return -1;
>
>
> > +
> }
> > +
> else if ((ir.modrm & 0x0f) - 0x08)
> > +
> {
> > + if
> (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm
> & 0x0f) - 0x08)))
> > +
> return -1;
> > +
> }
> > +
> }
> > +
> break;
> > + case 0xdb:
> > + if
> (0xe3 == ir.modrm)
> > +
> {
> > + if
> (i386_record_floats(&ir, I386_SAVE_FPU_ENV))
> > +
> return -1;
>
> > +
> }
> > + else
> if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm
> >> 4))
> > +
> {
> > +
> if (i386_record_floats(&ir, I386_ST0_REGNUM))
> > +
> return -1;
>
> > +
> if (((ir.modrm & 0x0f) > 0) &&
> ((ir.modrm & 0x0f) <= 7))
> > +
> {
> > +
> if (i386_record_floats(&ir,
> I386_ST0_REGNUM + (ir.modrm & 0x0f)))
> > +
> return -1;
>
>
> > +
> }
> > +
> else if ((ir.modrm & 0x0f) - 0x08)
> > +
> {
> > + if
> (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm
> & 0x0f) - 0x08)))
> > +
> return -1;
> > +
> }
> > +
> }
> > +
> break;
> > + case 0xdc:
> > + if
> ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >>
> 4) || (0x0f == ir.modrm >> 4))
> > +
> {
> > +
> if ((ir.modrm & 0x0f) <= 7)
> > +
> {
> > +
> if (i386_record_floats(&ir,
> I386_ST0_REGNUM + (ir.modrm & 0x0f)))
> > +
> return -1;
>
>
> > +
> }
> > +
> else
> > +
> {
> > + if
> (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm
> & 0x0f) - 0x08)))
> > +
> return -1;
> > +
> }
> > +
> }
> > +
> break;
> > + case
> 0xdd:
> > + if
> (0x0c == ir.modrm >> 4)
> > +
> {
> > +
> if (i386_record_floats(&ir,I386_FTAG))
> > +
> return -1;
> > +
> }
> > + else
> if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm
> >> 4))
> > +
> {
> > +
> if ((ir.modrm & 0x0f) <= 7)
> > +
> {
> > +
> if (i386_record_floats(&ir,
> I386_ST0_REGNUM + (ir.modrm & 0x0f)))
> > +
> return -1;
>
> > +
> }
> > +
> else
> > +
> {
> > +
> if (i386_record_floats(&ir,
> I386_SAVE_FPU_REGS))
> > +
> return -1;
> > +
> }
> > +
> }
> > +
> break;
> > + case 0xde:
> > + if
> ((0x0c == ir.modrm >> 4) || (0x0e == ir.modrm >>
> 4) || (0x0f == ir.modrm >> 4) || (0xd9 == ir.modrm))
> > +
> {
>
> > +
> if (i386_record_floats(&ir,
> I386_SAVE_FPU_REGS))
> > +
> return -1;
> > +
> }
> > +
> break;
> > + case 0xdf:
> > + if (0xe0 ==
> ir.modrm)
> > +
> {
> > +
> if (record_arch_list_add_reg (ir.regcache,
> I386_EAX_REGNUM))
> > +
> return -1;
> > +
> }
> > + else
> if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm
> >> 4))
> > +
> {
> > +
> if (i386_record_floats(&ir,
> I386_SAVE_FPU_REGS))
> > +
> return -1;
> > +
> }
> > +
> break;
> > + }
>
> > + }
>
> > break;
> > -
> > /* string ops */
> > /* movsS */
> > case 0xa4:
> > @@ -4623,10 +4905,17 @@
> > /* fwait */
> > /* XXX */
> > case 0x9b:
> > - printf_unfiltered (_("Process
> record doesn't support instruction "
> > -
> "fwait.\n"));
> > - ir.addr -= 1;
> > - goto no_support;
> > + if (target_read_memory (ir.addr,
> &tmpu8, 1))
> > + {
> > + if (record_debug)
> > + printf_unfiltered
> (_("Process record: error reading memory at "
> > +
> "addr 0x%s len = 1.\n"),
> > +
> paddr_nz (ir.addr));
> > + return -1;
> > + }
> > + opcode = (uint32_t) tmpu8;
> > + ir.addr++;
> > + goto reswitch;
>
> > break;
> >
> > /* int3 */
> > diff -urN gdb.orig/i386-tdep.h gdb.new/i386-tdep.h
> > --- gdb.orig/i386-tdep.h 2009-05-17
> 17:56:44.000000000 -0400
> > +++ gdb.new/i386-tdep.h 2009-05-31
> 16:33:14.000000000 -0400
> > @@ -145,7 +145,22 @@
> > I386_ES_REGNUM,
> /* %es */
> > I386_FS_REGNUM,
> /* %fs */
> > I386_GS_REGNUM,
> /* %gs */
> > - I386_ST0_REGNUM /*
> %st(0) */
> > + I386_ST0_REGNUM, /*
> %st(0) */
> > + I386_ST1_REGNUM, /*
> %st(1) */
> > + I386_ST2_REGNUM, /*
> %st(2) */
> > + I386_ST3_REGNUM, /*
> %st(3) */
> > + I386_ST4_REGNUM, /*
> %st(4) */
> > + I386_ST5_REGNUM, /*
> %st(5) */
> > + I386_ST6_REGNUM, /*
> %st(6) */
> > + I386_ST7_REGNUM, /*
> %st(7) */
> > + I386_FCTRL,
> /* floating point env regs : FCTRL-FOP */
>
> > + I386_FSTAT,
>
> > + I386_FTAG,
>
> > + I386_FISEG,
> > + I386_FIOFF,
> > + I386_FOSEG,
> > + I386_FOOFF,
> > + I386_FOP
> > };
>
> If you no longer need this, please remove this from your
> diff.
>
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-07-04 5:19 paawan oza
2009-07-05 10:15 ` Hui Zhu
0 siblings, 1 reply; 40+ messages in thread
From: paawan oza @ 2009-07-04 5:19 UTC (permalink / raw)
To: Michael Snyder; +Cc: Mark Kettenis, pedro, teawater, gdb-patches
Hi,
Actually, the initial patch which I submitted were using them.
but as I have incorporated Hui's comments I have removed those constants completely.
in the sense I have no longer extended the enumration.
but of course, those registers are recorded as and when required.
e.g. (ffree insn changes FTAG register, so we record it)
Regards,
Oza.
--- On Sat, 7/4/09, Michael Snyder <msnyder@vmware.com> wrote:
> From: Michael Snyder <msnyder@vmware.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Mark Kettenis" <mark.kettenis@xs4all.nl>, "pedro@codesourcery.com" <pedro@codesourcery.com>, "teawater@gmail.com" <teawater@gmail.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
> Date: Saturday, July 4, 2009, 3:19 AM
> paawan oza wrote:
> > Hi,
> >
> > In My understanding the point was like below.
> > in the patch there were following register extended in
> enumeration in i386-tdep.h
> >
> > I386_FSTAT,
> > I386_FTAG, I386_FISEG,
> > I386_FIOFF,
> > I386_FOSEG,
> > I386_FOOFF,
> > I386_FOP
> >
> >
> > According to Hui in some of his previous mails...his
> idea was
> >> FCTRL, FOP and so on are the fp reg of
> amd64. For now, prec is still
> >> not support amd64 And amd64's support are in
> amd64-tedp.... files. >Change i386_regnum is not a
> good idea. I suggest you divide fp patch to 2 >parts. One
> is for i386, the other for amd64. For now, just send i386
> patch >for review. And send amd64 patch when prec
> support amd64"
> >
> >
> > while, my idea/understanding is:
> > FCTRL, FOP registers are not only a part of amd64, but
> also part of i386 (x87 FPU unit) also.
> > so according to me these registers are part of i386
> also and it needed to be also in i386-tdep.h.
> >
> > Regards,
> > Oza.
>
> I'm not sure why you want to add those constants to
> i386-tdep.h,
> when the rest of your patch does not seem to use them.
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-04 5:19 paawan oza
@ 2009-07-05 10:15 ` Hui Zhu
0 siblings, 0 replies; 40+ messages in thread
From: Hui Zhu @ 2009-07-05 10:15 UTC (permalink / raw)
To: paawan oza; +Cc: Michael Snyder, Mark Kettenis, pedro, gdb-patches
Hi Paawan,
1. gcc -g -O2 -I. -I../../src/gdb -I../../src/gdb/common
-I../../src/gdb/config -DLOCALEDIR="\"/usr/local/share/locale\""
-DHAVE_CONFIG_H -I../../src/gdb/../include/opcode
-I../../src/gdb/../readline/.. -I../bfd -I../../src/gdb/../bfd
-I../../src/gdb/../include -I../libdecnumber
-I../../src/gdb/../libdecnumber -I../../src/gdb/gnulib -Ignulib
-DMI_OUT=1 -DTUI=1 -Wall -Wdeclaration-after-statement
-Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign -Wno-unused
-Wno-switch -Wno-char-subscripts -Werror -c -o i386-tdep.o -MT
i386-tdep.o -MMD -MP -MF .deps/i386-tdep.Tpo ../../src/gdb/i386-tdep.c
cc1: warnings being treated as errors
../../src/gdb/i386-tdep.c: In function 'i386_process_record':
../../src/gdb/i386-tdep.c:4985: warning: implicit declaration of
function 'paddr_nz'
../../src/gdb/i386-tdep.c:4985: warning: format '%s' expects type
'char *', but argument 2 has type 'int'
make[2]: *** [i386-tdep.o] Error 1
make[2]: Leaving directory `/media/disk/gdb/bgdb/gdb'
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory `/media/disk/gdb/bgdb'
make: *** [all] Error 2
paddr_nz was removed. Please update your patch follow cvs-head.
2. +#define I386_SAVE_FPU_REGS 0xFFFD
+#define I386_SAVE_FPU_ENV 0xFFFE
+#define I386_SAVE_FPU_ENV_REG_STACK 0xFFFF
They just used in prec right? Maybe you can move them close to record
code in i386-tedp.c.
3. +static int i386_record_floats(struct i386_record_s *ir, uint32_t iregnum)
+{
+ int i;
+
+ /* Oza : push/pop of fpu stack is going to happen
+ currently we store st0-st7 registers, but we need not store all
registers all the time.
+ using fstatus, we use 11-13 bits which gives us stack top and
hence we optimize our storage.
+ alternatively we can use ftag register too */
+ if (I386_SAVE_FPU_REGS == iregnum)
+ {
+ for (i=I386_ST0_REGNUM;i<=I386_ST0_REGNUM+7;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
About the number of fp regs. Please use the code:
#define I387_ST0_REGNUM(tdep) ((tdep)->st0_regnum)
#define I387_NUM_XMM_REGS(tdep) ((tdep)->num_xmm_regs)
#define I387_MM0_REGNUM(tdep) ((tdep)->mm0_regnum)
#define I387_FCTRL_REGNUM(tdep) (I387_ST0_REGNUM (tdep) + 8)
#define I387_FSTAT_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 1)
#define I387_FTAG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 2)
#define I387_FISEG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 3)
#define I387_FIOFF_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 4)
#define I387_FOSEG_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 5)
#define I387_FOOFF_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 6)
#define I387_FOP_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 7)
#define I387_XMM0_REGNUM(tdep) (I387_ST0_REGNUM (tdep) + 16)
#define I387_MXCSR_REGNUM(tdep) \
(I387_XMM0_REGNUM (tdep) + I387_NUM_XMM_REGS (tdep))
They are in i387-tdep.h.
And maybe you can try function i387_supply_fsave and i387_collect_fsave.
4. Your code's format is not very well. Please make it like the code in cvs.
Thanks,
Hui
On Sat, Jul 4, 2009 at 13:19, paawan oza<paawan1982@yahoo.com> wrote:
>
> Hi,
>
> Actually, the initial patch which I submitted were using them.
> but as I have incorporated Hui's comments I have removed those constants completely.
> in the sense I have no longer extended the enumration.
>
> but of course, those registers are recorded as and when required.
> e.g. (ffree insn changes FTAG register, so we record it)
>
> Regards,
> Oza.
>
> --- On Sat, 7/4/09, Michael Snyder <msnyder@vmware.com> wrote:
>
>> From: Michael Snyder <msnyder@vmware.com>
>> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
>> To: "paawan oza" <paawan1982@yahoo.com>
>> Cc: "Mark Kettenis" <mark.kettenis@xs4all.nl>, "pedro@codesourcery.com" <pedro@codesourcery.com>, "teawater@gmail.com" <teawater@gmail.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
>> Date: Saturday, July 4, 2009, 3:19 AM
>> paawan oza wrote:
>> > Hi,
>> >
>> > In My understanding the point was like below.
>> > in the patch there were following register extended in
>> enumeration in i386-tdep.h
>> >
>> > I386_FSTAT,
>> > I386_FTAG, I386_FISEG,
>> > I386_FIOFF,
>> > I386_FOSEG,
>> > I386_FOOFF,
>> > I386_FOP
>> >
>> >
>> > According to Hui in some of his previous mails...his
>> idea was
>> >> FCTRL, FOP and so on are the fp reg of
>> amd64. For now, prec is still
>> >> not support amd64 And amd64's support are in
>> amd64-tedp.... files. >Change i386_regnum is not a
>> good idea. I suggest you divide fp patch to 2 >parts. One
>> is for i386, the other for amd64. For now, just send i386
>> patch >for review. And send amd64 patch when prec
>> support amd64"
>> >
>> >
>> > while, my idea/understanding is:
>> > FCTRL, FOP registers are not only a part of amd64, but
>> also part of i386 (x87 FPU unit) also.
>> > so according to me these registers are part of i386
>> also and it needed to be also in i386-tdep.h.
>> >
>> > Regards,
>> > Oza.
>>
>> I'm not sure why you want to add those constants to
>> i386-tdep.h,
>> when the rest of your patch does not seem to use them.
>>
>>
>
>
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-07-02 7:40 paawan oza
0 siblings, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-07-02 7:40 UTC (permalink / raw)
To: Hui Zhu, Pedro Alves, Mark Kettenis, Michael Snyder, gdb-patches
Hi,
please ignore my previous mail regarding patch, some symbols were missing.
I have incorporated the comments given by Hui.
please find the latest patch in the email body.
------------
ChangeLog
-----------
Current: gdb-6.8.50.20090531
2009-07-02 Oza <paawan1982@yahoo.com>
* i386-tdep.c: Support for floating point recording.
------------
README
-----------
Patch description:
-> Provides floating point support for i386 (reversible debugging:record-replay)
-> previously gdb was not recording floating point registers, now all the floating point registers which are likely to be changed by floating point instructions, are recorded and replayed.
-> the patch intends to provide the full support for all i386 floating point instructions.
-----------------------------
test cases for the patch
----------------------------
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/* the test intends to test following insns.
flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp fsubrp fucomp fnstsw fsqrt
fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1 fldl2t fldl2e FLDPI FLDLG2 FLDLN2
FLDZ fincstp ffree fptan fpatan fincstp fsincos frndint fscale fsin fcos fcmovb
fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor fstsw
*/
float no1,no2,no3,no4,no5,no6,no7;
double x = 100.345, y = 25.7789;
long double ldx = 88888888888888888888.88, ldy = 9999999999999999999.99;
float result,resultd,resultld;
float *float_memory;
/* 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;
}
/* 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()
{
result = no1 + no2 + no3 + no4 + no5 + no6 + no7;
printf("result is %f\n",result);
result = fmodf(no2,no1);
printf("result is %f\n",result);
resultd = fmod(x,y);
printf("result is %f\n",resultd);
resultld = fmodl(ldy,ldy);
printf("result is %f\n",resultld);
result = fabsf(no1);
printf("result is %f\n",result);
result = no3 / no4;
printf("result is %f\n",result);
result = no1 * no2 * no3 * no4;
printf("result is %f\n",result);
result = no1 - no2 - no3 - no4;
printf("result is %f\n",result);
asm ("fld %0" : :"m"(*float_memory));
asm ("fchs");
/* test for f2xm1 */
asm ("fld %0" : :"m"(*float_memory));
asm ("f2xm1");
asm ("fyl2x");
asm ("fld %0" : :"m"(*float_memory));
asm ("fxtract");
asm ("fld %0" : :"m"(*float_memory));
asm ("fprem1");
/* decrement fpu stack pointer only status register should get affected */
asm ("fld %0" : :"m"(*float_memory));
empty_fpu_stack();
asm ("fld1");
asm ("fldl2t");
asm ("fldl2e");
asm ("fldpi");
asm ("fldlg2");
asm ("fldln2");
asm ("fldz");
empty_fpu_stack();
/* finishing emptying the stack */
result = sqrt(no3);
printf("result is %f\n",result);
}
void test_log_exp_floats()
{
result = log10(no3);
printf("result is %f\n",result);
result = log(no3);
printf("result is %f\n",result);
result = exp10(no3);
printf("result is %f\n",result);
result = exp(no3);
printf("result is %f\n",result);
}
void test_trigo_floats()
{
result = sin(30);
printf("result is %f\n",result);
result = cos(30);
printf("result is %f\n",result);
result = tan(30);
printf("result is %f\n",result);
result = atan(30);
printf("result is %f\n",result);
asm ("fld %0" : :"m"(*float_memory));
asm ("fptan");
/* changes st1 and popping register stack */
asm ("fpatan");
asm("fincstp");
asm ("fld %0" : :"m"(float_memory));
asm ("fsincos");
asm ("fld %0" : :"m"(*float_memory));
asm ("frndint");
asm ("fld %0" : :"m"(*float_memory));
asm ("fld %0" : :"m"(*(float_memory+1)));
asm ("fscale");
empty_fpu_stack();
asm ("fld %0" : :"m"(*float_memory));
asm ("fsin");
asm ("fcos");
/* currently we assume condition likely and always record the registers
code could be optimized only if the flag is set then record */
asm ("fld %0" : :"m"(*float_memory));
asm ("fld %0" : :"m"(*(float_memory+1)));
asm ("fcmovb %st(1), %st");
asm ("fcmovbe %st(1), %st");
asm ("fcmove %st(1), %st");
asm ("fcmovu %st(1), %st");
asm ("fcmovnb %st(1), %st");
asm ("fcmovnbe %st(1), %st");
empty_fpu_stack();
/* finished emtyping the stack */
}
void test_compare_floats()
{
ldy = 88888888888888888888.88;
if (ldx == ldy)
ldy = 7777777777777777777777777777.777;
else
ldy = 666666666666666666666666666.666;
}
/* test loading and saving of FPU environment */
void test_fpu_env()
{
asm ("fsave %0" : "=m"(*float_memory) : );
asm ("frstor %0" : : "m"(*float_memory));
asm ("fstsw %ax");
}
int main()
{
init_floats();
test_arith_floats();
test_log_exp_floats();
test_trigo_floats();
test_compare_floats();
test_fpu_env();
}
------------------------
i386.floats.prec.patch
-------------------------
diff -urN gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
--- gdb.orig/i386-tdep.c 2009-05-29 17:08:40.000000000 -0400
+++ gdb.new/i386-tdep.c 2009-07-02 12:56:56.000000000 -0400
@@ -543,6 +543,9 @@
/* The maximum number of saved registers. This should include all
registers mentioned above, and %eip. */
#define I386_NUM_SAVED_REGS I386_NUM_GREGS
+#define I386_SAVE_FPU_REGS 0xFFFD
+#define I386_SAVE_FPU_ENV 0xFFFE
+#define I386_SAVE_FPU_ENV_REG_STACK 0xFFFF
struct i386_frame_cache
{
@@ -2985,6 +2988,55 @@
return 0;
}
+/* Record the value of floating point registers which will be changed by the current instruction
+ to "record_arch_list".
+ return -1 if something is wrong. */
+
+static int i386_record_floats(struct i386_record_s *ir, uint32_t iregnum)
+{
+ int i;
+
+ /* Oza : push/pop of fpu stack is going to happen
+ currently we store st0-st7 registers, but we need not store all registers all the time.
+ using fstatus, we use 11-13 bits which gives us stack top and hence we optimize our storage.
+ alternatively we can use ftag register too */
+ if (I386_SAVE_FPU_REGS == iregnum)
+ {
+ for (i=I386_ST0_REGNUM;i<=I386_ST0_REGNUM+7;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV == iregnum)
+ {
+ for (i=I386_ST0_REGNUM+8;i<=I386_ST0_REGNUM+15;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+ {
+ for (i=I386_ST0_REGNUM;i<=I386_ST0_REGNUM+15;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (iregnum >= I386_ST0_REGNUM && iregnum <= I386_ST0_REGNUM+15)
+ {
+ if (record_arch_list_add_reg (ir->regcache,iregnum))
+ return -1;
+ }
+ else
+ {
+ /* param Error */
+ return -1;
+ }
+ return 0;
+}
+
/* Parse the current instruction and record the values of the registers and
memory that will be changed in current instruction to "record_arch_list".
Return -1 if something wrong. */
@@ -4035,7 +4087,6 @@
break;
/* floats */
- /* It just record the memory change of instrcution. */
case 0xd8:
case 0xd9:
case 0xda:
@@ -4056,39 +4107,49 @@
return -1;
switch (ir.reg)
{
- case 0x00:
- case 0x01:
case 0x02:
- case 0x03:
+ case 0x12:
+ case 0x22:
+ case 0x32:
+ /* for FCOM, FICOM nothing to do */
+ break;
+ case 0x03:
+ case 0x13:
+ case 0x23:
+ case 0x33:
+ /* FCOMP, FICOMP pop FPU stack, store all */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0x00:
+ case 0x01:
case 0x04:
case 0x05:
case 0x06:
case 0x07:
case 0x10:
- case 0x11:
- case 0x12:
- case 0x13:
+ case 0x11:
case 0x14:
case 0x15:
case 0x16:
case 0x17:
case 0x20:
case 0x21:
- case 0x22:
- case 0x23:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x30:
case 0x31:
- case 0x32:
- case 0x33:
case 0x34:
case 0x35:
case 0x36:
case 0x37:
- break;
+ /* FADD, FMUL, FSUB, FSUBR, FDIV, FDIVR, FIADD, FIMUL, FISUB, FISUBR, FIDIV, FIDIVR
+ ModR/M.reg is an extension of code, always affects st(0) register */
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
case 0x08:
case 0x0a:
case 0x0b:
@@ -4096,6 +4157,7 @@
case 0x19:
case 0x1a:
case 0x1b:
+ case 0x1d:
case 0x28:
case 0x29:
case 0x2a:
@@ -4103,11 +4165,16 @@
case 0x38:
case 0x39:
case 0x3a:
- case 0x3b:
+ case 0x3b:
+ case 0x3c:
+ case 0x3d:
switch (ir.reg & 7)
{
case 0:
- break;
+ /* FLD, FILD */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
case 1:
switch (ir.reg >> 4)
{
@@ -4120,6 +4187,7 @@
return -1;
break;
case 3:
+ break;
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4130,15 +4198,42 @@
switch (ir.reg >> 4)
{
case 0:
+ if (record_arch_list_add_mem (addr, 4))
+ return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* FSTP m32fp */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
case 1:
if (record_arch_list_add_mem (addr, 4))
return -1;
+ if ((3 == (ir.reg & 7)) || (5 == (ir.reg & 7)) || (7 == (ir.reg & 7)))
+ {
+ /* FSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 2:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* FSTP m64fp */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 3:
+ if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+ {
+ /* FISTP, FBLD, FILD, FBSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4147,54 +4242,71 @@
break;
}
break;
- case 0x0c:
- case 0x0d:
- case 0x1d:
- case 0x2c:
- case 0x3c:
- case 0x3d:
- break;
- case 0x0e:
+ case 0x0c:
+ /* FLDENV */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
+ case 0x0d:
+ /* FLDCW */
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + 8))
+ return -1;
+ break;
+ case 0x2c:
+ /* FRTSTOR */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
+ case 0x0e:
if (ir.dflag)
{
- if (record_arch_list_add_mem (addr, 28))
- return -1;
+ if (record_arch_list_add_mem (addr, 28))
+ return -1;
}
else
{
- if (record_arch_list_add_mem (addr, 14))
- return -1;
+ if (record_arch_list_add_mem (addr, 14))
+ return -1;
}
break;
- case 0x0f:
- case 0x2f:
+ case 0x0f:
+ case 0x2f:
if (record_arch_list_add_mem (addr, 2))
return -1;
break;
- case 0x1f:
- case 0x3e:
+ case 0x1f:
+ case 0x3e:
if (record_arch_list_add_mem (addr, 10))
return -1;
+ /* FSTP, FBSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
- case 0x2e:
+ case 0x2e:
if (ir.dflag)
{
- if (record_arch_list_add_mem (addr, 28))
- return -1;
- addr += 28;
+ if (record_arch_list_add_mem (addr, 28))
+ return -1;
+ addr += 28;
}
else
{
- if (record_arch_list_add_mem (addr, 14))
- return -1;
- addr += 14;
+ if (record_arch_list_add_mem (addr, 14))
+ return -1;
+ addr += 14;
}
if (record_arch_list_add_mem (addr, 80))
return -1;
+ /* FSAVE */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
break;
- case 0x3f:
+ case 0x3f:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ /* FISTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
default:
ir.addr -= 2;
@@ -4202,9 +4314,180 @@
goto no_support;
break;
}
- }
+ }
+ /* opcode is an extension of modR/M byte */
+ else
+ {
+ switch (opcode)
+ {
+ case 0xd8:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
+ case 0xd9:
+ if (0x0c == (ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ /* if only st(0) is changing, then we have already recorded */
+ if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ }
+ else
+ {
+ switch(ir.modrm)
+ {
+ case 0xe0:
+ case 0xe1:
+ case 0xf0:
+ case 0xf5:
+ case 0xf8:
+ case 0xfa:
+ case 0xfc:
+ case 0xfe:
+ case 0xff:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
+ case 0xf1:
+ case 0xf2:
+ case 0xf3:
+ case 0xf4:
+ case 0xf6:
+ case 0xf7:
+ case 0xe8:
+ case 0xe9:
+ case 0xea:
+ case 0xeb:
+ case 0xec:
+ case 0xed:
+ case 0xee:
+ case 0xf9:
+ case 0xfb:
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0xfd:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + 1))
+ return -1;
+ break;
+ }
+ }
+ break;
+ case 0xda:
+ if (0xe9 == ir.modrm)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdb:
+ if (0xe3 == ir.modrm)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV))
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdc:
+ if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4) || (0x0f == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdd:
+ if (0x0c == ir.modrm >> 4)
+ {
+ if (i386_record_floats(&ir,I386_ST0_REGNUM + 10))
+ return -1;
+ }
+ else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ }
+ break;
+ case 0xde:
+ if ((0x0c == ir.modrm >> 4) || (0x0e == ir.modrm >> 4) || (0x0f == ir.modrm >> 4) || (0xd9 == ir.modrm))
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ case 0xdf:
+ if (0xe0 == ir.modrm)
+ {
+ if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+ return -1;
+ }
+ else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ }
+ }
break;
-
/* string ops */
/* movsS */
case 0xa4:
@@ -4623,10 +4906,17 @@
/* fwait */
/* XXX */
case 0x9b:
- printf_unfiltered (_("Process record doesn't support instruction "
- "fwait.\n"));
- ir.addr -= 1;
- goto no_support;
+ if (target_read_memory (ir.addr, &tmpu8, 1))
+ {
+ if (record_debug)
+ printf_unfiltered (_("Process record: error reading memory at "
+ "addr 0x%s len = 1.\n"),
+ paddr_nz (ir.addr));
+ return -1;
+ }
+ opcode = (uint32_t) tmpu8;
+ ir.addr++;
+ goto reswitch;
break;
/* int3 */
--- On Thu, 7/2/09, Hui Zhu <teawater@gmail.com> wrote:
> From: Hui Zhu <teawater@gmail.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Pedro Alves" <pedro@codesourcery.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "Michael Snyder" <msnyder@vmware.com>, gdb-patches@sourceware.org
> Date: Thursday, July 2, 2009, 7:31 AM
> On Wed, Jul 1, 2009 at 23:59, paawan
> oza<paawan1982@yahoo.com>
> wrote:
> >
> > Hi Hui,
> >
> > As I clarified earlier,
> > these registers are already supported and extended by
> gdb much before this patch.
> > all floating point registers are already supported by
> gdb
> > (info floats/info all-registers command gives it)
> >
> > My aim is : only to make sure that whenever any
> floating point insn gets executed, we record the registers
> > (no matter whether it is %st(n) or FCTRL or FTAG or
> FSTATUS)
> > there are insns
> > e.g. 'ffree' changes FTAG register, so we must record
> it.
> >
> > Do you mean to say that we should remove it from just
> enumaration ?
> > but anyway we need to record those registers.
> >
>
> You are working on make prec x86 support fp insn, not to
> extend the fp
> function of i386 (If you want, you can make a special patch
> for it).
>
>
>
>
> >
> > --- On Wed, 7/1/09, Hui Zhu <teawater@gmail.com>
> wrote:
> >
> >> From: Hui Zhu <teawater@gmail.com>
> >> Subject: Re: i386.record.floating.point.patch :
> with more testing and assurity
> >> To: "paawan oza" <paawan1982@yahoo.com>,
> "Pedro Alves" <pedro@codesourcery.com>,
> "Mark Kettenis" <mark.kettenis@xs4all.nl>,
> "Michael Snyder" <msnyder@vmware.com>
> >> Cc: gdb-patches@sourceware.org
> >> Date: Wednesday, July 1, 2009, 11:23 AM
> >> About this patch, I say my idea
> >> again, I told in
> >> http://sourceware.org/ml/gdb-patches/2009-06/msg00014.html
> >> @@ -145,7 +145,22 @@
> >> I386_ES_REGNUM,
> >> /* %es */
> >> I386_FS_REGNUM,
> >> /* %fs */
> >> I386_GS_REGNUM,
> >> /* %gs */
> >> - I386_ST0_REGNUM
> >> /* %st(0) */
> >> + I386_ST0_REGNUM,
> >> /* %st(0) */
> >> + I386_ST1_REGNUM,
> >> /* %st(1) */
> >> + I386_ST2_REGNUM,
> >> /* %st(2) */
> >> + I386_ST3_REGNUM,
> >> /* %st(3) */
> >> + I386_ST4_REGNUM,
> >> /* %st(4) */
> >> + I386_ST5_REGNUM,
> >> /* %st(5) */
> >> + I386_ST6_REGNUM,
> >> /* %st(6) */
> >> + I386_ST7_REGNUM,
> >> /* %st(7) */
> >> + I386_FCTRL,
> >> /* floating point env regs : FCTRL-FOP
> >> */
> >> + I386_FSTAT,
> >> + I386_FTAG,
> >>
> >> + I386_FISEG,
> >> + I386_FIOFF,
> >> + I386_FOSEG,
> >> + I386_FOOFF,
> >> + I386_FOP
> >> };
> >>
> >> You are working on make prec x86 support fp insn,
> not to
> >> extend the fp
> >> function of i386 (If you want, you can make a
> special patch
> >> for it).
> >>
> >> Hui
> >>
> >> On Tue, Jun 30, 2009 at 23:05, paawan oza<paawan1982@yahoo.com>
> >> wrote:
> >> >
> >> > Hi,
> >> > As I am submitting the patch for the first
> time, I am
> >> not much aware of gdb test suite.
> >> > would you please guide me about how I can put
> the
> >> things in the testsuite ?
> >> > is it the testsuite which comes along with
> the gdb
> >> source ?
> >> > gdb\testsuite\gdb.base ??
> >> > Regards,
> >> > Oza.
> >> >
> >> > --- On Tue, 6/30/09, Pedro Alves <pedro@codesourcery.com>
> >> wrote:
> >> >
> >> >> From: Pedro Alves <pedro@codesourcery.com>
> >> >> Subject: Re:
> i386.record.floating.point.patch :
> >> with more testing and assurity
> >> >> To: gdb-patches@sourceware.org
> >> >> Cc: "paawan oza" <paawan1982@yahoo.com>,
> >> teawater@gmail.com
> >> >> Date: Tuesday, June 30, 2009, 7:09 PM
> >> >> On Tuesday 30 June 2009 14:23:30,
> >> >> paawan oza wrote:
> >> >> >
> >> >> > > As suggested by Hui,
> >> >> > > I have come up with more
> detailed and
> >> granular
> >> >> test case
> >> >> > > for the patch which I had
> submitted last
> >> week.
> >> >>
> >> >> Could you please consider migrating that
> test into
> >> the
> >> >> testsuite?
> >> >> You've gone through the trouble of
> writing tests
> >> to make
> >> >> sure
> >> >> the features work now --- putting it in
> the
> >> testsuite means
> >> >> we
> >> >> have an automatic-ish means to check that
> it
> >> doesn't get
> >> >> inadvertently broken in the future. The
> way it
> >> is,
> >> >> when your
> >> >> code gets in, the test will probably end
> up lost
> >> in the
> >> >> archives.
> >> >> We wouldn't want that, would we? :-)
> Having
> >> >> auto-tests, also helps
> >> >> the person doing the review in confirming
> things
> >> work as
> >> >> expected (without much effort).
> >> >>
> >> >> --
> >> >> Pedro Alves
> >> >>
> >> >
> >> >
> >> >
> >> >
> >>
> >
> >
> >
> >
>
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-07-02 3:39 paawan oza
0 siblings, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-07-02 3:39 UTC (permalink / raw)
To: Pedro Alves, Mark Kettenis, Michael Snyder, gdb-patches, Hui Zhu
Hi,
I have incorporated the comments of Hui. please find the new patch in the email body.
------------
ChangeLog
-----------
Current: gdb-6.8.50.20090531
2009-07-02 Oza <paawan1982@yahoo.com>
* i386-tdep.c: Support for floating point recording.
------------
README
-----------
Patch description:
-> Provides floating point support for i386 (reversible debugging:record-replay)
-> previously gdb was not recording floating point registers, now all the floating point registers which are likely to be changed by floating point instructions, are recorded and replayed.
-> the patch intends to provide the full support for all i386 floating point instructions.
-----------------------------
test cases for the patch
----------------------------
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/* the test intends to test following insns.
flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp fsubrp fucomp fnstsw fsqrt
fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1 fldl2t fldl2e FLDPI FLDLG2 FLDLN2
FLDZ fincstp ffree fptan fpatan fincstp fsincos frndint fscale fsin fcos fcmovb
fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor fstsw
*/
float no1,no2,no3,no4,no5,no6,no7;
double x = 100.345, y = 25.7789;
long double ldx = 88888888888888888888.88, ldy = 9999999999999999999.99;
float result,resultd,resultld;
float *float_memory;
/* 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;
}
/* 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()
{
result = no1 + no2 + no3 + no4 + no5 + no6 + no7;
printf("result is %f\n",result);
result = fmodf(no2,no1);
printf("result is %f\n",result);
resultd = fmod(x,y);
printf("result is %f\n",resultd);
resultld = fmodl(ldy,ldy);
printf("result is %f\n",resultld);
result = fabsf(no1);
printf("result is %f\n",result);
result = no3 / no4;
printf("result is %f\n",result);
result = no1 * no2 * no3 * no4;
printf("result is %f\n",result);
result = no1 - no2 - no3 - no4;
printf("result is %f\n",result);
asm ("fld %0" : :"m"(*float_memory));
asm ("fchs");
/* test for f2xm1 */
asm ("fld %0" : :"m"(*float_memory));
asm ("f2xm1");
asm ("fyl2x");
asm ("fld %0" : :"m"(*float_memory));
asm ("fxtract");
asm ("fld %0" : :"m"(*float_memory));
asm ("fprem1");
/* decrement fpu stack pointer only status register should get affected */
asm ("fld %0" : :"m"(*float_memory));
empty_fpu_stack();
asm ("fld1");
asm ("fldl2t");
asm ("fldl2e");
asm ("fldpi");
asm ("fldlg2");
asm ("fldln2");
asm ("fldz");
empty_fpu_stack();
/* finishing emptying the stack */
result = sqrt(no3);
printf("result is %f\n",result);
}
void test_log_exp_floats()
{
result = log10(no3);
printf("result is %f\n",result);
result = log(no3);
printf("result is %f\n",result);
result = exp10(no3);
printf("result is %f\n",result);
result = exp(no3);
printf("result is %f\n",result);
}
void test_trigo_floats()
{
result = sin(30);
printf("result is %f\n",result);
result = cos(30);
printf("result is %f\n",result);
result = tan(30);
printf("result is %f\n",result);
result = atan(30);
printf("result is %f\n",result);
asm ("fld %0" : :"m"(*float_memory));
asm ("fptan");
/* changes st1 and popping register stack */
asm ("fpatan");
asm("fincstp");
asm ("fld %0" : :"m"(float_memory));
asm ("fsincos");
asm ("fld %0" : :"m"(*float_memory));
asm ("frndint");
asm ("fld %0" : :"m"(*float_memory));
asm ("fld %0" : :"m"(*(float_memory+1)));
asm ("fscale");
empty_fpu_stack();
asm ("fld %0" : :"m"(*float_memory));
asm ("fsin");
asm ("fcos");
/* currently we assume condition likely and always record the registers
code could be optimized only if the flag is set then record */
asm ("fld %0" : :"m"(*float_memory));
asm ("fld %0" : :"m"(*(float_memory+1)));
asm ("fcmovb %st(1), %st");
asm ("fcmovbe %st(1), %st");
asm ("fcmove %st(1), %st");
asm ("fcmovu %st(1), %st");
asm ("fcmovnb %st(1), %st");
asm ("fcmovnbe %st(1), %st");
empty_fpu_stack();
/* finished emtyping the stack */
}
void test_compare_floats()
{
ldy = 88888888888888888888.88;
if (ldx == ldy)
ldy = 7777777777777777777777777777.777;
else
ldy = 666666666666666666666666666.666;
}
/* test loading and saving of FPU environment */
void test_fpu_env()
{
asm ("fsave %0" : "=m"(*float_memory) : );
asm ("frstor %0" : : "m"(*float_memory));
asm ("fstsw %ax");
}
int main()
{
init_floats();
test_arith_floats();
test_log_exp_floats();
test_trigo_floats();
test_compare_floats();
test_fpu_env();
}
-----------
patch
-----------
diff -urN gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
--- gdb.orig/i386-tdep.c 2009-05-29 17:08:40.000000000 -0400
+++ gdb.new/i386-tdep.c 2009-07-02 08:44:37.000000000 -0400
@@ -543,6 +543,9 @@
/* The maximum number of saved registers. This should include all
registers mentioned above, and %eip. */
#define I386_NUM_SAVED_REGS I386_NUM_GREGS
+#define I386_SAVE_FPU_REGS 0xFFFD
+#define I386_SAVE_FPU_ENV 0xFFFE
+#define I386_SAVE_FPU_ENV_REG_STACK 0xFFFF
struct i386_frame_cache
{
@@ -2985,6 +2988,55 @@
return 0;
}
+/* Record the value of floating point registers which will be changed by the current instruction
+ to "record_arch_list".
+ return -1 if something is wrong. */
+
+static int i386_record_floats(struct i386_record_s *ir, uint32_t iregnum)
+{
+ int i;
+
+ /* Oza : push/pop of fpu stack is going to happen
+ currently we store st0-st7 registers, but we need not store all registers all the time.
+ using fstatus, we use 11-13 bits which gives us stack top and hence we optimize our storage.
+ alternatively we can use ftag register too */
+ if (I386_SAVE_FPU_REGS == iregnum)
+ {
+ for (i=I386_ST0_REGNUM;i<=I386_ST0_REGNUM+7;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV == iregnum)
+ {
+ for (i=I386_ST0_REGNUM+8;i<=I386_ST0_REGNUM+15;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+ {
+ for (i=I386_ST0_REGNUM;i<=I386_ST0_REGNUM+15;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (iregnum >= I386_ST0_REGNUM && iregnum <= I386_ST0_REGNUM+15)
+ {
+ if (record_arch_list_add_reg (ir->regcache,iregnum))
+ return -1;
+ }
+ else
+ {
+ /* param Error */
+ return -1;
+ }
+ return 0;
+}
+
/* Parse the current instruction and record the values of the registers and
memory that will be changed in current instruction to "record_arch_list".
Return -1 if something wrong. */
@@ -4035,7 +4087,6 @@
break;
/* floats */
- /* It just record the memory change of instrcution. */
case 0xd8:
case 0xd9:
case 0xda:
@@ -4056,39 +4107,49 @@
return -1;
switch (ir.reg)
{
- case 0x00:
- case 0x01:
case 0x02:
- case 0x03:
+ case 0x12:
+ case 0x22:
+ case 0x32:
+ /* for FCOM, FICOM nothing to do */
+ break;
+ case 0x03:
+ case 0x13:
+ case 0x23:
+ case 0x33:
+ /* FCOMP, FICOMP pop FPU stack, store all */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0x00:
+ case 0x01:
case 0x04:
case 0x05:
case 0x06:
case 0x07:
case 0x10:
- case 0x11:
- case 0x12:
- case 0x13:
+ case 0x11:
case 0x14:
case 0x15:
case 0x16:
case 0x17:
case 0x20:
case 0x21:
- case 0x22:
- case 0x23:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x30:
case 0x31:
- case 0x32:
- case 0x33:
case 0x34:
case 0x35:
case 0x36:
case 0x37:
- break;
+ /* FADD, FMUL, FSUB, FSUBR, FDIV, FDIVR, FIADD, FIMUL, FISUB, FISUBR, FIDIV, FIDIVR
+ ModR/M.reg is an extension of code, always affects st(0) register */
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
case 0x08:
case 0x0a:
case 0x0b:
@@ -4096,6 +4157,7 @@
case 0x19:
case 0x1a:
case 0x1b:
+ case 0x1d:
case 0x28:
case 0x29:
case 0x2a:
@@ -4103,11 +4165,16 @@
case 0x38:
case 0x39:
case 0x3a:
- case 0x3b:
+ case 0x3b:
+ case 0x3c:
+ case 0x3d:
switch (ir.reg & 7)
{
case 0:
- break;
+ /* FLD, FILD */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
case 1:
switch (ir.reg >> 4)
{
@@ -4120,6 +4187,7 @@
return -1;
break;
case 3:
+ break;
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4130,15 +4198,42 @@
switch (ir.reg >> 4)
{
case 0:
+ if (record_arch_list_add_mem (addr, 4))
+ return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* FSTP m32fp */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
case 1:
if (record_arch_list_add_mem (addr, 4))
return -1;
+ if ((3 == (ir.reg & 7)) || (5 == (ir.reg & 7)) || (7 == (ir.reg & 7)))
+ {
+ /* FSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 2:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* FSTP m64fp */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 3:
+ if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+ {
+ /* FISTP, FBLD, FILD, FBSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4147,54 +4242,71 @@
break;
}
break;
- case 0x0c:
- case 0x0d:
- case 0x1d:
- case 0x2c:
- case 0x3c:
- case 0x3d:
- break;
- case 0x0e:
+ case 0x0c:
+ /* FLDENV */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
+ case 0x0d:
+ /* FLDCW */
+ if (i386_record_floats(&ir, I386_FCTRL))
+ return -1;
+ break;
+ case 0x2c:
+ /* FRTSTOR */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
+ case 0x0e:
if (ir.dflag)
{
- if (record_arch_list_add_mem (addr, 28))
- return -1;
+ if (record_arch_list_add_mem (addr, 28))
+ return -1;
}
else
{
- if (record_arch_list_add_mem (addr, 14))
- return -1;
+ if (record_arch_list_add_mem (addr, 14))
+ return -1;
}
break;
- case 0x0f:
- case 0x2f:
+ case 0x0f:
+ case 0x2f:
if (record_arch_list_add_mem (addr, 2))
return -1;
break;
- case 0x1f:
- case 0x3e:
+ case 0x1f:
+ case 0x3e:
if (record_arch_list_add_mem (addr, 10))
return -1;
+ /* FSTP, FBSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
- case 0x2e:
+ case 0x2e:
if (ir.dflag)
{
- if (record_arch_list_add_mem (addr, 28))
- return -1;
- addr += 28;
+ if (record_arch_list_add_mem (addr, 28))
+ return -1;
+ addr += 28;
}
else
{
- if (record_arch_list_add_mem (addr, 14))
- return -1;
- addr += 14;
+ if (record_arch_list_add_mem (addr, 14))
+ return -1;
+ addr += 14;
}
if (record_arch_list_add_mem (addr, 80))
return -1;
+ /* FSAVE */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
break;
- case 0x3f:
+ case 0x3f:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ /* FISTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
default:
ir.addr -= 2;
@@ -4202,9 +4314,180 @@
goto no_support;
break;
}
- }
+ }
+ /* opcode is an extension of modR/M byte */
+ else
+ {
+ switch (opcode)
+ {
+ case 0xd8:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
+ case 0xd9:
+ if (0x0c == (ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ /* if only st(0) is changing, then we have already recorded */
+ if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ }
+ else
+ {
+ switch(ir.modrm)
+ {
+ case 0xe0:
+ case 0xe1:
+ case 0xf0:
+ case 0xf5:
+ case 0xf8:
+ case 0xfa:
+ case 0xfc:
+ case 0xfe:
+ case 0xff:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
+ case 0xf1:
+ case 0xf2:
+ case 0xf3:
+ case 0xf4:
+ case 0xf6:
+ case 0xf7:
+ case 0xe8:
+ case 0xe9:
+ case 0xea:
+ case 0xeb:
+ case 0xec:
+ case 0xed:
+ case 0xee:
+ case 0xf9:
+ case 0xfb:
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0xfd:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (i386_record_floats(&ir, I386_ST1_REGNUM))
+ return -1;
+ break;
+ }
+ }
+ break;
+ case 0xda:
+ if (0xe9 == ir.modrm)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdb:
+ if (0xe3 == ir.modrm)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV))
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdc:
+ if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4) || (0x0f == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdd:
+ if (0x0c == ir.modrm >> 4)
+ {
+ if (i386_record_floats(&ir,I386_FTAG))
+ return -1;
+ }
+ else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ }
+ break;
+ case 0xde:
+ if ((0x0c == ir.modrm >> 4) || (0x0e == ir.modrm >> 4) || (0x0f == ir.modrm >> 4) || (0xd9 == ir.modrm))
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ case 0xdf:
+ if (0xe0 == ir.modrm)
+ {
+ if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+ return -1;
+ }
+ else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ }
+ }
break;
-
/* string ops */
/* movsS */
case 0xa4:
@@ -4623,10 +4906,17 @@
/* fwait */
/* XXX */
case 0x9b:
- printf_unfiltered (_("Process record doesn't support instruction "
- "fwait.\n"));
- ir.addr -= 1;
- goto no_support;
+ if (target_read_memory (ir.addr, &tmpu8, 1))
+ {
+ if (record_debug)
+ printf_unfiltered (_("Process record: error reading memory at "
+ "addr 0x%s len = 1.\n"),
+ paddr_nz (ir.addr));
+ return -1;
+ }
+ opcode = (uint32_t) tmpu8;
+ ir.addr++;
+ goto reswitch;
break;
/* int3 */
--- On Thu, 7/2/09, Hui Zhu <teawater@gmail.com> wrote:
> From: Hui Zhu <teawater@gmail.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Pedro Alves" <pedro@codesourcery.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "Michael Snyder" <msnyder@vmware.com>, gdb-patches@sourceware.org
> Date: Thursday, July 2, 2009, 7:31 AM
> On Wed, Jul 1, 2009 at 23:59, paawan
> oza<paawan1982@yahoo.com>
> wrote:
> >
> > Hi Hui,
> >
> > As I clarified earlier,
> > these registers are already supported and extended by
> gdb much before this patch.
> > all floating point registers are already supported by
> gdb
> > (info floats/info all-registers command gives it)
> >
> > My aim is : only to make sure that whenever any
> floating point insn gets executed, we record the registers
> > (no matter whether it is %st(n) or FCTRL or FTAG or
> FSTATUS)
> > there are insns
> > e.g. 'ffree' changes FTAG register, so we must record
> it.
> >
> > Do you mean to say that we should remove it from just
> enumaration ?
> > but anyway we need to record those registers.
> >
>
> You are working on make prec x86 support fp insn, not to
> extend the fp
> function of i386 (If you want, you can make a special patch
> for it).
>
>
>
>
> >
> > --- On Wed, 7/1/09, Hui Zhu <teawater@gmail.com>
> wrote:
> >
> >> From: Hui Zhu <teawater@gmail.com>
> >> Subject: Re: i386.record.floating.point.patch :
> with more testing and assurity
> >> To: "paawan oza" <paawan1982@yahoo.com>,
> "Pedro Alves" <pedro@codesourcery.com>,
> "Mark Kettenis" <mark.kettenis@xs4all.nl>,
> "Michael Snyder" <msnyder@vmware.com>
> >> Cc: gdb-patches@sourceware.org
> >> Date: Wednesday, July 1, 2009, 11:23 AM
> >> About this patch, I say my idea
> >> again, I told in
> >> http://sourceware.org/ml/gdb-patches/2009-06/msg00014.html
> >> @@ -145,7 +145,22 @@
> >> I386_ES_REGNUM,
> >> /* %es */
> >> I386_FS_REGNUM,
> >> /* %fs */
> >> I386_GS_REGNUM,
> >> /* %gs */
> >> - I386_ST0_REGNUM
> >> /* %st(0) */
> >> + I386_ST0_REGNUM,
> >> /* %st(0) */
> >> + I386_ST1_REGNUM,
> >> /* %st(1) */
> >> + I386_ST2_REGNUM,
> >> /* %st(2) */
> >> + I386_ST3_REGNUM,
> >> /* %st(3) */
> >> + I386_ST4_REGNUM,
> >> /* %st(4) */
> >> + I386_ST5_REGNUM,
> >> /* %st(5) */
> >> + I386_ST6_REGNUM,
> >> /* %st(6) */
> >> + I386_ST7_REGNUM,
> >> /* %st(7) */
> >> + I386_FCTRL,
> >> /* floating point env regs : FCTRL-FOP
> >> */
> >> + I386_FSTAT,
> >> + I386_FTAG,
> >>
> >> + I386_FISEG,
> >> + I386_FIOFF,
> >> + I386_FOSEG,
> >> + I386_FOOFF,
> >> + I386_FOP
> >> };
> >>
> >> You are working on make prec x86 support fp insn,
> not to
> >> extend the fp
> >> function of i386 (If you want, you can make a
> special patch
> >> for it).
> >>
> >> Hui
> >>
> >> On Tue, Jun 30, 2009 at 23:05, paawan oza<paawan1982@yahoo.com>
> >> wrote:
> >> >
> >> > Hi,
> >> > As I am submitting the patch for the first
> time, I am
> >> not much aware of gdb test suite.
> >> > would you please guide me about how I can put
> the
> >> things in the testsuite ?
> >> > is it the testsuite which comes along with
> the gdb
> >> source ?
> >> > gdb\testsuite\gdb.base ??
> >> > Regards,
> >> > Oza.
> >> >
> >> > --- On Tue, 6/30/09, Pedro Alves <pedro@codesourcery.com>
> >> wrote:
> >> >
> >> >> From: Pedro Alves <pedro@codesourcery.com>
> >> >> Subject: Re:
> i386.record.floating.point.patch :
> >> with more testing and assurity
> >> >> To: gdb-patches@sourceware.org
> >> >> Cc: "paawan oza" <paawan1982@yahoo.com>,
> >> teawater@gmail.com
> >> >> Date: Tuesday, June 30, 2009, 7:09 PM
> >> >> On Tuesday 30 June 2009 14:23:30,
> >> >> paawan oza wrote:
> >> >> >
> >> >> > > As suggested by Hui,
> >> >> > > I have come up with more
> detailed and
> >> granular
> >> >> test case
> >> >> > > for the patch which I had
> submitted last
> >> week.
> >> >>
> >> >> Could you please consider migrating that
> test into
> >> the
> >> >> testsuite?
> >> >> You've gone through the trouble of
> writing tests
> >> to make
> >> >> sure
> >> >> the features work now --- putting it in
> the
> >> testsuite means
> >> >> we
> >> >> have an automatic-ish means to check that
> it
> >> doesn't get
> >> >> inadvertently broken in the future. The
> way it
> >> is,
> >> >> when your
> >> >> code gets in, the test will probably end
> up lost
> >> in the
> >> >> archives.
> >> >> We wouldn't want that, would we? :-)
> Having
> >> >> auto-tests, also helps
> >> >> the person doing the review in confirming
> things
> >> work as
> >> >> expected (without much effort).
> >> >>
> >> >> --
> >> >> Pedro Alves
> >> >>
> >> >
> >> >
> >> >
> >> >
> >>
> >
> >
> >
> >
>
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-07-02 3:34 paawan oza
0 siblings, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-07-02 3:34 UTC (permalink / raw)
To: Hui Zhu; +Cc: Pedro Alves, Mark Kettenis, Michael Snyder, gdb-patches
Hi Hui,
Ok fine. I try to understand and incorporate your review comments.
I am sending the new patch in next mail.
Regards,
Oza.
--- On Thu, 7/2/09, Hui Zhu <teawater@gmail.com> wrote:
> From: Hui Zhu <teawater@gmail.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "Pedro Alves" <pedro@codesourcery.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "Michael Snyder" <msnyder@vmware.com>, gdb-patches@sourceware.org
> Date: Thursday, July 2, 2009, 7:31 AM
> On Wed, Jul 1, 2009 at 23:59, paawan
> oza<paawan1982@yahoo.com>
> wrote:
> >
> > Hi Hui,
> >
> > As I clarified earlier,
> > these registers are already supported and extended by
> gdb much before this patch.
> > all floating point registers are already supported by
> gdb
> > (info floats/info all-registers command gives it)
> >
> > My aim is : only to make sure that whenever any
> floating point insn gets executed, we record the registers
> > (no matter whether it is %st(n) or FCTRL or FTAG or
> FSTATUS)
> > there are insns
> > e.g. 'ffree' changes FTAG register, so we must record
> it.
> >
> > Do you mean to say that we should remove it from just
> enumaration ?
> > but anyway we need to record those registers.
> >
>
> You are working on make prec x86 support fp insn, not to
> extend the fp
> function of i386 (If you want, you can make a special patch
> for it).
>
>
>
>
> >
> > --- On Wed, 7/1/09, Hui Zhu <teawater@gmail.com>
> wrote:
> >
> >> From: Hui Zhu <teawater@gmail.com>
> >> Subject: Re: i386.record.floating.point.patch :
> with more testing and assurity
> >> To: "paawan oza" <paawan1982@yahoo.com>,
> "Pedro Alves" <pedro@codesourcery.com>,
> "Mark Kettenis" <mark.kettenis@xs4all.nl>,
> "Michael Snyder" <msnyder@vmware.com>
> >> Cc: gdb-patches@sourceware.org
> >> Date: Wednesday, July 1, 2009, 11:23 AM
> >> About this patch, I say my idea
> >> again, I told in
> >> http://sourceware.org/ml/gdb-patches/2009-06/msg00014.html
> >> @@ -145,7 +145,22 @@
> >> I386_ES_REGNUM,
> >> /* %es */
> >> I386_FS_REGNUM,
> >> /* %fs */
> >> I386_GS_REGNUM,
> >> /* %gs */
> >> - I386_ST0_REGNUM
> >> /* %st(0) */
> >> + I386_ST0_REGNUM,
> >> /* %st(0) */
> >> + I386_ST1_REGNUM,
> >> /* %st(1) */
> >> + I386_ST2_REGNUM,
> >> /* %st(2) */
> >> + I386_ST3_REGNUM,
> >> /* %st(3) */
> >> + I386_ST4_REGNUM,
> >> /* %st(4) */
> >> + I386_ST5_REGNUM,
> >> /* %st(5) */
> >> + I386_ST6_REGNUM,
> >> /* %st(6) */
> >> + I386_ST7_REGNUM,
> >> /* %st(7) */
> >> + I386_FCTRL,
> >> /* floating point env regs : FCTRL-FOP
> >> */
> >> + I386_FSTAT,
> >> + I386_FTAG,
> >>
> >> + I386_FISEG,
> >> + I386_FIOFF,
> >> + I386_FOSEG,
> >> + I386_FOOFF,
> >> + I386_FOP
> >> };
> >>
> >> You are working on make prec x86 support fp insn,
> not to
> >> extend the fp
> >> function of i386 (If you want, you can make a
> special patch
> >> for it).
> >>
> >> Hui
> >>
> >> On Tue, Jun 30, 2009 at 23:05, paawan oza<paawan1982@yahoo.com>
> >> wrote:
> >> >
> >> > Hi,
> >> > As I am submitting the patch for the first
> time, I am
> >> not much aware of gdb test suite.
> >> > would you please guide me about how I can put
> the
> >> things in the testsuite ?
> >> > is it the testsuite which comes along with
> the gdb
> >> source ?
> >> > gdb\testsuite\gdb.base ??
> >> > Regards,
> >> > Oza.
> >> >
> >> > --- On Tue, 6/30/09, Pedro Alves <pedro@codesourcery.com>
> >> wrote:
> >> >
> >> >> From: Pedro Alves <pedro@codesourcery.com>
> >> >> Subject: Re:
> i386.record.floating.point.patch :
> >> with more testing and assurity
> >> >> To: gdb-patches@sourceware.org
> >> >> Cc: "paawan oza" <paawan1982@yahoo.com>,
> >> teawater@gmail.com
> >> >> Date: Tuesday, June 30, 2009, 7:09 PM
> >> >> On Tuesday 30 June 2009 14:23:30,
> >> >> paawan oza wrote:
> >> >> >
> >> >> > > As suggested by Hui,
> >> >> > > I have come up with more
> detailed and
> >> granular
> >> >> test case
> >> >> > > for the patch which I had
> submitted last
> >> week.
> >> >>
> >> >> Could you please consider migrating that
> test into
> >> the
> >> >> testsuite?
> >> >> You've gone through the trouble of
> writing tests
> >> to make
> >> >> sure
> >> >> the features work now --- putting it in
> the
> >> testsuite means
> >> >> we
> >> >> have an automatic-ish means to check that
> it
> >> doesn't get
> >> >> inadvertently broken in the future. The
> way it
> >> is,
> >> >> when your
> >> >> code gets in, the test will probably end
> up lost
> >> in the
> >> >> archives.
> >> >> We wouldn't want that, would we? :-)
> Having
> >> >> auto-tests, also helps
> >> >> the person doing the review in confirming
> things
> >> work as
> >> >> expected (without much effort).
> >> >>
> >> >> --
> >> >> Pedro Alves
> >> >>
> >> >
> >> >
> >> >
> >> >
> >>
> >
> >
> >
> >
>
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-07-01 16:17 paawan oza
2009-07-05 18:33 ` Mark Kettenis
0 siblings, 1 reply; 40+ messages in thread
From: paawan oza @ 2009-07-01 16:17 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches, teawater
Hi,
For your review convenience, I am sending the patch in plain text as a part of email body.
please also refer to the previous mails, where a point is raised by Hui.
I provided justification for the same.
please help with the point to throw more light.
TEST_CASE
****************************************************
test_float.c
****************************************************
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/* the test intends to test following insns.
flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp fsubrp fucomp fnstsw fsqrt
fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1 fldl2t fldl2e FLDPI FLDLG2 FLDLN2
FLDZ fincstp ffree fptan fpatan fincstp fsincos frndint fscale fsin fcos fcmovb
fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor fstsw
*/
float no1,no2,no3,no4,no5,no6,no7;
double x = 100.345, y = 25.7789;
long double ldx = 88888888888888888888.88, ldy = 9999999999999999999.99;
float result,resultd,resultld;
float *float_memory;
/* 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;
}
/* 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()
{
result = no1 + no2 + no3 + no4 + no5 + no6 + no7;
printf("result is %f\n",result);
result = fmodf(no2,no1);
printf("result is %f\n",result);
resultd = fmod(x,y);
printf("result is %f\n",resultd);
resultld = fmodl(ldy,ldy);
printf("result is %f\n",resultld);
result = fabsf(no1);
printf("result is %f\n",result);
result = no3 / no4;
printf("result is %f\n",result);
result = no1 * no2 * no3 * no4;
printf("result is %f\n",result);
result = no1 - no2 - no3 - no4;
printf("result is %f\n",result);
asm ("fld %0" : :"m"(*float_memory));
asm ("fchs");
/* test for f2xm1 */
asm ("fld %0" : :"m"(*float_memory));
asm ("f2xm1");
asm ("fyl2x");
asm ("fld %0" : :"m"(*float_memory));
asm ("fxtract");
asm ("fld %0" : :"m"(*float_memory));
asm ("fprem1");
/* decrement fpu stack pointer only status register should get affected */
asm ("fld %0" : :"m"(*float_memory));
empty_fpu_stack();
asm ("fld1");
asm ("fldl2t");
asm ("fldl2e");
asm ("fldpi");
asm ("fldlg2");
asm ("fldln2");
asm ("fldz");
empty_fpu_stack();
/* finishing emptying the stack */
result = sqrt(no3);
printf("result is %f\n",result);
}
void test_log_exp_floats()
{
result = log10(no3);
printf("result is %f\n",result);
result = log(no3);
printf("result is %f\n",result);
result = exp10(no3);
printf("result is %f\n",result);
result = exp(no3);
printf("result is %f\n",result);
}
void test_trigo_floats()
{
result = sin(30);
printf("result is %f\n",result);
result = cos(30);
printf("result is %f\n",result);
result = tan(30);
printf("result is %f\n",result);
result = atan(30);
printf("result is %f\n",result);
asm ("fld %0" : :"m"(*float_memory));
asm ("fptan");
/* changes st1 and popping register stack */
asm ("fpatan");
asm("fincstp");
asm ("fld %0" : :"m"(float_memory));
asm ("fsincos");
asm ("fld %0" : :"m"(*float_memory));
asm ("frndint");
asm ("fld %0" : :"m"(*float_memory));
asm ("fld %0" : :"m"(*(float_memory+1)));
asm ("fscale");
empty_fpu_stack();
asm ("fld %0" : :"m"(*float_memory));
asm ("fsin");
asm ("fcos");
/* currently we assume condition likely and always record the registers
code could be optimized only if the flag is set then record */
asm ("fld %0" : :"m"(*float_memory));
asm ("fld %0" : :"m"(*(float_memory+1)));
asm ("fcmovb %st(1), %st");
asm ("fcmovbe %st(1), %st");
asm ("fcmove %st(1), %st");
asm ("fcmovu %st(1), %st");
asm ("fcmovnb %st(1), %st");
asm ("fcmovnbe %st(1), %st");
empty_fpu_stack();
/* finished emtyping the stack */
}
void test_compare_floats()
{
ldy = 88888888888888888888.88;
if (ldx == ldy)
ldy = 7777777777777777777777777777.777;
else
ldy = 666666666666666666666666666.666;
}
/* test loading and saving of FPU environment */
void test_fpu_env()
{
asm ("fsave %0" : "=m"(*float_memory) : );
asm ("frstor %0" : : "m"(*float_memory));
asm ("fstsw %ax");
}
int main()
{
init_floats();
test_arith_floats();
test_log_exp_floats();
test_trigo_floats();
test_compare_floats();
test_fpu_env();
}
******************************************************
i386-record-floats.patch
******************************************************
diff -urN gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
--- gdb.orig/i386-tdep.c 2009-05-29 17:08:40.000000000 -0400
+++ gdb.new/i386-tdep.c 2009-06-01 20:02:23.000000000 -0400
@@ -543,6 +543,9 @@
/* The maximum number of saved registers. This should include all
registers mentioned above, and %eip. */
#define I386_NUM_SAVED_REGS I386_NUM_GREGS
+#define I386_SAVE_FPU_REGS 0xFFFD
+#define I386_SAVE_FPU_ENV 0xFFFE
+#define I386_SAVE_FPU_ENV_REG_STACK 0xFFFF
struct i386_frame_cache
{
@@ -2985,6 +2988,54 @@
return 0;
}
+/* Record the value of floating point registers which will be changed by the current instruction
+ to "record_arch_list".
+ return -1 if something is wrong. */
+
+static int i386_record_floats(struct i386_record_s *ir, uint32_t iregnum)
+{
+ int i;
+
+ /* Oza : push/pop of fpu stack is going to happen
+ currently we store st0-st7 registers, but we need not store all registers all the time.
+ using fstatus, we use 11-13 bits which gives us stack top and hence we optimize our storage. */
+ if (I386_SAVE_FPU_REGS == iregnum)
+ {
+ for (i=I386_ST0_REGNUM;i<=I386_ST7_REGNUM;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV == iregnum)
+ {
+ for (i=I386_FCTRL;i<=I386_FOP;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+ {
+ for (i=I386_ST0_REGNUM;i<=I386_FOP;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (iregnum >= I386_ST0_REGNUM && iregnum <= I386_FOP)
+ {
+ if (record_arch_list_add_reg (ir->regcache,iregnum))
+ return -1;
+ }
+ else
+ {
+ /* param Error */
+ return -1;
+ }
+ return 0;
+}
+
/* Parse the current instruction and record the values of the registers and
memory that will be changed in current instruction to "record_arch_list".
Return -1 if something wrong. */
@@ -4035,7 +4086,6 @@
break;
/* floats */
- /* It just record the memory change of instrcution. */
case 0xd8:
case 0xd9:
case 0xda:
@@ -4056,39 +4106,49 @@
return -1;
switch (ir.reg)
{
- case 0x00:
- case 0x01:
case 0x02:
- case 0x03:
+ case 0x12:
+ case 0x22:
+ case 0x32:
+ /* for FCOM, FICOM nothing to do */
+ break;
+ case 0x03:
+ case 0x13:
+ case 0x23:
+ case 0x33:
+ /* FCOMP, FICOMP pop FPU stack, store all */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0x00:
+ case 0x01:
case 0x04:
case 0x05:
case 0x06:
case 0x07:
case 0x10:
- case 0x11:
- case 0x12:
- case 0x13:
+ case 0x11:
case 0x14:
case 0x15:
case 0x16:
case 0x17:
case 0x20:
case 0x21:
- case 0x22:
- case 0x23:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x30:
case 0x31:
- case 0x32:
- case 0x33:
case 0x34:
case 0x35:
case 0x36:
case 0x37:
- break;
+ /* FADD, FMUL, FSUB, FSUBR, FDIV, FDIVR, FIADD, FIMUL, FISUB, FISUBR, FIDIV, FIDIVR
+ ModR/M.reg is an extension of code, always affects st(0) register */
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
case 0x08:
case 0x0a:
case 0x0b:
@@ -4096,6 +4156,7 @@
case 0x19:
case 0x1a:
case 0x1b:
+ case 0x1d:
case 0x28:
case 0x29:
case 0x2a:
@@ -4103,11 +4164,16 @@
case 0x38:
case 0x39:
case 0x3a:
- case 0x3b:
+ case 0x3b:
+ case 0x3c:
+ case 0x3d:
switch (ir.reg & 7)
{
case 0:
- break;
+ /* FLD, FILD */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
case 1:
switch (ir.reg >> 4)
{
@@ -4120,6 +4186,7 @@
return -1;
break;
case 3:
+ break;
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4130,15 +4197,42 @@
switch (ir.reg >> 4)
{
case 0:
+ if (record_arch_list_add_mem (addr, 4))
+ return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* FSTP m32fp */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
case 1:
if (record_arch_list_add_mem (addr, 4))
return -1;
+ if ((3 == (ir.reg & 7)) || (5 == (ir.reg & 7)) || (7 == (ir.reg & 7)))
+ {
+ /* FSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 2:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* FSTP m64fp */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 3:
+ if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+ {
+ /* FISTP, FBLD, FILD, FBSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4147,54 +4241,71 @@
break;
}
break;
- case 0x0c:
- case 0x0d:
- case 0x1d:
- case 0x2c:
- case 0x3c:
- case 0x3d:
- break;
- case 0x0e:
+ case 0x0c:
+ /* FLDENV */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
+ case 0x0d:
+ /* FLDCW */
+ if (i386_record_floats(&ir, I386_FCTRL))
+ return -1;
+ break;
+ case 0x2c:
+ /* FRTSTOR */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
+ case 0x0e:
if (ir.dflag)
{
- if (record_arch_list_add_mem (addr, 28))
- return -1;
+ if (record_arch_list_add_mem (addr, 28))
+ return -1;
}
else
{
- if (record_arch_list_add_mem (addr, 14))
- return -1;
+ if (record_arch_list_add_mem (addr, 14))
+ return -1;
}
break;
- case 0x0f:
- case 0x2f:
+ case 0x0f:
+ case 0x2f:
if (record_arch_list_add_mem (addr, 2))
return -1;
break;
- case 0x1f:
- case 0x3e:
+ case 0x1f:
+ case 0x3e:
if (record_arch_list_add_mem (addr, 10))
return -1;
+ /* FSTP, FBSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
- case 0x2e:
+ case 0x2e:
if (ir.dflag)
{
- if (record_arch_list_add_mem (addr, 28))
- return -1;
- addr += 28;
+ if (record_arch_list_add_mem (addr, 28))
+ return -1;
+ addr += 28;
}
else
{
- if (record_arch_list_add_mem (addr, 14))
- return -1;
- addr += 14;
+ if (record_arch_list_add_mem (addr, 14))
+ return -1;
+ addr += 14;
}
if (record_arch_list_add_mem (addr, 80))
return -1;
+ /* FSAVE */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
break;
- case 0x3f:
+ case 0x3f:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ /* FISTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
default:
ir.addr -= 2;
@@ -4202,9 +4313,180 @@
goto no_support;
break;
}
- }
+ }
+ /* opcode is an extension of modR/M byte */
+ else
+ {
+ switch (opcode)
+ {
+ case 0xd8:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
+ case 0xd9:
+ if (0x0c == (ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ /* if only st(0) is changing, then we have already recorded */
+ if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ }
+ else
+ {
+ switch(ir.modrm)
+ {
+ case 0xe0:
+ case 0xe1:
+ case 0xf0:
+ case 0xf5:
+ case 0xf8:
+ case 0xfa:
+ case 0xfc:
+ case 0xfe:
+ case 0xff:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
+ case 0xf1:
+ case 0xf2:
+ case 0xf3:
+ case 0xf4:
+ case 0xf6:
+ case 0xf7:
+ case 0xe8:
+ case 0xe9:
+ case 0xea:
+ case 0xeb:
+ case 0xec:
+ case 0xed:
+ case 0xee:
+ case 0xf9:
+ case 0xfb:
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0xfd:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (i386_record_floats(&ir, I386_ST1_REGNUM))
+ return -1;
+ break;
+ }
+ }
+ break;
+ case 0xda:
+ if (0xe9 == ir.modrm)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdb:
+ if (0xe3 == ir.modrm)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV))
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdc:
+ if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4) || (0x0f == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdd:
+ if (0x0c == ir.modrm >> 4)
+ {
+ if (i386_record_floats(&ir,I386_FTAG))
+ return -1;
+ }
+ else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ }
+ break;
+ case 0xde:
+ if ((0x0c == ir.modrm >> 4) || (0x0e == ir.modrm >> 4) || (0x0f == ir.modrm >> 4) || (0xd9 == ir.modrm))
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ case 0xdf:
+ if (0xe0 == ir.modrm)
+ {
+ if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+ return -1;
+ }
+ else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ }
+ }
break;
-
/* string ops */
/* movsS */
case 0xa4:
@@ -4623,10 +4905,17 @@
/* fwait */
/* XXX */
case 0x9b:
- printf_unfiltered (_("Process record doesn't support instruction "
- "fwait.\n"));
- ir.addr -= 1;
- goto no_support;
+ if (target_read_memory (ir.addr, &tmpu8, 1))
+ {
+ if (record_debug)
+ printf_unfiltered (_("Process record: error reading memory at "
+ "addr 0x%s len = 1.\n"),
+ paddr_nz (ir.addr));
+ return -1;
+ }
+ opcode = (uint32_t) tmpu8;
+ ir.addr++;
+ goto reswitch;
break;
/* int3 */
diff -urN gdb.orig/i386-tdep.h gdb.new/i386-tdep.h
--- gdb.orig/i386-tdep.h 2009-05-17 17:56:44.000000000 -0400
+++ gdb.new/i386-tdep.h 2009-05-31 16:33:14.000000000 -0400
@@ -145,7 +145,22 @@
I386_ES_REGNUM, /* %es */
I386_FS_REGNUM, /* %fs */
I386_GS_REGNUM, /* %gs */
- I386_ST0_REGNUM /* %st(0) */
+ I386_ST0_REGNUM, /* %st(0) */
+ I386_ST1_REGNUM, /* %st(1) */
+ I386_ST2_REGNUM, /* %st(2) */
+ I386_ST3_REGNUM, /* %st(3) */
+ I386_ST4_REGNUM, /* %st(4) */
+ I386_ST5_REGNUM, /* %st(5) */
+ I386_ST6_REGNUM, /* %st(6) */
+ I386_ST7_REGNUM, /* %st(7) */
+ I386_FCTRL, /* floating point env regs : FCTRL-FOP */
+ I386_FSTAT,
+ I386_FTAG,
+ I386_FISEG,
+ I386_FIOFF,
+ I386_FOSEG,
+ I386_FOOFF,
+ I386_FOP
};
#define I386_NUM_GREGS 16
--- On Tue, 6/30/09, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> From: Mark Kettenis <mark.kettenis@xs4all.nl>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: paawan1982@yahoo.com
> Cc: gdb-patches@sourceware.org, teawater@gmail.com
> Date: Tuesday, June 30, 2009, 7:12 PM
> > Date: Tue, 30 Jun 2009 06:23:30
> -0700 (PDT)
> > From: paawan oza <paawan1982@yahoo.com>
> >
> > Hi,
> > Again I am sending the patch, with the test cases.
> > please do the needful
> > Regards,
> > Oza.
>
> Sorry, but if you want me to review your patch, don't send
> it as
> base64 encoded MIME.
>
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-01 16:17 paawan oza
@ 2009-07-05 18:33 ` Mark Kettenis
0 siblings, 0 replies; 40+ messages in thread
From: Mark Kettenis @ 2009-07-05 18:33 UTC (permalink / raw)
To: paawan1982; +Cc: gdb-patches, teawater
> Date: Wed, 1 Jul 2009 09:17:41 -0700 (PDT)
> From: paawan oza <paawan1982@yahoo.com>
>
> Hi,
>
> For your review convenience, I am sending the patch in plain text as a part of email body.
> please also refer to the previous mails, where a point is raised by Hui.
> I provided justification for the same.
> please help with the point to throw more light.
Please review the GNU coding standards. Your new code has some
formatting problems.
> TEST_CASE
> ****************************************************
> test_float.c
> ****************************************************
> #include <stdio.h>
> #include <math.h>
> #include <stdlib.h>
>
> /* the test intends to test following insns.
> flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp fsubrp fucomp fnstsw fsqrt
> fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1 fldl2t fldl2e FLDPI FLDLG2 FLDLN2
> FLDZ fincstp ffree fptan fpatan fincstp fsincos frndint fscale fsin fcos fcmovb
> fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor fstsw
> */
>
> float no1,no2,no3,no4,no5,no6,no7;
> double x = 100.345, y = 25.7789;
> long double ldx = 88888888888888888888.88, ldy = 9999999999999999999.99;
> float result,resultd,resultld;
> float *float_memory;
>
> /* 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;
> }
>
> /* 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()
> {
> result = no1 + no2 + no3 + no4 + no5 + no6 + no7;
> printf("result is %f\n",result);
>
> result = fmodf(no2,no1);
> printf("result is %f\n",result);
>
> resultd = fmod(x,y);
> printf("result is %f\n",resultd);
>
> resultld = fmodl(ldy,ldy);
> printf("result is %f\n",resultld);
>
> result = fabsf(no1);
> printf("result is %f\n",result);
>
> result = no3 / no4;
> printf("result is %f\n",result);
>
> result = no1 * no2 * no3 * no4;
> printf("result is %f\n",result);
>
> result = no1 - no2 - no3 - no4;
> printf("result is %f\n",result);
>
>
> asm ("fld %0" : :"m"(*float_memory));
> asm ("fchs");
>
> /* test for f2xm1 */
> asm ("fld %0" : :"m"(*float_memory));
> asm ("f2xm1");
>
> asm ("fyl2x");
>
> asm ("fld %0" : :"m"(*float_memory));
> asm ("fxtract");
>
> asm ("fld %0" : :"m"(*float_memory));
> asm ("fprem1");
>
> /* decrement fpu stack pointer only status register should get affected */
> asm ("fld %0" : :"m"(*float_memory));
>
> empty_fpu_stack();
>
> asm ("fld1");
> asm ("fldl2t");
> asm ("fldl2e");
> asm ("fldpi");
> asm ("fldlg2");
> asm ("fldln2");
> asm ("fldz");
>
> empty_fpu_stack();
> /* finishing emptying the stack */
>
> result = sqrt(no3);
> printf("result is %f\n",result);
> }
>
> void test_log_exp_floats()
> {
> result = log10(no3);
> printf("result is %f\n",result);
>
> result = log(no3);
> printf("result is %f\n",result);
>
> result = exp10(no3);
> printf("result is %f\n",result);
>
> result = exp(no3);
> printf("result is %f\n",result);
> }
>
> void test_trigo_floats()
> {
> result = sin(30);
> printf("result is %f\n",result);
>
> result = cos(30);
> printf("result is %f\n",result);
>
> result = tan(30);
> printf("result is %f\n",result);
>
> result = atan(30);
> printf("result is %f\n",result);
>
> asm ("fld %0" : :"m"(*float_memory));
> asm ("fptan");
>
> /* changes st1 and popping register stack */
> asm ("fpatan");
>
> asm("fincstp");
> asm ("fld %0" : :"m"(float_memory));
> asm ("fsincos");
>
> asm ("fld %0" : :"m"(*float_memory));
> asm ("frndint");
>
> asm ("fld %0" : :"m"(*float_memory));
> asm ("fld %0" : :"m"(*(float_memory+1)));
> asm ("fscale");
>
> empty_fpu_stack();
>
> asm ("fld %0" : :"m"(*float_memory));
> asm ("fsin");
> asm ("fcos");
>
> /* currently we assume condition likely and always record the registers
> code could be optimized only if the flag is set then record */
> asm ("fld %0" : :"m"(*float_memory));
> asm ("fld %0" : :"m"(*(float_memory+1)));
> asm ("fcmovb %st(1), %st");
> asm ("fcmovbe %st(1), %st");
> asm ("fcmove %st(1), %st");
> asm ("fcmovu %st(1), %st");
> asm ("fcmovnb %st(1), %st");
> asm ("fcmovnbe %st(1), %st");
>
> empty_fpu_stack();
> /* finished emtyping the stack */
> }
>
> void test_compare_floats()
> {
> ldy = 88888888888888888888.88;
> if (ldx == ldy)
> ldy = 7777777777777777777777777777.777;
> else
> ldy = 666666666666666666666666666.666;
> }
>
> /* test loading and saving of FPU environment */
> void test_fpu_env()
> {
> asm ("fsave %0" : "=m"(*float_memory) : );
> asm ("frstor %0" : : "m"(*float_memory));
> asm ("fstsw %ax");
> }
>
> int main()
> {
> init_floats();
> test_arith_floats();
> test_log_exp_floats();
> test_trigo_floats();
> test_compare_floats();
> test_fpu_env();
> }
As other already indicated, you should really turn this into something
that is integrated in the GDB testsuite.
> diff -urN gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
> --- gdb.orig/i386-tdep.c 2009-05-29 17:08:40.000000000 -0400
> +++ gdb.new/i386-tdep.c 2009-06-01 20:02:23.000000000 -0400
> @@ -543,6 +543,9 @@
> /* The maximum number of saved registers. This should include all
> registers mentioned above, and %eip. */
> #define I386_NUM_SAVED_REGS I386_NUM_GREGS
> +#define I386_SAVE_FPU_REGS 0xFFFD
> +#define I386_SAVE_FPU_ENV 0xFFFE
> +#define I386_SAVE_FPU_ENV_REG_STACK 0xFFFF
What are these constants used for? Do they have anything to do with
the number of saved registers? Also, please use lowercase for
hexadecimal constants.
> struct i386_frame_cache
> {
> @@ -2985,6 +2988,54 @@
> return 0;
> }
>
> +/* Record the value of floating point registers which will be changed by the current instruction
> + to "record_arch_list".
> + return -1 if something is wrong. */
Everey new sentence should start with a capital; everey full stop (.)
should be followed by two spaces. Also please wrap your comments such
that fit in a 80-column wide screen.
> +
> +static int i386_record_floats(struct i386_record_s *ir, uint32_t iregnum)
static int
> +{
> + int i;
> +
> + /* Oza : push/pop of fpu stack is going to happen
> + currently we store st0-st7 registers, but we need not store all registers all the time.
> + using fstatus, we use 11-13 bits which gives us stack top and hence we optimize our storage. */
Sorry, but I don't understand what you're saying here.
> + if (I386_SAVE_FPU_REGS == iregnum)
> + {
> + for (i=I386_ST0_REGNUM;i<=I386_ST7_REGNUM;i++)
Spacing problems.
> + {
> + if (record_arch_list_add_reg (ir->regcache,i))
> + return -1;
> + }
> + }
> + else if (I386_SAVE_FPU_ENV == iregnum)
> + {
> + for (i=I386_FCTRL;i<=I386_FOP;i++)
> + {
> + if (record_arch_list_add_reg (ir->regcache,i))
> + return -1;
> + }
> + }
> + else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
> + {
> + for (i=I386_ST0_REGNUM;i<=I386_FOP;i++)
> + {
> + if (record_arch_list_add_reg (ir->regcache,i))
> + return -1;
> + }
> + }
> + else if (iregnum >= I386_ST0_REGNUM && iregnum <= I386_FOP)
> + {
> + if (record_arch_list_add_reg (ir->regcache,iregnum))
> + return -1;
> + }
> + else
> + {
> + /* param Error */
Capitalization; missing full stop.
> + return -1;
> + }
> + return 0;
> +}
> +
> /* Parse the current instruction and record the values of the registers and
> memory that will be changed in current instruction to "record_arch_list".
> Return -1 if something wrong. */
> @@ -4035,7 +4086,6 @@
> break;
>
> /* floats */
> - /* It just record the memory change of instrcution. */
> case 0xd8:
> case 0xd9:
> case 0xda:
> @@ -4056,39 +4106,49 @@
> return -1;
> switch (ir.reg)
> {
> - case 0x00:
> - case 0x01:
> case 0x02:
> - case 0x03:
> + case 0x12:
> + case 0x22:
> + case 0x32:
> + /* for FCOM, FICOM nothing to do */
Please use lowercase for assembler mnemonics.
> + break;
> + case 0x03:
> + case 0x13:
> + case 0x23:
> + case 0x33:
> + /* FCOMP, FICOMP pop FPU stack, store all */
> + if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return -1;
> + break;
> + case 0x00:
> + case 0x01:
> case 0x04:
> case 0x05:
> case 0x06:
> case 0x07:
> case 0x10:
> - case 0x11:
> - case 0x12:
> - case 0x13:
> + case 0x11:
> case 0x14:
> case 0x15:
> case 0x16:
> case 0x17:
> case 0x20:
> case 0x21:
> - case 0x22:
> - case 0x23:
> case 0x24:
> case 0x25:
> case 0x26:
> case 0x27:
> case 0x30:
> case 0x31:
> - case 0x32:
> - case 0x33:
> case 0x34:
> case 0x35:
> case 0x36:
> case 0x37:
> - break;
> + /* FADD, FMUL, FSUB, FSUBR, FDIV, FDIVR, FIADD, FIMUL, FISUB, FISUBR, FIDIV, FIDIVR
> + ModR/M.reg is an extension of code, always affects st(0) register */
> + if (i386_record_floats(&ir, I386_ST0_REGNUM))
> + return -1;
> + break;
> case 0x08:
> case 0x0a:
> case 0x0b:
> @@ -4096,6 +4156,7 @@
> case 0x19:
> case 0x1a:
> case 0x1b:
> + case 0x1d:
> case 0x28:
> case 0x29:
> case 0x2a:
> @@ -4103,11 +4164,16 @@
> case 0x38:
> case 0x39:
> case 0x3a:
> - case 0x3b:
> + case 0x3b:
> + case 0x3c:
> + case 0x3d:
> switch (ir.reg & 7)
> {
> case 0:
> - break;
> + /* FLD, FILD */
> + if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return -1;
> + break;
> case 1:
> switch (ir.reg >> 4)
> {
> @@ -4120,6 +4186,7 @@
> return -1;
> break;
> case 3:
> + break;
> default:
> if (record_arch_list_add_mem (addr, 2))
> return -1;
> @@ -4130,15 +4197,42 @@
> switch (ir.reg >> 4)
> {
> case 0:
> + if (record_arch_list_add_mem (addr, 4))
> + return -1;
> + if (3 == (ir.reg & 7))
> + {
> + /* FSTP m32fp */
> + if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return -1;
> + }
> + break;
> case 1:
> if (record_arch_list_add_mem (addr, 4))
> return -1;
> + if ((3 == (ir.reg & 7)) || (5 == (ir.reg & 7)) || (7 == (ir.reg & 7)))
> + {
> + /* FSTP */
> + if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return -1;
> + }
> break;
> case 2:
> if (record_arch_list_add_mem (addr, 8))
> return -1;
> + if (3 == (ir.reg & 7))
> + {
> + /* FSTP m64fp */
> + if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return -1;
> + }
> break;
> case 3:
> + if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
> + {
> + /* FISTP, FBLD, FILD, FBSTP */
> + if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return -1;
> + }
> default:
> if (record_arch_list_add_mem (addr, 2))
> return -1;
> @@ -4147,54 +4241,71 @@
> break;
> }
> break;
> - case 0x0c:
> - case 0x0d:
> - case 0x1d:
> - case 0x2c:
> - case 0x3c:
> - case 0x3d:
> - break;
> - case 0x0e:
> + case 0x0c:
> + /* FLDENV */
> + if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
> + return -1;
> + break;
> + case 0x0d:
> + /* FLDCW */
> + if (i386_record_floats(&ir, I386_FCTRL))
> + return -1;
> + break;
> + case 0x2c:
> + /* FRTSTOR */
> + if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
> + return -1;
> + break;
> + case 0x0e:
> if (ir.dflag)
> {
> - if (record_arch_list_add_mem (addr, 28))
> - return -1;
> + if (record_arch_list_add_mem (addr, 28))
> + return -1;
> }
> else
> {
> - if (record_arch_list_add_mem (addr, 14))
> - return -1;
> + if (record_arch_list_add_mem (addr, 14))
> + return -1;
> }
> break;
> - case 0x0f:
> - case 0x2f:
> + case 0x0f:
> + case 0x2f:
> if (record_arch_list_add_mem (addr, 2))
> return -1;
> break;
> - case 0x1f:
> - case 0x3e:
> + case 0x1f:
> + case 0x3e:
> if (record_arch_list_add_mem (addr, 10))
> return -1;
> + /* FSTP, FBSTP */
> + if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return -1;
> break;
> - case 0x2e:
> + case 0x2e:
> if (ir.dflag)
> {
> - if (record_arch_list_add_mem (addr, 28))
> - return -1;
> - addr += 28;
> + if (record_arch_list_add_mem (addr, 28))
> + return -1;
> + addr += 28;
> }
> else
> {
> - if (record_arch_list_add_mem (addr, 14))
> - return -1;
> - addr += 14;
> + if (record_arch_list_add_mem (addr, 14))
> + return -1;
> + addr += 14;
> }
> if (record_arch_list_add_mem (addr, 80))
> return -1;
> + /* FSAVE */
> + if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
> + return -1;
> break;
> - case 0x3f:
> + case 0x3f:
> if (record_arch_list_add_mem (addr, 8))
> return -1;
> + /* FISTP */
> + if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return -1;
> break;
> default:
> ir.addr -= 2;
> @@ -4202,9 +4313,180 @@
> goto no_support;
> break;
> }
> - }
> + }
> + /* opcode is an extension of modR/M byte */
> + else
> + {
> + switch (opcode)
> + {
> + case 0xd8:
> + if (i386_record_floats(&ir, I386_ST0_REGNUM))
> + return -1;
> + break;
> + case 0xd9:
> + if (0x0c == (ir.modrm >> 4))
> + {
> + if ((ir.modrm & 0x0f) <= 7)
> + {
> + if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return -1;
> + }
> + else
> + {
> + if (i386_record_floats(&ir, I386_ST0_REGNUM))
> + return -1;
> + /* if only st(0) is changing, then we have already recorded */
> + if ((ir.modrm & 0x0f) - 0x08)
> + {
> + if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
> + return -1;
> + }
> + }
> + }
> + else
> + {
> + switch(ir.modrm)
> + {
> + case 0xe0:
> + case 0xe1:
> + case 0xf0:
> + case 0xf5:
> + case 0xf8:
> + case 0xfa:
> + case 0xfc:
> + case 0xfe:
> + case 0xff:
> + if (i386_record_floats(&ir, I386_ST0_REGNUM))
> + return -1;
> + break;
> + case 0xf1:
> + case 0xf2:
> + case 0xf3:
> + case 0xf4:
> + case 0xf6:
> + case 0xf7:
> + case 0xe8:
> + case 0xe9:
> + case 0xea:
> + case 0xeb:
> + case 0xec:
> + case 0xed:
> + case 0xee:
> + case 0xf9:
> + case 0xfb:
> + if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return -1;
> + break;
> + case 0xfd:
> + if (i386_record_floats(&ir, I386_ST0_REGNUM))
> + return -1;
> + if (i386_record_floats(&ir, I386_ST1_REGNUM))
> + return -1;
> + break;
> + }
> + }
> + break;
> + case 0xda:
> + if (0xe9 == ir.modrm)
> + {
> + if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return -1;
> + }
> + else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
> + {
> + if (i386_record_floats(&ir, I386_ST0_REGNUM))
> + return -1;
> + if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
> + {
> + if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
> + return -1;
> + }
> + else if ((ir.modrm & 0x0f) - 0x08)
> + {
> + if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
> + return -1;
> + }
> + }
> + break;
> + case 0xdb:
> + if (0xe3 == ir.modrm)
> + {
> + if (i386_record_floats(&ir, I386_SAVE_FPU_ENV))
> + return -1;
> + }
> + else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
> + {
> + if (i386_record_floats(&ir, I386_ST0_REGNUM))
> + return -1;
> + if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
> + {
> + if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
> + return -1;
> + }
> + else if ((ir.modrm & 0x0f) - 0x08)
> + {
> + if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
> + return -1;
> + }
> + }
> + break;
> + case 0xdc:
> + if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4) || (0x0f == ir.modrm >> 4))
> + {
> + if ((ir.modrm & 0x0f) <= 7)
> + {
> + if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
> + return -1;
> + }
> + else
> + {
> + if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
> + return -1;
> + }
> + }
> + break;
> + case 0xdd:
> + if (0x0c == ir.modrm >> 4)
> + {
> + if (i386_record_floats(&ir,I386_FTAG))
> + return -1;
> + }
> + else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
> + {
> + if ((ir.modrm & 0x0f) <= 7)
> + {
> + if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
> + return -1;
> + }
> + else
> + {
> + if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return -1;
> + }
> + }
> + break;
> + case 0xde:
> + if ((0x0c == ir.modrm >> 4) || (0x0e == ir.modrm >> 4) || (0x0f == ir.modrm >> 4) || (0xd9 == ir.modrm))
> + {
> + if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return -1;
> + }
> + break;
> + case 0xdf:
> + if (0xe0 == ir.modrm)
> + {
> + if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
> + return -1;
> + }
> + else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
> + {
> + if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return -1;
> + }
> + break;
> + }
> + }
> break;
> -
> /* string ops */
> /* movsS */
> case 0xa4:
> @@ -4623,10 +4905,17 @@
> /* fwait */
> /* XXX */
> case 0x9b:
> - printf_unfiltered (_("Process record doesn't support instruction "
> - "fwait.\n"));
> - ir.addr -= 1;
> - goto no_support;
> + if (target_read_memory (ir.addr, &tmpu8, 1))
> + {
> + if (record_debug)
> + printf_unfiltered (_("Process record: error reading memory at "
> + "addr 0x%s len = 1.\n"),
> + paddr_nz (ir.addr));
> + return -1;
> + }
> + opcode = (uint32_t) tmpu8;
> + ir.addr++;
> + goto reswitch;
> break;
>
> /* int3 */
> diff -urN gdb.orig/i386-tdep.h gdb.new/i386-tdep.h
> --- gdb.orig/i386-tdep.h 2009-05-17 17:56:44.000000000 -0400
> +++ gdb.new/i386-tdep.h 2009-05-31 16:33:14.000000000 -0400
> @@ -145,7 +145,22 @@
> I386_ES_REGNUM, /* %es */
> I386_FS_REGNUM, /* %fs */
> I386_GS_REGNUM, /* %gs */
> - I386_ST0_REGNUM /* %st(0) */
> + I386_ST0_REGNUM, /* %st(0) */
> + I386_ST1_REGNUM, /* %st(1) */
> + I386_ST2_REGNUM, /* %st(2) */
> + I386_ST3_REGNUM, /* %st(3) */
> + I386_ST4_REGNUM, /* %st(4) */
> + I386_ST5_REGNUM, /* %st(5) */
> + I386_ST6_REGNUM, /* %st(6) */
> + I386_ST7_REGNUM, /* %st(7) */
> + I386_FCTRL, /* floating point env regs : FCTRL-FOP */
> + I386_FSTAT,
> + I386_FTAG,
> + I386_FISEG,
> + I386_FIOFF,
> + I386_FOSEG,
> + I386_FOOFF,
> + I386_FOP
> };
If you no longer need this, please remove this from your diff.
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-07-01 16:02 paawan oza
2009-07-01 16:14 ` Mark Kettenis
0 siblings, 1 reply; 40+ messages in thread
From: paawan oza @ 2009-07-01 16:02 UTC (permalink / raw)
To: Pedro Alves, Mark Kettenis, Michael Snyder, Hui Zhu; +Cc: gdb-patches
Can somebody please help with this open point ?
--- On Wed, 7/1/09, paawan oza <paawan1982@yahoo.com> wrote:
> From: paawan oza <paawan1982@yahoo.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: "Pedro Alves" <pedro@codesourcery.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "Michael Snyder" <msnyder@vmware.com>, "Hui Zhu" <teawater@gmail.com>
> Cc: gdb-patches@sourceware.org
> Date: Wednesday, July 1, 2009, 9:30 PM
> Hi Hui,
>
> As I clarified earlier,
> these registers are already supported and extended by gdb
> much before this patch.
> all floating point registers are already supported by gdb
> (info floats/info all-registers command gives it)
>
> My aim is : only to make sure that whenever any floating
> point insn gets executed, we record the registers
> (no matter whether it is %st(n) or FCTRL or FTAG or
> FSTATUS)
> there are insns
> e.g. 'ffree' changes FTAG register, so we must record it.
>
> Do you mean to say that we should remove it from just
> enumaration ?
> but anyway we need to record those registers.
>
> Regards,
> Oza.
>
> --- On Wed, 7/1/09, Hui Zhu <teawater@gmail.com>
> wrote:
>
> > From: Hui Zhu <teawater@gmail.com>
> > Subject: Re: i386.record.floating.point.patch : with
> more testing and assurity
> > To: "paawan oza" <paawan1982@yahoo.com>,
> "Pedro Alves" <pedro@codesourcery.com>,
> "Mark Kettenis" <mark.kettenis@xs4all.nl>,
> "Michael Snyder" <msnyder@vmware.com>
> > Cc: gdb-patches@sourceware.org
> > Date: Wednesday, July 1, 2009, 11:23 AM
> > About this patch, I say my idea
> > again, I told in
> > http://sourceware.org/ml/gdb-patches/2009-06/msg00014.html
> > @@ -145,7 +145,22 @@
> > I386_ES_REGNUM,
> > /* %es */
> > I386_FS_REGNUM,
> > /* %fs */
> > I386_GS_REGNUM,
> > /* %gs */
> > - I386_ST0_REGNUM
> > /* %st(0) */
> > + I386_ST0_REGNUM,
> > /* %st(0) */
> > + I386_ST1_REGNUM,
> > /* %st(1) */
> > + I386_ST2_REGNUM,
> > /* %st(2) */
> > + I386_ST3_REGNUM,
> > /* %st(3) */
> > + I386_ST4_REGNUM,
> > /* %st(4) */
> > + I386_ST5_REGNUM,
> > /* %st(5) */
> > + I386_ST6_REGNUM,
> > /* %st(6) */
> > + I386_ST7_REGNUM,
> > /* %st(7) */
> > + I386_FCTRL,
> > /* floating point env regs : FCTRL-FOP
> > */
> > + I386_FSTAT,
> > + I386_FTAG,
> >
> > + I386_FISEG,
> > + I386_FIOFF,
> > + I386_FOSEG,
> > + I386_FOOFF,
> > + I386_FOP
> > };
> >
> > You are working on make prec x86 support fp insn, not
> to
> > extend the fp
> > function of i386 (If you want, you can make a special
> patch
> > for it).
> >
> > Hui
> >
> > On Tue, Jun 30, 2009 at 23:05, paawan oza<paawan1982@yahoo.com>
> > wrote:
> > >
> > > Hi,
> > > As I am submitting the patch for the first time,
> I am
> > not much aware of gdb test suite.
> > > would you please guide me about how I can put
> the
> > things in the testsuite ?
> > > is it the testsuite which comes along with the
> gdb
> > source ?
> > > gdb\testsuite\gdb.base ??
> > > Regards,
> > > Oza.
> > >
> > > --- On Tue, 6/30/09, Pedro Alves <pedro@codesourcery.com>
> > wrote:
> > >
> > >> From: Pedro Alves <pedro@codesourcery.com>
> > >> Subject: Re: i386.record.floating.point.patch
> :
> > with more testing and assurity
> > >> To: gdb-patches@sourceware.org
> > >> Cc: "paawan oza" <paawan1982@yahoo.com>,
> > teawater@gmail.com
> > >> Date: Tuesday, June 30, 2009, 7:09 PM
> > >> On Tuesday 30 June 2009 14:23:30,
> > >> paawan oza wrote:
> > >> >
> > >> > > As suggested by Hui,
> > >> > > I have come up with more detailed
> and
> > granular
> > >> test case
> > >> > > for the patch which I had submitted
> last
> > week.
> > >>
> > >> Could you please consider migrating that test
> into
> > the
> > >> testsuite?
> > >> You've gone through the trouble of writing
> tests
> > to make
> > >> sure
> > >> the features work now --- putting it in the
> > testsuite means
> > >> we
> > >> have an automatic-ish means to check that it
> > doesn't get
> > >> inadvertently broken in the future. The way
> it
> > is,
> > >> when your
> > >> code gets in, the test will probably end up
> lost
> > in the
> > >> archives.
> > >> We wouldn't want that, would we? :-)
> Having
> > >> auto-tests, also helps
> > >> the person doing the review in confirming
> things
> > work as
> > >> expected (without much effort).
> > >>
> > >> --
> > >> Pedro Alves
> > >>
> > >
> > >
> > >
> > >
> >
>
>
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-01 16:02 paawan oza
@ 2009-07-01 16:14 ` Mark Kettenis
0 siblings, 0 replies; 40+ messages in thread
From: Mark Kettenis @ 2009-07-01 16:14 UTC (permalink / raw)
To: paawan1982; +Cc: pedro, msnyder, teawater, gdb-patches
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 5112 bytes --]
> Date: Wed, 1 Jul 2009 09:02:17 -0700 (PDT)
> From: paawan oza <paawan1982@yahoo.com>
>
> Can somebody please help with this open point ?
Sorry, I don't understand what point.
> --- On Wed, 7/1/09, paawan oza <paawan1982@yahoo.com> wrote:
>
> > From: paawan oza <paawan1982@yahoo.com>
> > Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> > To: "Pedro Alves" <pedro@codesourcery.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "Michael Snyder" <msnyder@vmware.com>, "Hui Zhu" <teawater@gmail.com>
> > Cc: gdb-patches@sourceware.org
> > Date: Wednesday, July 1, 2009, 9:30 PM
> > Hi Hui,
> >
> > As I clarified earlier,
> > these registers are already supported and extended by gdb
> > much before this patch.
> > all floating point registers are already supported by gdb
> > (info floats/info all-registers command gives it)
> >
> > My aim is : only to make sure that whenever any floating
> > point insn gets executed, we record the registers
> > (no matter whether it is %st(n) or FCTRL or FTAG or
> > FSTATUS)
> > there are insns
> > e.g. 'ffree' changes FTAG register, so we must record it.
> >
> > Do you mean to say that we should remove it from just
> > enumaration ?
> > but anyway we need to record those registers.
> >
> > Regards,
> > Oza.
> >
> > --- On Wed, 7/1/09, Hui Zhu <teawater@gmail.com>
> > wrote:
> >
> > > From: Hui Zhu <teawater@gmail.com>
> > > Subject: Re: i386.record.floating.point.patch : with
> > more testing and assurity
> > > To: "paawan oza" <paawan1982@yahoo.com>,
> > "Pedro Alves" <pedro@codesourcery.com>,
> > "Mark Kettenis" <mark.kettenis@xs4all.nl>,
> > "Michael Snyder" <msnyder@vmware.com>
> > > Cc: gdb-patches@sourceware.org
> > > Date: Wednesday, July 1, 2009, 11:23 AM
> > > About this patch, I say my idea
> > > again, I told in
> > > http://sourceware.org/ml/gdb-patches/2009-06/msg00014.html
> > > @@ -145,7 +145,22 @@
> > > I386_ES_REGNUM,
> > > /* %es */
> > > I386_FS_REGNUM,
> > > /* %fs */
> > > I386_GS_REGNUM,
> > > /* %gs */
> > > - I386_ST0_REGNUM
> > > /* %st(0) */
> > > + I386_ST0_REGNUM,
> > > /* %st(0) */
> > > + I386_ST1_REGNUM,
> > > /* %st(1) */
> > > + I386_ST2_REGNUM,
> > > /* %st(2) */
> > > + I386_ST3_REGNUM,
> > > /* %st(3) */
> > > + I386_ST4_REGNUM,
> > > /* %st(4) */
> > > + I386_ST5_REGNUM,
> > > /* %st(5) */
> > > + I386_ST6_REGNUM,
> > > /* %st(6) */
> > > + I386_ST7_REGNUM,
> > > /* %st(7) */
> > > + I386_FCTRL,
> > > /* floating point env regs : FCTRL-FOP
> > > */
> > > + I386_FSTAT,
> > > + I386_FTAG,
> > >
> > > + I386_FISEG,
> > > + I386_FIOFF,
> > > + I386_FOSEG,
> > > + I386_FOOFF,
> > > + I386_FOP
> > > };
> > >
> > > You are working on make prec x86 support fp insn, not
> > to
> > > extend the fp
> > > function of i386 (If you want, you can make a special
> > patch
> > > for it).
> > >
> > > Hui
> > >
> > > On Tue, Jun 30, 2009 at 23:05, paawan oza<paawan1982@yahoo.com>
> > > wrote:
> > > >
> > > > Hi,
> > > > As I am submitting the patch for the first time,
> > I am
> > > not much aware of gdb test suite.
> > > > would you please guide me about how I can put
> > the
> > > things in the testsuite ?
> > > > is it the testsuite which comes along with the
> > gdb
> > > source ?
> > > > gdb\testsuite\gdb.base ??
> > > > Regards,
> > > > Oza.
> > > >
> > > > --- On Tue, 6/30/09, Pedro Alves <pedro@codesourcery.com>
> > > wrote:
> > > >
> > > >> From: Pedro Alves <pedro@codesourcery.com>
> > > >> Subject: Re: i386.record.floating.point.patch
> > :
> > > with more testing and assurity
> > > >> To: gdb-patches@sourceware.org
> > > >> Cc: "paawan oza" <paawan1982@yahoo.com>,
> > > teawater@gmail.com
> > > >> Date: Tuesday, June 30, 2009, 7:09 PM
> > > >> On Tuesday 30 June 2009 14:23:30,
> > > >> paawan oza wrote:
> > > >> >
> > > >> > > As suggested by Hui,
> > > >> > > I have come up with more detailed
> > and
> > > granular
> > > >> test case
> > > >> > > for the patch which I had submitted
> > last
> > > week.
> > > >>
> > > >> Could you please consider migrating that test
> > into
> > > the
> > > >> testsuite?
> > > >> You've gone through the trouble of writing
> > tests
> > > to make
> > > >> sure
> > > >> the features work now --- putting it in the
> > > testsuite means
> > > >> we
> > > >> have an automatic-ish means to check that it
> > > doesn't get
> > > >> inadvertently broken in the future. The way
> > it
> > > is,
> > > >> when your
> > > >> code gets in, the test will probably end up
> > lost
> > > in the
> > > >> archives.
> > > >> We wouldn't want that, would we? :-)
> > Having
> > > >> auto-tests, also helps
> > > >> the person doing the review in confirming
> > things
> > > work as
> > > >> expected (without much effort).
> > > >>
> > > >> --
> > > >> Pedro Alves
> > > >>
> > > >
> > > >
> > > >
> > > >
> > >
> >
> >
> >
> >
>
>
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-07-01 16:01 paawan oza
0 siblings, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-07-01 16:01 UTC (permalink / raw)
To: Pedro Alves, Mark Kettenis, Michael Snyder, Hui Zhu; +Cc: gdb-patches
Hi Hui,
As I clarified earlier,
these registers are already supported and extended by gdb much before this patch.
all floating point registers are already supported by gdb
(info floats/info all-registers command gives it)
My aim is : only to make sure that whenever any floating point insn gets executed, we record the registers
(no matter whether it is %st(n) or FCTRL or FTAG or FSTATUS)
there are insns
e.g. 'ffree' changes FTAG register, so we must record it.
Do you mean to say that we should remove it from just enumaration ?
but anyway we need to record those registers.
Regards,
Oza.
--- On Wed, 7/1/09, Hui Zhu <teawater@gmail.com> wrote:
> From: Hui Zhu <teawater@gmail.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: "paawan oza" <paawan1982@yahoo.com>, "Pedro Alves" <pedro@codesourcery.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "Michael Snyder" <msnyder@vmware.com>
> Cc: gdb-patches@sourceware.org
> Date: Wednesday, July 1, 2009, 11:23 AM
> About this patch, I say my idea
> again, I told in
> http://sourceware.org/ml/gdb-patches/2009-06/msg00014.html
> @@ -145,7 +145,22 @@
> I386_ES_REGNUM,
> /* %es */
> I386_FS_REGNUM,
> /* %fs */
> I386_GS_REGNUM,
> /* %gs */
> - I386_ST0_REGNUM
> /* %st(0) */
> + I386_ST0_REGNUM,
> /* %st(0) */
> + I386_ST1_REGNUM,
> /* %st(1) */
> + I386_ST2_REGNUM,
> /* %st(2) */
> + I386_ST3_REGNUM,
> /* %st(3) */
> + I386_ST4_REGNUM,
> /* %st(4) */
> + I386_ST5_REGNUM,
> /* %st(5) */
> + I386_ST6_REGNUM,
> /* %st(6) */
> + I386_ST7_REGNUM,
> /* %st(7) */
> + I386_FCTRL,
> /* floating point env regs : FCTRL-FOP
> */
> + I386_FSTAT,
> + I386_FTAG,
>
> + I386_FISEG,
> + I386_FIOFF,
> + I386_FOSEG,
> + I386_FOOFF,
> + I386_FOP
> };
>
> You are working on make prec x86 support fp insn, not to
> extend the fp
> function of i386 (If you want, you can make a special patch
> for it).
>
> Hui
>
> On Tue, Jun 30, 2009 at 23:05, paawan oza<paawan1982@yahoo.com>
> wrote:
> >
> > Hi,
> > As I am submitting the patch for the first time, I am
> not much aware of gdb test suite.
> > would you please guide me about how I can put the
> things in the testsuite ?
> > is it the testsuite which comes along with the gdb
> source ?
> > gdb\testsuite\gdb.base ??
> > Regards,
> > Oza.
> >
> > --- On Tue, 6/30/09, Pedro Alves <pedro@codesourcery.com>
> wrote:
> >
> >> From: Pedro Alves <pedro@codesourcery.com>
> >> Subject: Re: i386.record.floating.point.patch :
> with more testing and assurity
> >> To: gdb-patches@sourceware.org
> >> Cc: "paawan oza" <paawan1982@yahoo.com>,
> teawater@gmail.com
> >> Date: Tuesday, June 30, 2009, 7:09 PM
> >> On Tuesday 30 June 2009 14:23:30,
> >> paawan oza wrote:
> >> >
> >> > > As suggested by Hui,
> >> > > I have come up with more detailed and
> granular
> >> test case
> >> > > for the patch which I had submitted last
> week.
> >>
> >> Could you please consider migrating that test into
> the
> >> testsuite?
> >> You've gone through the trouble of writing tests
> to make
> >> sure
> >> the features work now --- putting it in the
> testsuite means
> >> we
> >> have an automatic-ish means to check that it
> doesn't get
> >> inadvertently broken in the future. The way it
> is,
> >> when your
> >> code gets in, the test will probably end up lost
> in the
> >> archives.
> >> We wouldn't want that, would we? :-) Having
> >> auto-tests, also helps
> >> the person doing the review in confirming things
> work as
> >> expected (without much effort).
> >>
> >> --
> >> Pedro Alves
> >>
> >
> >
> >
> >
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-07-01 15:59 paawan oza
2009-07-02 2:02 ` Hui Zhu
0 siblings, 1 reply; 40+ messages in thread
From: paawan oza @ 2009-07-01 15:59 UTC (permalink / raw)
To: Pedro Alves, Mark Kettenis, Michael Snyder, Hui Zhu; +Cc: gdb-patches
Hi Hui,
As I clarified earlier,
these registers are already supported and extended by gdb much before this patch.
all floating point registers are already supported by gdb
(info floats/info all-registers command gives it)
My aim is : only to make sure that whenever any floating point insn gets executed, we record the registers
(no matter whether it is %st(n) or FCTRL or FTAG or FSTATUS)
there are insns
e.g. 'ffree' changes FTAG register, so we must record it.
Do you mean to say that we should remove it from just enumaration ?
but anyway we need to record those registers.
Regards,
Oza.
--- On Wed, 7/1/09, Hui Zhu <teawater@gmail.com> wrote:
> From: Hui Zhu <teawater@gmail.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: "paawan oza" <paawan1982@yahoo.com>, "Pedro Alves" <pedro@codesourcery.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "Michael Snyder" <msnyder@vmware.com>
> Cc: gdb-patches@sourceware.org
> Date: Wednesday, July 1, 2009, 11:23 AM
> About this patch, I say my idea
> again, I told in
> http://sourceware.org/ml/gdb-patches/2009-06/msg00014.html
> @@ -145,7 +145,22 @@
> I386_ES_REGNUM,
> /* %es */
> I386_FS_REGNUM,
> /* %fs */
> I386_GS_REGNUM,
> /* %gs */
> - I386_ST0_REGNUM
> /* %st(0) */
> + I386_ST0_REGNUM,
> /* %st(0) */
> + I386_ST1_REGNUM,
> /* %st(1) */
> + I386_ST2_REGNUM,
> /* %st(2) */
> + I386_ST3_REGNUM,
> /* %st(3) */
> + I386_ST4_REGNUM,
> /* %st(4) */
> + I386_ST5_REGNUM,
> /* %st(5) */
> + I386_ST6_REGNUM,
> /* %st(6) */
> + I386_ST7_REGNUM,
> /* %st(7) */
> + I386_FCTRL,
> /* floating point env regs : FCTRL-FOP
> */
> + I386_FSTAT,
> + I386_FTAG,
>
> + I386_FISEG,
> + I386_FIOFF,
> + I386_FOSEG,
> + I386_FOOFF,
> + I386_FOP
> };
>
> You are working on make prec x86 support fp insn, not to
> extend the fp
> function of i386 (If you want, you can make a special patch
> for it).
>
> Hui
>
> On Tue, Jun 30, 2009 at 23:05, paawan oza<paawan1982@yahoo.com>
> wrote:
> >
> > Hi,
> > As I am submitting the patch for the first time, I am
> not much aware of gdb test suite.
> > would you please guide me about how I can put the
> things in the testsuite ?
> > is it the testsuite which comes along with the gdb
> source ?
> > gdb\testsuite\gdb.base ??
> > Regards,
> > Oza.
> >
> > --- On Tue, 6/30/09, Pedro Alves <pedro@codesourcery.com>
> wrote:
> >
> >> From: Pedro Alves <pedro@codesourcery.com>
> >> Subject: Re: i386.record.floating.point.patch :
> with more testing and assurity
> >> To: gdb-patches@sourceware.org
> >> Cc: "paawan oza" <paawan1982@yahoo.com>,
> teawater@gmail.com
> >> Date: Tuesday, June 30, 2009, 7:09 PM
> >> On Tuesday 30 June 2009 14:23:30,
> >> paawan oza wrote:
> >> >
> >> > > As suggested by Hui,
> >> > > I have come up with more detailed and
> granular
> >> test case
> >> > > for the patch which I had submitted last
> week.
> >>
> >> Could you please consider migrating that test into
> the
> >> testsuite?
> >> You've gone through the trouble of writing tests
> to make
> >> sure
> >> the features work now --- putting it in the
> testsuite means
> >> we
> >> have an automatic-ish means to check that it
> doesn't get
> >> inadvertently broken in the future. The way it
> is,
> >> when your
> >> code gets in, the test will probably end up lost
> in the
> >> archives.
> >> We wouldn't want that, would we? :-) Having
> >> auto-tests, also helps
> >> the person doing the review in confirming things
> work as
> >> expected (without much effort).
> >>
> >> --
> >> Pedro Alves
> >>
> >
> >
> >
> >
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-01 15:59 paawan oza
@ 2009-07-02 2:02 ` Hui Zhu
0 siblings, 0 replies; 40+ messages in thread
From: Hui Zhu @ 2009-07-02 2:02 UTC (permalink / raw)
To: paawan oza; +Cc: Pedro Alves, Mark Kettenis, Michael Snyder, gdb-patches
On Wed, Jul 1, 2009 at 23:59, paawan oza<paawan1982@yahoo.com> wrote:
>
> Hi Hui,
>
> As I clarified earlier,
> these registers are already supported and extended by gdb much before this patch.
> all floating point registers are already supported by gdb
> (info floats/info all-registers command gives it)
>
> My aim is : only to make sure that whenever any floating point insn gets executed, we record the registers
> (no matter whether it is %st(n) or FCTRL or FTAG or FSTATUS)
> there are insns
> e.g. 'ffree' changes FTAG register, so we must record it.
>
> Do you mean to say that we should remove it from just enumaration ?
> but anyway we need to record those registers.
>
You are working on make prec x86 support fp insn, not to extend the fp
function of i386 (If you want, you can make a special patch for it).
>
> --- On Wed, 7/1/09, Hui Zhu <teawater@gmail.com> wrote:
>
>> From: Hui Zhu <teawater@gmail.com>
>> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
>> To: "paawan oza" <paawan1982@yahoo.com>, "Pedro Alves" <pedro@codesourcery.com>, "Mark Kettenis" <mark.kettenis@xs4all.nl>, "Michael Snyder" <msnyder@vmware.com>
>> Cc: gdb-patches@sourceware.org
>> Date: Wednesday, July 1, 2009, 11:23 AM
>> About this patch, I say my idea
>> again, I told in
>> http://sourceware.org/ml/gdb-patches/2009-06/msg00014.html
>> @@ -145,7 +145,22 @@
>> I386_ES_REGNUM,
>> /* %es */
>> I386_FS_REGNUM,
>> /* %fs */
>> I386_GS_REGNUM,
>> /* %gs */
>> - I386_ST0_REGNUM
>> /* %st(0) */
>> + I386_ST0_REGNUM,
>> /* %st(0) */
>> + I386_ST1_REGNUM,
>> /* %st(1) */
>> + I386_ST2_REGNUM,
>> /* %st(2) */
>> + I386_ST3_REGNUM,
>> /* %st(3) */
>> + I386_ST4_REGNUM,
>> /* %st(4) */
>> + I386_ST5_REGNUM,
>> /* %st(5) */
>> + I386_ST6_REGNUM,
>> /* %st(6) */
>> + I386_ST7_REGNUM,
>> /* %st(7) */
>> + I386_FCTRL,
>> /* floating point env regs : FCTRL-FOP
>> */
>> + I386_FSTAT,
>> + I386_FTAG,
>>
>> + I386_FISEG,
>> + I386_FIOFF,
>> + I386_FOSEG,
>> + I386_FOOFF,
>> + I386_FOP
>> };
>>
>> You are working on make prec x86 support fp insn, not to
>> extend the fp
>> function of i386 (If you want, you can make a special patch
>> for it).
>>
>> Hui
>>
>> On Tue, Jun 30, 2009 at 23:05, paawan oza<paawan1982@yahoo.com>
>> wrote:
>> >
>> > Hi,
>> > As I am submitting the patch for the first time, I am
>> not much aware of gdb test suite.
>> > would you please guide me about how I can put the
>> things in the testsuite ?
>> > is it the testsuite which comes along with the gdb
>> source ?
>> > gdb\testsuite\gdb.base ??
>> > Regards,
>> > Oza.
>> >
>> > --- On Tue, 6/30/09, Pedro Alves <pedro@codesourcery.com>
>> wrote:
>> >
>> >> From: Pedro Alves <pedro@codesourcery.com>
>> >> Subject: Re: i386.record.floating.point.patch :
>> with more testing and assurity
>> >> To: gdb-patches@sourceware.org
>> >> Cc: "paawan oza" <paawan1982@yahoo.com>,
>> teawater@gmail.com
>> >> Date: Tuesday, June 30, 2009, 7:09 PM
>> >> On Tuesday 30 June 2009 14:23:30,
>> >> paawan oza wrote:
>> >> >
>> >> > > As suggested by Hui,
>> >> > > I have come up with more detailed and
>> granular
>> >> test case
>> >> > > for the patch which I had submitted last
>> week.
>> >>
>> >> Could you please consider migrating that test into
>> the
>> >> testsuite?
>> >> You've gone through the trouble of writing tests
>> to make
>> >> sure
>> >> the features work now --- putting it in the
>> testsuite means
>> >> we
>> >> have an automatic-ish means to check that it
>> doesn't get
>> >> inadvertently broken in the future. The way it
>> is,
>> >> when your
>> >> code gets in, the test will probably end up lost
>> in the
>> >> archives.
>> >> We wouldn't want that, would we? :-) Having
>> >> auto-tests, also helps
>> >> the person doing the review in confirming things
>> work as
>> >> expected (without much effort).
>> >>
>> >> --
>> >> Pedro Alves
>> >>
>> >
>> >
>> >
>> >
>>
>
>
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
@ 2009-06-30 15:05 paawan oza
2009-07-01 5:53 ` Hui Zhu
2009-07-12 11:12 ` Michael Snyder
0 siblings, 2 replies; 40+ messages in thread
From: paawan oza @ 2009-06-30 15:05 UTC (permalink / raw)
To: gdb-patches, Pedro Alves; +Cc: teawater
Hi,
As I am submitting the patch for the first time, I am not much aware of gdb test suite.
would you please guide me about how I can put the things in the testsuite ?
is it the testsuite which comes along with the gdb source ?
gdb\testsuite\gdb.base ??
Regards,
Oza.
--- On Tue, 6/30/09, Pedro Alves <pedro@codesourcery.com> wrote:
> From: Pedro Alves <pedro@codesourcery.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: gdb-patches@sourceware.org
> Cc: "paawan oza" <paawan1982@yahoo.com>, teawater@gmail.com
> Date: Tuesday, June 30, 2009, 7:09 PM
> On Tuesday 30 June 2009 14:23:30,
> paawan oza wrote:
> >
> > > As suggested by Hui,
> > > I have come up with more detailed and granular
> test case
> > > for the patch which I had submitted last week.
>
> Could you please consider migrating that test into the
> testsuite?
> You've gone through the trouble of writing tests to make
> sure
> the features work now --- putting it in the testsuite means
> we
> have an automatic-ish means to check that it doesn't get
> inadvertently broken in the future. The way it is,
> when your
> code gets in, the test will probably end up lost in the
> archives.
> We wouldn't want that, would we? :-) Having
> auto-tests, also helps
> the person doing the review in confirming things work as
> expected (without much effort).
>
> --
> Pedro Alves
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
2009-06-30 15:05 paawan oza
@ 2009-07-01 5:53 ` Hui Zhu
2009-07-12 11:12 ` Michael Snyder
1 sibling, 0 replies; 40+ messages in thread
From: Hui Zhu @ 2009-07-01 5:53 UTC (permalink / raw)
To: paawan oza, Pedro Alves, Mark Kettenis, Michael Snyder; +Cc: gdb-patches
About this patch, I say my idea again, I told in
http://sourceware.org/ml/gdb-patches/2009-06/msg00014.html
@@ -145,7 +145,22 @@
I386_ES_REGNUM, /* %es */
I386_FS_REGNUM, /* %fs */
I386_GS_REGNUM, /* %gs */
- I386_ST0_REGNUM /* %st(0) */
+ I386_ST0_REGNUM, /* %st(0) */
+ I386_ST1_REGNUM, /* %st(1) */
+ I386_ST2_REGNUM, /* %st(2) */
+ I386_ST3_REGNUM, /* %st(3) */
+ I386_ST4_REGNUM, /* %st(4) */
+ I386_ST5_REGNUM, /* %st(5) */
+ I386_ST6_REGNUM, /* %st(6) */
+ I386_ST7_REGNUM, /* %st(7) */
+ I386_FCTRL, /* floating point env regs : FCTRL-FOP */
+ I386_FSTAT,
+ I386_FTAG,
+ I386_FISEG,
+ I386_FIOFF,
+ I386_FOSEG,
+ I386_FOOFF,
+ I386_FOP
};
You are working on make prec x86 support fp insn, not to extend the fp
function of i386 (If you want, you can make a special patch for it).
Hui
On Tue, Jun 30, 2009 at 23:05, paawan oza<paawan1982@yahoo.com> wrote:
>
> Hi,
> As I am submitting the patch for the first time, I am not much aware of gdb test suite.
> would you please guide me about how I can put the things in the testsuite ?
> is it the testsuite which comes along with the gdb source ?
> gdb\testsuite\gdb.base ??
> Regards,
> Oza.
>
> --- On Tue, 6/30/09, Pedro Alves <pedro@codesourcery.com> wrote:
>
>> From: Pedro Alves <pedro@codesourcery.com>
>> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
>> To: gdb-patches@sourceware.org
>> Cc: "paawan oza" <paawan1982@yahoo.com>, teawater@gmail.com
>> Date: Tuesday, June 30, 2009, 7:09 PM
>> On Tuesday 30 June 2009 14:23:30,
>> paawan oza wrote:
>> >
>> > > As suggested by Hui,
>> > > I have come up with more detailed and granular
>> test case
>> > > for the patch which I had submitted last week.
>>
>> Could you please consider migrating that test into the
>> testsuite?
>> You've gone through the trouble of writing tests to make
>> sure
>> the features work now --- putting it in the testsuite means
>> we
>> have an automatic-ish means to check that it doesn't get
>> inadvertently broken in the future. The way it is,
>> when your
>> code gets in, the test will probably end up lost in the
>> archives.
>> We wouldn't want that, would we? :-) Having
>> auto-tests, also helps
>> the person doing the review in confirming things work as
>> expected (without much effort).
>>
>> --
>> Pedro Alves
>>
>
>
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
2009-06-30 15:05 paawan oza
2009-07-01 5:53 ` Hui Zhu
@ 2009-07-12 11:12 ` Michael Snyder
2009-07-12 17:47 ` paawan oza
1 sibling, 1 reply; 40+ messages in thread
From: Michael Snyder @ 2009-07-12 11:12 UTC (permalink / raw)
To: paawan oza; +Cc: gdb-patches, Pedro Alves, teawater
paawan oza wrote:
> Hi,
> As I am submitting the patch for the first time, I am not much aware of gdb test suite.
> would you please guide me about how I can put the things in the testsuite ?
> is it the testsuite which comes along with the gdb source ?
> gdb\testsuite\gdb.base ??
> Regards,
> Oza.
Hi Oza,
Yes, we are talking about the automated regression testsuite that
comes with the gdb source tree, at src/gdb/testsuite. You'll need
to be familiar with it, both to use it and to write tests.
All tests for the GNU tools are written in (are you ready for this)
* dejagnu, which is a layer written on top of
* expect, which is a language written on top of
* tcl.
There are many many tests already in the testsuite. Each consists of
1) one 'expect' script, such as
src/gdb/testsuite/gdb.base/break-always.exp
2) one or more source files, such as
src/gdb/testsuite/gdb.base/break-always.c
I chose that one as a relatively simple example for you to look at.
Each script
* compiles the corresponding source file,
* starts gdb, and
* runs a set of gdb commands.
The output of the commands is automatically compared to a set
of expected outputs (hence the name 'expect'), and if the output
matches the expected output the script will output "PASS".
Otherwise it will output "FAIL".
We use these test scripts regularly, both to validate new patches,
and to make sure that new changes haven't broken any old changes.
To run the gdb tests, you need to have installed
* dejagnu version 1.4.4
* expect version 5.42.1
* tcl at least version 8.4
With those installed, you should be able to do the following
in your build tree, with these results: then we'll talk about
writing tests. ;-)
bash-3.00$ cd gdb/testsuite
bash-3.00$ make check RUNTESTFLAGS=break-always.exp
[some noise]
=== gdb tests ===
Schedule of variations:
unix
Running target unix
Using /usr/share/dejagnu/baseboards/unix.exp as board description file
for target.
Using /usr/share/dejagnu/config/unix.exp as generic interface file for
target.
Using /data/home/msnyder/cvs/localhost/oza/gdb/testsuite/config/unix.exp
as tool-and-target-specific interface file.
Running
/data/home/msnyder/cvs/localhost/oza/gdb/testsuite/gdb.base/break-always.exp
...
=== gdb Summary ===
# of expected passes 4
/data/home/msnyder/builds/native/oza/gdb/testsuite/../../gdb/gdb version
6.8.50.20090711-cvs -nw -nx
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-12 11:12 ` Michael Snyder
@ 2009-07-12 17:47 ` paawan oza
2009-07-13 0:38 ` Michael Snyder
0 siblings, 1 reply; 40+ messages in thread
From: paawan oza @ 2009-07-12 17:47 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches, Pedro Alves, teawater
Hi,
Thank you very much for your elaborated reply.
I will integrate the test example with test suite by next week-end.
And, also take of all yours and Hui's formatting comments.
I will come up with the final up to date patch with integrated test-suite.
Thank you again for your response. : )
I start working towards it.
Regards,
Oza.
--- On Sun, 7/12/09, Michael Snyder <msnyder@vmware.com> wrote:
> From: Michael Snyder <msnyder@vmware.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: "paawan oza" <paawan1982@yahoo.com>
> Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, "Pedro Alves" <pedro@codesourcery.com>, "teawater@gmail.com" <teawater@gmail.com>
> Date: Sunday, July 12, 2009, 4:55 AM
> paawan oza wrote:
> > Hi,
> > As I am submitting the patch for the first time, I am
> not much aware of gdb test suite.
> > would you please guide me about how I can put the
> things in the testsuite ?
> > is it the testsuite which comes along with the gdb
> source ?
> > gdb\testsuite\gdb.base ??
> > Regards,
> > Oza.
>
> Hi Oza,
>
> Yes, we are talking about the automated regression
> testsuite that
> comes with the gdb source tree, at src/gdb/testsuite.
> You'll need
> to be familiar with it, both to use it and to write tests.
>
> All tests for the GNU tools are written in (are you ready
> for this)
> * dejagnu, which is a layer written on top of
> * expect, which is a language written on top of
> * tcl.
>
> There are many many tests already in the testsuite.
> Each consists of
> 1) one 'expect' script, such as
>
> src/gdb/testsuite/gdb.base/break-always.exp
> 2) one or more source files, such as
>
> src/gdb/testsuite/gdb.base/break-always.c
>
> I chose that one as a relatively simple example for you to
> look at.
>
> Each script
> * compiles the corresponding source file,
> * starts gdb, and
> * runs a set of gdb commands.
>
> The output of the commands is automatically compared to a
> set
> of expected outputs (hence the name 'expect'), and if the
> output
> matches the expected output the script will output "PASS".
> Otherwise it will output "FAIL".
>
> We use these test scripts regularly, both to validate new
> patches,
> and to make sure that new changes haven't broken any old
> changes.
>
> To run the gdb tests, you need to have installed
> * dejagnu version 1.4.4
> * expect version 5.42.1
> * tcl at least version 8.4
>
> With those installed, you should be able to do the
> following
> in your build tree, with these results: then we'll talk
> about
> writing tests. ;-)
>
> bash-3.00$ cd gdb/testsuite
> bash-3.00$ make check RUNTESTFLAGS=break-always.exp
> [some noise]
>
> ===
> gdb tests ===
>
> Schedule of variations:
> unix
>
> Running target unix
> Using /usr/share/dejagnu/baseboards/unix.exp as board
> description file for target.
> Using /usr/share/dejagnu/config/unix.exp as generic
> interface file for target.
> Using
> /data/home/msnyder/cvs/localhost/oza/gdb/testsuite/config/unix.exp
> as tool-and-target-specific interface file.
> Running
> /data/home/msnyder/cvs/localhost/oza/gdb/testsuite/gdb.base/break-always.exp
> ...
>
> ===
> gdb Summary ===
>
> # of expected passes
> 4
> /data/home/msnyder/builds/native/oza/gdb/testsuite/../../gdb/gdb
> version 6.8.50.20090711-cvs -nw -nx
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-12 17:47 ` paawan oza
@ 2009-07-13 0:38 ` Michael Snyder
2009-07-13 17:03 ` Hui Zhu
0 siblings, 1 reply; 40+ messages in thread
From: Michael Snyder @ 2009-07-13 0:38 UTC (permalink / raw)
To: paawan oza; +Cc: gdb-patches, Pedro Alves, teawater
[-- Attachment #1: Type: text/plain, Size: 1611 bytes --]
paawan oza wrote:
> Hi,
> Thank you very much for your elaborated reply.
> I will integrate the test example with test suite by next week-end.
> And, also take of all yours and Hui's formatting comments.
> I will come up with the final up to date patch with integrated test-suite.
> Thank you again for your response. : )
> I start working towards it.
> Regards,
> Oza.
Excellent. Now let's talk about what the test should test.
I don't think it is necessary to test each individual instruction
(unless you really want to). We don't usually go to that extreme.
What we want to establish is "does the patch do what it's intended
to do", so let's make a statement about what it's intended to do.
You correct me if I'm wrong, but in my impression, it can be summed
up as: preserve and restore the state of the standard Intel floating
point unit during record and replay".
So you just need to test that the FP machine state is preserved,
and that when we go backwards, the state is restored to what it
was before. I think that means mainly the '387' registers, or
the state that is displayed when we say "info float".
To help you get started, I've attached a simple gdb test that
checks to see if we can save and restore one register ('st0').
This will show you in general how it is done, and if you want
to, you can use it as a starting point, and add tests for the
rest of the registers.
The subroutines that we use, such as "gdb_test", are mostly
defined in gdb/testsuite/lib/gdb.exp, if you need to look at
them. There's some documentation in the comments, and also
in gdb/doc/gdbint.texinfo.
[-- Attachment #2: i387-float-reverse.c --]
[-- Type: text/x-csrc, Size: 958 bytes --]
/* Reverse debugging of floating point registers.
Copyright 2009, Free Software Foundation, Inc.
This file is part of GDB.
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/>. */
int main (void)
{
int i = 0; /* BEGIN I387-FLOAT-REVERSE */
asm ("fldz"); /* test st0 register */
asm ("fld1");
asm ("nop");
return i; /* END I387-FLOAT-REVERSE */
}
[-- Attachment #3: i387-float-reverse.exp --]
[-- Type: text/plain, Size: 2632 bytes --]
# 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-float-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 st0 register
set location [gdb_get_line_number "test st0 register"]
gdb_test "until $location" ".*/$srcfile:$location.*asm.*fldz.*" \
"begin test st0"
gdb_test "stepi" "asm.*fld1.*" "set st0 == 0"
gdb_test "info register st0" "st0 *0\t.*" "verify st0 == 0"
gdb_test "stepi" "asm.*nop.*" "set st0 == 1"
gdb_test "info register st0" "st0 *1\t.*" "verify st0 == 1"
# Now step backward, and check that st0 value reverts to zero.
gdb_test "reverse-stepi" "asm.*fld1.*" "undo set st0 == 1"
gdb_test "info register st0" "st0 *0\t.*" "verify st0 == 0 again"
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-13 0:38 ` Michael Snyder
@ 2009-07-13 17:03 ` Hui Zhu
2009-07-13 20:16 ` Michael Snyder
0 siblings, 1 reply; 40+ messages in thread
From: Hui Zhu @ 2009-07-13 17:03 UTC (permalink / raw)
To: Michael Snyder; +Cc: paawan oza, gdb-patches, Pedro Alves
Could you post it in patch format? That will make me can try it directly. :)
Thanks,
Hui
On Mon, Jul 13, 2009 at 02:05, Michael Snyder<msnyder@vmware.com> wrote:
> paawan oza wrote:
>>
>> Hi, Thank you very much for your elaborated reply.
>> I will integrate the test example with test suite by next week-end.
>> And, also take of all yours and Hui's formatting comments.
>> I will come up with the final up to date patch with integrated test-suite.
>> Thank you again for your response. : )
>> I start working towards it.
>> Regards,
>> Oza.
>
> Excellent. Now let's talk about what the test should test.
>
> I don't think it is necessary to test each individual instruction
> (unless you really want to). We don't usually go to that extreme.
>
> What we want to establish is "does the patch do what it's intended
> to do", so let's make a statement about what it's intended to do.
> You correct me if I'm wrong, but in my impression, it can be summed
> up as: preserve and restore the state of the standard Intel floating
> point unit during record and replay".
>
> So you just need to test that the FP machine state is preserved,
> and that when we go backwards, the state is restored to what it
> was before. I think that means mainly the '387' registers, or
> the state that is displayed when we say "info float".
>
> To help you get started, I've attached a simple gdb test that
> checks to see if we can save and restore one register ('st0').
> This will show you in general how it is done, and if you want
> to, you can use it as a starting point, and add tests for the
> rest of the registers.
>
> The subroutines that we use, such as "gdb_test", are mostly
> defined in gdb/testsuite/lib/gdb.exp, if you need to look at
> them. There's some documentation in the comments, and also
> in gdb/doc/gdbint.texinfo.
>
>
>
>
>
>
>
>
> # 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-float-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 st0 register
>
> set location [gdb_get_line_number "test st0 register"]
> gdb_test "until $location" ".*/$srcfile:$location.*asm.*fldz.*" \
> "begin test st0"
> gdb_test "stepi" "asm.*fld1.*" "set st0 == 0"
> gdb_test "info register st0" "st0 *0\t.*" "verify st0 == 0"
> gdb_test "stepi" "asm.*nop.*" "set st0 == 1"
> gdb_test "info register st0" "st0 *1\t.*" "verify st0 == 1"
>
> # Now step backward, and check that st0 value reverts to zero.
>
> gdb_test "reverse-stepi" "asm.*fld1.*" "undo set st0 == 1"
> gdb_test "info register st0" "st0 *0\t.*" "verify st0 == 0 again"
>
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-13 17:03 ` Hui Zhu
@ 2009-07-13 20:16 ` Michael Snyder
2009-07-15 9:21 ` Hui Zhu
2009-07-18 23:36 ` paawan oza
0 siblings, 2 replies; 40+ messages in thread
From: Michael Snyder @ 2009-07-13 20:16 UTC (permalink / raw)
To: Hui Zhu; +Cc: paawan oza, gdb-patches, Pedro Alves
[-- Attachment #1: Type: text/plain, Size: 213 bytes --]
Hui Zhu wrote:
> Could you post it in patch format? That will make me can try it directly. :)
>
> Thanks,
> Hui
OK, but this is not intended as a submission.
It's just an example or starting point.
Michael
[-- Attachment #2: i387.txt --]
[-- Type: text/plain, Size: 4161 bytes --]
diff -rNu gdb.tmp/i387-float-reverse.c gdb.arch/i387-float-reverse.c
--- gdb.tmp/i387-float-reverse.c 1969-12-31 16:00:00.000000000 -0800
+++ gdb.arch/i387-float-reverse.c 2009-07-11 17:16:56.000000000 -0700
@@ -0,0 +1,30 @@
+/* Reverse debugging of floating point registers.
+
+ Copyright 2009, Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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/>. */
+
+int main (void)
+{
+ int i = 0; /* BEGIN I387-FLOAT-REVERSE */
+
+ asm ("fldz"); /* test st0 register */
+ asm ("fld1");
+ asm ("nop");
+
+ return i; /* END I387-FLOAT-REVERSE */
+}
+
diff -rNu gdb.tmp/i387-float-reverse.exp gdb.arch/i387-float-reverse.exp
--- gdb.tmp/i387-float-reverse.exp 1969-12-31 16:00:00.000000000 -0800
+++ gdb.arch/i387-float-reverse.exp 2009-07-11 17:30:03.000000000 -0700
@@ -0,0 +1,83 @@
+# 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-float-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 st0 register
+
+set location [gdb_get_line_number "test st0 register"]
+gdb_test "until $location" ".*/$srcfile:$location.*asm.*fldz.*" \
+ "begin test st0"
+gdb_test "stepi" "asm.*fld1.*" "set st0 == 0"
+gdb_test "info register st0" "st0 *0\t.*" "verify st0 == 0"
+gdb_test "stepi" "asm.*nop.*" "set st0 == 1"
+gdb_test "info register st0" "st0 *1\t.*" "verify st0 == 1"
+
+# Now step backward, and check that st0 value reverts to zero.
+
+gdb_test "reverse-stepi" "asm.*fld1.*" "undo set st0 == 1"
+gdb_test "info register st0" "st0 *0\t.*" "verify st0 == 0 again"
+
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-13 20:16 ` Michael Snyder
@ 2009-07-15 9:21 ` Hui Zhu
2009-07-19 3:27 ` paawan oza
2009-07-18 23:36 ` paawan oza
1 sibling, 1 reply; 40+ messages in thread
From: Hui Zhu @ 2009-07-15 9:21 UTC (permalink / raw)
To: Michael Snyder; +Cc: paawan oza, gdb-patches, Pedro Alves
I try this test with fp insn patch. Everything is OK. Thanks.
BTW, I copy them to "src/gdb/testsuite/gdb.reverse". And use command
make check RUNTESTFLAGS="i387-float-reverse.exp --target_board=precord"
in testsuite directory.
Thanks,
Hui
On Tue, Jul 14, 2009 at 03:38, Michael Snyder<msnyder@vmware.com> wrote:
> Hui Zhu wrote:
>>
>> Could you post it in patch format? That will make me can try it directly.
>> :)
>>
>> Thanks,
>> Hui
>
>
> OK, but this is not intended as a submission.
> It's just an example or starting point.
>
> Michael
>
>
> diff -rNu gdb.tmp/i387-float-reverse.c gdb.arch/i387-float-reverse.c
> --- gdb.tmp/i387-float-reverse.c 1969-12-31 16:00:00.000000000 -0800
> +++ gdb.arch/i387-float-reverse.c 2009-07-11 17:16:56.000000000 -0700
> @@ -0,0 +1,30 @@
> +/* Reverse debugging of floating point registers.
> +
> + Copyright 2009, Free Software Foundation, Inc.
> +
> + This file is part of GDB.
> +
> + 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/>.
> */
> +
> +int main (void)
> +{
> + int i = 0; /* BEGIN I387-FLOAT-REVERSE */
> +
> + asm ("fldz"); /* test st0 register */
> + asm ("fld1");
> + asm ("nop");
> +
> + return i; /* END I387-FLOAT-REVERSE */
> +}
> +
> diff -rNu gdb.tmp/i387-float-reverse.exp gdb.arch/i387-float-reverse.exp
> --- gdb.tmp/i387-float-reverse.exp 1969-12-31 16:00:00.000000000 -0800
> +++ gdb.arch/i387-float-reverse.exp 2009-07-11 17:30:03.000000000 -0700
> @@ -0,0 +1,83 @@
> +# 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-float-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 st0 register
> +
> +set location [gdb_get_line_number "test st0 register"]
> +gdb_test "until $location" ".*/$srcfile:$location.*asm.*fldz.*" \
> + "begin test st0"
> +gdb_test "stepi" "asm.*fld1.*" "set st0 == 0"
> +gdb_test "info register st0" "st0 *0\t.*" "verify st0 == 0"
> +gdb_test "stepi" "asm.*nop.*" "set st0 == 1"
> +gdb_test "info register st0" "st0 *1\t.*" "verify st0 == 1"
> +
> +# Now step backward, and check that st0 value reverts to zero.
> +
> +gdb_test "reverse-stepi" "asm.*fld1.*" "undo set st0 == 1"
> +gdb_test "info register st0" "st0 *0\t.*" "verify st0 == 0 again"
> +
>
>
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-15 9:21 ` Hui Zhu
@ 2009-07-19 3:27 ` paawan oza
0 siblings, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-07-19 3:27 UTC (permalink / raw)
To: Michael Snyder, Hui Zhu; +Cc: gdb-patches, Pedro Alves
Hi,
thank you for the update.
just to confirm....I start adding some tests regarding floatin_patch into
src/gdb/testsuite/gdb.reverse
Regards,
Oza.
--- On Wed, 7/15/09, Hui Zhu <teawater@gmail.com> wrote:
> From: Hui Zhu <teawater@gmail.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: "Michael Snyder" <msnyder@vmware.com>
> Cc: "paawan oza" <paawan1982@yahoo.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, "Pedro Alves" <pedro@codesourcery.com>
> Date: Wednesday, July 15, 2009, 1:05 PM
> I try this test with fp insn
> patch. Everything is OK. Thanks.
>
> BTW, I copy them to "src/gdb/testsuite/gdb.reverse".
> And use command
> make check RUNTESTFLAGS="i387-float-reverse.exp
> --target_board=precord"
> in testsuite directory.
>
> Thanks,
> Hui
>
> On Tue, Jul 14, 2009 at 03:38, Michael Snyder<msnyder@vmware.com>
> wrote:
> > Hui Zhu wrote:
> >>
> >> Could you post it in patch format? That will
> make me can try it directly.
> >> :)
> >>
> >> Thanks,
> >> Hui
> >
> >
> > OK, but this is not intended as a submission.
> > It's just an example or starting point.
> >
> > Michael
> >
> >
> > diff -rNu gdb.tmp/i387-float-reverse.c
> gdb.arch/i387-float-reverse.c
> > --- gdb.tmp/i387-float-reverse.c 1969-12-31
> 16:00:00.000000000 -0800
> > +++ gdb.arch/i387-float-reverse.c 2009-07-11
> 17:16:56.000000000 -0700
> > @@ -0,0 +1,30 @@
> > +/* Reverse debugging of floating point registers.
> > +
> > + Copyright 2009, Free Software Foundation, Inc.
> > +
> > + This file is part of GDB.
> > +
> > + 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/>.
> > */
> > +
> > +int main (void)
> > +{
> > + int i = 0; /* BEGIN I387-FLOAT-REVERSE */
> > +
> > + asm ("fldz"); /* test st0 register */
> > + asm ("fld1");
> > + asm ("nop");
> > +
> > + return i; /* END I387-FLOAT-REVERSE */
> > +}
> > +
> > diff -rNu gdb.tmp/i387-float-reverse.exp
> gdb.arch/i387-float-reverse.exp
> > --- gdb.tmp/i387-float-reverse.exp 1969-12-31
> 16:00:00.000000000 -0800
> > +++ gdb.arch/i387-float-reverse.exp 2009-07-11
> 17:30:03.000000000 -0700
> > @@ -0,0 +1,83 @@
> > +# 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-float-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 st0 register
> > +
> > +set location [gdb_get_line_number "test st0
> register"]
> > +gdb_test "until $location"
> ".*/$srcfile:$location.*asm.*fldz.*" \
> > + "begin test st0"
> > +gdb_test "stepi" "asm.*fld1.*" "set
> st0 == 0"
> > +gdb_test "info register st0" "st0 *0\t.*" "verify st0
> == 0"
> > +gdb_test "stepi" "asm.*nop.*" "set
> st0 == 1"
> > +gdb_test "info register st0" "st0 *1\t.*" "verify st0
> == 1"
> > +
> > +# Now step backward, and check that st0 value reverts
> to zero.
> > +
> > +gdb_test "reverse-stepi" "asm.*fld1.*" "undo set
> st0 == 1"
> > +gdb_test "info register st0" "st0 *0\t.*" "verify st0
> == 0 again"
> > +
> >
> >
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
2009-07-13 20:16 ` Michael Snyder
2009-07-15 9:21 ` Hui Zhu
@ 2009-07-18 23:36 ` paawan oza
1 sibling, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-07-18 23:36 UTC (permalink / raw)
To: Hui Zhu, Michael Snyder; +Cc: gdb-patches, Pedro Alves
Hi,
Thank you very much for your example...
I will turn test_example into gdb_testsuite and finish the things.
I am working on it.
Regards,
Oza.
--- On Tue, 7/14/09, Michael Snyder <msnyder@vmware.com> wrote:
> From: Michael Snyder <msnyder@vmware.com>
> Subject: Re: i386.record.floating.point.patch : with more testing and assurity
> To: "Hui Zhu" <teawater@gmail.com>
> Cc: "paawan oza" <paawan1982@yahoo.com>, "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>, "Pedro Alves" <pedro@codesourcery.com>
> Date: Tuesday, July 14, 2009, 1:08 AM
> Hui Zhu wrote:
> > Could you post it in patch format? That will
> make me can try it directly. :)
> >
> > Thanks,
> > Hui
>
>
> OK, but this is not intended as a submission.
> It's just an example or starting point.
>
> Michael
>
>
> -----Inline Attachment Follows-----
>
> diff -rNu
> gdb.tmp/i387-float-reverse.c gdb.arch/i387-float-reverse.c
> --- gdb.tmp/i387-float-reverse.c
> 1969-12-31 16:00:00.000000000 -0800
> +++ gdb.arch/i387-float-reverse.c
> 2009-07-11 17:16:56.000000000 -0700
> @@ -0,0 +1,30 @@
> +/* Reverse debugging of floating point registers.
> +
> + Copyright 2009, Free Software
> Foundation, Inc.
> +
> + This file is part of GDB.
> +
> + 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/>. */
> +
> +int main (void)
> +{
> + int i = 0; /* BEGIN
> I387-FLOAT-REVERSE */
> +
> + asm ("fldz"); /* test st0
> register */
> + asm ("fld1");
> + asm ("nop");
> +
> + return i; /* END
> I387-FLOAT-REVERSE */
> +}
> +
> diff -rNu gdb.tmp/i387-float-reverse.exp
> gdb.arch/i387-float-reverse.exp
> --- gdb.tmp/i387-float-reverse.exp
> 1969-12-31 16:00:00.000000000 -0800
> +++ gdb.arch/i387-float-reverse.exp
> 2009-07-11 17:30:03.000000000 -0700
> @@ -0,0 +1,83 @@
> +# 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-float-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 st0 register
> +
> +set location [gdb_get_line_number "test st0 register"]
> +gdb_test "until $location"
> ".*/$srcfile:$location.*asm.*fldz.*" \
> + "begin test st0"
> +gdb_test "stepi" "asm.*fld1.*"
> "set st0 == 0"
> +gdb_test "info register st0" "st0 *0\t.*" "verify st0 ==
> 0"
> +gdb_test "stepi" "asm.*nop.*"
> "set st0 == 1"
> +gdb_test "info register st0" "st0 *1\t.*" "verify st0 ==
> 1"
> +
> +# Now step backward, and check that st0 value reverts to
> zero.
> +
> +gdb_test "reverse-stepi" "asm.*fld1.*" "undo
> set st0 == 1"
> +gdb_test "info register st0" "st0 *0\t.*" "verify st0 == 0
> again"
> +
>
^ permalink raw reply [flat|nested] 40+ messages in thread
* i386.record.floating.point.patch : with more testing and assurity
@ 2009-06-30 13:23 paawan oza
2009-06-30 13:38 ` Pedro Alves
2009-06-30 13:42 ` Mark Kettenis
0 siblings, 2 replies; 40+ messages in thread
From: paawan oza @ 2009-06-30 13:23 UTC (permalink / raw)
To: gdb-patches; +Cc: teawater
[-- Attachment #1: Type: text/plain, Size: 26513 bytes --]
Hi,
Again I am sending the patch, with the test cases.
please do the needful
Regards,
Oza.
--- On Thu, 6/4/09, paawan oza <paawan1982@yahoo.com> wrote:
> From: paawan oza <paawan1982@yahoo.com>
> Subject: i386.record.floating.point.patch : with more testing and assurity
> To: gdb-patches@sourceware.org
> Cc: "Hui Zhu" <teawater@gmail.com>
> Date: Thursday, June 4, 2009, 8:20 PM
> Hi All,
>
> As suggested by Hui,
> I have come up with more detailed and granular test case
> for the patch which I had submitted last week.
>
> -> it does basic as well as advanced verification for
> the patch, details could be found in test_floats.c
> -> I have also tried to take coverage using gcov and the
> number is almost around 80-85% for that patch, which is nice
> to have.
> -> the patch works well with all the scenarios described
> in test_floats.c
>
> please find the patch and test_float.c attached, as well as
> part of email body also.
>
> PS : there os no change in patch, only improvement is it is
> tested throughly as much as posible.
>
> please provide your review comments.
>
> Regards,
> Oza.
>
>
> ****************************************************
> test_float.c
> ****************************************************
> #include <stdio.h>
> #include <math.h>
> #include <stdlib.h>
>
> /* the test intends to test following insns.
> flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp fsubrp
> fucomp fnstsw fsqrt
> fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1 fldl2t
> fldl2e FLDPI FLDLG2 FLDLN2
> FLDZ fincstp ffree fptan fpatan fincstp fsincos frndint
> fscale fsin fcos fcmovb
> fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor fstsw
> */
>
> float no1,no2,no3,no4,no5,no6,no7;
> double x = 100.345, y = 25.7789;
> long double ldx = 88888888888888888888.88, ldy =
> 9999999999999999999.99;
> float result,resultd,resultld;
> float *float_memory;
>
> /* 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;
> }
>
> /* 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()
> {
> result = no1 + no2 + no3 + no4 + no5 + no6 + no7;
> printf("result is %f\n",result);
>
> result = fmodf(no2,no1);
> printf("result is %f\n",result);
>
> resultd = fmod(x,y);
> printf("result is %f\n",resultd);
>
> resultld = fmodl(ldy,ldy);
> printf("result is %f\n",resultld);
>
> result = fabsf(no1);
> printf("result is %f\n",result);
>
> result = no3 / no4;
> printf("result is %f\n",result);
>
> result = no1 * no2 * no3 * no4;
> printf("result is %f\n",result);
>
> result = no1 - no2 - no3 - no4;
> printf("result is %f\n",result);
>
>
> asm ("fld %0" : :"m"(*float_memory));
> asm ("fchs");
>
> /* test for f2xm1 */
> asm ("fld %0" : :"m"(*float_memory));
> asm ("f2xm1");
>
> asm ("fyl2x");
>
> asm ("fld %0" : :"m"(*float_memory));
> asm ("fxtract");
>
> asm ("fld %0" : :"m"(*float_memory));
> asm ("fprem1");
>
> /* decrement fpu stack pointer only status register
> should get affected */
> asm ("fld %0" :
> :"m"(*float_memory));
>
> empty_fpu_stack();
>
> asm ("fld1");
> asm ("fldl2t");
> asm ("fldl2e");
> asm ("fldpi");
> asm ("fldlg2");
> asm ("fldln2");
> asm ("fldz");
>
> empty_fpu_stack();
> /* finishing emptying the stack */
>
> result = sqrt(no3);
> printf("result is %f\n",result);
> }
>
> void test_log_exp_floats()
> {
> result = log10(no3);
> printf("result is %f\n",result);
>
> result = log(no3);
> printf("result is %f\n",result);
>
> result = exp10(no3);
> printf("result is %f\n",result);
>
> result = exp(no3);
> printf("result is %f\n",result);
> }
>
> void test_trigo_floats()
> {
> result = sin(30);
> printf("result is %f\n",result);
>
> result = cos(30);
> printf("result is %f\n",result);
>
> result = tan(30);
> printf("result is %f\n",result);
>
> result = atan(30);
> printf("result is %f\n",result);
>
> asm ("fld %0" : :"m"(*float_memory));
> asm ("fptan");
>
> /* changes st1 and popping register stack */
> asm ("fpatan");
>
> asm("fincstp");
> asm ("fld %0" : :"m"(float_memory));
> asm ("fsincos");
>
> asm ("fld %0" : :"m"(*float_memory));
> asm ("frndint");
>
> asm ("fld %0" : :"m"(*float_memory));
> asm ("fld %0" : :"m"(*(float_memory+1)));
> asm ("fscale");
>
> empty_fpu_stack();
>
> asm ("fld %0" : :"m"(*float_memory));
> asm ("fsin");
> asm ("fcos");
>
> /* currently we assume condition likely and always
> record the registers
> code could be optimized only if the flag is set then
> record */
> asm ("fld %0" : :"m"(*float_memory));
> asm ("fld %0" : :"m"(*(float_memory+1)));
> asm ("fcmovb %st(1), %st");
> asm ("fcmovbe %st(1), %st");
> asm ("fcmove %st(1), %st");
> asm ("fcmovu %st(1), %st");
> asm ("fcmovnb %st(1), %st");
> asm ("fcmovnbe %st(1), %st");
>
> empty_fpu_stack();
> /* finished emtyping the stack */
> }
>
> void test_compare_floats()
> {
> ldy = 88888888888888888888.88;
> if (ldx == ldy)
> ldy =
> 7777777777777777777777777777.777;
> else
> ldy =
> 666666666666666666666666666.666;
> }
>
> /* test loading and saving of FPU environment */
> void test_fpu_env()
> {
> asm ("fsave %0" : "=m"(*float_memory) : );
> asm ("frstor %0" : : "m"(*float_memory));
> asm ("fstsw %ax");
> }
>
> int main()
> {
> init_floats();
> test_arith_floats();
> test_log_exp_floats();
> test_trigo_floats();
> test_compare_floats();
> test_fpu_env();
> }
>
> ******************************************************
> i386-record-floats.patch
> ******************************************************
>
> diff -urN gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
> --- gdb.orig/i386-tdep.c 2009-05-29
> 17:08:40.000000000 -0400
> +++ gdb.new/i386-tdep.c 2009-06-01
> 20:02:23.000000000 -0400
> @@ -543,6 +543,9 @@
> /* The maximum number of saved registers. This
> should include all
> registers mentioned above, and %eip.
> */
> #define I386_NUM_SAVED_REGS
> I386_NUM_GREGS
> +#define I386_SAVE_FPU_REGS
> 0xFFFD
> +#define I386_SAVE_FPU_ENV
> 0xFFFE
> +#define I386_SAVE_FPU_ENV_REG_STACK
> 0xFFFF
>
> struct i386_frame_cache
> {
> @@ -2985,6 +2988,54 @@
> return 0;
> }
>
> +/* Record the value of floating point registers which will
> be changed by the current instruction
> + to "record_arch_list".
> + return -1 if something is wrong.
> */
> +
> +static int i386_record_floats(struct i386_record_s *ir,
> uint32_t iregnum)
> +{
> + int i;
> +
> + /* Oza : push/pop of fpu stack is going to happen
> + currently we store st0-st7
> registers, but we need not store all registers all the
> time.
> + using fstatus, we use 11-13 bits
> which gives us stack top and hence we optimize our storage.
> */
> + if (I386_SAVE_FPU_REGS == iregnum)
> + {
> + for
> (i=I386_ST0_REGNUM;i<=I386_ST7_REGNUM;i++)
> + {
> + if
> (record_arch_list_add_reg (ir->regcache,i))
> + return -1;
>
> + }
> + }
> + else if (I386_SAVE_FPU_ENV == iregnum)
> + {
> + for
> (i=I386_FCTRL;i<=I386_FOP;i++)
> + {
> + if (record_arch_list_add_reg
> (ir->regcache,i))
> + return -1;
>
> + }
> + }
> + else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
> + {
> + for
> (i=I386_ST0_REGNUM;i<=I386_FOP;i++)
> + {
> + if (record_arch_list_add_reg
> (ir->regcache,i))
> + return -1;
>
> + }
> + }
> + else if (iregnum >= I386_ST0_REGNUM &&
> iregnum <= I386_FOP)
> + {
> + if (record_arch_list_add_reg
> (ir->regcache,iregnum))
> + return -1;
> + }
> + else
> + {
> + /* param Error */
> + return -1;
> + }
> + return 0;
> +}
> +
> /* Parse the current instruction and record the values of
> the registers and
> memory that will be changed in current
> instruction to "record_arch_list".
> Return -1 if something wrong. */
> @@ -4035,7 +4086,6 @@
> break;
>
> /* floats */
> - /* It just record the memory change
> of instrcution. */
> case 0xd8:
> case 0xd9:
> case 0xda:
> @@ -4056,39 +4106,49 @@
> return -1;
> switch (ir.reg)
> {
> - case 0x00:
> - case 0x01:
> case 0x02:
> - case 0x03:
> + case 0x12:
> + case 0x22:
> + case 0x32:
> + /* for FCOM, FICOM
> nothing to do */
> + break;
> + case 0x03:
> + case 0x13:
> + case 0x23:
> + case 0x33:
> + /* FCOMP,
> FICOMP pop FPU stack, store all */
> + if
> (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> +
> return -1;
> + break;
> + case 0x00:
> +
> case 0x01:
> case 0x04:
> case 0x05:
> case 0x06:
> case 0x07:
> case 0x10:
> - case 0x11:
> - case 0x12:
> - case 0x13:
> +
> case 0x11:
> case 0x14:
> case 0x15:
> case 0x16:
> case 0x17:
> case 0x20:
> case 0x21:
> - case 0x22:
> - case 0x23:
> case 0x24:
> case 0x25:
> case 0x26:
> case 0x27:
> case 0x30:
> case 0x31:
> - case 0x32:
> - case 0x33:
> case 0x34:
> case 0x35:
> case 0x36:
> case 0x37:
> - break;
> + /* FADD, FMUL,
> FSUB, FSUBR, FDIV, FDIVR, FIADD, FIMUL, FISUB, FISUBR,
> FIDIV, FIDIVR
> +
> ModR/M.reg is an extension of code, always affects st(0)
> register */
> + if
> (i386_record_floats(&ir, I386_ST0_REGNUM))
> +
> return -1;
> +
> break;
>
>
> case 0x08:
> case 0x0a:
> case 0x0b:
> @@ -4096,6 +4156,7 @@
> case 0x19:
> case 0x1a:
> case 0x1b:
> + case 0x1d:
> case 0x28:
> case 0x29:
> case 0x2a:
> @@ -4103,11 +4164,16 @@
> case 0x38:
> case 0x39:
> case 0x3a:
> - case 0x3b:
> + case
> 0x3b:
> + case 0x3c:
> + case 0x3d:
> switch (ir.reg
> & 7)
> {
> case 0:
> - break;
> + /* FLD, FILD
> */
> + if
> (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> +
> return -1;
> +
> break;
> case 1:
> switch
> (ir.reg >> 4)
> {
> @@ -4120,6 +4186,7 @@
>
> return -1;
>
> break;
> case
> 3:
> +
> break;
>
> default:
>
> if (record_arch_list_add_mem (addr, 2))
>
> return -1;
> @@ -4130,15 +4197,42 @@
> switch
> (ir.reg >> 4)
> {
> case
> 0:
> +
> if (record_arch_list_add_mem (addr, 4))
> +
> return -1;
> +
> if (3 == (ir.reg & 7))
> +
> {
> +
> /* FSTP m32fp */
> +
> if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> +
> return -1;
>
> +
> }
> +
> break;
> case
> 1:
>
> if (record_arch_list_add_mem (addr, 4))
>
> return -1;
> +
> if ((3 == (ir.reg & 7)) || (5 == (ir.reg & 7)) || (7
> == (ir.reg & 7)))
> +
> {
> +
> /* FSTP */
> +
> if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> +
> return -1;
>
> +
> }
>
> break;
> case
> 2:
>
> if (record_arch_list_add_mem (addr, 8))
>
> return -1;
> +
> if (3 == (ir.reg & 7))
> +
> {
> +
> /* FSTP m64fp */
> +
> if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> +
> return -1;
>
> +
> }
>
> break;
> case
> 3:
> +
> if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg
> & 7)))
> +
> {
> +
> /* FISTP, FBLD, FILD, FBSTP */
> +
> if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> +
> return -1;
>
> +
> }
>
>
> default:
>
> if (record_arch_list_add_mem (addr, 2))
>
> return -1;
> @@ -4147,54 +4241,71 @@
> break;
> }
> break;
> - case 0x0c:
> - case 0x0d:
> - case 0x1d:
> - case 0x2c:
> - case 0x3c:
> - case 0x3d:
> - break;
> - case 0x0e:
> + case
> 0x0c:
> + /* FLDENV */
> + if
> (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
> + return
> -1;
> + break;
> + case 0x0d:
> + /* FLDCW
> */
> + if
> (i386_record_floats(&ir, I386_FCTRL))
> + return
> -1;
> + break;
> + case 0x2c:
> + /*
> FRTSTOR */
> + if
> (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
> + return
> -1;
> + break;
> + case 0x0e:
> if (ir.dflag)
> {
> - if
> (record_arch_list_add_mem (addr, 28))
> - return
> -1;
> + if
> (record_arch_list_add_mem (addr, 28))
> + return -1;
> }
> else
> {
> - if
> (record_arch_list_add_mem (addr, 14))
> - return
> -1;
> + if
> (record_arch_list_add_mem (addr, 14))
> + return -1;
> }
> break;
> - case 0x0f:
> - case 0x2f:
> + case 0x0f:
> + case 0x2f:
> if
> (record_arch_list_add_mem (addr, 2))
> return -1;
> break;
> - case 0x1f:
> - case 0x3e:
> + case 0x1f:
> + case 0x3e:
> if
> (record_arch_list_add_mem (addr, 10))
> return -1;
> + /* FSTP,
> FBSTP */
> + if
> (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return
> -1;
>
>
> break;
> - case 0x2e:
> + case 0x2e:
> if (ir.dflag)
> {
> - if
> (record_arch_list_add_mem (addr, 28))
> - return
> -1;
> - addr += 28;
> + if
> (record_arch_list_add_mem (addr, 28))
> + return -1;
> + addr += 28;
> }
> else
> {
> - if
> (record_arch_list_add_mem (addr, 14))
> - return
> -1;
> - addr += 14;
> + if
> (record_arch_list_add_mem (addr, 14))
> + return -1;
> + addr += 14;
> }
> if
> (record_arch_list_add_mem (addr, 80))
> return -1;
> + /* FSAVE
> */
> + if
> (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
> + return
> -1;
> break;
> - case 0x3f:
> + case 0x3f:
> if
> (record_arch_list_add_mem (addr, 8))
> return -1;
> + /* FISTP */
> + if
> (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> + return
> -1;
> break;
> default:
> ir.addr -= 2;
> @@ -4202,9 +4313,180 @@
> goto no_support;
> break;
> }
> - }
> + }
> + /* opcode is an extension of
> modR/M byte */
> + else
> + {
> + switch (opcode)
> + {
> + case 0xd8:
> + if
> (i386_record_floats(&ir, I386_ST0_REGNUM))
> +
> return -1;
> + break;
> + case 0xd9:
>
> + if (0x0c
> == (ir.modrm >> 4))
> + {
> +
> if ((ir.modrm & 0x0f) <= 7)
> +
> {
> +
> if (i386_record_floats(&ir,
> I386_SAVE_FPU_REGS))
> +
> return -1;
> +
> }
> +
> else
> +
> {
> +
> if (i386_record_floats(&ir,
> I386_ST0_REGNUM))
> +
> return -1;
> +
> /* if only st(0) is changing, then we have
> already recorded */
> +
> if ((ir.modrm & 0x0f) - 0x08)
> +
> {
> +
> if (i386_record_floats(&ir,
> I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
> +
> return -1;
>
>
> +
> }
> +
> }
> + }
> + else
> + {
> +
> switch(ir.modrm)
> +
> {
> +
> case 0xe0:
> +
> case 0xe1:
> +
> case 0xf0:
> +
> case 0xf5:
> +
> case 0xf8:
> +
> case 0xfa:
> +
> case 0xfc:
> +
> case 0xfe:
> +
> case 0xff:
> +
> if (i386_record_floats(&ir,
> I386_ST0_REGNUM))
> +
> return -1;
> +
> break;
>
> +
> case 0xf1:
> +
> case 0xf2:
> +
> case 0xf3:
> +
> case 0xf4:
> +
> case 0xf6:
> +
> case 0xf7:
> +
> case 0xe8:
> +
> case 0xe9:
> +
> case 0xea:
> +
> case 0xeb:
> +
> case 0xec:
> +
> case 0xed:
> +
> case 0xee:
> +
> case 0xf9:
> +
> case 0xfb:
> +
> if (i386_record_floats(&ir,
> I386_SAVE_FPU_REGS))
> +
> return -1;
> +
> break;
> +
> case 0xfd:
> +
> if (i386_record_floats(&ir,
> I386_ST0_REGNUM))
> +
> return -1;
> +
> if (i386_record_floats(&ir,
> I386_ST1_REGNUM))
> +
> return -1;
> +
> break;
> +
> }
> + }
> + break;
> + case 0xda:
> + if (0xe9
> == ir.modrm)
> + {
> + if
> (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> +
> return -1;
>
> + }
> + else if
> ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >>
> 4))
> + {
> + if
> (i386_record_floats(&ir, I386_ST0_REGNUM))
> +
> return -1;
>
> + if
> (((ir.modrm & 0x0f) > 0) && ((ir.modrm &
> 0x0f) <= 7))
> +
> {
> +
> if (i386_record_floats(&ir, I386_ST0_REGNUM +
> (ir.modrm & 0x0f)))
> +
> return -1;
>
>
> +
> }
> +
> else if ((ir.modrm & 0x0f) - 0x08)
> +
> {
> + if
> (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm
> & 0x0f) - 0x08)))
> +
> return -1;
> +
> }
> +
> }
> + break;
> + case 0xdb:
> + if (0xe3
> == ir.modrm)
> + {
> + if
> (i386_record_floats(&ir, I386_SAVE_FPU_ENV))
> +
> return -1;
>
> + }
> + else if
> ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >>
> 4))
> + {
> + if
> (i386_record_floats(&ir, I386_ST0_REGNUM))
> +
> return -1;
>
> + if
> (((ir.modrm & 0x0f) > 0) && ((ir.modrm &
> 0x0f) <= 7))
> +
> {
> +
> if (i386_record_floats(&ir, I386_ST0_REGNUM +
> (ir.modrm & 0x0f)))
> +
> return -1;
>
>
> +
> }
> +
> else if ((ir.modrm & 0x0f) - 0x08)
> +
> {
> + if
> (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm
> & 0x0f) - 0x08)))
> +
> return -1;
> +
> }
> +
> }
> + break;
> + case 0xdc:
> + if ((0x0c
> == ir.modrm >> 4) || (0x0d == ir.modrm >> 4) ||
> (0x0f == ir.modrm >> 4))
> + {
> + if
> ((ir.modrm & 0x0f) <= 7)
> +
> {
> +
> if (i386_record_floats(&ir, I386_ST0_REGNUM +
> (ir.modrm & 0x0f)))
> +
> return -1;
>
>
> +
> }
> +
> else
> +
> {
> + if
> (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm
> & 0x0f) - 0x08)))
> +
> return -1;
> +
> }
> +
> }
> +
> break;
> + case 0xdd:
>
> + if (0x0c
> == ir.modrm >> 4)
> + {
> +
> if (i386_record_floats(&ir,I386_FTAG))
> +
> return -1;
> + }
> + else if
> ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >>
> 4))
> + {
>
> +
> if ((ir.modrm & 0x0f) <= 7)
> +
> {
> +
> if (i386_record_floats(&ir,
> I386_ST0_REGNUM + (ir.modrm & 0x0f)))
> +
> return
> -1;
> +
> }
> +
> else
> +
> {
> +
> if (i386_record_floats(&ir,
> I386_SAVE_FPU_REGS))
> +
> return -1;
> +
> }
> +
> }
> + break;
> + case 0xde:
> + if ((0x0c
> == ir.modrm >> 4) || (0x0e == ir.modrm >> 4) ||
> (0x0f == ir.modrm >> 4) || (0xd9 == ir.modrm))
> +
> {
>
> +
> if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> +
> return -1;
> +
> }
> + break;
> + case 0xdf:
> + if (0xe0 ==
> ir.modrm)
> + {
> +
> if (record_arch_list_add_reg (ir.regcache,
> I386_EAX_REGNUM))
> +
> return -1;
> + }
> + else if
> ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >>
> 4))
> + {
>
> +
> if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
> +
> return -1;
> + }
>
> + break;
> + }
>
> + }
>
> break;
> -
> /* string ops */
> /* movsS */
> case 0xa4:
> @@ -4623,10 +4905,17 @@
> /* fwait */
> /* XXX */
> case 0x9b:
> - printf_unfiltered (_("Process record
> doesn't support instruction "
> -
> "fwait.\n"));
> - ir.addr -= 1;
> - goto no_support;
> + if (target_read_memory (ir.addr,
> &tmpu8, 1))
> + {
> + if (record_debug)
> + printf_unfiltered
> (_("Process record: error reading memory at "
> +
> "addr 0x%s len = 1.\n"),
> +
> paddr_nz (ir.addr));
> + return -1;
> + }
> + opcode = (uint32_t) tmpu8;
> + ir.addr++;
> + goto reswitch;
>
> break;
>
> /* int3 */
> diff -urN gdb.orig/i386-tdep.h gdb.new/i386-tdep.h
> --- gdb.orig/i386-tdep.h 2009-05-17
> 17:56:44.000000000 -0400
> +++ gdb.new/i386-tdep.h 2009-05-31
> 16:33:14.000000000 -0400
> @@ -145,7 +145,22 @@
> I386_ES_REGNUM,
> /* %es */
> I386_FS_REGNUM,
> /* %fs */
> I386_GS_REGNUM,
> /* %gs */
> - I386_ST0_REGNUM
> /* %st(0) */
> + I386_ST0_REGNUM,
> /* %st(0) */
> + I386_ST1_REGNUM,
> /* %st(1) */
> + I386_ST2_REGNUM,
> /* %st(2) */
> + I386_ST3_REGNUM,
> /* %st(3) */
> + I386_ST4_REGNUM,
> /* %st(4) */
> + I386_ST5_REGNUM,
> /* %st(5) */
> + I386_ST6_REGNUM,
> /* %st(6) */
> + I386_ST7_REGNUM,
> /* %st(7) */
> + I386_FCTRL,
> /* floating point env regs : FCTRL-FOP
> */
> + I386_FSTAT,
>
> + I386_FTAG,
>
> + I386_FISEG,
> + I386_FIOFF,
> + I386_FOSEG,
> + I386_FOOFF,
> + I386_FOP
> };
>
> #define I386_NUM_GREGS 16
>
>
>
>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: i386-record-floats.patch --]
[-- Type: text/x-patch; name="i386-record-floats.patch", Size: 16155 bytes --]
diff -urN gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
--- gdb.orig/i386-tdep.c 2009-05-29 17:08:40.000000000 -0400
+++ gdb.new/i386-tdep.c 2009-06-01 20:02:23.000000000 -0400
@@ -543,6 +543,9 @@
/* The maximum number of saved registers. This should include all
registers mentioned above, and %eip. */
#define I386_NUM_SAVED_REGS I386_NUM_GREGS
+#define I386_SAVE_FPU_REGS 0xFFFD
+#define I386_SAVE_FPU_ENV 0xFFFE
+#define I386_SAVE_FPU_ENV_REG_STACK 0xFFFF
struct i386_frame_cache
{
@@ -2985,6 +2988,54 @@
return 0;
}
+/* Record the value of floating point registers which will be changed by the current instruction
+ to "record_arch_list".
+ return -1 if something is wrong. */
+
+static int i386_record_floats(struct i386_record_s *ir, uint32_t iregnum)
+{
+ int i;
+
+ /* Oza : push/pop of fpu stack is going to happen
+ currently we store st0-st7 registers, but we need not store all registers all the time.
+ using fstatus, we use 11-13 bits which gives us stack top and hence we optimize our storage. */
+ if (I386_SAVE_FPU_REGS == iregnum)
+ {
+ for (i=I386_ST0_REGNUM;i<=I386_ST7_REGNUM;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV == iregnum)
+ {
+ for (i=I386_FCTRL;i<=I386_FOP;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+ {
+ for (i=I386_ST0_REGNUM;i<=I386_FOP;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (iregnum >= I386_ST0_REGNUM && iregnum <= I386_FOP)
+ {
+ if (record_arch_list_add_reg (ir->regcache,iregnum))
+ return -1;
+ }
+ else
+ {
+ /* param Error */
+ return -1;
+ }
+ return 0;
+}
+
/* Parse the current instruction and record the values of the registers and
memory that will be changed in current instruction to "record_arch_list".
Return -1 if something wrong. */
@@ -4035,7 +4086,6 @@
break;
/* floats */
- /* It just record the memory change of instrcution. */
case 0xd8:
case 0xd9:
case 0xda:
@@ -4056,39 +4106,49 @@
return -1;
switch (ir.reg)
{
- case 0x00:
- case 0x01:
case 0x02:
- case 0x03:
+ case 0x12:
+ case 0x22:
+ case 0x32:
+ /* for FCOM, FICOM nothing to do */
+ break;
+ case 0x03:
+ case 0x13:
+ case 0x23:
+ case 0x33:
+ /* FCOMP, FICOMP pop FPU stack, store all */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0x00:
+ case 0x01:
case 0x04:
case 0x05:
case 0x06:
case 0x07:
case 0x10:
- case 0x11:
- case 0x12:
- case 0x13:
+ case 0x11:
case 0x14:
case 0x15:
case 0x16:
case 0x17:
case 0x20:
case 0x21:
- case 0x22:
- case 0x23:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x30:
case 0x31:
- case 0x32:
- case 0x33:
case 0x34:
case 0x35:
case 0x36:
case 0x37:
- break;
+ /* FADD, FMUL, FSUB, FSUBR, FDIV, FDIVR, FIADD, FIMUL, FISUB, FISUBR, FIDIV, FIDIVR
+ ModR/M.reg is an extension of code, always affects st(0) register */
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
case 0x08:
case 0x0a:
case 0x0b:
@@ -4096,6 +4156,7 @@
case 0x19:
case 0x1a:
case 0x1b:
+ case 0x1d:
case 0x28:
case 0x29:
case 0x2a:
@@ -4103,11 +4164,16 @@
case 0x38:
case 0x39:
case 0x3a:
- case 0x3b:
+ case 0x3b:
+ case 0x3c:
+ case 0x3d:
switch (ir.reg & 7)
{
case 0:
- break;
+ /* FLD, FILD */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
case 1:
switch (ir.reg >> 4)
{
@@ -4120,6 +4186,7 @@
return -1;
break;
case 3:
+ break;
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4130,15 +4197,42 @@
switch (ir.reg >> 4)
{
case 0:
+ if (record_arch_list_add_mem (addr, 4))
+ return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* FSTP m32fp */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
case 1:
if (record_arch_list_add_mem (addr, 4))
return -1;
+ if ((3 == (ir.reg & 7)) || (5 == (ir.reg & 7)) || (7 == (ir.reg & 7)))
+ {
+ /* FSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 2:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* FSTP m64fp */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 3:
+ if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+ {
+ /* FISTP, FBLD, FILD, FBSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4147,54 +4241,71 @@
break;
}
break;
- case 0x0c:
- case 0x0d:
- case 0x1d:
- case 0x2c:
- case 0x3c:
- case 0x3d:
- break;
- case 0x0e:
+ case 0x0c:
+ /* FLDENV */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
+ case 0x0d:
+ /* FLDCW */
+ if (i386_record_floats(&ir, I386_FCTRL))
+ return -1;
+ break;
+ case 0x2c:
+ /* FRTSTOR */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
+ case 0x0e:
if (ir.dflag)
{
- if (record_arch_list_add_mem (addr, 28))
- return -1;
+ if (record_arch_list_add_mem (addr, 28))
+ return -1;
}
else
{
- if (record_arch_list_add_mem (addr, 14))
- return -1;
+ if (record_arch_list_add_mem (addr, 14))
+ return -1;
}
break;
- case 0x0f:
- case 0x2f:
+ case 0x0f:
+ case 0x2f:
if (record_arch_list_add_mem (addr, 2))
return -1;
break;
- case 0x1f:
- case 0x3e:
+ case 0x1f:
+ case 0x3e:
if (record_arch_list_add_mem (addr, 10))
return -1;
+ /* FSTP, FBSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
- case 0x2e:
+ case 0x2e:
if (ir.dflag)
{
- if (record_arch_list_add_mem (addr, 28))
- return -1;
- addr += 28;
+ if (record_arch_list_add_mem (addr, 28))
+ return -1;
+ addr += 28;
}
else
{
- if (record_arch_list_add_mem (addr, 14))
- return -1;
- addr += 14;
+ if (record_arch_list_add_mem (addr, 14))
+ return -1;
+ addr += 14;
}
if (record_arch_list_add_mem (addr, 80))
return -1;
+ /* FSAVE */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
break;
- case 0x3f:
+ case 0x3f:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ /* FISTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
default:
ir.addr -= 2;
@@ -4202,9 +4313,180 @@
goto no_support;
break;
}
- }
+ }
+ /* opcode is an extension of modR/M byte */
+ else
+ {
+ switch (opcode)
+ {
+ case 0xd8:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
+ case 0xd9:
+ if (0x0c == (ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ /* if only st(0) is changing, then we have already recorded */
+ if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ }
+ else
+ {
+ switch(ir.modrm)
+ {
+ case 0xe0:
+ case 0xe1:
+ case 0xf0:
+ case 0xf5:
+ case 0xf8:
+ case 0xfa:
+ case 0xfc:
+ case 0xfe:
+ case 0xff:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
+ case 0xf1:
+ case 0xf2:
+ case 0xf3:
+ case 0xf4:
+ case 0xf6:
+ case 0xf7:
+ case 0xe8:
+ case 0xe9:
+ case 0xea:
+ case 0xeb:
+ case 0xec:
+ case 0xed:
+ case 0xee:
+ case 0xf9:
+ case 0xfb:
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0xfd:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (i386_record_floats(&ir, I386_ST1_REGNUM))
+ return -1;
+ break;
+ }
+ }
+ break;
+ case 0xda:
+ if (0xe9 == ir.modrm)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdb:
+ if (0xe3 == ir.modrm)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV))
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdc:
+ if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4) || (0x0f == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdd:
+ if (0x0c == ir.modrm >> 4)
+ {
+ if (i386_record_floats(&ir,I386_FTAG))
+ return -1;
+ }
+ else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ }
+ break;
+ case 0xde:
+ if ((0x0c == ir.modrm >> 4) || (0x0e == ir.modrm >> 4) || (0x0f == ir.modrm >> 4) || (0xd9 == ir.modrm))
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ case 0xdf:
+ if (0xe0 == ir.modrm)
+ {
+ if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+ return -1;
+ }
+ else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ }
+ }
break;
-
/* string ops */
/* movsS */
case 0xa4:
@@ -4623,10 +4905,17 @@
/* fwait */
/* XXX */
case 0x9b:
- printf_unfiltered (_("Process record doesn't support instruction "
- "fwait.\n"));
- ir.addr -= 1;
- goto no_support;
+ if (target_read_memory (ir.addr, &tmpu8, 1))
+ {
+ if (record_debug)
+ printf_unfiltered (_("Process record: error reading memory at "
+ "addr 0x%s len = 1.\n"),
+ paddr_nz (ir.addr));
+ return -1;
+ }
+ opcode = (uint32_t) tmpu8;
+ ir.addr++;
+ goto reswitch;
break;
/* int3 */
diff -urN gdb.orig/i386-tdep.h gdb.new/i386-tdep.h
--- gdb.orig/i386-tdep.h 2009-05-17 17:56:44.000000000 -0400
+++ gdb.new/i386-tdep.h 2009-05-31 16:33:14.000000000 -0400
@@ -145,7 +145,22 @@
I386_ES_REGNUM, /* %es */
I386_FS_REGNUM, /* %fs */
I386_GS_REGNUM, /* %gs */
- I386_ST0_REGNUM /* %st(0) */
+ I386_ST0_REGNUM, /* %st(0) */
+ I386_ST1_REGNUM, /* %st(1) */
+ I386_ST2_REGNUM, /* %st(2) */
+ I386_ST3_REGNUM, /* %st(3) */
+ I386_ST4_REGNUM, /* %st(4) */
+ I386_ST5_REGNUM, /* %st(5) */
+ I386_ST6_REGNUM, /* %st(6) */
+ I386_ST7_REGNUM, /* %st(7) */
+ I386_FCTRL, /* floating point env regs : FCTRL-FOP */
+ I386_FSTAT,
+ I386_FTAG,
+ I386_FISEG,
+ I386_FIOFF,
+ I386_FOSEG,
+ I386_FOOFF,
+ I386_FOP
};
#define I386_NUM_GREGS 16
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: test_floats.c --]
[-- Type: text/x-csrc; name="test_floats.c", Size: 4462 bytes --]
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/* the test intends to test following insns.
flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp fsubrp fucomp fnstsw fsqrt
fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1 fldl2t fldl2e FLDPI FLDLG2 FLDLN2
FLDZ fincstp ffree fptan fpatan fincstp fsincos frndint fscale fsin fcos fcmovb
fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor fstsw
*/
float no1,no2,no3,no4,no5,no6,no7;
double x = 100.345, y = 25.7789;
long double ldx = 88888888888888888888.88, ldy = 9999999999999999999.99;
float result,resultd,resultld;
float *float_memory;
/* 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;
}
/* 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()
{
result = no1 + no2 + no3 + no4 + no5 + no6 + no7;
printf("result is %f\n",result);
result = fmodf(no2,no1);
printf("result is %f\n",result);
resultd = fmod(x,y);
printf("result is %f\n",resultd);
resultld = fmodl(ldy,ldy);
printf("result is %f\n",resultld);
result = fabsf(no1);
printf("result is %f\n",result);
result = no3 / no4;
printf("result is %f\n",result);
result = no1 * no2 * no3 * no4;
printf("result is %f\n",result);
result = no1 - no2 - no3 - no4;
printf("result is %f\n",result);
asm ("fld %0" : :"m"(*float_memory));
asm ("fchs");
/* test for f2xm1 */
asm ("fld %0" : :"m"(*float_memory));
asm ("f2xm1");
asm ("fyl2x");
asm ("fld %0" : :"m"(*float_memory));
asm ("fxtract");
asm ("fld %0" : :"m"(*float_memory));
asm ("fprem1");
/* decrement fpu stack pointer only status register should get affected */
asm ("fld %0" : :"m"(*float_memory));
empty_fpu_stack();
asm ("fld1");
asm ("fldl2t");
asm ("fldl2e");
asm ("fldpi");
asm ("fldlg2");
asm ("fldln2");
asm ("fldz");
empty_fpu_stack();
/* finishing emptying the stack */
result = sqrt(no3);
printf("result is %f\n",result);
}
void test_log_exp_floats()
{
result = log10(no3);
printf("result is %f\n",result);
result = log(no3);
printf("result is %f\n",result);
result = exp10(no3);
printf("result is %f\n",result);
result = exp(no3);
printf("result is %f\n",result);
}
void test_trigo_floats()
{
result = sin(30);
printf("result is %f\n",result);
result = cos(30);
printf("result is %f\n",result);
result = tan(30);
printf("result is %f\n",result);
result = atan(30);
printf("result is %f\n",result);
asm ("fld %0" : :"m"(*float_memory));
asm ("fptan");
/* changes st1 and popping register stack */
asm ("fpatan");
asm("fincstp");
asm ("fld %0" : :"m"(float_memory));
asm ("fsincos");
asm ("fld %0" : :"m"(*float_memory));
asm ("frndint");
asm ("fld %0" : :"m"(*float_memory));
asm ("fld %0" : :"m"(*(float_memory+1)));
asm ("fscale");
empty_fpu_stack();
asm ("fld %0" : :"m"(*float_memory));
asm ("fsin");
asm ("fcos");
/* currently we assume condition likely and always record the registers
code could be optimized only if the flag is set then record */
asm ("fld %0" : :"m"(*float_memory));
asm ("fld %0" : :"m"(*(float_memory+1)));
asm ("fcmovb %st(1), %st");
asm ("fcmovbe %st(1), %st");
asm ("fcmove %st(1), %st");
asm ("fcmovu %st(1), %st");
asm ("fcmovnb %st(1), %st");
asm ("fcmovnbe %st(1), %st");
empty_fpu_stack();
/* finished emtyping the stack */
}
void test_compare_floats()
{
ldy = 88888888888888888888.88;
if (ldx == ldy)
ldy = 7777777777777777777777777777.777;
else
ldy = 666666666666666666666666666.666;
}
/* test loading and saving of FPU environment */
void test_fpu_env()
{
asm ("fsave %0" : "=m"(*float_memory) : );
asm ("frstor %0" : : "m"(*float_memory));
asm ("fstsw %ax");
}
int main()
{
init_floats();
test_arith_floats();
test_log_exp_floats();
test_trigo_floats();
test_compare_floats();
test_fpu_env();
}
^ permalink raw reply [flat|nested] 40+ messages in thread* Re: i386.record.floating.point.patch : with more testing and assurity
2009-06-30 13:23 paawan oza
@ 2009-06-30 13:38 ` Pedro Alves
2009-06-30 13:42 ` Mark Kettenis
1 sibling, 0 replies; 40+ messages in thread
From: Pedro Alves @ 2009-06-30 13:38 UTC (permalink / raw)
To: gdb-patches; +Cc: paawan oza, teawater
On Tuesday 30 June 2009 14:23:30, paawan oza wrote:
>
> > As suggested by Hui,
> > I have come up with more detailed and granular test case
> > for the patch which I had submitted last week.
Could you please consider migrating that test into the testsuite?
You've gone through the trouble of writing tests to make sure
the features work now --- putting it in the testsuite means we
have an automatic-ish means to check that it doesn't get
inadvertently broken in the future. The way it is, when your
code gets in, the test will probably end up lost in the archives.
We wouldn't want that, would we? :-) Having auto-tests, also helps
the person doing the review in confirming things work as
expected (without much effort).
--
Pedro Alves
^ permalink raw reply [flat|nested] 40+ messages in thread
* Re: i386.record.floating.point.patch : with more testing and assurity
2009-06-30 13:23 paawan oza
2009-06-30 13:38 ` Pedro Alves
@ 2009-06-30 13:42 ` Mark Kettenis
1 sibling, 0 replies; 40+ messages in thread
From: Mark Kettenis @ 2009-06-30 13:42 UTC (permalink / raw)
To: paawan1982; +Cc: gdb-patches, teawater
> Date: Tue, 30 Jun 2009 06:23:30 -0700 (PDT)
> From: paawan oza <paawan1982@yahoo.com>
>
> Hi,
> Again I am sending the patch, with the test cases.
> please do the needful
> Regards,
> Oza.
Sorry, but if you want me to review your patch, don't send it as
base64 encoded MIME.
^ permalink raw reply [flat|nested] 40+ messages in thread
* i386.record.floating.point.patch : with more testing and assurity
@ 2009-06-04 14:50 paawan oza
0 siblings, 0 replies; 40+ messages in thread
From: paawan oza @ 2009-06-04 14:50 UTC (permalink / raw)
To: gdb-patches; +Cc: Hui Zhu
[-- Attachment #1: Type: text/plain, Size: 21564 bytes --]
Hi All,
As suggested by Hui,
I have come up with more detailed and granular test case for the patch which I had submitted last week.
-> it does basic as well as advanced verification for the patch, details could be found in test_floats.c
-> I have also tried to take coverage using gcov and the number is almost around 80-85% for that patch, which is nice to have.
-> the patch works well with all the scenarios described in test_floats.c
please find the patch and test_float.c attached, as well as part of email body also.
PS : there os no change in patch, only improvement is it is tested throughly as much as posible.
please provide your review comments.
Regards,
Oza.
****************************************************
test_float.c
****************************************************
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/* the test intends to test following insns.
flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp fsubrp fucomp fnstsw fsqrt
fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1 fldl2t fldl2e FLDPI FLDLG2 FLDLN2
FLDZ fincstp ffree fptan fpatan fincstp fsincos frndint fscale fsin fcos fcmovb
fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor fstsw
*/
float no1,no2,no3,no4,no5,no6,no7;
double x = 100.345, y = 25.7789;
long double ldx = 88888888888888888888.88, ldy = 9999999999999999999.99;
float result,resultd,resultld;
float *float_memory;
/* 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;
}
/* 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()
{
result = no1 + no2 + no3 + no4 + no5 + no6 + no7;
printf("result is %f\n",result);
result = fmodf(no2,no1);
printf("result is %f\n",result);
resultd = fmod(x,y);
printf("result is %f\n",resultd);
resultld = fmodl(ldy,ldy);
printf("result is %f\n",resultld);
result = fabsf(no1);
printf("result is %f\n",result);
result = no3 / no4;
printf("result is %f\n",result);
result = no1 * no2 * no3 * no4;
printf("result is %f\n",result);
result = no1 - no2 - no3 - no4;
printf("result is %f\n",result);
asm ("fld %0" : :"m"(*float_memory));
asm ("fchs");
/* test for f2xm1 */
asm ("fld %0" : :"m"(*float_memory));
asm ("f2xm1");
asm ("fyl2x");
asm ("fld %0" : :"m"(*float_memory));
asm ("fxtract");
asm ("fld %0" : :"m"(*float_memory));
asm ("fprem1");
/* decrement fpu stack pointer only status register should get affected */
asm ("fld %0" : :"m"(*float_memory));
empty_fpu_stack();
asm ("fld1");
asm ("fldl2t");
asm ("fldl2e");
asm ("fldpi");
asm ("fldlg2");
asm ("fldln2");
asm ("fldz");
empty_fpu_stack();
/* finishing emptying the stack */
result = sqrt(no3);
printf("result is %f\n",result);
}
void test_log_exp_floats()
{
result = log10(no3);
printf("result is %f\n",result);
result = log(no3);
printf("result is %f\n",result);
result = exp10(no3);
printf("result is %f\n",result);
result = exp(no3);
printf("result is %f\n",result);
}
void test_trigo_floats()
{
result = sin(30);
printf("result is %f\n",result);
result = cos(30);
printf("result is %f\n",result);
result = tan(30);
printf("result is %f\n",result);
result = atan(30);
printf("result is %f\n",result);
asm ("fld %0" : :"m"(*float_memory));
asm ("fptan");
/* changes st1 and popping register stack */
asm ("fpatan");
asm("fincstp");
asm ("fld %0" : :"m"(float_memory));
asm ("fsincos");
asm ("fld %0" : :"m"(*float_memory));
asm ("frndint");
asm ("fld %0" : :"m"(*float_memory));
asm ("fld %0" : :"m"(*(float_memory+1)));
asm ("fscale");
empty_fpu_stack();
asm ("fld %0" : :"m"(*float_memory));
asm ("fsin");
asm ("fcos");
/* currently we assume condition likely and always record the registers
code could be optimized only if the flag is set then record */
asm ("fld %0" : :"m"(*float_memory));
asm ("fld %0" : :"m"(*(float_memory+1)));
asm ("fcmovb %st(1), %st");
asm ("fcmovbe %st(1), %st");
asm ("fcmove %st(1), %st");
asm ("fcmovu %st(1), %st");
asm ("fcmovnb %st(1), %st");
asm ("fcmovnbe %st(1), %st");
empty_fpu_stack();
/* finished emtyping the stack */
}
void test_compare_floats()
{
ldy = 88888888888888888888.88;
if (ldx == ldy)
ldy = 7777777777777777777777777777.777;
else
ldy = 666666666666666666666666666.666;
}
/* test loading and saving of FPU environment */
void test_fpu_env()
{
asm ("fsave %0" : "=m"(*float_memory) : );
asm ("frstor %0" : : "m"(*float_memory));
asm ("fstsw %ax");
}
int main()
{
init_floats();
test_arith_floats();
test_log_exp_floats();
test_trigo_floats();
test_compare_floats();
test_fpu_env();
}
******************************************************
i386-record-floats.patch
******************************************************
diff -urN gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
--- gdb.orig/i386-tdep.c 2009-05-29 17:08:40.000000000 -0400
+++ gdb.new/i386-tdep.c 2009-06-01 20:02:23.000000000 -0400
@@ -543,6 +543,9 @@
/* The maximum number of saved registers. This should include all
registers mentioned above, and %eip. */
#define I386_NUM_SAVED_REGS I386_NUM_GREGS
+#define I386_SAVE_FPU_REGS 0xFFFD
+#define I386_SAVE_FPU_ENV 0xFFFE
+#define I386_SAVE_FPU_ENV_REG_STACK 0xFFFF
struct i386_frame_cache
{
@@ -2985,6 +2988,54 @@
return 0;
}
+/* Record the value of floating point registers which will be changed by the current instruction
+ to "record_arch_list".
+ return -1 if something is wrong. */
+
+static int i386_record_floats(struct i386_record_s *ir, uint32_t iregnum)
+{
+ int i;
+
+ /* Oza : push/pop of fpu stack is going to happen
+ currently we store st0-st7 registers, but we need not store all registers all the time.
+ using fstatus, we use 11-13 bits which gives us stack top and hence we optimize our storage. */
+ if (I386_SAVE_FPU_REGS == iregnum)
+ {
+ for (i=I386_ST0_REGNUM;i<=I386_ST7_REGNUM;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV == iregnum)
+ {
+ for (i=I386_FCTRL;i<=I386_FOP;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+ {
+ for (i=I386_ST0_REGNUM;i<=I386_FOP;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (iregnum >= I386_ST0_REGNUM && iregnum <= I386_FOP)
+ {
+ if (record_arch_list_add_reg (ir->regcache,iregnum))
+ return -1;
+ }
+ else
+ {
+ /* param Error */
+ return -1;
+ }
+ return 0;
+}
+
/* Parse the current instruction and record the values of the registers and
memory that will be changed in current instruction to "record_arch_list".
Return -1 if something wrong. */
@@ -4035,7 +4086,6 @@
break;
/* floats */
- /* It just record the memory change of instrcution. */
case 0xd8:
case 0xd9:
case 0xda:
@@ -4056,39 +4106,49 @@
return -1;
switch (ir.reg)
{
- case 0x00:
- case 0x01:
case 0x02:
- case 0x03:
+ case 0x12:
+ case 0x22:
+ case 0x32:
+ /* for FCOM, FICOM nothing to do */
+ break;
+ case 0x03:
+ case 0x13:
+ case 0x23:
+ case 0x33:
+ /* FCOMP, FICOMP pop FPU stack, store all */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0x00:
+ case 0x01:
case 0x04:
case 0x05:
case 0x06:
case 0x07:
case 0x10:
- case 0x11:
- case 0x12:
- case 0x13:
+ case 0x11:
case 0x14:
case 0x15:
case 0x16:
case 0x17:
case 0x20:
case 0x21:
- case 0x22:
- case 0x23:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x30:
case 0x31:
- case 0x32:
- case 0x33:
case 0x34:
case 0x35:
case 0x36:
case 0x37:
- break;
+ /* FADD, FMUL, FSUB, FSUBR, FDIV, FDIVR, FIADD, FIMUL, FISUB, FISUBR, FIDIV, FIDIVR
+ ModR/M.reg is an extension of code, always affects st(0) register */
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
case 0x08:
case 0x0a:
case 0x0b:
@@ -4096,6 +4156,7 @@
case 0x19:
case 0x1a:
case 0x1b:
+ case 0x1d:
case 0x28:
case 0x29:
case 0x2a:
@@ -4103,11 +4164,16 @@
case 0x38:
case 0x39:
case 0x3a:
- case 0x3b:
+ case 0x3b:
+ case 0x3c:
+ case 0x3d:
switch (ir.reg & 7)
{
case 0:
- break;
+ /* FLD, FILD */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
case 1:
switch (ir.reg >> 4)
{
@@ -4120,6 +4186,7 @@
return -1;
break;
case 3:
+ break;
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4130,15 +4197,42 @@
switch (ir.reg >> 4)
{
case 0:
+ if (record_arch_list_add_mem (addr, 4))
+ return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* FSTP m32fp */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
case 1:
if (record_arch_list_add_mem (addr, 4))
return -1;
+ if ((3 == (ir.reg & 7)) || (5 == (ir.reg & 7)) || (7 == (ir.reg & 7)))
+ {
+ /* FSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 2:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* FSTP m64fp */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 3:
+ if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+ {
+ /* FISTP, FBLD, FILD, FBSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4147,54 +4241,71 @@
break;
}
break;
- case 0x0c:
- case 0x0d:
- case 0x1d:
- case 0x2c:
- case 0x3c:
- case 0x3d:
- break;
- case 0x0e:
+ case 0x0c:
+ /* FLDENV */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
+ case 0x0d:
+ /* FLDCW */
+ if (i386_record_floats(&ir, I386_FCTRL))
+ return -1;
+ break;
+ case 0x2c:
+ /* FRTSTOR */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
+ case 0x0e:
if (ir.dflag)
{
- if (record_arch_list_add_mem (addr, 28))
- return -1;
+ if (record_arch_list_add_mem (addr, 28))
+ return -1;
}
else
{
- if (record_arch_list_add_mem (addr, 14))
- return -1;
+ if (record_arch_list_add_mem (addr, 14))
+ return -1;
}
break;
- case 0x0f:
- case 0x2f:
+ case 0x0f:
+ case 0x2f:
if (record_arch_list_add_mem (addr, 2))
return -1;
break;
- case 0x1f:
- case 0x3e:
+ case 0x1f:
+ case 0x3e:
if (record_arch_list_add_mem (addr, 10))
return -1;
+ /* FSTP, FBSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
- case 0x2e:
+ case 0x2e:
if (ir.dflag)
{
- if (record_arch_list_add_mem (addr, 28))
- return -1;
- addr += 28;
+ if (record_arch_list_add_mem (addr, 28))
+ return -1;
+ addr += 28;
}
else
{
- if (record_arch_list_add_mem (addr, 14))
- return -1;
- addr += 14;
+ if (record_arch_list_add_mem (addr, 14))
+ return -1;
+ addr += 14;
}
if (record_arch_list_add_mem (addr, 80))
return -1;
+ /* FSAVE */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
break;
- case 0x3f:
+ case 0x3f:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ /* FISTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
default:
ir.addr -= 2;
@@ -4202,9 +4313,180 @@
goto no_support;
break;
}
- }
+ }
+ /* opcode is an extension of modR/M byte */
+ else
+ {
+ switch (opcode)
+ {
+ case 0xd8:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
+ case 0xd9:
+ if (0x0c == (ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ /* if only st(0) is changing, then we have already recorded */
+ if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ }
+ else
+ {
+ switch(ir.modrm)
+ {
+ case 0xe0:
+ case 0xe1:
+ case 0xf0:
+ case 0xf5:
+ case 0xf8:
+ case 0xfa:
+ case 0xfc:
+ case 0xfe:
+ case 0xff:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
+ case 0xf1:
+ case 0xf2:
+ case 0xf3:
+ case 0xf4:
+ case 0xf6:
+ case 0xf7:
+ case 0xe8:
+ case 0xe9:
+ case 0xea:
+ case 0xeb:
+ case 0xec:
+ case 0xed:
+ case 0xee:
+ case 0xf9:
+ case 0xfb:
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0xfd:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (i386_record_floats(&ir, I386_ST1_REGNUM))
+ return -1;
+ break;
+ }
+ }
+ break;
+ case 0xda:
+ if (0xe9 == ir.modrm)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdb:
+ if (0xe3 == ir.modrm)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV))
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdc:
+ if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4) || (0x0f == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdd:
+ if (0x0c == ir.modrm >> 4)
+ {
+ if (i386_record_floats(&ir,I386_FTAG))
+ return -1;
+ }
+ else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ }
+ break;
+ case 0xde:
+ if ((0x0c == ir.modrm >> 4) || (0x0e == ir.modrm >> 4) || (0x0f == ir.modrm >> 4) || (0xd9 == ir.modrm))
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ case 0xdf:
+ if (0xe0 == ir.modrm)
+ {
+ if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+ return -1;
+ }
+ else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ }
+ }
break;
-
/* string ops */
/* movsS */
case 0xa4:
@@ -4623,10 +4905,17 @@
/* fwait */
/* XXX */
case 0x9b:
- printf_unfiltered (_("Process record doesn't support instruction "
- "fwait.\n"));
- ir.addr -= 1;
- goto no_support;
+ if (target_read_memory (ir.addr, &tmpu8, 1))
+ {
+ if (record_debug)
+ printf_unfiltered (_("Process record: error reading memory at "
+ "addr 0x%s len = 1.\n"),
+ paddr_nz (ir.addr));
+ return -1;
+ }
+ opcode = (uint32_t) tmpu8;
+ ir.addr++;
+ goto reswitch;
break;
/* int3 */
diff -urN gdb.orig/i386-tdep.h gdb.new/i386-tdep.h
--- gdb.orig/i386-tdep.h 2009-05-17 17:56:44.000000000 -0400
+++ gdb.new/i386-tdep.h 2009-05-31 16:33:14.000000000 -0400
@@ -145,7 +145,22 @@
I386_ES_REGNUM, /* %es */
I386_FS_REGNUM, /* %fs */
I386_GS_REGNUM, /* %gs */
- I386_ST0_REGNUM /* %st(0) */
+ I386_ST0_REGNUM, /* %st(0) */
+ I386_ST1_REGNUM, /* %st(1) */
+ I386_ST2_REGNUM, /* %st(2) */
+ I386_ST3_REGNUM, /* %st(3) */
+ I386_ST4_REGNUM, /* %st(4) */
+ I386_ST5_REGNUM, /* %st(5) */
+ I386_ST6_REGNUM, /* %st(6) */
+ I386_ST7_REGNUM, /* %st(7) */
+ I386_FCTRL, /* floating point env regs : FCTRL-FOP */
+ I386_FSTAT,
+ I386_FTAG,
+ I386_FISEG,
+ I386_FIOFF,
+ I386_FOSEG,
+ I386_FOOFF,
+ I386_FOP
};
#define I386_NUM_GREGS 16
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: i386-record-floats.patch --]
[-- Type: text/x-patch; name="i386-record-floats.patch", Size: 16155 bytes --]
diff -urN gdb.orig/i386-tdep.c gdb.new/i386-tdep.c
--- gdb.orig/i386-tdep.c 2009-05-29 17:08:40.000000000 -0400
+++ gdb.new/i386-tdep.c 2009-06-01 20:02:23.000000000 -0400
@@ -543,6 +543,9 @@
/* The maximum number of saved registers. This should include all
registers mentioned above, and %eip. */
#define I386_NUM_SAVED_REGS I386_NUM_GREGS
+#define I386_SAVE_FPU_REGS 0xFFFD
+#define I386_SAVE_FPU_ENV 0xFFFE
+#define I386_SAVE_FPU_ENV_REG_STACK 0xFFFF
struct i386_frame_cache
{
@@ -2985,6 +2988,54 @@
return 0;
}
+/* Record the value of floating point registers which will be changed by the current instruction
+ to "record_arch_list".
+ return -1 if something is wrong. */
+
+static int i386_record_floats(struct i386_record_s *ir, uint32_t iregnum)
+{
+ int i;
+
+ /* Oza : push/pop of fpu stack is going to happen
+ currently we store st0-st7 registers, but we need not store all registers all the time.
+ using fstatus, we use 11-13 bits which gives us stack top and hence we optimize our storage. */
+ if (I386_SAVE_FPU_REGS == iregnum)
+ {
+ for (i=I386_ST0_REGNUM;i<=I386_ST7_REGNUM;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV == iregnum)
+ {
+ for (i=I386_FCTRL;i<=I386_FOP;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (I386_SAVE_FPU_ENV_REG_STACK == iregnum)
+ {
+ for (i=I386_ST0_REGNUM;i<=I386_FOP;i++)
+ {
+ if (record_arch_list_add_reg (ir->regcache,i))
+ return -1;
+ }
+ }
+ else if (iregnum >= I386_ST0_REGNUM && iregnum <= I386_FOP)
+ {
+ if (record_arch_list_add_reg (ir->regcache,iregnum))
+ return -1;
+ }
+ else
+ {
+ /* param Error */
+ return -1;
+ }
+ return 0;
+}
+
/* Parse the current instruction and record the values of the registers and
memory that will be changed in current instruction to "record_arch_list".
Return -1 if something wrong. */
@@ -4035,7 +4086,6 @@
break;
/* floats */
- /* It just record the memory change of instrcution. */
case 0xd8:
case 0xd9:
case 0xda:
@@ -4056,39 +4106,49 @@
return -1;
switch (ir.reg)
{
- case 0x00:
- case 0x01:
case 0x02:
- case 0x03:
+ case 0x12:
+ case 0x22:
+ case 0x32:
+ /* for FCOM, FICOM nothing to do */
+ break;
+ case 0x03:
+ case 0x13:
+ case 0x23:
+ case 0x33:
+ /* FCOMP, FICOMP pop FPU stack, store all */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0x00:
+ case 0x01:
case 0x04:
case 0x05:
case 0x06:
case 0x07:
case 0x10:
- case 0x11:
- case 0x12:
- case 0x13:
+ case 0x11:
case 0x14:
case 0x15:
case 0x16:
case 0x17:
case 0x20:
case 0x21:
- case 0x22:
- case 0x23:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x30:
case 0x31:
- case 0x32:
- case 0x33:
case 0x34:
case 0x35:
case 0x36:
case 0x37:
- break;
+ /* FADD, FMUL, FSUB, FSUBR, FDIV, FDIVR, FIADD, FIMUL, FISUB, FISUBR, FIDIV, FIDIVR
+ ModR/M.reg is an extension of code, always affects st(0) register */
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
case 0x08:
case 0x0a:
case 0x0b:
@@ -4096,6 +4156,7 @@
case 0x19:
case 0x1a:
case 0x1b:
+ case 0x1d:
case 0x28:
case 0x29:
case 0x2a:
@@ -4103,11 +4164,16 @@
case 0x38:
case 0x39:
case 0x3a:
- case 0x3b:
+ case 0x3b:
+ case 0x3c:
+ case 0x3d:
switch (ir.reg & 7)
{
case 0:
- break;
+ /* FLD, FILD */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
case 1:
switch (ir.reg >> 4)
{
@@ -4120,6 +4186,7 @@
return -1;
break;
case 3:
+ break;
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4130,15 +4197,42 @@
switch (ir.reg >> 4)
{
case 0:
+ if (record_arch_list_add_mem (addr, 4))
+ return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* FSTP m32fp */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
case 1:
if (record_arch_list_add_mem (addr, 4))
return -1;
+ if ((3 == (ir.reg & 7)) || (5 == (ir.reg & 7)) || (7 == (ir.reg & 7)))
+ {
+ /* FSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 2:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ if (3 == (ir.reg & 7))
+ {
+ /* FSTP m64fp */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
break;
case 3:
+ if ((3 <= (ir.reg & 7)) && (6 <= (ir.reg & 7)))
+ {
+ /* FISTP, FBLD, FILD, FBSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
default:
if (record_arch_list_add_mem (addr, 2))
return -1;
@@ -4147,54 +4241,71 @@
break;
}
break;
- case 0x0c:
- case 0x0d:
- case 0x1d:
- case 0x2c:
- case 0x3c:
- case 0x3d:
- break;
- case 0x0e:
+ case 0x0c:
+ /* FLDENV */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
+ case 0x0d:
+ /* FLDCW */
+ if (i386_record_floats(&ir, I386_FCTRL))
+ return -1;
+ break;
+ case 0x2c:
+ /* FRTSTOR */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
+ break;
+ case 0x0e:
if (ir.dflag)
{
- if (record_arch_list_add_mem (addr, 28))
- return -1;
+ if (record_arch_list_add_mem (addr, 28))
+ return -1;
}
else
{
- if (record_arch_list_add_mem (addr, 14))
- return -1;
+ if (record_arch_list_add_mem (addr, 14))
+ return -1;
}
break;
- case 0x0f:
- case 0x2f:
+ case 0x0f:
+ case 0x2f:
if (record_arch_list_add_mem (addr, 2))
return -1;
break;
- case 0x1f:
- case 0x3e:
+ case 0x1f:
+ case 0x3e:
if (record_arch_list_add_mem (addr, 10))
return -1;
+ /* FSTP, FBSTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
- case 0x2e:
+ case 0x2e:
if (ir.dflag)
{
- if (record_arch_list_add_mem (addr, 28))
- return -1;
- addr += 28;
+ if (record_arch_list_add_mem (addr, 28))
+ return -1;
+ addr += 28;
}
else
{
- if (record_arch_list_add_mem (addr, 14))
- return -1;
- addr += 14;
+ if (record_arch_list_add_mem (addr, 14))
+ return -1;
+ addr += 14;
}
if (record_arch_list_add_mem (addr, 80))
return -1;
+ /* FSAVE */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV_REG_STACK))
+ return -1;
break;
- case 0x3f:
+ case 0x3f:
if (record_arch_list_add_mem (addr, 8))
return -1;
+ /* FISTP */
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
break;
default:
ir.addr -= 2;
@@ -4202,9 +4313,180 @@
goto no_support;
break;
}
- }
+ }
+ /* opcode is an extension of modR/M byte */
+ else
+ {
+ switch (opcode)
+ {
+ case 0xd8:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
+ case 0xd9:
+ if (0x0c == (ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ /* if only st(0) is changing, then we have already recorded */
+ if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ }
+ else
+ {
+ switch(ir.modrm)
+ {
+ case 0xe0:
+ case 0xe1:
+ case 0xf0:
+ case 0xf5:
+ case 0xf8:
+ case 0xfa:
+ case 0xfc:
+ case 0xfe:
+ case 0xff:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ break;
+ case 0xf1:
+ case 0xf2:
+ case 0xf3:
+ case 0xf4:
+ case 0xf6:
+ case 0xf7:
+ case 0xe8:
+ case 0xe9:
+ case 0xea:
+ case 0xeb:
+ case 0xec:
+ case 0xed:
+ case 0xee:
+ case 0xf9:
+ case 0xfb:
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ break;
+ case 0xfd:
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (i386_record_floats(&ir, I386_ST1_REGNUM))
+ return -1;
+ break;
+ }
+ }
+ break;
+ case 0xda:
+ if (0xe9 == ir.modrm)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdb:
+ if (0xe3 == ir.modrm)
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_ENV))
+ return -1;
+ }
+ else if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM))
+ return -1;
+ if (((ir.modrm & 0x0f) > 0) && ((ir.modrm & 0x0f) <= 7))
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else if ((ir.modrm & 0x0f) - 0x08)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdc:
+ if ((0x0c == ir.modrm >> 4) || (0x0d == ir.modrm >> 4) || (0x0f == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + ((ir.modrm & 0x0f) - 0x08)))
+ return -1;
+ }
+ }
+ break;
+ case 0xdd:
+ if (0x0c == ir.modrm >> 4)
+ {
+ if (i386_record_floats(&ir,I386_FTAG))
+ return -1;
+ }
+ else if ((0x0d == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if ((ir.modrm & 0x0f) <= 7)
+ {
+ if (i386_record_floats(&ir, I386_ST0_REGNUM + (ir.modrm & 0x0f)))
+ return -1;
+ }
+ else
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ }
+ break;
+ case 0xde:
+ if ((0x0c == ir.modrm >> 4) || (0x0e == ir.modrm >> 4) || (0x0f == ir.modrm >> 4) || (0xd9 == ir.modrm))
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ case 0xdf:
+ if (0xe0 == ir.modrm)
+ {
+ if (record_arch_list_add_reg (ir.regcache, I386_EAX_REGNUM))
+ return -1;
+ }
+ else if ((0x0f == ir.modrm >> 4) || (0x0e == ir.modrm >> 4))
+ {
+ if (i386_record_floats(&ir, I386_SAVE_FPU_REGS))
+ return -1;
+ }
+ break;
+ }
+ }
break;
-
/* string ops */
/* movsS */
case 0xa4:
@@ -4623,10 +4905,17 @@
/* fwait */
/* XXX */
case 0x9b:
- printf_unfiltered (_("Process record doesn't support instruction "
- "fwait.\n"));
- ir.addr -= 1;
- goto no_support;
+ if (target_read_memory (ir.addr, &tmpu8, 1))
+ {
+ if (record_debug)
+ printf_unfiltered (_("Process record: error reading memory at "
+ "addr 0x%s len = 1.\n"),
+ paddr_nz (ir.addr));
+ return -1;
+ }
+ opcode = (uint32_t) tmpu8;
+ ir.addr++;
+ goto reswitch;
break;
/* int3 */
diff -urN gdb.orig/i386-tdep.h gdb.new/i386-tdep.h
--- gdb.orig/i386-tdep.h 2009-05-17 17:56:44.000000000 -0400
+++ gdb.new/i386-tdep.h 2009-05-31 16:33:14.000000000 -0400
@@ -145,7 +145,22 @@
I386_ES_REGNUM, /* %es */
I386_FS_REGNUM, /* %fs */
I386_GS_REGNUM, /* %gs */
- I386_ST0_REGNUM /* %st(0) */
+ I386_ST0_REGNUM, /* %st(0) */
+ I386_ST1_REGNUM, /* %st(1) */
+ I386_ST2_REGNUM, /* %st(2) */
+ I386_ST3_REGNUM, /* %st(3) */
+ I386_ST4_REGNUM, /* %st(4) */
+ I386_ST5_REGNUM, /* %st(5) */
+ I386_ST6_REGNUM, /* %st(6) */
+ I386_ST7_REGNUM, /* %st(7) */
+ I386_FCTRL, /* floating point env regs : FCTRL-FOP */
+ I386_FSTAT,
+ I386_FTAG,
+ I386_FISEG,
+ I386_FIOFF,
+ I386_FOSEG,
+ I386_FOOFF,
+ I386_FOP
};
#define I386_NUM_GREGS 16
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: test_floats.c --]
[-- Type: text/x-csrc; name="test_floats.c", Size: 4462 bytes --]
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/* the test intends to test following insns.
flds faddp fstps fstpl fldl fxch fabs fdivrp fmulp fsubrp fucomp fnstsw fsqrt
fchs f2xm1 fyl2x fxtract fprem1 fld fdecstp fld1 fldl2t fldl2e FLDPI FLDLG2 FLDLN2
FLDZ fincstp ffree fptan fpatan fincstp fsincos frndint fscale fsin fcos fcmovb
fcmovbe fcmove fcmovu fcmovnb fcmovnbe fsave frstor fstsw
*/
float no1,no2,no3,no4,no5,no6,no7;
double x = 100.345, y = 25.7789;
long double ldx = 88888888888888888888.88, ldy = 9999999999999999999.99;
float result,resultd,resultld;
float *float_memory;
/* 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;
}
/* 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()
{
result = no1 + no2 + no3 + no4 + no5 + no6 + no7;
printf("result is %f\n",result);
result = fmodf(no2,no1);
printf("result is %f\n",result);
resultd = fmod(x,y);
printf("result is %f\n",resultd);
resultld = fmodl(ldy,ldy);
printf("result is %f\n",resultld);
result = fabsf(no1);
printf("result is %f\n",result);
result = no3 / no4;
printf("result is %f\n",result);
result = no1 * no2 * no3 * no4;
printf("result is %f\n",result);
result = no1 - no2 - no3 - no4;
printf("result is %f\n",result);
asm ("fld %0" : :"m"(*float_memory));
asm ("fchs");
/* test for f2xm1 */
asm ("fld %0" : :"m"(*float_memory));
asm ("f2xm1");
asm ("fyl2x");
asm ("fld %0" : :"m"(*float_memory));
asm ("fxtract");
asm ("fld %0" : :"m"(*float_memory));
asm ("fprem1");
/* decrement fpu stack pointer only status register should get affected */
asm ("fld %0" : :"m"(*float_memory));
empty_fpu_stack();
asm ("fld1");
asm ("fldl2t");
asm ("fldl2e");
asm ("fldpi");
asm ("fldlg2");
asm ("fldln2");
asm ("fldz");
empty_fpu_stack();
/* finishing emptying the stack */
result = sqrt(no3);
printf("result is %f\n",result);
}
void test_log_exp_floats()
{
result = log10(no3);
printf("result is %f\n",result);
result = log(no3);
printf("result is %f\n",result);
result = exp10(no3);
printf("result is %f\n",result);
result = exp(no3);
printf("result is %f\n",result);
}
void test_trigo_floats()
{
result = sin(30);
printf("result is %f\n",result);
result = cos(30);
printf("result is %f\n",result);
result = tan(30);
printf("result is %f\n",result);
result = atan(30);
printf("result is %f\n",result);
asm ("fld %0" : :"m"(*float_memory));
asm ("fptan");
/* changes st1 and popping register stack */
asm ("fpatan");
asm("fincstp");
asm ("fld %0" : :"m"(float_memory));
asm ("fsincos");
asm ("fld %0" : :"m"(*float_memory));
asm ("frndint");
asm ("fld %0" : :"m"(*float_memory));
asm ("fld %0" : :"m"(*(float_memory+1)));
asm ("fscale");
empty_fpu_stack();
asm ("fld %0" : :"m"(*float_memory));
asm ("fsin");
asm ("fcos");
/* currently we assume condition likely and always record the registers
code could be optimized only if the flag is set then record */
asm ("fld %0" : :"m"(*float_memory));
asm ("fld %0" : :"m"(*(float_memory+1)));
asm ("fcmovb %st(1), %st");
asm ("fcmovbe %st(1), %st");
asm ("fcmove %st(1), %st");
asm ("fcmovu %st(1), %st");
asm ("fcmovnb %st(1), %st");
asm ("fcmovnbe %st(1), %st");
empty_fpu_stack();
/* finished emtyping the stack */
}
void test_compare_floats()
{
ldy = 88888888888888888888.88;
if (ldx == ldy)
ldy = 7777777777777777777777777777.777;
else
ldy = 666666666666666666666666666.666;
}
/* test loading and saving of FPU environment */
void test_fpu_env()
{
asm ("fsave %0" : "=m"(*float_memory) : );
asm ("frstor %0" : : "m"(*float_memory));
asm ("fstsw %ax");
}
int main()
{
init_floats();
test_arith_floats();
test_log_exp_floats();
test_trigo_floats();
test_compare_floats();
test_fpu_env();
}
^ permalink raw reply [flat|nested] 40+ messages in thread
end of thread, other threads:[~2009-07-26 22:51 UTC | newest]
Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-03 18:55 i386.record.floating.point.patch : with more testing and assurity paawan oza
2009-07-03 21:52 ` Michael Snyder
[not found] <992589.56162.qm@web112513.mail.gq1.yahoo.com>
2009-07-26 19:10 ` Mark Kettenis
-- strict thread matches above, loose matches on Subject: below --
2009-07-26 14:27 paawan oza
2009-07-26 22:51 ` Michael Snyder
2009-07-27 1:09 ` Michael Snyder
2009-07-27 2:33 ` Samuel Bronson
2009-07-06 19:09 paawan oza
2009-07-06 19:05 paawan oza
2009-07-08 9:00 ` Hui Zhu
2009-07-12 9:52 ` Michael Snyder
2009-07-12 18:12 ` Michael Snyder
2009-07-06 19:03 paawan oza
2009-07-06 19:01 paawan oza
2009-07-04 5:19 paawan oza
2009-07-05 10:15 ` Hui Zhu
2009-07-02 7:40 paawan oza
2009-07-02 3:39 paawan oza
2009-07-02 3:34 paawan oza
2009-07-01 16:17 paawan oza
2009-07-05 18:33 ` Mark Kettenis
2009-07-01 16:02 paawan oza
2009-07-01 16:14 ` Mark Kettenis
2009-07-01 16:01 paawan oza
2009-07-01 15:59 paawan oza
2009-07-02 2:02 ` Hui Zhu
2009-06-30 15:05 paawan oza
2009-07-01 5:53 ` Hui Zhu
2009-07-12 11:12 ` Michael Snyder
2009-07-12 17:47 ` paawan oza
2009-07-13 0:38 ` Michael Snyder
2009-07-13 17:03 ` Hui Zhu
2009-07-13 20:16 ` Michael Snyder
2009-07-15 9:21 ` Hui Zhu
2009-07-19 3:27 ` paawan oza
2009-07-18 23:36 ` paawan oza
2009-06-30 13:23 paawan oza
2009-06-30 13:38 ` Pedro Alves
2009-06-30 13:42 ` Mark Kettenis
2009-06-04 14:50 paawan oza
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox