gdb/mips-sde-tdep.c - gdb
Global variables defined
Functions defined
Source code
- #include "defs.h"
- #include "osabi.h"
- #include "elf-bfd.h"
- #include "block.h"
- #include "symtab.h"
- #include "frame.h"
- #include "frame-unwind.h"
- #include "frame-base.h"
- #include "trad-frame.h"
- #include "mips-tdep.h"
- static struct trad_frame_cache *
- mips_sde_frame_cache (struct frame_info *this_frame, void **this_cache)
- {
- struct gdbarch *gdbarch = get_frame_arch (this_frame);
- const struct mips_regnum *regs = mips_regnum (gdbarch);
- const int sizeof_reg_t = mips_abi_regsize (gdbarch);
- enum mips_abi abi = mips_abi (gdbarch);
- struct trad_frame_cache *cache;
- CORE_ADDR xcpt_frame;
- CORE_ADDR start_addr;
- CORE_ADDR stack_addr;
- CORE_ADDR pc;
- int i;
- if (*this_cache != NULL)
- return *this_cache;
- cache = trad_frame_cache_zalloc (this_frame);
- *this_cache = cache;
-
- stack_addr = get_frame_register_signed (this_frame,
- gdbarch_sp_regnum (gdbarch));
- switch (abi)
- {
- case MIPS_ABI_O32:
-
- xcpt_frame = stack_addr + 40;
- break;
- case MIPS_ABI_N32:
- case MIPS_ABI_N64:
- default:
-
- xcpt_frame = stack_addr + 16;
- break;
- }
- trad_frame_set_reg_addr (cache,
- MIPS_PS_REGNUM + gdbarch_num_regs (gdbarch),
- xcpt_frame + 0 * sizeof_reg_t);
- trad_frame_set_reg_addr (cache,
- regs->cause + gdbarch_num_regs (gdbarch),
- xcpt_frame + 1 * sizeof_reg_t);
- trad_frame_set_reg_addr (cache,
- regs->pc + gdbarch_num_regs (gdbarch),
- xcpt_frame + 2 * sizeof_reg_t);
- trad_frame_set_reg_addr (cache,
- regs->badvaddr + gdbarch_num_regs (gdbarch),
- xcpt_frame + 3 * sizeof_reg_t);
- for (i = 0; i < MIPS_NUMREGS; i++)
- trad_frame_set_reg_addr (cache,
- i + MIPS_ZERO_REGNUM + gdbarch_num_regs (gdbarch),
- xcpt_frame + (4 + i) * sizeof_reg_t);
- trad_frame_set_reg_addr (cache,
- regs->lo + gdbarch_num_regs (gdbarch),
- xcpt_frame + 36 * sizeof_reg_t);
- trad_frame_set_reg_addr (cache,
- regs->hi + gdbarch_num_regs (gdbarch),
- xcpt_frame + 37 * sizeof_reg_t);
- pc = get_frame_pc (this_frame);
- find_pc_partial_function (pc, NULL, &start_addr, NULL);
- trad_frame_set_id (cache, frame_id_build (start_addr, stack_addr));
- return cache;
- }
- static void
- mips_sde_frame_this_id (struct frame_info *this_frame, void **this_cache,
- struct frame_id *this_id)
- {
- struct trad_frame_cache *this_trad_cache
- = mips_sde_frame_cache (this_frame, this_cache);
- trad_frame_get_id (this_trad_cache, this_id);
- }
- static struct value *
- mips_sde_frame_prev_register (struct frame_info *this_frame,
- void **this_cache,
- int prev_regnum)
- {
- struct trad_frame_cache *trad_cache
- = mips_sde_frame_cache (this_frame, this_cache);
- return trad_frame_get_register (trad_cache, this_frame, prev_regnum);
- }
- static int
- mips_sde_frame_sniffer (const struct frame_unwind *self,
- struct frame_info *this_frame,
- void **this_cache)
- {
- CORE_ADDR pc = get_frame_pc (this_frame);
- const char *name;
- find_pc_partial_function (pc, &name, NULL, NULL);
- return (name
- && (strcmp (name, "_xcptcall") == 0
- || strcmp (name, "_sigtramp") == 0));
- }
- static const struct frame_unwind mips_sde_frame_unwind =
- {
- SIGTRAMP_FRAME,
- default_frame_unwind_stop_reason,
- mips_sde_frame_this_id,
- mips_sde_frame_prev_register,
- NULL,
- mips_sde_frame_sniffer
- };
- static CORE_ADDR
- mips_sde_frame_base_address (struct frame_info *this_frame, void **this_cache)
- {
- struct trad_frame_cache *this_trad_cache
- = mips_sde_frame_cache (this_frame, this_cache);
- return trad_frame_get_this_base (this_trad_cache);
- }
- static const struct frame_base mips_sde_frame_base =
- {
- &mips_sde_frame_unwind,
- mips_sde_frame_base_address,
- mips_sde_frame_base_address,
- mips_sde_frame_base_address
- };
- static const struct frame_base *
- mips_sde_frame_base_sniffer (struct frame_info *this_frame)
- {
- if (mips_sde_frame_sniffer (&mips_sde_frame_unwind, this_frame, NULL))
- return &mips_sde_frame_base;
- else
- return NULL;
- }
- static void
- mips_sde_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect,
- void *obj)
- {
- enum gdb_osabi *os_ident_ptr = obj;
- const char *name;
- name = bfd_get_section_name (abfd, sect);
-
- if (strncmp (name, ".sde", 4) == 0)
- *os_ident_ptr = GDB_OSABI_SDE;
- }
- static enum gdb_osabi
- mips_sde_elf_osabi_sniffer (bfd *abfd)
- {
- enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
- unsigned int elfosabi;
-
- bfd_map_over_sections (abfd,
- generic_elf_osabi_sniff_abi_tag_sections,
- &osabi);
- if (osabi != GDB_OSABI_UNKNOWN)
- return GDB_OSABI_UNKNOWN;
- elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
- if (elfosabi == ELFOSABI_NONE)
- {
-
- bfd_map_over_sections (abfd,
- mips_sde_elf_osabi_sniff_abi_tag_sections,
- &osabi);
- }
- return osabi;
- }
- static void
- mips_sde_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
- {
- frame_unwind_append_unwinder (gdbarch, &mips_sde_frame_unwind);
- frame_base_append_sniffer (gdbarch, mips_sde_frame_base_sniffer);
- }
- extern initialize_file_ftype _initialize_mips_sde_tdep;
- void
- _initialize_mips_sde_tdep (void)
- {
- gdbarch_register_osabi_sniffer (bfd_arch_mips,
- bfd_target_elf_flavour,
- mips_sde_elf_osabi_sniffer);
- gdbarch_register_osabi (bfd_arch_mips, 0, GDB_OSABI_SDE, mips_sde_init_abi);
- }