Add to go32-nat.c the code from coming DJGPP version

Robert Hoehne
1999-04-01T00:00:00Z

This patch for go32-nat.c (which is not yet part of the official
gdb snapshots) adds some code, which will be available in the
next DJGPP version. For now it is enclosed in a conditional
checking the DJGPP version.

Additionally I added the decls of all static function near the beginning
of the file.

This patch is against "a March 10th snapshot from DJ"
which I got from DJ Delorie.

Sun Mar 14 1999 Robert Hoehne <robert.hoehne@gmx.net>

* go32-nat.c: Add code for the FPU saving/restoring and adding
decls for all static functions

--- gdb-snap-march-10th-from-DJ/gdb/go32-nat.c.orig Thu Mar 11 19:56:56 1999
+++ gdb-snap-march-10th-from-DJ/gdb/go32-nat.c Sun Mar 14 16:28:42 1999
@@ -29,12 +29,72 @@
#include "command.h"
#include "floatformat.h"

+#include <stdio.h> /* required for __DJGPP_MINOR__ */
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <debug/v2load.h>
#include <debug/dbgcom.h>

+#if __DJGPP_MINOR__ < 3
+/* This code will be provided from DJGPP 2.03 on. Until then I code it
+ here */
+typedef struct {
+ unsigned short sig0;
+ unsigned short sig1;
+ unsigned short sig2;
+ unsigned short sig3;
+ unsigned short exponent:15;
+ unsigned short sign:1;
+} NPXREG;
+
+typedef struct {
+ unsigned int control;
+ unsigned int status;
+ unsigned int tag;
+ unsigned int eip;
+ unsigned int cs;
+ unsigned int dataptr;
+ unsigned int datasel;
+ NPXREG reg[8];
+} NPX;
+
+static NPX npx;
+
+static void save_npx (void); /* Save the FPU of the debugged program */
+static void load_npx (void); /* Restore the FPU of the debugged program */
+
+/* ------------------------------------------------------------------------- */
+/* Store the contents of the NPX in the global variable `npx'. */
+
+static void
+save_npx (void)
+{
+ asm ("inb $0xa0, %%al
+ testb $0x20, %%al
+ jz 1f
+ xorb %%al, %%al
+ outb %%al, $0xf0
+ movb $0x20, %%al
+ outb %%al, $0xa0
+ outb %%al, $0x20
+1:
+ fnsave %0
+ fwait"
+ : "=m" (npx)
+ : /* No input */
+ : "%eax");
+}
+/* ------------------------------------------------------------------------- */
+/* Reload the contents of the NPX from the global variable `npx'. */
+
+static void
+load_npx (void)
+{
+ asm ("frstor %0" : "=m" (npx));
+}
+#endif /* __DJGPP_MINOR < 3 */
+
extern void _initialize_go32_nat (void);

struct env387
@@ -58,9 +118,54 @@

#define SOME_PID 42

-/* FIXME add decls of all static functions here */
-
static int prog_has_started = 0;
+static void
+print_387_status (unsigned short status, struct env387 *ep);
+static void
+go32_open (char *name, int from_tty);
+static void
+go32_close (int quitting);
+static void
+go32_attach (char *args, int from_tty);
+static void
+go32_detach (char *args, int from_tty);
+static void
+go32_resume (int pid, int step, enum target_signal siggnal);
+static int
+go32_wait (int pid, struct target_waitstatus *status);
+static void
+go32_fetch_registers (int regno);
+static void
+store_register (int regno);
+static void
+go32_store_registers (int regno);
+static void
+go32_prepare_to_store (void);
+static int
+go32_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+ struct target_ops *target);
+static void
+go32_files_info (struct target_ops *target);
+static void
+go32_stop (void);
+static void
+go32_kill_inferior (void);
+static void
+go32_create_inferior (char *exec_file, char *args, char **env);
+static void
+go32_mourn_inferior (void);
+static int
+go32_can_run (void);
+static void
+ignore (void);
+static void
+ignore2 (char *a, int b);
+static int go32_insert_aligned_watchpoint (int pid, CORE_ADDR waddr,
+ CORE_ADDR addr, int len, int rw);
+static int go32_insert_nonaligned_watchpoint (int pid, CORE_ADDR waddr,
+ CORE_ADDR addr, int len, int rw);
+
+static struct target_ops go32_ops;

static void
print_387_status (unsigned short status, struct env387 *ep)
@@ -245,7 +350,13 @@
else
a_tss.tss_eflags &= 0xfeff;

+#if __DJGPP_MINOR__ < 3
+ save_npx ();
+#endif
run_child ();
+#if __DJGPP_MINOR__ < 3
+ load_npx ();
+#endif

if (a_tss.tss_irqn == 0x21)
{
@@ -522,12 +633,6 @@
#define SHOW_DR(text) do {} while (0)
#endif

-static int go32_insert_aligned_watchpoint (int pid, CORE_ADDR waddr,
- CORE_ADDR addr, int len, int rw);
-
-static int go32_insert_nonaligned_watchpoint (int pid, CORE_ADDR waddr,
- CORE_ADDR addr, int len, int rw);
-
/* Insert a watchpoint. */

int
@@ -705,8 +810,6 @@

return 0;
}
-
-static struct target_ops go32_ops;

static void
init_go32_ops (void)

******************************************************
* email: Robert Hoehne <robert.hoehne@gmx.net> *
* Post: Am Berg 3, D-09573 Dittmannsdorf, Germany *
* WWW: http://www.tu-chemnitz.de/~sho/rho *
******************************************************