aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2004-12-24 14:45:32 +0000
committerMark Kettenis <kettenis@gnu.org>2004-12-24 14:45:32 +0000
commit3d171c85e745078ae90f558ff156122855f458c1 (patch)
tree5eab1354183438893c244c7c49103c6ad6122b59 /gdb
parentb4c8d1433fcaf4c36d9e506e70ed0ac11b705ca3 (diff)
downloadgdb-3d171c85e745078ae90f558ff156122855f458c1.zip
gdb-3d171c85e745078ae90f558ff156122855f458c1.tar.gz
gdb-3d171c85e745078ae90f558ff156122855f458c1.tar.bz2
* 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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/i386-nto-tdep.c73
-rw-r--r--gdb/i386-tdep.h8
-rw-r--r--gdb/nto-tdep.c37
3 files changed, 52 insertions, 66 deletions
diff --git a/gdb/i386-nto-tdep.c b/gdb/i386-nto-tdep.c
index ad9cfe5..744b8c9 100644
--- a/gdb/i386-nto-tdep.c
+++ b/gdb/i386-nto-tdep.c
@@ -35,6 +35,9 @@
#include "nto-tdep.h"
#include "solib-svr4.h"
+/* Target vector for QNX NTO x86. */
+static struct nto_target_ops i386_nto_target;
+
#ifndef X86_CPU_FXSR
#define X86_CPU_FXSR (1L << 12)
#endif
@@ -44,47 +47,51 @@
that is just filler. Don't ask me, ask the kernel guys. */
#define NUM_GPREGS 13
-/* Map a GDB register number to an offset in the reg structure. */
-static int regmap[] = {
- (7 * 4), /* eax */
- (6 * 4), /* ecx */
- (5 * 4), /* edx */
- (4 * 4), /* ebx */
- (11 * 4), /* esp */
- (2 * 4), /* epb */
- (1 * 4), /* esi */
- (0 * 4), /* edi */
- (8 * 4), /* eip */
- (10 * 4), /* eflags */
- (9 * 4), /* cs */
- (12 * 4), /* ss */
- (-1 * 4) /* filler */
+/* Mapping between the general-purpose registers in `struct xxx'
+ format and GDB's register cache layout. */
+
+/* From <x86/context.h>. */
+static int i386nto_gregset_reg_offset[] =
+{
+ 7 * 4, /* %eax */
+ 6 * 4, /* %ecx */
+ 5 * 4, /* %edx */
+ 4 * 4, /* %ebx */
+ 11 * 4, /* %esp */
+ 2 * 4, /* %epb */
+ 1 * 4, /* %esi */
+ 0 * 4, /* %edi */
+ 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
-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
i386nto_supply_gregset (char *gpregs)
{
- unsigned regno;
- int empty = 0;
+ struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
- for (regno = 0; regno < I386_NUM_GREGS; regno++)
- {
- int offset = nto_reg_offset (regno);
- if (offset == -1)
- regcache_raw_supply (current_regcache, regno, (char *) &empty);
- else
- regcache_raw_supply (current_regcache, regno, gpregs + offset);
- }
+ if(tdep->gregset == NULL)
+ tdep->gregset = regset_alloc (current_gdbarch, i386_supply_gregset,
+ i386_collect_gregset);
+
+ gdb_assert (tdep->gregset_reg_offset == i386nto_gregset_reg_offset);
+ tdep->gregset->supply_regset (tdep->gregset, current_regcache, -1,
+ gpregs, NUM_GPREGS * 4);
}
static void
@@ -101,7 +108,7 @@ i386nto_supply_regset (int regset, char *data)
{
switch (regset)
{
- case NTO_REG_GENERAL: /* QNX has different ordering of GP regs than GDB. */
+ case NTO_REG_GENERAL:
i386nto_supply_gregset (data);
break;
case NTO_REG_FLOAT:
@@ -258,6 +265,10 @@ i386nto_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* NTO has shared libraries. */
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->sigcontext_addr = i386nto_sigcontext_addr;
tdep->sc_pc_offset = 56;
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index 29f2f27..8e51a3a 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -166,6 +166,14 @@ extern void i386_supply_gregset (const struct regset *regset,
struct regcache *regcache, int regnum,
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
by SECT_NAME and SECT_SIZE. */
extern const struct regset *
diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c
index b882a22..7cc1218 100644
--- a/gdb/nto-tdep.c
+++ b/gdb/nto-tdep.c
@@ -66,7 +66,7 @@ nto_target (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_supply_gregset = targ->supply_gregset;
@@ -345,41 +345,10 @@ enum gdb_osabi
nto_elf_osabi_sniffer (bfd *abfd)
{
if (nto_is_nto_target)
- return nto_is_nto_target (abfd);
+ return nto_is_nto_target (abfd);
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
nto_initialize_signals (void)
{
@@ -414,6 +383,4 @@ When non-zero, nto specific debug info is\n\
displayed. Different information is displayed\n\
for different positive values.", "\
QNX NTO internal debugging is %s.", NULL, NULL, &setdebuglist, &showdebuglist);
- /* Register core file support. */
- deprecated_add_core_fns (&regset_core_fns);
}