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'.
This commit is contained in:
Mark Kettenis 2003-05-31 16:08:06 +00:00
parent 25ab47902d
commit a338618604
8 changed files with 255 additions and 59 deletions

View File

@ -1,3 +1,49 @@
2003-05-31 Mark Kettenis <kettenis@gnu.org>
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'.
2003-05-31 Andrew Cagney <cagney@redhat.com>
* mips-tdep.c (mips_gdbarch_init): Do not set the deprecated

View File

@ -439,6 +439,27 @@ i386_linux_svr4_fetch_link_map_offsets (void)
}
/* From <asm/sigcontext.h>. */
static int i386_linux_sc_reg_offset[I386_NUM_GREGS] =
{
11 * 4, /* %eax */
10 * 4, /* %ecx */
9 * 4, /* %edx */
8 * 4, /* %ebx */
7 * 4, /* %esp */
6 * 4, /* %ebp */
5 * 4, /* %esi */
4 * 4, /* %edi */
14 * 4, /* %eip */
16 * 4, /* %eflags */
15 * 4, /* %cs */
18 * 4, /* %ss */
3 * 4, /* %ds */
2 * 4, /* %es */
1 * 4, /* %fs */
0 * 4 /* %gs */
};
static void
i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
@ -462,8 +483,8 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->jb_pc_offset = 20; /* From <bits/setjmp.h>. */
tdep->sigcontext_addr = i386_linux_sigcontext_addr;
tdep->sc_pc_offset = 14 * 4; /* From <asm/sigcontext.h>. */
tdep->sc_sp_offset = 7 * 4;
tdep->sc_reg_offset = i386_linux_sc_reg_offset;
tdep->sc_num_regs = I386_NUM_GREGS;
/* When the i386 Linux kernel calls a signal handler, the return
address points to a bit of code on the stack. This function is

View File

@ -47,16 +47,6 @@
#include "i386-tdep.h"
#include "i387-tdep.h"
/* Register numbers of various important registers. */
#define I386_EAX_REGNUM 0 /* %eax */
#define I386_EDX_REGNUM 2 /* %edx */
#define I386_ESP_REGNUM 4 /* %esp */
#define I386_EBP_REGNUM 5 /* %ebp */
#define I386_EIP_REGNUM 8 /* %eip */
#define I386_EFLAGS_REGNUM 9 /* %eflags */
#define I386_ST0_REGNUM 16 /* %st(0) */
/* Names of the registers. The first 10 registers match the register
numbering scheme used by GCC for stabs and DWARF. */
@ -248,7 +238,7 @@ i386_breakpoint_from_pc (CORE_ADDR *pc, int *len)
/* The maximum number of saved registers. This should include all
registers mentioned above, and %eip. */
#define I386_NUM_SAVED_REGS 9
#define I386_NUM_SAVED_REGS I386_NUM_GREGS
struct i386_frame_cache
{
@ -884,8 +874,21 @@ i386_sigtramp_frame_cache (struct frame_info *next_frame, void **this_cache)
cache->base = extract_unsigned_integer (buf, 4) - 4;
addr = tdep->sigcontext_addr (next_frame);
cache->saved_regs[I386_EIP_REGNUM] = addr + tdep->sc_pc_offset;
cache->saved_regs[I386_ESP_REGNUM] = addr + tdep->sc_sp_offset;
if (tdep->sc_reg_offset)
{
int i;
gdb_assert (tdep->sc_num_regs <= I386_NUM_SAVED_REGS);
for (i = 0; i < tdep->sc_num_regs; i++)
if (tdep->sc_reg_offset[i] != -1)
cache->saved_regs[i] = addr + tdep->sc_reg_offset[i];
}
else
{
cache->saved_regs[I386_EIP_REGNUM] = addr + tdep->sc_pc_offset;
cache->saved_regs[I386_ESP_REGNUM] = addr + tdep->sc_sp_offset;
}
*this_cache = cache;
return cache;
@ -1621,6 +1624,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
tdep->sigtramp_start = 0;
tdep->sigtramp_end = 0;
tdep->sigcontext_addr = NULL;
tdep->sc_reg_offset = NULL;
tdep->sc_pc_offset = -1;
tdep->sc_sp_offset = -1;

View File

@ -71,7 +71,12 @@ struct gdbarch_tdep
/* Get address of sigcontext for sigtramp. */
CORE_ADDR (*sigcontext_addr) (struct frame_info *);
/* Offset of saved PC and SP in `struct sigcontext'. */
/* Offset of registers in `struct sigcontext'. */
int *sc_reg_offset;
int sc_num_regs;
/* Offset of saved PC and SP in `struct sigcontext'. Usage of these
is deprecated, please use `sc_reg_offset' instead. */
int sc_pc_offset;
int sc_sp_offset;
};
@ -137,6 +142,16 @@ extern int i386_mxcsr_regnum_p (int regnum);
#define FDS_REGNUM FOSEG_REGNUM
#define FDOFF_REGNUM FOOFF_REGNUM
/* Register numbers of various important registers. */
#define I386_EAX_REGNUM 0 /* %eax */
#define I386_EDX_REGNUM 2 /* %edx */
#define I386_ESP_REGNUM 4 /* %esp */
#define I386_EBP_REGNUM 5 /* %ebp */
#define I386_EIP_REGNUM 8 /* %eip */
#define I386_EFLAGS_REGNUM 9 /* %eflags */
#define I386_ST0_REGNUM 16 /* %st(0) */
#define I386_NUM_GREGS 16
#define I386_NUM_FREGS 16
#define I386_NUM_XREGS 9

