gdb/mipsnbsd-tdep.c - gdb
Global variables defined
Functions defined
Macros defined
Source code
- #include "defs.h"
- #include "gdbcore.h"
- #include "regcache.h"
- #include "regset.h"
- #include "target.h"
- #include "value.h"
- #include "osabi.h"
- #include "nbsd-tdep.h"
- #include "mipsnbsd-tdep.h"
- #include "mips-tdep.h"
- #include "solib-svr4.h"
- #define MIPS_PC_REGNUM MIPS_EMBED_PC_REGNUM
- #define MIPS_FP0_REGNUM MIPS_EMBED_FP0_REGNUM
- #define MIPS_FSR_REGNUM MIPS_EMBED_FP0_REGNUM + 32
- #define MIPSNBSD_NUM_GREGS 38
- #define MIPSNBSD_NUM_FPREGS 33
- static void
- mipsnbsd_supply_fpregset (const struct regset *regset,
- struct regcache *regcache,
- int regnum, const void *fpregs, size_t len)
- {
- size_t regsize = mips_isa_regsize (get_regcache_arch (regcache));
- const char *regs = fpregs;
- int i;
- gdb_assert (len >= MIPSNBSD_NUM_FPREGS * regsize);
- for (i = MIPS_FP0_REGNUM; i <= MIPS_FSR_REGNUM; i++)
- {
- if (regnum == i || regnum == -1)
- regcache_raw_supply (regcache, i,
- regs + (i - MIPS_FP0_REGNUM) * regsize);
- }
- }
- static void
- mipsnbsd_supply_gregset (const struct regset *regset,
- struct regcache *regcache, int regnum,
- const void *gregs, size_t len)
- {
- size_t regsize = mips_isa_regsize (get_regcache_arch (regcache));
- const char *regs = gregs;
- int i;
- gdb_assert (len >= MIPSNBSD_NUM_GREGS * regsize);
- for (i = 0; i <= MIPS_PC_REGNUM; i++)
- {
- if (regnum == i || regnum == -1)
- regcache_raw_supply (regcache, i, regs + i * regsize);
- }
- if (len >= (MIPSNBSD_NUM_GREGS + MIPSNBSD_NUM_FPREGS) * regsize)
- {
- regs += MIPSNBSD_NUM_GREGS * regsize;
- len -= MIPSNBSD_NUM_GREGS * regsize;
- mipsnbsd_supply_fpregset (regset, regcache, regnum, regs, len);
- }
- }
- static const struct regset mipsnbsd_gregset =
- {
- NULL,
- mipsnbsd_supply_gregset
- };
- static const struct regset mipsnbsd_fpregset =
- {
- NULL,
- mipsnbsd_supply_fpregset
- };
- static void
- mipsnbsd_iterate_over_regset_sections (struct gdbarch *gdbarch,
- iterate_over_regset_sections_cb *cb,
- void *cb_data,
- const struct regcache *regcache)
- {
- size_t regsize = mips_isa_regsize (gdbarch);
- cb (".reg", MIPSNBSD_NUM_GREGS * regsize, &mipsnbsd_gregset,
- NULL, cb_data);
- cb (".reg2", MIPSNBSD_NUM_FPREGS * regsize, &mipsnbsd_fpregset,
- NULL, cb_data);
- }
- void
- mipsnbsd_supply_reg (struct regcache *regcache, const char *regs, int regno)
- {
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
- int i;
- for (i = 0; i <= gdbarch_pc_regnum (gdbarch); i++)
- {
- if (regno == i || regno == -1)
- {
- if (gdbarch_cannot_fetch_register (gdbarch, i))
- regcache_raw_supply (regcache, i, NULL);
- else
- regcache_raw_supply (regcache, i,
- regs + (i * mips_isa_regsize (gdbarch)));
- }
- }
- }
- void
- mipsnbsd_fill_reg (const struct regcache *regcache, char *regs, int regno)
- {
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
- int i;
- for (i = 0; i <= gdbarch_pc_regnum (gdbarch); i++)
- if ((regno == i || regno == -1)
- && ! gdbarch_cannot_store_register (gdbarch, i))
- regcache_raw_collect (regcache, i,
- regs + (i * mips_isa_regsize (gdbarch)));
- }
- void
- mipsnbsd_supply_fpreg (struct regcache *regcache,
- const char *fpregs, int regno)
- {
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
- int i;
- for (i = gdbarch_fp0_regnum (gdbarch);
- i <= mips_regnum (gdbarch)->fp_implementation_revision;
- i++)
- {
- if (regno == i || regno == -1)
- {
- if (gdbarch_cannot_fetch_register (gdbarch, i))
- regcache_raw_supply (regcache, i, NULL);
- else
- regcache_raw_supply (regcache, i,
- fpregs
- + ((i - gdbarch_fp0_regnum (gdbarch))
- * mips_isa_regsize (gdbarch)));
- }
- }
- }
- void
- mipsnbsd_fill_fpreg (const struct regcache *regcache, char *fpregs, int regno)
- {
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
- int i;
- for (i = gdbarch_fp0_regnum (gdbarch);
- i <= mips_regnum (gdbarch)->fp_control_status;
- i++)
- if ((regno == i || regno == -1)
- && ! gdbarch_cannot_store_register (gdbarch, i))
- regcache_raw_collect (regcache, i,
- fpregs + ((i - gdbarch_fp0_regnum (gdbarch))
- * mips_isa_regsize (gdbarch)));
- }
- #if 0
- #endif
- #define NBSD_MIPS_JB_PC (2 * 4)
- #define NBSD_MIPS_JB_ELEMENT_SIZE(gdbarch) mips_isa_regsize (gdbarch)
- #define NBSD_MIPS_JB_OFFSET(gdbarch) (NBSD_MIPS_JB_PC * \
- NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch))
- static int
- mipsnbsd_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
- {
- struct gdbarch *gdbarch = get_frame_arch (frame);
- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- CORE_ADDR jb_addr;
- gdb_byte *buf;
- buf = alloca (NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch));
- jb_addr = get_frame_register_unsigned (frame, MIPS_A0_REGNUM);
- if (target_read_memory (jb_addr + NBSD_MIPS_JB_OFFSET (gdbarch), buf,
- NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch)))
- return 0;
- *pc = extract_unsigned_integer (buf, NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch),
- byte_order);
- return 1;
- }
- static int
- mipsnbsd_cannot_fetch_register (struct gdbarch *gdbarch, int regno)
- {
- return (regno == MIPS_ZERO_REGNUM
- || regno == mips_regnum (gdbarch)->fp_implementation_revision);
- }
- static int
- mipsnbsd_cannot_store_register (struct gdbarch *gdbarch, int regno)
- {
- return (regno == MIPS_ZERO_REGNUM
- || regno == mips_regnum (gdbarch)->fp_implementation_revision);
- }
- static struct link_map_offsets *
- mipsnbsd_ilp32_fetch_link_map_offsets (void)
- {
- static struct link_map_offsets lmo;
- static struct link_map_offsets *lmp = NULL;
- if (lmp == NULL)
- {
- lmp = &lmo;
- lmo.r_version_offset = 0;
- lmo.r_version_size = 4;
- lmo.r_map_offset = 4;
- lmo.r_brk_offset = 8;
- lmo.r_ldsomap_offset = -1;
-
- lmo.link_map_size = 24;
- lmo.l_addr_offset = 4;
- lmo.l_name_offset = 8;
- lmo.l_ld_offset = 12;
- lmo.l_next_offset = 16;
- lmo.l_prev_offset = 20;
- }
- return lmp;
- }
- static struct link_map_offsets *
- mipsnbsd_lp64_fetch_link_map_offsets (void)
- {
- static struct link_map_offsets lmo;
- static struct link_map_offsets *lmp = NULL;
- if (lmp == NULL)
- {
- lmp = &lmo;
- lmo.r_version_offset = 0;
- lmo.r_version_size = 4;
- lmo.r_map_offset = 8;
- lmo.r_brk_offset = 16;
- lmo.r_ldsomap_offset = -1;
-
- lmo.link_map_size = 48;
- lmo.l_addr_offset = 0;
- lmo.l_name_offset = 16;
- lmo.l_ld_offset = 24;
- lmo.l_next_offset = 32;
- lmo.l_prev_offset = 40;
- }
- return lmp;
- }
- static void
- mipsnbsd_init_abi (struct gdbarch_info info,
- struct gdbarch *gdbarch)
- {
- set_gdbarch_iterate_over_regset_sections
- (gdbarch, mipsnbsd_iterate_over_regset_sections);
- set_gdbarch_get_longjmp_target (gdbarch, mipsnbsd_get_longjmp_target);
- set_gdbarch_cannot_fetch_register (gdbarch, mipsnbsd_cannot_fetch_register);
- set_gdbarch_cannot_store_register (gdbarch, mipsnbsd_cannot_store_register);
- set_gdbarch_software_single_step (gdbarch, mips_software_single_step);
-
- set_solib_svr4_fetch_link_map_offsets
- (gdbarch, (gdbarch_ptr_bit (gdbarch) == 32 ?
- mipsnbsd_ilp32_fetch_link_map_offsets :
- mipsnbsd_lp64_fetch_link_map_offsets));
- }
- extern initialize_file_ftype _initialize_mipsnbsd_tdep;
- void
- _initialize_mipsnbsd_tdep (void)
- {
- gdbarch_register_osabi (bfd_arch_mips, 0, GDB_OSABI_NETBSD_ELF,
- mipsnbsd_init_abi);
- }