0ba6dca974
* gdbarch.sh (DEPRECATED_TARGET_READ_FP): Replace TARGET_READ_FP. (DEPRECATED_FP_REGNUM): Replace FP_REGNUM. * gdbarch.h, gdbarch.c: Re-generate. * infcall.c (call_function_by_hand): Use DEPRECATED_FP_REGNUM, DEPRECATED_TARGET_READ_FP, or "sp" to create the dummy frame ID. * inferior.h (deprecated_read_fp): Rename read_fp. (generic_target_read_fp): Delete declaration. * regcache.c (generic_target_read_fp): Delete function. (deprecated_read_fp): Replace read_fp, use DEPRECATED_TARGET_READ_FP or DEPRECATED_FP_REGNUM. * d10v-tdep.c (d10v_read_fp): Delete function. (d10v_gdbarch_init): Do not set deprecated_read_fp. * sparc-tdep.c (sparc_gdbarch_init): Do not set deprecated_target_read_fp to generic_target_read_fp. * sh-tdep.c (sh_gdbarch_init): Ditto. * rs6000-tdep.c (rs6000_gdbarch_init): Ditto. * m68hc11-tdep.c (m68hc11_gdbarch_init): Ditto. * frv-tdep.c (frv_gdbarch_init): Ditto. * xstormy16-tdep.c (xstormy16_gdbarch_init): Set deprecated_fp_regnum. * x86-64-tdep.c (x86_64_init_abi): Ditto. * vax-tdep.c (vax_gdbarch_init): Ditto. * v850-tdep.c (v850_gdbarch_init): Ditto. * sparc-tdep.c (sparc_gdbarch_init): Ditto. * sh-tdep.c (sh_gdbarch_init): Ditto. * s390-tdep.c (s390_gdbarch_init): Ditto. * rs6000-tdep.c (rs6000_gdbarch_init): Ditto. * mn10300-tdep.c (mn10300_gdbarch_init): Ditto. * mcore-tdep.c (mcore_gdbarch_init): Ditto. * m68k-tdep.c (m68k_gdbarch_init): Ditto. * m68hc11-tdep.c (m68hc11_gdbarch_init): Ditto. * ia64-tdep.c (ia64_gdbarch_init): Ditto. * i386-tdep.c (i386_gdbarch_init): Ditto. * hppa-tdep.c (hppa_gdbarch_init): Ditto. * h8300-tdep.c (h8300_gdbarch_init): Ditto. * frv-tdep.c (frv_gdbarch_init): Ditto. * cris-tdep.c (cris_gdbarch_init): Ditto. * avr-tdep.c (avr_gdbarch_init): Ditto. * arm-tdep.c (arm_gdbarch_init): Ditto. * alpha-tdep.c (alpha_gdbarch_init): Ditto. * x86-64-tdep.c (x86_64_init_abi): Set deprecated_target_read_fp. * v850-tdep.c (v850_gdbarch_init): Ditto. * sparc-tdep.c (sparc_gdbarch_init): Ditto. * sh-tdep.c (sh_gdbarch_init): Ditto. * s390-tdep.c (s390_gdbarch_init): Ditto. * rs6000-tdep.c (rs6000_gdbarch_init): Ditto. * mn10300-tdep.c (mn10300_gdbarch_init): Ditto. * mips-tdep.c (mips_gdbarch_init): Ditto. * m68hc11-tdep.c (m68hc11_gdbarch_init): Ditto. * ia64-tdep.c (ia64_gdbarch_init): Ditto. * hppa-tdep.c (hppa_gdbarch_init): Ditto. * frv-tdep.c (frv_gdbarch_init): Ditto. * avr-tdep.c (avr_gdbarch_init): Ditto. * arm-tdep.c (arm_gdbarch_init): Ditto. * vax-tdep.c (vax_frame_init_saved_regs): Replace FP_REGNUM with DEPRECATED_FP_REGNUM. (vax_push_dummy_frame, vax_pop_frame): Ditto. * std-regs.c (value_of_builtin_frame_fp_reg): Ditto. * sparc-tdep.c (sparc_init_extra_frame_info): Ditto. (sparc_push_dummy_frame, sparc64_read_fp): Ditto. (sparc32_register_virtual_type): Ditto. * sh-tdep.c (sh64_frame_chain): Ditto. (sh64_get_saved_register, sh64_pop_frame): Ditto. (sh_nofp_frame_init_saved_regs): Ditto. (sh64_nofp_frame_init_saved_regs): Ditto. (sh_fp_frame_init_saved_regs): Ditto. * remote-mips.c (mips_wait, mips_fetch_registers): Ditto. * remote-e7000.c (fetch_regs_from_dump): Ditto. * procfs.c (procfs_fetch_registers): Ditto. (procfs_store_registers): Ditto. * ns32knbsd-nat.c (fetch_inferior_registers): Ditto. (store_inferior_registers, fetch_core_registers): Ditto. (fetch_kcore_registers, clear_regs): Ditto. * ns32k-tdep.c (ns32k_frame_init_saved_regs): Ditto. (ns32k_push_dummy_frame, ns32k_pop_frame): Ditto. * nlm/i386.h (DEPRECATED_FP_REGNUM): Ditto. * nlm/i386.c (do_status): Ditto. * mipsv4-nat.c (supply_gregset): Ditto. * mips-tdep.c: Ditto for comments. * mips-nat.c (fetch_inferior_registers): Ditto. (store_inferior_registers, fetch_core_registers): Ditto. * m68k-tdep.c (m68k_push_dummy_frame): Ditto. (m68k_pop_frame, m68k_frame_init_saved_regs): Ditto. * i386-tdep.c (i386_frame_init_saved_regs): Ditto. (i386_do_pop_frame, i386_register_type): Ditto. * hppa-tdep.c (hppa_frame_chain): Ditto. (hppa_push_dummy_frame, find_dummy_frame_regs): Ditto. (hppa_pop_frame, hppa_read_fp): Ditto. (skip_prologue_hard_way, hppa_frame_find_saved_regs): Ditto. * cris-tdep.c (cris_examine, cris_pop_frame): Ditto. * config/vax/nm-vax.h (REGISTER_U_ADDR): Ditto. * config/sparc/tm-sparc.h (DEPRECATED_FP_REGNUM): Ditto. * config/sparc/tm-sp64.h (DEPRECATED_FP_REGNUM): Ditto. * config/s390/tm-s390.h (DEPRECATED_FP_REGNUM): Ditto. * config/pa/tm-hppa64.h (DEPRECATED_FP_REGNUM): Ditto. * config/ia64/tm-ia64.h (DEPRECATED_FP_REGNUM): Ditto. * blockframe.c: Ditto for comments. * arch-utils.h: Ditto for comments. * arch-utils.c (legacy_virtual_frame_pointer): Ditto. * alphanbsd-tdep.c (fetch_core_registers): Ditto. * alphabsd-nat.c (fetch_inferior_registers): Ditto. * alpha-tdep.h: Ditto for comments. * alpha-tdep.c (alpha_cannot_fetch_register): Ditto. (alpha_cannot_store_register): Ditto. (alpha_push_dummy_frame): Ditto. * alpha-nat.c (supply_gregset): Ditto. * config/sparc/tm-sp64.h (DEPRECATED_TARGET_READ_FP): Update. * config/pa/tm-hppa64.h (DEPRECATED_TARGET_READ_FP): Update. * config/sparc/tm-sparc.h: Update comment. * hppa-tdep.c (hppa_init_extra_frame_info): Use deprecated_read_fp instead of TARGET_READ_FP. (hppa_init_extra_frame_info, hppa_frame_chain): Ditto. (hppa_push_dummy_frame, hppa_read_fp): Ditto. * sparc-tdep.c (sparc_init_extra_frame_info): Use deprecated_read_fp instead of read_fp. * s390-tdep.c (s390_push_arguments): Ditto. * ia64-tdep.c (ia64_gdbarch_init): Ditto. * frame.h: Ditto in comments. * frame.c (legacy_get_prev_frame): Ditto. * dummy-frame.c (dummy_frame_this_id): Ditto. * arm-tdep.c (arm_init_extra_frame_info): Ditto. 2003-04-28 Andrew Cagney <cagney@redhat.com> * gdbint.texinfo (Target Architecture Definition): Replace read_fp, TARGET_READ_FP and FP_REGNUM, with deprecated_read_fp, DEPRECATED_TARGET_READ_FP and DEPRECATED_REGNUM.
241 lines
6.8 KiB
C
241 lines
6.8 KiB
C
/* Target-dependent code for NetBSD/Alpha.
|
|
Copyright 2002, 2003 Free Software Foundation, Inc.
|
|
Contributed by Wasabi Systems, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
#include "defs.h"
|
|
#include "gdbcore.h"
|
|
#include "frame.h"
|
|
#include "regcache.h"
|
|
#include "value.h"
|
|
#include "osabi.h"
|
|
|
|
#include "solib-svr4.h"
|
|
|
|
#include "alpha-tdep.h"
|
|
#include "alphabsd-tdep.h"
|
|
#include "nbsd-tdep.h"
|
|
|
|
static void
|
|
fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which,
|
|
CORE_ADDR ignore)
|
|
{
|
|
char *regs, *fpregs;
|
|
int regno;
|
|
|
|
/* Table to map a gdb register number to a trapframe register index. */
|
|
static const int regmap[] =
|
|
{
|
|
0, 1, 2, 3,
|
|
4, 5, 6, 7,
|
|
8, 9, 10, 11,
|
|
12, 13, 14, 15,
|
|
30, 31, 32, 16,
|
|
17, 18, 19, 20,
|
|
21, 22, 23, 24,
|
|
25, 29, 26
|
|
};
|
|
#define SIZEOF_TRAPFRAME (33 * 8)
|
|
|
|
/* We get everything from one section. */
|
|
if (which != 0)
|
|
return;
|
|
|
|
regs = core_reg_sect;
|
|
fpregs = core_reg_sect + SIZEOF_TRAPFRAME;
|
|
|
|
if (core_reg_size < (SIZEOF_TRAPFRAME + SIZEOF_STRUCT_FPREG))
|
|
{
|
|
warning ("Wrong size register set in core file.");
|
|
return;
|
|
}
|
|
|
|
/* Integer registers. */
|
|
for (regno = 0; regno < ALPHA_ZERO_REGNUM; regno++)
|
|
supply_register (regno, regs + (regmap[regno] * 8));
|
|
supply_register (ALPHA_ZERO_REGNUM, NULL);
|
|
supply_register (DEPRECATED_FP_REGNUM, NULL);
|
|
supply_register (PC_REGNUM, regs + (28 * 8));
|
|
|
|
/* Floating point registers. */
|
|
alphabsd_supply_fpreg (fpregs, -1);
|
|
}
|
|
|
|
static void
|
|
fetch_elfcore_registers (char *core_reg_sect, unsigned core_reg_size, int which,
|
|
CORE_ADDR ignore)
|
|
{
|
|
switch (which)
|
|
{
|
|
case 0: /* Integer registers. */
|
|
if (core_reg_size != SIZEOF_STRUCT_REG)
|
|
warning ("Wrong size register set in core file.");
|
|
else
|
|
alphabsd_supply_reg (core_reg_sect, -1);
|
|
break;
|
|
|
|
case 2: /* Floating point registers. */
|
|
if (core_reg_size != SIZEOF_STRUCT_FPREG)
|
|
warning ("Wrong size FP register set in core file.");
|
|
else
|
|
alphabsd_supply_fpreg (core_reg_sect, -1);
|
|
break;
|
|
|
|
default:
|
|
/* Don't know what kind of register request this is; just ignore it. */
|
|
break;
|
|
}
|
|
}
|
|
|
|
static struct core_fns alphanbsd_core_fns =
|
|
{
|
|
bfd_target_unknown_flavour, /* core_flavour */
|
|
default_check_format, /* check_format */
|
|
default_core_sniffer, /* core_sniffer */
|
|
fetch_core_registers, /* core_read_registers */
|
|
NULL /* next */
|
|
};
|
|
|
|
static struct core_fns alphanbsd_elfcore_fns =
|
|
{
|
|
bfd_target_elf_flavour, /* core_flavour */
|
|
default_check_format, /* check_format */
|
|
default_core_sniffer, /* core_sniffer */
|
|
fetch_elfcore_registers, /* core_read_registers */
|
|
NULL /* next */
|
|
};
|
|
|
|
/* Under NetBSD/alpha, signal handler invocations can be identified by the
|
|
designated code sequence that is used to return from a signal handler.
|
|
In particular, the return address of a signal handler points to the
|
|
following code sequence:
|
|
|
|
ldq a0, 0(sp)
|
|
lda sp, 16(sp)
|
|
lda v0, 295(zero) # __sigreturn14
|
|
call_pal callsys
|
|
|
|
Each instruction has a unique encoding, so we simply attempt to match
|
|
the instruction the PC is pointing to with any of the above instructions.
|
|
If there is a hit, we know the offset to the start of the designated
|
|
sequence and can then check whether we really are executing in the
|
|
signal trampoline. If not, -1 is returned, otherwise the offset from the
|
|
start of the return sequence is returned. */
|
|
static const unsigned char sigtramp_retcode[] =
|
|
{
|
|
0x00, 0x00, 0x1e, 0xa6, /* ldq a0, 0(sp) */
|
|
0x10, 0x00, 0xde, 0x23, /* lda sp, 16(sp) */
|
|
0x27, 0x01, 0x1f, 0x20, /* lda v0, 295(zero) */
|
|
0x83, 0x00, 0x00, 0x00, /* call_pal callsys */
|
|
};
|
|
#define RETCODE_NWORDS 4
|
|
#define RETCODE_SIZE (RETCODE_NWORDS * 4)
|
|
|
|
LONGEST
|
|
alphanbsd_sigtramp_offset (CORE_ADDR pc)
|
|
{
|
|
unsigned char ret[RETCODE_SIZE], w[4];
|
|
LONGEST off;
|
|
int i;
|
|
|
|
if (read_memory_nobpt (pc, (char *) w, 4) != 0)
|
|
return -1;
|
|
|
|
for (i = 0; i < RETCODE_NWORDS; i++)
|
|
{
|
|
if (memcmp (w, sigtramp_retcode + (i * 4), 4) == 0)
|
|
break;
|
|
}
|
|
if (i == RETCODE_NWORDS)
|
|
return (-1);
|
|
|
|
off = i * 4;
|
|
pc -= off;
|
|
|
|
if (read_memory_nobpt (pc, (char *) ret, sizeof (ret)) != 0)
|
|
return -1;
|
|
|
|
if (memcmp (ret, sigtramp_retcode, RETCODE_SIZE) == 0)
|
|
return off;
|
|
|
|
return -1;
|
|
}
|
|
|
|
static int
|
|
alphanbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
|
|
{
|
|
return (nbsd_pc_in_sigtramp (pc, func_name)
|
|
|| alphanbsd_sigtramp_offset (pc) >= 0);
|
|
}
|
|
|
|
static CORE_ADDR
|
|
alphanbsd_sigcontext_addr (struct frame_info *frame)
|
|
{
|
|
/* FIXME: This is not correct for all versions of NetBSD/alpha.
|
|
We will probably need to disassemble the trampoline to figure
|
|
out which trampoline frame type we have. */
|
|
return frame->frame;
|
|
}
|
|
|
|
static CORE_ADDR
|
|
alphanbsd_skip_sigtramp_frame (struct frame_info *frame, CORE_ADDR pc)
|
|
{
|
|
char *name;
|
|
|
|
/* FIXME: This is not correct for all versions of NetBSD/alpha.
|
|
We will probably need to disassemble the trampoline to figure
|
|
out which trampoline frame type we have. */
|
|
find_pc_partial_function (pc, &name, (CORE_ADDR *) NULL, (CORE_ADDR *) NULL);
|
|
if (PC_IN_SIGTRAMP (pc, name))
|
|
return frame->frame;
|
|
return 0;
|
|
}
|
|
|
|
static void
|
|
alphanbsd_init_abi (struct gdbarch_info info,
|
|
struct gdbarch *gdbarch)
|
|
{
|
|
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
|
|
|
set_gdbarch_pc_in_sigtramp (gdbarch, alphanbsd_pc_in_sigtramp);
|
|
|
|
/* NetBSD/alpha does not provide single step support via ptrace(2); we
|
|
must use software single-stepping. */
|
|
set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
|
|
|
|
set_solib_svr4_fetch_link_map_offsets (gdbarch,
|
|
nbsd_lp64_solib_svr4_fetch_link_map_offsets);
|
|
|
|
tdep->skip_sigtramp_frame = alphanbsd_skip_sigtramp_frame;
|
|
tdep->dynamic_sigtramp_offset = alphanbsd_sigtramp_offset;
|
|
tdep->sigcontext_addr = alphanbsd_sigcontext_addr;
|
|
|
|
tdep->jb_pc = 2;
|
|
tdep->jb_elt_size = 8;
|
|
}
|
|
|
|
void
|
|
_initialize_alphanbsd_tdep (void)
|
|
{
|
|
gdbarch_register_osabi (bfd_arch_alpha, 0, GDB_OSABI_NETBSD_ELF,
|
|
alphanbsd_init_abi);
|
|
|
|
add_core_fns (&alphanbsd_core_fns);
|
|
add_core_fns (&alphanbsd_elfcore_fns);
|
|
}
|