View File

@ -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 = 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_FP_OFFSET = offset;
}

View File

@ -86,8 +86,25 @@ i386bsd_aout_in_solib_call_trampoline (CORE_ADDR pc, char *name)
/* Traditional BSD (4.3 BSD, still used for BSDI and 386BSD). */
/* From <machine/signal.h>. */
int i386bsd_sc_pc_offset = 20;
int i386bsd_sc_sp_offset = 8;
int i386bsd_sc_reg_offset[I386_NUM_GREGS] =
{
-1, /* %eax */
-1, /* %ecx */
-1, /* %edx */
-1, /* %ebx */
8 + 0 * 4, /* %esp */
8 + 1 * 4, /* %ebp */
-1, /* %esi */
-1, /* %edi */
8 + 3 * 4, /* %eip */
8 + 4 * 4, /* %eflags */
-1, /* %cs */
-1, /* %ss */
-1, /* %ds */
-1, /* %es */
-1, /* %fs */
-1 /* %gs */
};
void
i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
@ -109,8 +126,8 @@ i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->sigtramp_start = 0xfdbfdfc0;
tdep->sigtramp_end = 0xfdbfe000;
tdep->sigcontext_addr = i386bsd_sigcontext_addr;
tdep->sc_pc_offset = i386bsd_sc_pc_offset;
tdep->sc_sp_offset = i386bsd_sc_sp_offset;
tdep->sc_reg_offset = i386bsd_sc_reg_offset;
tdep->sc_num_regs = I386_NUM_GREGS;
}
/* FreeBSD 3.0-RELEASE or later. */
@ -118,6 +135,27 @@ i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
CORE_ADDR i386fbsd_sigtramp_start = 0xbfbfdf20;
CORE_ADDR i386fbsd_sigtramp_end = 0xbfbfdff0;
/* From <machine/signal.h>. */
int i386fbsd_sc_reg_offset[I386_NUM_GREGS] =
{
8 + 14 * 4, /* %eax */
8 + 13 * 4, /* %ecx */
8 + 12 * 4, /* %edx */
8 + 11 * 4, /* %ebx */
8 + 0 * 4, /* %esp */
8 + 1 * 4, /* %ebp */
8 + 10 * 4, /* %esi */
8 + 9 * 4, /* %edi */
8 + 3 * 4, /* %eip */
8 + 4 * 4, /* %eflags */
8 + 7 * 4, /* %cs */
8 + 8 * 4, /* %ss */
8 + 6 * 4, /* %ds */
8 + 5 * 4, /* %es */
8 + 15 * 4, /* %fs */
8 + 16 * 4 /* %gs */
};
static void
i386fbsdaout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
@ -132,6 +170,10 @@ i386fbsdaout_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* FreeBSD uses a different memory layout. */
tdep->sigtramp_start = i386fbsd_sigtramp_start;
tdep->sigtramp_end = i386fbsd_sigtramp_end;
/* FreeBSD has a more complete `struct sigcontext'. */
tdep->sc_reg_offset = i386fbsd_sc_reg_offset;
tdep->sc_num_regs = I386_NUM_GREGS;
}
static void
@ -151,8 +193,25 @@ i386fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* FreeBSD 4.0-RELEASE or later. */
/* From <machine/signal.h>. */
int i386fbsd4_sc_pc_offset = 76;
int i386fbsd4_sc_sp_offset = 88;
int i386fbsd4_sc_reg_offset[I386_NUM_GREGS] =
{
20 + 11 * 4, /* %eax */
20 + 10 * 4, /* %ecx */
20 + 9 * 4, /* %edx */
20 + 8 * 4, /* %ebx */
20 + 17 * 4, /* %esp */
20 + 6 * 4, /* %ebp */
20 + 5 * 4, /* %esi */
20 + 4 * 4, /* %edi */
20 + 14 * 4, /* %eip */
20 + 16 * 4, /* %eflags */
20 + 15 * 4, /* %cs */
20 + 18 * 4, /* %ss */
20 + 3 * 4, /* %ds */
20 + 2 * 4, /* %es */
20 + 1 * 4, /* %fs */
20 + 0 * 4 /* %gs */
};
static void
i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
@ -164,8 +223,8 @@ i386fbsd4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
i386fbsd_init_abi (info, gdbarch);
/* FreeBSD 4.0 introduced a new `struct sigcontext'. */
tdep->sc_pc_offset = i386fbsd4_sc_pc_offset;
tdep->sc_sp_offset = i386fbsd4_sc_sp_offset;
tdep->sc_reg_offset = i386fbsd4_sc_reg_offset;
tdep->sc_num_regs = I386_NUM_GREGS;
}

