* i386-tdep.h (i386_collect_gregset): New prototype.

* i386-nto-tdep.c (i386_nto_target): Move variable.  Add comment.
(i386nto_gregset_reg_offset): Rename frame regmap.
(nto_reg_offset): Tweak comment.  Use ARRAY_SIZE.
(i386nto_supply_gregset): Implement using register set support.
(i386nto_supply_regset): Remove redundant comment.
(i386nto_init_abi): Initialize TDEP->gregset_reg_offset,
TDEP->gregset_num_regs and TDEP->sizeof_gregset.
* nto-tdep.c (fetch_core_registers): Remove function.
(regset_core_fns): Remove structure.
(_initialize_nto_tdep): Don't call deprecated_add_core_fns.
This commit is contained in:
Mark Kettenis 2004-12-24 14:45:32 +00:00
parent b4c8d1433f
commit 3d171c85e7
3 changed files with 52 additions and 66 deletions

View file

@ -35,6 +35,9 @@
#include "nto-tdep.h" #include "nto-tdep.h"
#include "solib-svr4.h" #include "solib-svr4.h"
/* Target vector for QNX NTO x86. */
static struct nto_target_ops i386_nto_target;
#ifndef X86_CPU_FXSR #ifndef X86_CPU_FXSR
#define X86_CPU_FXSR (1L << 12) #define X86_CPU_FXSR (1L << 12)
#endif #endif
@ -44,47 +47,51 @@
that is just filler. Don't ask me, ask the kernel guys. */ that is just filler. Don't ask me, ask the kernel guys. */
#define NUM_GPREGS 13 #define NUM_GPREGS 13
/* Map a GDB register number to an offset in the reg structure. */ /* Mapping between the general-purpose registers in `struct xxx'
static int regmap[] = { format and GDB's register cache layout. */
(7 * 4), /* eax */
(6 * 4), /* ecx */ /* From <x86/context.h>. */
(5 * 4), /* edx */ static int i386nto_gregset_reg_offset[] =
(4 * 4), /* ebx */ {
(11 * 4), /* esp */ 7 * 4, /* %eax */
(2 * 4), /* epb */ 6 * 4, /* %ecx */
(1 * 4), /* esi */ 5 * 4, /* %edx */
(0 * 4), /* edi */ 4 * 4, /* %ebx */
(8 * 4), /* eip */ 11 * 4, /* %esp */
(10 * 4), /* eflags */ 2 * 4, /* %epb */
(9 * 4), /* cs */ 1 * 4, /* %esi */
(12 * 4), /* ss */ 0 * 4, /* %edi */
(-1 * 4) /* filler */ 8 * 4, /* %eip */
10 * 4, /* %eflags */
9 * 4, /* %cs */
12 * 4, /* %ss */
-1 /* filler */
}; };
static struct nto_target_ops i386_nto_target; /* Given a GDB register number REGNUM, return the offset into
Neutrino's register structure or -1 if the register is unknown. */
/* Given a gdb regno, return the offset into Neutrino's register structure
or -1 if register is unknown. */
static int static int
nto_reg_offset (int regno) nto_reg_offset (int regnum)
{ {
return (regno >= 0 && regno < NUM_GPREGS) ? regmap[regno] : -1; if (regnum >= 0 && regnum < ARRAY_SIZE (i386nto_gregset_reg_offset))
return i386nto_gregset_reg_offset[regnum];
return -1;
} }
static void static void
i386nto_supply_gregset (char *gpregs) i386nto_supply_gregset (char *gpregs)
{ {
unsigned regno; struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
int empty = 0;
for (regno = 0; regno < I386_NUM_GREGS; regno++) if(tdep->gregset == NULL)
{ tdep->gregset = regset_alloc (current_gdbarch, i386_supply_gregset,
int offset = nto_reg_offset (regno); i386_collect_gregset);
if (offset == -1)
regcache_raw_supply (current_regcache, regno, (char *) &empty); gdb_assert (tdep->gregset_reg_offset == i386nto_gregset_reg_offset);
else tdep->gregset->supply_regset (tdep->gregset, current_regcache, -1,
regcache_raw_supply (current_regcache, regno, gpregs + offset); gpregs, NUM_GPREGS * 4);
}
} }
static void static void
@ -101,7 +108,7 @@ i386nto_supply_regset (int regset, char *data)
{ {
switch (regset) switch (regset)
{ {
case NTO_REG_GENERAL: /* QNX has different ordering of GP regs than GDB. */ case NTO_REG_GENERAL:
i386nto_supply_gregset (data); i386nto_supply_gregset (data);
break; break;
case NTO_REG_FLOAT: case NTO_REG_FLOAT:
@ -258,6 +265,10 @@ i386nto_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* NTO has shared libraries. */ /* NTO has shared libraries. */
set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target); set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
tdep->gregset_reg_offset = i386nto_gregset_reg_offset;
tdep->gregset_num_regs = ARRAY_SIZE (i386nto_gregset_reg_offset);
tdep->sizeof_gregset = NUM_GPREGS * 4;
tdep->sigtramp_p = i386nto_sigtramp_p; tdep->sigtramp_p = i386nto_sigtramp_p;
tdep->sigcontext_addr = i386nto_sigcontext_addr; tdep->sigcontext_addr = i386nto_sigcontext_addr;
tdep->sc_pc_offset = 56; tdep->sc_pc_offset = 56;

View file

@ -166,6 +166,14 @@ extern void i386_supply_gregset (const struct regset *regset,
struct regcache *regcache, int regnum, struct regcache *regcache, int regnum,
const void *gregs, size_t len); const void *gregs, size_t len);
/* Collect register REGNUM from the register cache REGCACHE and store
it in the buffer specified by GREGS and LEN as described by the
general-purpose register set REGSET. If REGNUM is -1, do this for
all registers in REGSET. */
extern void i386_collect_gregset (const struct regset *regset,
const struct regcache *regcache,
int regnum, void *gregs, size_t len);
/* Return the appropriate register set for the core section identified /* Return the appropriate register set for the core section identified
by SECT_NAME and SECT_SIZE. */ by SECT_NAME and SECT_SIZE. */
extern const struct regset * extern const struct regset *

View file

@ -66,7 +66,7 @@ nto_target (void)
} }
void void
nto_set_target(struct nto_target_ops *targ) nto_set_target (struct nto_target_ops *targ)
{ {
nto_regset_id = targ->regset_id; nto_regset_id = targ->regset_id;
nto_supply_gregset = targ->supply_gregset; nto_supply_gregset = targ->supply_gregset;
@ -349,37 +349,6 @@ nto_elf_osabi_sniffer (bfd *abfd)
return GDB_OSABI_UNKNOWN; return GDB_OSABI_UNKNOWN;
} }
static void
fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
int which, CORE_ADDR reg_addr)
{
nto_regset_t regset;
/* See corelow.c:get_core_registers for values of WHICH. */
if (which == 0)
{
memcpy ((char *) &regset, core_reg_sect,
min (core_reg_size, sizeof (regset)));
nto_supply_gregset ((char *) &regset);
}
else if (which == 2)
{
memcpy ((char *) &regset, core_reg_sect,
min (core_reg_size, sizeof (regset)));
nto_supply_fpregset ((char *) &regset);
}
}
/* Register that we are able to handle ELF file formats using standard
procfs "regset" structures. */
static struct core_fns regset_core_fns = {
bfd_target_elf_flavour, /* core_flavour */
default_check_format, /* check_format */
default_core_sniffer, /* core_sniffer */
fetch_core_registers, /* core_read_registers */
NULL /* next */
};
void void
nto_initialize_signals (void) nto_initialize_signals (void)
{ {
@ -414,6 +383,4 @@ When non-zero, nto specific debug info is\n\
displayed. Different information is displayed\n\ displayed. Different information is displayed\n\
for different positive values.", "\ for different positive values.", "\
QNX NTO internal debugging is %s.", NULL, NULL, &setdebuglist, &showdebuglist); QNX NTO internal debugging is %s.", NULL, NULL, &setdebuglist, &showdebuglist);
/* Register core file support. */
deprecated_add_core_fns (&regset_core_fns);
} }