aboutsummaryrefslogtreecommitdiff
path: root/gdb/i386nbsd-nat.c
diff options
context:
space:
mode:
authorJason Thorpe <thorpej@netbsd.org>2002-01-05 18:36:32 +0000
committerJason Thorpe <thorpej@netbsd.org>2002-01-05 18:36:32 +0000
commit7e89e3575daf98bac9dece8abfab33dc42664626 (patch)
treed71aa1e80a63622dbc0b9023d444fb7d00c009c0 /gdb/i386nbsd-nat.c
parent3dfe7a8c3a88e7b06afe7f8b98d247de175bec99 (diff)
downloadgdb-7e89e3575daf98bac9dece8abfab33dc42664626.zip
gdb-7e89e3575daf98bac9dece8abfab33dc42664626.tar.gz
gdb-7e89e3575daf98bac9dece8abfab33dc42664626.tar.bz2
* acconfig.h (HAVE_PT_GETXMMREGS): New.
* config.in: Regenerate. * configure.in: Update copyright years. Add test for PT_GETXMMREGS supplied by <sys/ptrace.h>. * configure: Regenerate. * i386bsd-nat.c: Update copyright years. (fill_gregset): Use regcache_collect. (fetch_inferior_registers): Only fetch integer registers if requested to do so. Add support for XMM registers using PT_GETXMMREGS. (store_inferior_registers): Only store integer registers if requested to do so. Add support for XMM registers using PT_SETXMMREGS. * i386nbsd-nat.c (fetch_inferior_registers): Remove. (store_inferior_registers): Remove. (fetch_core_registers): Use supply_gregset and i387_supply_fsave. (fetch_elfcore_registers): New function. (i386nbsd_elfcore_fns): New. (_initialize_i386nbsd_nat): Register i386nbsd_elfcore_fns. * config/i386/nbsd.mh (NATDEPFILES): Add i387-nat.o and i386bsd-nat.o. * config/i386/nbsdelf.mh (NATDEPFILES): Likewise. * config/i386/nbsd.mt (TDEPFILES): Add i386bsd-nat.o. * config/i386/nbsdelf.mt (TDEPFILES): Likewise. * config/i386/tm-nbsd.h: Update copyright years. (HAVE_SSE_REGS): Define. (IN_SIGTRAMP): Define as i386bsd_in_sigtramp. (SIGTRAMP_START): Redefine as i386bsd_sigtramp_start. (SIGTRAMP_END): Redefine as i386bsd_sigtramp_end. (SIGCONTEXT_PC_OFFSET): Remove. (FRAME_SAVED_PC): Define as i386bsd_frame_saved_pc.
Diffstat (limited to 'gdb/i386nbsd-nat.c')
-rw-r--r--gdb/i386nbsd-nat.c218
1 files changed, 71 insertions, 147 deletions
diff --git a/gdb/i386nbsd-nat.c b/gdb/i386nbsd-nat.c
index a3d5d63..32a3d78 100644
--- a/gdb/i386nbsd-nat.c
+++ b/gdb/i386nbsd-nat.c
@@ -25,136 +25,26 @@
#include <machine/reg.h>
#include <machine/frame.h>
#include "inferior.h"
-#include "gdbcore.h" /* for registers_fetched() */
+#include "gdbcore.h"
#include "regcache.h"
-/* Defines for XMM0_REGNUM etc. */
-#include "i386-tdep.h"
-
-#define RF(dst, src) \
- memcpy(&registers[REGISTER_BYTE(dst)], &src, sizeof(src))
-
-#define RS(src, dst) \
- memcpy(&dst, &registers[REGISTER_BYTE(src)], sizeof(dst))
-
-struct env387
- {
- unsigned short control;
- unsigned short r0;
- unsigned short status;
- unsigned short r1;
- unsigned short tag;
- unsigned short r2;
- unsigned long eip;
- unsigned short code_seg;
- unsigned short opcode;
- unsigned long operand;
- unsigned short operand_seg;
- unsigned short r3;
- unsigned char regs[8][10];
- };
+#ifndef HAVE_GREGSET_T
+typedef struct reg gregset_t;
+#endif
-void
-fetch_inferior_registers (int regno)
-{
- struct reg inferior_registers;
- struct env387 inferior_fpregisters;
-
- ptrace (PT_GETREGS, PIDGET (inferior_ptid),
- (PTRACE_ARG3_TYPE) &inferior_registers, 0);
- ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
- (PTRACE_ARG3_TYPE) &inferior_fpregisters, 0);
-
- RF ( 0, inferior_registers.r_eax);
- RF ( 1, inferior_registers.r_ecx);
- RF ( 2, inferior_registers.r_edx);
- RF ( 3, inferior_registers.r_ebx);
- RF ( 4, inferior_registers.r_esp);
- RF ( 5, inferior_registers.r_ebp);
- RF ( 6, inferior_registers.r_esi);
- RF ( 7, inferior_registers.r_edi);
- RF ( 8, inferior_registers.r_eip);
- RF ( 9, inferior_registers.r_eflags);
- RF (10, inferior_registers.r_cs);
- RF (11, inferior_registers.r_ss);
- RF (12, inferior_registers.r_ds);
- RF (13, inferior_registers.r_es);
- RF (14, inferior_registers.r_fs);
- RF (15, inferior_registers.r_gs);
-
- RF (FP0_REGNUM, inferior_fpregisters.regs[0]);
- RF (FP0_REGNUM + 1, inferior_fpregisters.regs[1]);
- RF (FP0_REGNUM + 2, inferior_fpregisters.regs[2]);
- RF (FP0_REGNUM + 3, inferior_fpregisters.regs[3]);
- RF (FP0_REGNUM + 4, inferior_fpregisters.regs[4]);
- RF (FP0_REGNUM + 5, inferior_fpregisters.regs[5]);
- RF (FP0_REGNUM + 6, inferior_fpregisters.regs[6]);
- RF (FP0_REGNUM + 7, inferior_fpregisters.regs[7]);
-
- RF (FCTRL_REGNUM, inferior_fpregisters.control);
- RF (FSTAT_REGNUM, inferior_fpregisters.status);
- RF (FTAG_REGNUM, inferior_fpregisters.tag);
- RF (FCS_REGNUM, inferior_fpregisters.code_seg);
- RF (FCOFF_REGNUM, inferior_fpregisters.eip);
- RF (FDS_REGNUM, inferior_fpregisters.operand_seg);
- RF (FDOFF_REGNUM, inferior_fpregisters.operand);
- RF (FOP_REGNUM, inferior_fpregisters.opcode);
-
- registers_fetched ();
-}
+#ifndef HAVE_FPREGSET_T
+typedef struct fpreg fpregset_t;
+#endif
+
+#include "gregset.h"
+
+/* Prototypes for i387_supply_fsave etc. */
+#include "i387-nat.h"
-void
-store_inferior_registers (int regno)
-{
- struct reg inferior_registers;
- struct env387 inferior_fpregisters;
-
- RS ( 0, inferior_registers.r_eax);
- RS ( 1, inferior_registers.r_ecx);
- RS ( 2, inferior_registers.r_edx);
- RS ( 3, inferior_registers.r_ebx);
- RS ( 4, inferior_registers.r_esp);
- RS ( 5, inferior_registers.r_ebp);
- RS ( 6, inferior_registers.r_esi);
- RS ( 7, inferior_registers.r_edi);
- RS ( 8, inferior_registers.r_eip);
- RS ( 9, inferior_registers.r_eflags);
- RS (10, inferior_registers.r_cs);
- RS (11, inferior_registers.r_ss);
- RS (12, inferior_registers.r_ds);
- RS (13, inferior_registers.r_es);
- RS (14, inferior_registers.r_fs);
- RS (15, inferior_registers.r_gs);
-
-
- RS (FP0_REGNUM, inferior_fpregisters.regs[0]);
- RS (FP0_REGNUM + 1, inferior_fpregisters.regs[1]);
- RS (FP0_REGNUM + 2, inferior_fpregisters.regs[2]);
- RS (FP0_REGNUM + 3, inferior_fpregisters.regs[3]);
- RS (FP0_REGNUM + 4, inferior_fpregisters.regs[4]);
- RS (FP0_REGNUM + 5, inferior_fpregisters.regs[5]);
- RS (FP0_REGNUM + 6, inferior_fpregisters.regs[6]);
- RS (FP0_REGNUM + 7, inferior_fpregisters.regs[7]);
-
- RS (FCTRL_REGNUM, inferior_fpregisters.control);
- RS (FSTAT_REGNUM, inferior_fpregisters.status);
- RS (FTAG_REGNUM, inferior_fpregisters.tag);
- RS (FCS_REGNUM, inferior_fpregisters.code_seg);
- RS (FCOFF_REGNUM, inferior_fpregisters.eip);
- RS (FDS_REGNUM, inferior_fpregisters.operand_seg);
- RS (FDOFF_REGNUM, inferior_fpregisters.operand);
- RS (FOP_REGNUM, inferior_fpregisters.opcode);
-
- ptrace (PT_SETREGS, PIDGET (inferior_ptid),
- (PTRACE_ARG3_TYPE) &inferior_registers, 0);
- ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
- (PTRACE_ARG3_TYPE) &inferior_fpregisters, 0);
-}
-
struct md_core
{
struct reg intreg;
- struct env387 freg;
+ char freg[108];
};
static void
@@ -163,30 +53,54 @@ fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
{
struct md_core *core_reg = (struct md_core *) core_reg_sect;
- /* integer registers */
- memcpy (&registers[REGISTER_BYTE (0)], &core_reg->intreg,
- sizeof (struct reg));
-
- /* floating point registers */
- RF (FP0_REGNUM, core_reg->freg.regs[0]);
- RF (FP0_REGNUM + 1, core_reg->freg.regs[1]);
- RF (FP0_REGNUM + 2, core_reg->freg.regs[2]);
- RF (FP0_REGNUM + 3, core_reg->freg.regs[3]);
- RF (FP0_REGNUM + 4, core_reg->freg.regs[4]);
- RF (FP0_REGNUM + 5, core_reg->freg.regs[5]);
- RF (FP0_REGNUM + 6, core_reg->freg.regs[6]);
- RF (FP0_REGNUM + 7, core_reg->freg.regs[7]);
-
- RF (FCTRL_REGNUM, core_reg->freg.control);
- RF (FSTAT_REGNUM, core_reg->freg.status);
- RF (FTAG_REGNUM, core_reg->freg.tag);
- RF (FCS_REGNUM, core_reg->freg.code_seg);
- RF (FCOFF_REGNUM, core_reg->freg.eip);
- RF (FDS_REGNUM, core_reg->freg.operand_seg);
- RF (FDOFF_REGNUM, core_reg->freg.operand);
- RF (FOP_REGNUM, core_reg->freg.opcode);
-
- registers_fetched ();
+ /* We get everything from one section. */
+ if (which != 0)
+ return;
+
+ /* Integer registers. */
+ supply_gregset (&core_reg->intreg);
+
+ /* Floating point registers. */
+ i387_supply_fsave (core_reg->freg);
+}
+
+static void
+fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size, int which,
+ CORE_ADDR ignore)
+{
+ gregset_t gregset;
+
+ switch (which)
+ {
+ case 0: /* Integer registers. */
+ if (core_reg_size != sizeof (struct reg))
+ warning ("Wrong size register set in core file.");
+ else
+ {
+ memcpy (&gregset, core_reg_sect, sizeof (gregset));
+ supply_gregset (&gregset);
+ }
+ break;
+
+ case 2: /* Floating point registers. */
+ if (core_reg_size != 108)
+ warning ("Wrong size FP register set in core file.");
+ else
+ i387_supply_fsave (core_reg_sect);
+ break;
+
+ case 3: /* "Extended" floating point registers. This is gdb-speak
+ for SSE/SSE2. */
+ if (core_reg_size != 512)
+ warning ("Wrong size XMM register set in core file.");
+ else
+ i387_supply_fxsave (core_reg_sect);
+ break;
+
+ default:
+ /* Don't know what kind of register request this is; just ignore it. */
+ break;
+ }
}
/* Register that we are able to handle i386nbsd core file formats.
@@ -201,8 +115,18 @@ static struct core_fns i386nbsd_core_fns =
NULL /* next */
};
+static struct core_fns i386nbsd_elfcore_fns =
+{
+ bfd_target_elf_flavour, /* core_flavour */
+ default_check_format, /* check_format */
+ default_core_sniffer, /* core_sniffer */
+ fetch_elfcore_registers, /* core_read_registers */
+ NULL /* next */
+};
+
void
_initialize_i386nbsd_nat (void)
{
add_core_fns (&i386nbsd_core_fns);
+ add_core_fns (&i386nbsd_elfcore_fns);
}