This is the mail archive of the
gdb@sourceware.cygnus.com
mailing list for the GDB project.
A patch for x86 FPU
- To: gdb AT sourceware.cygnus dot com (GDB)
- Subject: A patch for x86 FPU
- From: hjl AT varesearch dot com (H.J. Lu)
- Date: Tue, 14 Sep 1999 12:03:59 -0700 (PDT)
With this kludge, I built gdb on both Linux/x86 and Solaris 7/x86.
--
H.J. Lu (hjl@gnu.org)
--
Tue Sep 14 11:48:49 1999 H.J. Lu <hjl@gnu.org>
* config/i386/tm-i386.h (FPC_REGNUM): Defined as -1
(FPCONTROL_REGNUM, FPSTATUS_REGNUM, FPTAG_REGNUM, FPIPO_REGNUM,
FPIPS_REGNUM, FPOOS_REGNUM, FPOPS_REGNUM): New.
* config/i386/tm-linux.h (FPSTART_REGNUM): Undefine it before
defining.
(FPCONTROL_REGNUM): Likewise.
(FPSTATUS_REGNUM): Likewise.
(FPTAG_REGNUM): Likewise.
(FPDATA_REGNUM): Likewise.
(FPEND_REGNUM): Likewise.
* i386-tdep.c (i386_extract_return_value): Protect
LOW_RETURN_REGNUM.
(i386_print_register): Protect FPSTART_REGNUM.
* i387-tdep.c (i387_print_register): Check FPREG_RAW_SIZE only
if it is defined. Protect FPDATA_REGNUM and FPSTART_REGNUM.
* config/i386/xm-i386sol2.h: New.
* config/i386/i386sol2.mh (XM_FILE): Set to xm-i386sol2.h.
Index: config/i386/tm-i386.h
===================================================================
RCS file: /work/cvs/gnu/gdb/gdb/config/i386/tm-i386.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 tm-i386.h
--- config/i386/tm-i386.h 1999/09/09 00:38:38 1.1.1.1
+++ config/i386/tm-i386.h 1999/09/14 17:37:28
@@ -108,7 +108,15 @@ extern int i386_skip_prologue PARAMS ((i
#define PS_REGNUM 9 /* (ps) Contains processor status */
#define FP0_REGNUM 16 /* (st0) 387 register */
-#define FPC_REGNUM 25 /* 80387 control register */
+#define FPC_REGNUM -1 /* 80387 control register */
+
+#define FPCONTROL_REGNUM FPC_REGNUM
+#define FPSTATUS_REGNUM -1 /* FPU status register */
+#define FPTAG_REGNUM -1 /* FPU tag register */
+#define FPIPO_REGNUM -1 /* FPU instruction pointer offset register */
+#define FPIPS_REGNUM -1 /* FPU instruction pointer selector egister */
+#define FPOOS_REGNUM -1 /* FPU operand pointer offset register */
+#define FPOPS_REGNUM -1 /* FPU operand pointer selector register */
/* Total amount of space needed to store our copies of the machine's register
state, the array `registers'. */
Index: config/i386/i386sol2.mh
===================================================================
RCS file: /work/cvs/gnu/gdb/gdb/config/i386/i386sol2.mh,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 i386sol2.mh
--- config/i386/i386sol2.mh 1999/09/09 00:38:38 1.1.1.1
+++ config/i386/i386sol2.mh 1999/09/14 18:28:46
@@ -1,6 +1,6 @@
# Host: Intel 386 running Solaris 2 (SVR4)
-XM_FILE= xm-i386v4.h
+XM_FILE= xm-i386sol2.h
XDEPFILES=
NAT_FILE= nm-i386sol2.h
Index: i386-tdep.c
===================================================================
RCS file: /work/cvs/gnu/gdb/gdb/i386-tdep.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 i386-tdep.c
--- i386-tdep.c 1999/09/09 00:38:38 1.1.1.1
+++ i386-tdep.c 1999/09/14 16:56:54
@@ -691,6 +691,7 @@ i386_extract_return_value (type, regbuf,
else
#endif /* I386_AIX_TARGET || I386_GNULINUX_TARGET*/
{
+#ifdef LOW_RETURN_REGNUM
int len = TYPE_LENGTH (type);
int low_size = REGISTER_RAW_SIZE (LOW_RETURN_REGNUM);
int high_size = REGISTER_RAW_SIZE (HIGH_RETURN_REGNUM);
@@ -708,6 +709,9 @@ i386_extract_return_value (type, regbuf,
}
else
error ("GDB bug: i386-tdep.c (i386_extract_return_value): Don't know how to find a return value %d bytes long", len);
+#else /* LOW_RETURN_REGNUM */
+ memcpy (valbuf, regbuf, TYPE_LENGTH (type));
+#endif /* LOW_RETURN_REGNUM */
}
}
@@ -961,6 +965,8 @@ set_disassembly_flavor ()
set_architecture_from_arch_mach (bfd_arch_i386, bfd_mach_i386_i386_intel_syntax);
}
+#ifdef FPSTART_REGNUM
+
/* Print the register regnum, or all registers if regnum is -1 */
void
@@ -1005,6 +1011,8 @@ i386_print_register (raw_regs, regnum, f
for (i = FPSTART_REGNUM; i < FPEND_REGNUM; i++)
i387_print_register (raw_regs, i);
}
+
+#endif /* FPSTART_REGNUM */
void
_initialize_i386_tdep ()
Index: i387-tdep.c
===================================================================
RCS file: /work/cvs/gnu/gdb/gdb/i387-tdep.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 i387-tdep.c
--- i387-tdep.c 1999/09/14 14:51:26 1.1.1.2
+++ i387-tdep.c 1999/09/14 18:53:36
@@ -160,21 +160,48 @@ i387_print_register (raw_regs, regnum)
unsigned swd, tags, expon, top, norm, ls, ms;
char string[12];
-#if (FPREG_RAW_SIZE != 10)
+#if defined(FPREG_RAW_SIZE) && (FPREG_RAW_SIZE != 10)
#error "Bad FPREG_RAW_SIZE"
#endif
printf_filtered ("%8.8s: ", REGISTER_NAME (regnum));
+#ifdef FPDATA_REGNUM
if (regnum < FPDATA_REGNUM)
+#else
+ if (REGISTER_RAW_SIZE (regnum) == 4)
+#endif
{
val = extract_unsigned_integer (raw_regs + REGISTER_BYTE (regnum), 4);
+#ifdef FPSTART_REGNUM
if ( (regnum < FPSTART_REGNUM + 3) ||
(regnum == FPSTART_REGNUM + 6) )
/* Don't print the un-modifiable bytes. */
sprintf(string, "0x%04x", val & 0xffff);
else
sprintf(string, "0x%08x", val);
+#else
+ switch (regnum)
+ {
+ case FPCONTROL_REGNUM:
+#if FPSTATUS_REGNUM != -1
+ case FPSTATUS_REGNUM:
+#endif
+#if FPTAG_REGNUM != -1
+ case FPTAG_REGNUM:
+#endif
+#if FPOPS_REGNUM != -1
+ case FPOPS_REGNUM:
+#endif
+ /* Don't print the un-modifiable bytes. */
+ sprintf(string, "0x%04x", val & 0xffff);
+ break;
+ default:
+ sprintf(string, "0x%08x", val);
+ break;
+ }
+#endif
+
printf_unfiltered ("%10.10s", string);
if (regnum == FPCONTROL_REGNUM)
@@ -185,8 +212,12 @@ i387_print_register (raw_regs, regnum)
else
{
/* An FPU stack register. */
+#ifdef FPREG_RAW_SIZE
if ( REGISTER_RAW_SIZE (regnum) != FPREG_RAW_SIZE )
error ("GDB bug: i387-tdep.c (i387_print_register): wrong size for FPU stack register");
+#else
+#define FPREG_RAW_SIZE REGISTER_RAW_SIZE (regnum)
+#endif
/* Put the data in the buffer. No conversions are ever necessary. */
memcpy (virtual_buffer, raw_regs + REGISTER_BYTE (regnum),
@@ -206,6 +237,9 @@ i387_print_register (raw_regs, regnum)
puts_unfiltered (" ");
special = 0;
+#ifndef FPDATA_REGNUM
+#define FPDATA_REGNUM FP0_REGNUM
+#endif
switch ((tags >> (((regnum - FPDATA_REGNUM + top) & 7) * 2)) & 3)
{
case 0: puts_unfiltered ("Valid "); break;
@@ -278,6 +312,7 @@ i387_print_register (raw_regs, regnum)
void i387_float_info(void)
{
+#ifdef FPSTART_REGNUM
char raw_regs [REGISTER_BYTES];
int i;
@@ -286,6 +321,7 @@ void i387_float_info(void)
for (i = FPSTART_REGNUM; i <= FPEND_REGNUM; i++)
i387_print_register (raw_regs, i);
+#endif
}
#ifdef LD_I387
--- /dev/null Tue May 5 13:32:27 1998
+++ config/i386/xm-i386sol2.h Tue Sep 14 11:29:56 1999
@@ -0,0 +1,6 @@
+#include "i386/xm-i386v4.h"
+
+/* On sol2.7, <curses.h> emits a bunch of 'macro redefined'
+ warnings, which makes autoconf think curses.h doesn't
+ exist. Compensate fot that here. */
+#define HAVE_CURSES_H 1
Index: config/i386/tm-linux.h
===================================================================
RCS file: /work/cvs/gnu/gdb/gdb/config/i386/tm-linux.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 tm-linux.h
--- config/i386/tm-linux.h 1999/09/09 00:38:38 1.1.1.1
+++ config/i386/tm-linux.h 1999/09/14 18:58:49
@@ -74,11 +75,17 @@
#define LOW_RETURN_REGNUM 0 /* holds low four bytes of result */
#define HIGH_RETURN_REGNUM 2 /* holds high four bytes of result */
+#undef FPSTART_REGNUM
#define FPSTART_REGNUM 16 /* start of FPU registers */
+#undef FPCONTROL_REGNUM
#define FPCONTROL_REGNUM 16 /* FPU control register */
+#undef FPSTATUS_REGNUM
#define FPSTATUS_REGNUM 17 /* FPU status register */
+#undef FPTAG_REGNUM
#define FPTAG_REGNUM 18 /* FPU tag register */
+#undef FPDATA_REGNUM
#define FPDATA_REGNUM 23 /* actual floating-point values */
+#undef FPEND_REGNUM
#define FPEND_REGNUM (FPSTART_REGNUM + 14) /* last FPU register */
#define FPENV_BYTES (7 * 4)