View File

@ -239,8 +239,25 @@ i386nbsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
}
/* From <machine/signal.h>. */
int i386nbsd_sc_pc_offset = 44;
int i386nbsd_sc_sp_offset = 56;
int i386nbsd_sc_reg_offset[I386_NUM_GREGS] =
{
10 * 4, /* %eax */
9 * 4, /* %ecx */
8 * 4, /* %edx */
7 * 4, /* %ebx */
14 * 4, /* %esp */
6 * 4, /* %ebp */
5 * 4, /* %esi */
4 * 4, /* %edi */
11 * 4, /* %eip */
13 * 4, /* %eflags */
12 * 4, /* %cs */
15 * 4, /* %ss */
3 * 4, /* %ds */
2 * 4, /* %es */
1 * 4, /* %fs */
0 * 4 /* %gs */
};
static void
i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
@ -263,8 +280,8 @@ i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* NetBSD has a `struct sigcontext' that's different from the
origional 4.3 BSD. */
tdep->sc_pc_offset = i386nbsd_sc_pc_offset;
tdep->sc_sp_offset = i386nbsd_sc_sp_offset;
tdep->sc_reg_offset = i386nbsd_sc_reg_offset;
tdep->sc_num_regs = I386_NUM_GREGS;
}
/* NetBSD ELF. */

View File

@ -83,8 +83,25 @@ CORE_ADDR i386obsd_sigtramp_start = 0xbfbfdf20;
CORE_ADDR i386obsd_sigtramp_end = 0xbfbfdff0;
/* From <machine/signal.h>. */
int i386obsd_sc_pc_offset = 44;
int i386obsd_sc_sp_offset = 56;
int i386obsd_sc_reg_offset[I386_NUM_GREGS] =
{
10 * 4, /* %eax */
9 * 4, /* %ecx */
8 * 4, /* %edx */
7 * 4, /* %ebx */
14 * 4, /* %esp */
6 * 4, /* %ebp */
5 * 4, /* %esi */
4 * 4, /* %edi */
11 * 4, /* %eip */
13 * 4, /* %eflags */
12 * 4, /* %cs */
15 * 4, /* %ss */
3 * 4, /* %ds */
2 * 4, /* %es */
1 * 4, /* %fs */
0 * 4 /* %gs */
};
static void
i386obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
@ -103,8 +120,8 @@ i386obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* OpenBSD has a `struct sigcontext' that's different from the
origional 4.3 BSD. */
tdep->sc_pc_offset = i386obsd_sc_pc_offset;
tdep->sc_sp_offset = i386obsd_sc_sp_offset;
tdep->sc_reg_offset = i386obsd_sc_reg_offset;
tdep->sc_num_regs = I386_NUM_GREGS;
}
void