From 138e7be507e1244fa17077ed394f0bad769ebc5d Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Fri, 11 Jul 2003 21:49:04 +0000 Subject: [PATCH] * alpha-tdep.h (struct gdbarch_tdep): Add members `sc_pc_offset', `sc_regs_offset' and `sc_fpregs_offset'. * alpha-tdep.c (SIGFRAME_PC_OFF, SIGFRAME_REGSAVE_OFF, SIGFRAME_FPREGSAVE_OFF): Remove defines. (alpha_sigtramp_register_address): Rewrite to use new members of `struct gdbarch_tdep'. (alpha_gdbarch_init): Initialize new members of struct gdbarch_tdep'. * alphafbsd-tdep.c (alphafbsd_use_struct_convention): Use ALPHA_REGISTER_SIZE instead of DEPRECATED_REGISTER_SIZE. (alphafbsd_sigtramp_start, alphafbsd_sigtramp_end): Nre variables. (alphafbsd_pc_in_sigtramp): Implement. (alphafbsd_sigtramp_offset): New function. (alphafbsd_sigcontext_addr): New function. (alphafbsd_init_abi): Initialize signal trampoline related members of `struct gdbarch_tdep'. (_initialize_alphafbsd_tdep): Add prototype. --- gdb/ChangeLog | 20 ++++++++++++++++++++ gdb/alpha-tdep.c | 29 ++++++++++++++-------------- gdb/alpha-tdep.h | 5 +++++ gdb/alphafbsd-tdep.c | 45 ++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 80 insertions(+), 19 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5d5cec59698..cfa5e1f4219 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,23 @@ +2003-07-11 Mark Kettenis + + * alpha-tdep.h (struct gdbarch_tdep): Add members `sc_pc_offset', + `sc_regs_offset' and `sc_fpregs_offset'. + * alpha-tdep.c (SIGFRAME_PC_OFF, SIGFRAME_REGSAVE_OFF, + SIGFRAME_FPREGSAVE_OFF): Remove defines. + (alpha_sigtramp_register_address): Rewrite to use new members of + `struct gdbarch_tdep'. + (alpha_gdbarch_init): Initialize new members of struct + gdbarch_tdep'. + * alphafbsd-tdep.c (alphafbsd_use_struct_convention): Use + ALPHA_REGISTER_SIZE instead of DEPRECATED_REGISTER_SIZE. + (alphafbsd_sigtramp_start, alphafbsd_sigtramp_end): Nre variables. + (alphafbsd_pc_in_sigtramp): Implement. + (alphafbsd_sigtramp_offset): New function. + (alphafbsd_sigcontext_addr): New function. + (alphafbsd_init_abi): Initialize signal trampoline related members + of `struct gdbarch_tdep'. + (_initialize_alphafbsd_tdep): Add prototype. + 2003-07-11 Theodore A. Roth * Makefile.in (install-only): Quote sed expression when generating diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index fb2ca1851b5..0a3185fd890 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -753,24 +753,20 @@ alpha_sigtramp_frame_unwind_cache (struct frame_info *next_frame, return info; } -/* Return the address of REGNO in a sigtramp frame. Since this is all - arithmetic, it doesn't seem worthwhile to cache it. */ - -#ifndef SIGFRAME_PC_OFF -#define SIGFRAME_PC_OFF (2 * 8) -#define SIGFRAME_REGSAVE_OFF (4 * 8) -#define SIGFRAME_FPREGSAVE_OFF (SIGFRAME_REGSAVE_OFF + 32 * 8 + 8) -#endif +/* Return the address of REGNUM in a sigtramp frame. Since this is + all arithmetic, it doesn't seem worthwhile to cache it. */ static CORE_ADDR -alpha_sigtramp_register_address (CORE_ADDR sigcontext_addr, unsigned int regno) +alpha_sigtramp_register_address (CORE_ADDR sigcontext_addr, int regnum) { - if (regno < 32) - return sigcontext_addr + SIGFRAME_REGSAVE_OFF + regno * 8; - if (regno >= ALPHA_FP0_REGNUM && regno < ALPHA_FP0_REGNUM + 32) - return sigcontext_addr + SIGFRAME_FPREGSAVE_OFF + regno * 8; - if (regno == ALPHA_PC_REGNUM) - return sigcontext_addr + SIGFRAME_PC_OFF; + struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + + if (regnum >= 0 && regnum < 32) + return sigcontext_addr + tdep->sc_regs_offset + regnum * 8; + else if (regnum >= ALPHA_FP0_REGNUM && regnum < ALPHA_FP0_REGNUM + 32) + return sigcontext_addr + tdep->sc_fpregs_offset + regnum * 8; + else if (regnum == ALPHA_PC_REGNUM) + return sigcontext_addr + tdep->sc_pc_offset; return 0; } @@ -1495,6 +1491,9 @@ alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->dynamic_sigtramp_offset = NULL; tdep->sigcontext_addr = NULL; + tdep->sc_pc_offset = 2 * 8; + tdep->sc_regs_offset = 4 * 8; + tdep->sc_fpregs_offset = tdep->sc_regs_offset + 32 * 8 + 8; tdep->jb_pc = -1; /* longjmp support not enabled by default */ diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h index c0e28e65772..9afe7be5f53 100644 --- a/gdb/alpha-tdep.h +++ b/gdb/alpha-tdep.h @@ -82,6 +82,11 @@ struct gdbarch_tdep the sigcontext structure for that signal handler. */ CORE_ADDR (*sigcontext_addr) (struct frame_info *); + /* Offset of registers in `struct sigcontext'. */ + int sc_pc_offset; + int sc_regs_offset; + int sc_fpregs_offset; + int jb_pc; /* Offset to PC value in jump buffer. If htis is negative, longjmp support will be disabled. */ diff --git a/gdb/alphafbsd-tdep.c b/gdb/alphafbsd-tdep.c index 680e303f587..d8f4fa039c3 100644 --- a/gdb/alphafbsd-tdep.c +++ b/gdb/alphafbsd-tdep.c @@ -32,7 +32,7 @@ alphafbsd_use_struct_convention (int gcc_p, struct type *type) /* All aggregate types that won't fit in a register must be returned in memory. */ - if (TYPE_LENGTH (type) > DEPRECATED_REGISTER_SIZE) + if (TYPE_LENGTH (type) > ALPHA_REGISTER_SIZE) return 1; /* The only aggregate types that can be returned in a register are @@ -54,14 +54,41 @@ alphafbsd_use_struct_convention (int gcc_p, struct type *type) return 0; } + + +/* Support for signal handlers. */ + +/* Return whether PC is in a BSD sigtramp routine. */ + +CORE_ADDR alphafbsd_sigtramp_start = 0x11ffff68; +CORE_ADDR alphafbsd_sigtramp_end = 0x11ffffe0; static int alphafbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name) { - /* FIXME */ - return 0; + return (pc >= alphafbsd_sigtramp_start && pc < alphafbsd_sigtramp_end); } +static LONGEST +alphafbsd_sigtramp_offset (CORE_ADDR pc) +{ + return pc - alphafbsd_sigtramp_start; +} + +/* Assuming NEXT_FRAME is for a frame following a BSD sigtramp + routine, return the address of the associated sigcontext structure. */ + +static CORE_ADDR +alphafbsd_sigcontext_addr (struct frame_info *next_frame) +{ + ULONGEST sp; + + frame_unwind_unsigned_register (next_frame, ALPHA_SP_REGNUM, &sp); + return sp + 24; +} + +/* FreeBSD 5.0-RELEASE or later. */ + static void alphafbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) @@ -74,13 +101,23 @@ alphafbsd_init_abi (struct gdbarch_info info, /* Hook into the MDEBUG frame unwinder. */ alpha_mdebug_init_abi (info, gdbarch); + set_gdbarch_use_struct_convention (gdbarch, alphafbsd_use_struct_convention); + set_gdbarch_pc_in_sigtramp (gdbarch, alphafbsd_pc_in_sigtramp); - set_gdbarch_use_struct_convention (gdbarch, alphafbsd_use_struct_convention); + tdep->dynamic_sigtramp_offset = alphafbsd_sigtramp_offset; + tdep->sigcontext_addr = alphafbsd_sigcontext_addr; + tdep->sc_pc_offset = 288; + tdep->sc_regs_offset = 24; + tdep->sc_fpregs_offset = 320; tdep->jb_pc = 2; tdep->jb_elt_size = 8; } + + +/* Provide a prototype to silence -Wmissing-prototypes. */ +void _initialize_alphafbsd_tdep (void); void _initialize_alphafbsd_tdep (void) -- 2.30.2