/* Native debugging support for Intel x86 running DJGPP.
- Copyright 1997, 1999 Free Software Foundation, Inc.
+ Copyright 1997, 1999, 2001 Free Software Foundation, Inc.
Written by Robert Hoehne.
This file is part of GDB.
#include "command.h"
#include "floatformat.h"
#include "buildsym.h"
+#include "i387-nat.h"
+#include "regcache.h"
#include <stdio.h> /* required for __DJGPP_MINOR__ */
#include <stdlib.h>
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);
+ int write,
+ struct mem_attrib *attrib,
+ struct target_ops *target);
static void go32_files_info (struct target_ops *target);
static void go32_stop (void);
static void go32_kill_inferior (void);
point of changing back to where GDB thinks is its cwd, when we
return control to the debugger, but restore child's cwd before we
run it. */
+ /* Initialize child_cwd, before the first call to run_child and not
+ in the initialization, so the child get also the changed directory
+ set with the gdb-command "cd ..." */
+ if (!*child_cwd)
+ /* Initialize child's cwd with the current one. */
+ getcwd (child_cwd, sizeof (child_cwd));
+
chdir (child_cwd);
#if __DJGPP_MINOR__ < 3
}
static void
-go32_fetch_registers (int regno)
+fetch_register (int regno)
{
- /*JHW */
- int end_reg = regno + 1; /* just one reg initially */
-
- if (regno < 0) /* do the all registers */
- {
- regno = 0; /* start at first register */
- /* # regs in table */
- end_reg = sizeof (regno_mapping) / sizeof (regno_mapping[0]);
- }
+ 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 (__FILE__, __LINE__,
+ "Invalid register no. %d in fetch_register.", regno);
+}
- for (; regno < end_reg; regno++)
+static void
+go32_fetch_registers (int regno)
+{
+ if (regno >= 0)
+ fetch_register (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);
}
}
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 */
+ internal_error (__FILE__, __LINE__,
+ "Invalid register no. %d in store_register.", regno);
}
static void
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);
}
}
static int
go32_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
+ struct mem_attrib *attrib ATTRIBUTE_UNUSED,
struct target_ops *target ATTRIBUTE_UNUSED)
{
if (write)
}
resume_signal = -1;
resume_is_step = 0;
+
+ /* Initialize child's cwd as empty to be initialized when starting
+ the child. */
+ *child_cwd = 0;
+
/* Init command line storage. */
if (redir_debug_init (&child_cmd) == -1)
- internal_error ("Cannot allocate redirection storage: not enough memory.\n");
+ internal_error (__FILE__, __LINE__,
+ "Cannot allocate redirection storage: not enough memory.\n");
/* Parse the command line and create redirections. */
if (strpbrk (args, "<>"))
else if (what == wp_count)
rv++;
else
- status = -1;
+ status = EINVAL;
/* We keep the loop going even after a failure, because some of
the other aligned watchpoints might still succeed, e.g. if
they watch addresses that are already watched, and thus just
}
SHOW_DR (insert_hw, 0);
- return i < 4 ? 0 : -1;
+ return i < 4 ? 0 : EBUSY;
}
/* Put the device open on handle FD into either raw or cooked
go32_ops.to_has_execution = 1;
go32_ops.to_magic = OPS_MAGIC;
- /* Initialize child's cwd with the current one. */
- getcwd (child_cwd, sizeof (child_cwd));
+ /* Initialize child's cwd as empty to be initialized when starting
+ the child. */
+ *child_cwd = 0;
/* Initialize child's command line storage. */
if (redir_debug_init (&child_cmd) == -1)
- internal_error ("Cannot allocate redirection storage: not enough memory.\n");
+ internal_error (__FILE__, __LINE__,
+ "Cannot allocate redirection storage: not enough memory.\n");
/* We are always processing GCC-compiled programs. */
processing_gcc_compilation = 2;