This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] go32-nat.c to use i387-nat.c
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: [PATCH] go32-nat.c to use i387-nat.c
- From: Eli Zaretskii <eliz at is dot elta dot co dot il>
- Date: Sun, 18 Feb 2001 09:35:09 +0200 (IST)
FYI: I committed today the following patches, that make go32-nat.c use
i387-nat.c functions for fetching and storing x87 registers.
Thanks to Mark for making it so easy with the latest changes to
i387-nat.c.
2001-02-18 Eli Zaretskii <eliz@is.elta.co.il>
* go32-nat.c: Include i387-nat.h.
(fetch_register): New function, uses some of the guts of
go32_fetch_registers and calls i387_supply_register.
(go32_fetch_registers): Most of the code moved into
fetch_register. Use i387_supply_fsave.
(store_register): Use i387_fill_fsave instead of custom code.
(go32_store_registers): Use i387_fill_fsave.
* Makefile.in (go32-nat.o): Depend on i387-nat.h.
* config/i386/go32.mh (NATDEPFILES): Add i387-nat.o.
--- gdb/go32-nat.c~0 Sat Feb 3 18:44:52 2001
+++ gdb/go32-nat.c Wed Feb 7 22:40:40 2001
@@ -28,6 +28,7 @@
#include "command.h"
#include "floatformat.h"
#include "buildsym.h"
+#include "i387-nat.h"
#include <stdio.h> /* required for __DJGPP_MINOR__ */
#include <stdlib.h>
@@ -450,54 +451,29 @@ go32_wait (int pid ATTRIBUTE_UNUSED, str
}
static void
-go32_fetch_registers (int regno)
+fetch_register (int regno)
{
- /*JHW */
- int end_reg = regno + 1; /* just one reg initially */
+ if (regno < FP0_REGNUM)
+ supply_register (regno, (char *) &a_tss + regno_mapping[regno].tss_ofs);
+ else if (regno <= LAST_FPU_CTRL_REGNUM)
+ i387_supply_register (regno, (char *) &npx);
+ else
+ internal_error ("Invalid register no. %d in fetch_register.", regno);
+}
- if (regno < 0) /* do the all registers */
+static void
+go32_fetch_registers (int regno)
+{
+ if (regno >= 0)
{
- regno = 0; /* start at first register */
- /* # regs in table */
- end_reg = sizeof (regno_mapping) / sizeof (regno_mapping[0]);
+ fetch_register (regno);
}
- for (; regno < end_reg; regno++)
+ else
{
- if (regno < 16)
- supply_register (regno,
- (char *) &a_tss + regno_mapping[regno].tss_ofs);
- else if (regno < 24)
- supply_register (regno,
- (char *) &npx.reg[regno_mapping[regno].tss_ofs]);
- else if (regno < 32)
- {
- unsigned regval;
-
- switch (regno_mapping[regno].size)
- {
- case 2:
- regval = *(unsigned short *)
- ((char *) &npx + regno_mapping[regno].tss_ofs);
- regval &= 0xffff;
- if (regno == FOP_REGNUM && regval)
- /* Feature: restore the 5 bits of the opcode
- stripped by FSAVE/FNSAVE. */
- regval |= 0xd800;
- break;
- case 4:
- regval = *(unsigned *)
- ((char *) &npx + regno_mapping[regno].tss_ofs);
- break;
- default:
- internal_error ("\
-Invalid native size for register no. %d in go32_fetch_register.", regno);
- }
- supply_register (regno, (char *) ®val);
- }
- else
- internal_error ("Invalid register no. %d in go32_fetch_register.",
- regno);
+ for (regno = 0; regno < FP0_REGNUM; regno++)
+ fetch_register (regno);
+ i387_supply_fsave ((char *) &npx);
}
}
@@ -507,17 +483,13 @@ store_register (int regno)
void *rp;
void *v = (void *) ®isters[REGISTER_BYTE (regno)];
- if (regno < 16)
- rp = (char *) &a_tss + regno_mapping[regno].tss_ofs;
- else if (regno < 24)
- rp = (char *) &npx.reg[regno_mapping[regno].tss_ofs];
- else if (regno < 32)
- rp = (char *) &npx + regno_mapping[regno].tss_ofs;
+ if (regno < FP0_REGNUM)
+ memcpy ((char *) &a_tss + regno_mapping[regno].tss_ofs,
+ v, regno_mapping[regno].size);
+ else if (regno <= LAST_FPU_CTRL_REGNUM)
+ i387_fill_fsave ((char *)&npx, regno);
else
internal_error ("Invalid register no. %d in store_register.", regno);
- memcpy (rp, v, regno_mapping[regno].size);
- if (regno == FOP_REGNUM)
- *(short *)rp &= 0x07ff; /* strip high 5 bits, in case they added them */
}
static void
@@ -529,8 +501,9 @@ go32_store_registers (int regno)
store_register (regno);
else
{
- for (r = 0; r < sizeof (regno_mapping) / sizeof (regno_mapping[0]); r++)
+ for (r = 0; r < FP0_REGNUM; r++)
store_register (r);
+ i387_fill_fsave ((char *) &npx, -1);
}
}
Index: src/gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.61
retrieving revision 1.62
diff -c -r1.61 -r1.62
*** Makefile.in 2001/02/09 01:47:34 1.61
--- Makefile.in 2001/02/18 07:22:16 1.62
***************
*** 1450,1456 ****
$(value_h) gdb_string.h wrapper.h
go32-nat.o: go32-nat.c $(defs_h) $(inferior_h) gdb_wait.h $(gdbcore_h) \
! $(command_h) $(floatformat_h) target.h
gnu-nat.o: process_reply_S.h exc_request_S.h notify_S.h msg_reply_S.h \
exc_request_U.h msg_U.h gnu-nat.h
--- 1450,1456 ----
$(value_h) gdb_string.h wrapper.h
go32-nat.o: go32-nat.c $(defs_h) $(inferior_h) gdb_wait.h $(gdbcore_h) \
! $(command_h) $(floatformat_h) target.h i387-nat.h
gnu-nat.o: process_reply_S.h exc_request_S.h notify_S.h msg_reply_S.h \
exc_request_U.h msg_U.h gnu-nat.h
Index: src/gdb/config/i386/go32.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/go32.mh,v
retrieving revision 1.2
retrieving revision 1.3
diff -c -r1.2 -r1.3
*** go32.mh 2000/06/12 06:09:05 1.2
--- go32.mh 2001/02/18 07:22:17 1.3
***************
*** 8,14 ****
XDEPFILES=
NAT_FILE= nm-go32.h
! NATDEPFILES= go32-nat.o
TERMCAP=
HOST_IPC=
--- 8,14 ----
XDEPFILES=
NAT_FILE= nm-go32.h
! NATDEPFILES= go32-nat.o i387-nat.o
TERMCAP=
HOST_IPC=