diff options
author | Mark Kettenis <kettenis@gnu.org> | 2003-05-31 16:08:06 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@gnu.org> | 2003-05-31 16:08:06 +0000 |
commit | a338618604d020a6e8bde2f5e298a7e41abe290c (patch) | |
tree | 3ed44cb0d3bc55d72a54291a74bd58c4e26d717c /gdb/i386bsd-nat.c | |
parent | 25ab47902d12c8ffca6ab50b2b17151f1d86ce9b (diff) | |
download | gdb-a338618604d020a6e8bde2f5e298a7e41abe290c.zip gdb-a338618604d020a6e8bde2f5e298a7e41abe290c.tar.gz gdb-a338618604d020a6e8bde2f5e298a7e41abe290c.tar.bz2 |
From Michal Ludvig <mludvig@suse.cz>:
* i386-tdep.h (struct gdbarch_tdep): Add members `sc_reg_offset'
and `sc_num_regs'.
(I386_EAX_REGNUM, I386_EDX_REGNUM, I386_ESP_REGNUM,
I386_EBP_REGNUM, I386_EIP_REGNUM, I386_EFLAGS_REGNUM,
I386_ST0_REGNUM): Move here from...
* i386-tdep.c: ... here.
(I386_NUM_SAVED_REGS): Define to I386_NUM_REGS.
(i386_sigtramp_frame_cache): Use `sc_reg_offset' to find saved
registers if possible.
(i386_gdbarch_init): Initialize TDEP->sc_reg_offset.
* i386bsd-tdep.c (i386bsd_sc_pc_offset, i386bsd_sc_sp_offset):
Remove variables.
(i386bsd_sc_reg_offset): New variable.
(i386bsd_init_abi): Initialize TDEP->sc_reg_offset and
TDEP->sc_num_regs instead of TDEP->sc_pc_offset and
TDEP->sc_sp_offset.
(i386fbsd_sc_reg_offset): New variable.
(i386fbsdaout_init_abi): Initialize TDEP->sc_reg_offset and
TDEP->sc_num_regs.
(i386fbsd4_sc_pc_offset, i386fbsd4_sc_sp_offset): Remove
variables.
(i386fbsd4_sc_reg_offset): New variable.
(i3864bsd4_init_abi): Initialize TDEP->sc_reg_offset and
TDEP->sc_num_regs instead of TDEP->sc_pc_offset and
TDEP->sc_sp_offset.
* i386-linux-tdep.c (i386_linux_sc_reg_offset): New variable.
(i386_linux_init_abi): Set TDEP->sc_reg_offset and TDEP->sc_num_regs.
* i386nbsd-tdep.c (i386nbsd_sc_pc_offset, i386nbsd_sc_sp_offset):
Remove variables.
(i386nbsd_sc_reg_offset): New variable.
(i386nbsd_init_abi): Initialize TDEP->sc_reg_offset and
TDEP->sc_num_regs instead of TDEP->sc_pc_offset and
TDEP->sc_sp_offset.
* i386obsd-tdep.c (i386obsd_sc_pc_offset, i386obsd_sc_sp_offset):
Remove variables.
(i386obsd_sc_reg_offset): New variable.
(i386obsd_init_abi): Initialize TDEP->sc_reg_offset and
TDEP->sc_num_regs instead of TDEP->sc_pc_offset and
TDEP->sc_sp_offset.
* i386bsd-nat.c (_initialize_i386bsd_nat): Adjust for changes in
i386bsd-tdep.c, i386nbsd-tdep.c and i386obsd-tdep.c. Add check
for frame pointer offset in `struct sigcontext'.
Diffstat (limited to 'gdb/i386bsd-nat.c')
-rw-r--r-- | gdb/i386bsd-nat.c | 71 |
1 files changed, 44 insertions, 27 deletions
diff --git a/gdb/i386bsd-nat.c b/gdb/i386bsd-nat.c index ec38e13..60524de 100644 --- a/gdb/i386bsd-nat.c +++ b/gdb/i386bsd-nat.c @@ -386,8 +386,7 @@ kernel_u_size (void) void _initialize_i386bsd_nat (void) { - int sc_pc_offset; - int sc_sp_offset; + int offset; /* To support the recognition of signal handlers, i386bsd-tdep.c hardcodes some constants. Inclusion of this file means that we @@ -396,51 +395,69 @@ _initialize_i386bsd_nat (void) information. */ #if defined (__FreeBSD_version) && __FreeBSD_version >= 400011 - extern int i386fbsd4_sc_pc_offset; - extern int i386fbsd4_sc_sp_offset; -#define SC_PC_OFFSET i386fbsd4_sc_pc_offset -#define SC_SP_OFFSET i386fbsd4_sc_sp_offset + extern int i386fbsd4_sc_reg_offset[]; +#define SC_REG_OFFSET i386fbsd4_sc_reg_offset +#elif defined (__FreeBSD_version) && __FreeBSD_version >= 300005 + extern int i386fbsd_sc_reg_offset[]; +#define SC_REG_OFFSET i386fbsd_sc_reg_offset #elif defined (NetBSD) || defined (__NetBSD_Version__) - extern int i386nbsd_sc_pc_offset; - extern int i386nbsd_sc_sp_offset; -#define SC_PC_OFFSET i386nbsd_sc_pc_offset -#define SC_SP_OFFSET i386nbsd_sc_sp_offset + extern int i386nbsd_sc_reg_offset[]; +#define SC_REG_OFFSET i386nbsd_sc_reg_offset #elif defined (OpenBSD) - extern int i386obsd_sc_pc_offset; - extern int i386obsd_sc_sp_offset; -#define SC_PC_OFFSET i386obsd_sc_pc_offset -#define SC_SP_OFFSET i386obsd_sc_sp_offset + extern int i386obsd_sc_reg_offset[]; +#define SC_REG_OFFSET i386obsd_sc_reg_offset #else - extern int i386bsd_sc_pc_offset; - extern int i386bsd_sc_sp_offset; -#define SC_PC_OFFSET i386bsd_sc_pc_offset -#define SC_SP_OFFSET i386bsd_sc_sp_offset + extern int i386bsd_sc_reg_offset[]; +#define SC_PC_OFFSET i386bsd_sc_reg_offset #endif + /* We only check the program counter, stack pointer and frame + pointer since these members of `struct sigcontext' are essential + for providing backtraces. More checks could be added, but would + involve adding configure checks for the appropriate structure + members, since older BSD's don't provide all of them. */ + +#define SC_PC_OFFSET SC_REG_OFFSET[I386_EIP_REGNUM] +#define SC_SP_OFFSET SC_REG_OFFSET[I386_ESP_REGNUM] +#define SC_FP_OFFSET SC_REG_OFFSET[I386_EBP_REGNUM] + /* Override the default value for the offset of the program counter in the sigcontext structure. */ - sc_pc_offset = offsetof (struct sigcontext, sc_pc); + offset = offsetof (struct sigcontext, sc_pc); - if (SC_PC_OFFSET != sc_pc_offset) + if (SC_PC_OFFSET != offset) { warning ("\ offsetof (struct sigcontext, sc_pc) yields %d instead of %d.\n\ -Please report this to <bug-gdb@gnu.org>.", - sc_pc_offset, SC_PC_OFFSET); +Please report this to <bug-gdb@gnu.org>.", + offset, SC_PC_OFFSET); } - SC_PC_OFFSET = sc_pc_offset; + SC_PC_OFFSET = offset; /* Likewise for the stack pointer. */ - sc_sp_offset = offsetof (struct sigcontext, sc_sp); + offset = offsetof (struct sigcontext, sc_sp); - if (SC_SP_OFFSET != sc_sp_offset) + if (SC_SP_OFFSET != offset) { warning ("\ offsetof (struct sigcontext, sc_sp) yields %d instead of %d.\n\ Please report this to <bug-gdb@gnu.org>.", - sc_sp_offset, SC_SP_OFFSET); + offset, SC_SP_OFFSET); + } + + SC_SP_OFFSET = offset; + + /* And the frame pointer. */ + offset = offsetof (struct sigcontext, sc_fp); + + if (SC_FP_OFFSET != offset) + { + warning ("\ +offsetof (struct sigcontext, sc_fp) yields %d instead of %d.\n\ +Please report this to <bug-gdb@gnu.org>.", + offset, SC_FP_OFFSET); } - SC_SP_OFFSET = sc_sp_offset; + SC_FP_OFFSET = offset; } |