This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: FLOAT INFO QUESTION (fwd)
- To: takis at xfree86 dot org
- Subject: Re: FLOAT INFO QUESTION (fwd)
- From: Mark Kettenis <kettenis at wins dot uva dot nl>
- Date: Thu, 22 Jun 2000 19:46:32 +0200
- CC: gdb-patches at sourceware dot cygnus dot com, msnyder at cygnus dot com
- References: <39523E2C.7CF3@cygnus.com>
Date: Thu, 22 Jun 2000 06:47:32 -0700 (PDT)
From: takis@xfree86.org
Hello,
I had a look in the new float info routines
of gdb 5.0 and I am a little confused. If you look
in <linux/processor.h> you will find that the 387
structure is like
cwd (fctrl)
swd (fstat)
twd (ftag)
fip
fcs
foo
80 bytes = 8*10
status
Yes, this is the layout used by the fsave and frstor floating point
instructions. Most systems that support x86 floating point use this
layout.
Now in the operating system that I run (aka DG/UX unix)
and want to do a port of 5.0, I find the structure:
struct fpregset {
union{
struct fpchip_state fpchip_state;
emulation struct
int f_fpreg[62];
}
long f_wregs[33]; /* weitek */
}
Where: struct fpchip_state {
int state[27];
int status;
}
So the first member reserves 108 bytes = 7 4 bytes fpregs + 8 *10.
Tah agrees with the linux idea.
Great, that means that support the FPU is probably not too difficult!
The stuff marked with /* weitek */ is probably for systems that have a
Weitek FPU instead of an Intel i387 FPU. Supporting those may be
difficult. But I don't think there are a lot of systems that have one
around anymore.
Now in GDB-5.0 we find in tm-i386.h a new layout as
fctrl, fstat, ftag, fiseg, fioff, foseg, fooff, fop
Which is clearly different from the struct of linux. Basically
if I want to unpack fpchip_state above to floating regs I dont know
if the order is fctrl, fstat, ftag , fiseg(=fcs), fioff(=?) , ????
or (what I always thought is)
fctrl,fstat,ftag,fip,fcs,fopoff,fopsel,status
And in this new layout in tm-i386.h which one is the status? I
clearly have 108 bytes so how I would obtain the fop
mentioned in tm-i386.h?
This stuff is a bit complicated. GDB sees all FPU control registers
as being 4 bytes long. But some of them are actually shorter. You
should be able to determine how things work by looking at the code in
i386-linux-nat.c. You might also want to consult the Intel ia32
processor manuals (you can get those in PDF from developer.intel.com).
Anyway, I recently added the file i387-nat.c to GDB (you can find it
in the CVS tree, but not in GDB 5.0). It defines two functions
i387_supply_fsave() and i387_fill_fsave() that convert back and forth
between the fsave format used by the FPU and the format used by GDB.
I'd like to encourage you to use these functions if possible.
Suppose you have the fpu registers in a struct fpregset `fpregs'.
Then you can simply call
i386_supply_fsave (&fpregs);
to let GDB know about the FPU registers. Take a look at i386bsd.c for
a real-life example on how to use these functions.
Mark