30 #include "gdb/sim-lm32.h"
31 #include "gdb/callback.h"
32 #include "gdb/remote-sim.h"
38 #include "opcodes/lm32-desc.h"
41 #define LM32_OPCODE(insn) ((insn >> 26) & 0x3f)
42 #define LM32_REG0(insn) ((insn >> 21) & 0x1f)
43 #define LM32_REG1(insn) ((insn >> 16) & 0x1f)
44 #define LM32_REG2(insn) ((insn >> 11) & 0x1f)
45 #define LM32_IMM16(insn) ((((long)insn & 0xffff) << 16) >> 16)
80 return ((regnum >= SIM_LM32_R0_REGNUM) && (regnum <= SIM_LM32_RA_REGNUM))
81 || (regnum == SIM_LM32_PC_REGNUM);
83 return ((regnum >= SIM_LM32_EA_REGNUM) && (regnum <= SIM_LM32_BA_REGNUM))
84 || ((regnum >= SIM_LM32_EID_REGNUM) && (regnum <= SIM_LM32_IP_REGNUM));
93 static char *register_names[] = {
94 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
95 "r8",
"r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15",
96 "r16",
"r17",
"r18",
"r19",
"r20",
"r21",
"r22",
"r23",
97 "r24",
"r25",
"gp",
"fp",
"sp",
"ra",
"ea",
"ba",
98 "PC",
"EID",
"EBA",
"DEBA",
"IE",
"IM",
"IP"
101 if ((reg_nr < 0) || (reg_nr >= ARRAY_SIZE (register_names)))
104 return register_names[reg_nr];
120 return (regno == SIM_LM32_R0_REGNUM) || (regno == SIM_LM32_EID_REGNUM);
131 unsigned long instruction;
136 for (; pc < limit; pc += 4)
143 && (
LM32_REG0 (instruction) == SIM_LM32_SP_REGNUM))
152 && (
LM32_REG1 (instruction) == SIM_LM32_SP_REGNUM))
160 && (
LM32_REG2 (instruction) == SIM_LM32_FP_REGNUM)
161 && (
LM32_REG0 (instruction) == SIM_LM32_FP_REGNUM)
162 && (
LM32_REG1 (instruction) == SIM_LM32_SP_REGNUM))
165 && (
LM32_REG1 (instruction) == SIM_LM32_FP_REGNUM)
166 && (
LM32_REG0 (instruction) == SIM_LM32_R0_REGNUM)))
199 if (post_prologue_pc != 0)
200 return max (pc, post_prologue_pc);
225 *lenptr =
sizeof (breakpoint);
239 int first_arg_reg = SIM_LM32_R1_REGNUM;
240 int num_arg_regs = 8;
257 for (i = 0; i < nargs; i++)
259 struct value *arg = args[i];
288 if (i < num_arg_regs)
327 memcpy (valbuf, &l, 4);
329 memcpy (valbuf + 4, &l, 4);
365 error (
_(
"lm32_store_return_value: type length too large."));
424 if ((*this_prologue_cache))
425 return (*this_prologue_cache);
428 (*this_prologue_cache) = info;
434 info->
pc, current_pc, info);
438 prev_sp = this_base + info->
size;
439 info->
base = this_base;
468 if (cache->
base == 0)
474 static struct value *
476 void **this_prologue_cache,
int regnum)
505 lm32_frame_base_address
516 static struct gdbarch *
519 struct gdbarch *gdbarch;
void reggroup_add(struct gdbarch *gdbarch, struct reggroup *group)
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
void set_gdbarch_double_bit(struct gdbarch *gdbarch, int double_bit)
void set_gdbarch_frame_align(struct gdbarch *gdbarch, gdbarch_frame_align_ftype frame_align)
void set_gdbarch_have_nonsteppable_watchpoint(struct gdbarch *gdbarch, int have_nonsteppable_watchpoint)
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
static const struct frame_unwind lm32_frame_unwind
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
static CORE_ADDR lm32_frame_align(struct gdbarch *gdbarch, CORE_ADDR sp)
void set_gdbarch_float_bit(struct gdbarch *gdbarch, int float_bit)
CORE_ADDR get_frame_pc(struct frame_info *frame)
static struct lm32_frame_cache * lm32_frame_cache(struct frame_info *this_frame, void **this_prologue_cache)
struct value * trad_frame_get_prev_register(struct frame_info *this_frame, struct trad_frame_saved_reg this_saved_regs[], int regnum)
int trad_frame_addr_p(struct trad_frame_saved_reg this_saved_regs[], int regnum)
struct gdbarch * get_regcache_arch(const struct regcache *regcache)
void trad_frame_set_value(struct trad_frame_saved_reg this_saved_regs[], int regnum, LONGEST val)
ULONGEST frame_unwind_register_unsigned(struct frame_info *frame, int regnum)
void regcache_cooked_write_signed(struct regcache *regcache, int regnum, LONGEST val)
void set_gdbarch_short_bit(struct gdbarch *gdbarch, int short_bit)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
void set_gdbarch_register_reggroup_p(struct gdbarch *gdbarch, gdbarch_register_reggroup_p_ftype register_reggroup_p)
struct gdbarch_list * gdbarch_list_lookup_by_info(struct gdbarch_list *arches, const struct gdbarch_info *info)
CORE_ADDR skip_prologue_using_sal(struct gdbarch *gdbarch, CORE_ADDR func_addr)
int gdbarch_num_regs(struct gdbarch *gdbarch)
struct reggroup *const all_reggroup
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
struct type * builtin_int32
#define FRAME_OBSTACK_ZALLOC(TYPE)
void store_unsigned_integer(gdb_byte *, int, enum bfd_endian, ULONGEST)
static int lm32_register_reggroup_p(struct gdbarch *gdbarch, int regnum, struct reggroup *group)
static void lm32_frame_this_id(struct frame_info *this_frame, void **this_cache, struct frame_id *this_id)
static CORE_ADDR lm32_push_dummy_call(struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr)
void frame_base_set_default(struct gdbarch *gdbarch, const struct frame_base *default_base)
struct trad_frame_saved_reg * saved_regs
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype register_type)
struct type * check_typedef(struct type *type)
LONGEST read_memory_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
const gdb_byte * value_contents(struct value *value)
struct reggroup *const general_reggroup
void initialize_file_ftype(void)
enum register_status regcache_cooked_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
struct reggroup *const system_reggroup
void set_gdbarch_sp_regnum(struct gdbarch *gdbarch, int sp_regnum)
static struct value * lm32_frame_prev_register(struct frame_info *this_frame, void **this_prologue_cache, int regnum)
void set_gdbarch_decr_pc_after_break(struct gdbarch *gdbarch, CORE_ADDR decr_pc_after_break)
void set_gdbarch_dummy_id(struct gdbarch *gdbarch, gdbarch_dummy_id_ftype dummy_id)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
static CORE_ADDR lm32_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
void set_gdbarch_cannot_store_register(struct gdbarch *gdbarch, gdbarch_cannot_store_register_ftype cannot_store_register)
static const gdb_byte * lm32_breakpoint_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
int find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr)
void set_gdbarch_unwind_pc(struct gdbarch *gdbarch, gdbarch_unwind_pc_ftype unwind_pc)
void set_gdbarch_breakpoint_from_pc(struct gdbarch *gdbarch, gdbarch_breakpoint_from_pc_ftype breakpoint_from_pc)
int default_frame_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache)
initialize_file_ftype _initialize_lm32_tdep
static CORE_ADDR lm32_unwind_sp(struct gdbarch *gdbarch, struct frame_info *next_frame)
struct value * value_cast(struct type *type, struct value *arg2)
void set_gdbarch_unwind_sp(struct gdbarch *gdbarch, gdbarch_unwind_sp_ftype unwind_sp)
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
void set_gdbarch_frame_args_skip(struct gdbarch *gdbarch, CORE_ADDR frame_args_skip)
void set_gdbarch_long_long_bit(struct gdbarch *gdbarch, int long_long_bit)
static const char * lm32_register_name(struct gdbarch *gdbarch, int reg_nr)
static CORE_ADDR lm32_analyze_prologue(struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR limit, struct lm32_frame_cache *info)
static CORE_ADDR lm32_unwind_pc(struct gdbarch *gdbarch, struct frame_info *next_frame)
struct trad_frame_saved_reg * trad_frame_alloc_saved_regs(struct frame_info *this_frame)
static enum return_value_convention lm32_return_value(struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
#define TYPE_CODE(thistype)
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
static void lm32_add_reggroups(struct gdbarch *gdbarch)
void set_gdbarch_int_bit(struct gdbarch *gdbarch, int int_bit)
static CORE_ADDR lm32_frame_base_address(struct frame_info *this_frame, void **this_cache)
static void lm32_extract_return_value(struct type *type, struct regcache *regcache, gdb_byte *valbuf)
static int lm32_cannot_store_register(struct gdbarch *gdbarch, int regno)
static struct type * lm32_register_type(struct gdbarch *gdbarch, int reg_nr)
static struct gdbarch * lm32_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
unsigned long long ULONGEST
enum unwind_stop_reason default_frame_unwind_stop_reason(struct frame_info *this_frame, void **this_cache)
void set_gdbarch_long_double_bit(struct gdbarch *gdbarch, int long_double_bit)
struct type * value_type(const struct value *value)
void set_gdbarch_long_bit(struct gdbarch *gdbarch, int long_bit)
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype return_value)
static void lm32_store_return_value(struct type *type, struct regcache *regcache, const gdb_byte *valbuf)
int default_register_reggroup_p(struct gdbarch *gdbarch, int regnum, struct reggroup *group)
#define TYPE_LENGTH(thistype)
void set_gdbarch_ptr_bit(struct gdbarch *gdbarch, int ptr_bit)
void set_gdbarch_push_dummy_call(struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype push_dummy_call)
void register_gdbarch_init(enum bfd_architecture bfd_architecture, gdbarch_init_ftype *init)
void write_memory(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
void set_gdbarch_skip_prologue(struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype skip_prologue)
static struct frame_id lm32_dummy_id(struct gdbarch *gdbarch, struct frame_info *this_frame)
enum bfd_endian byte_order
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
void set_gdbarch_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype register_name)
CORE_ADDR get_frame_func(struct frame_info *this_frame)
void error(const char *fmt,...)
struct gdbarch * gdbarch_alloc(const struct gdbarch_info *info, struct gdbarch_tdep *tdep)
void set_gdbarch_inner_than(struct gdbarch *gdbarch, gdbarch_inner_than_ftype inner_than)
#define LM32_OPCODE(insn)
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
void set_gdbarch_print_insn(struct gdbarch *gdbarch, gdbarch_print_insn_ftype print_insn)
const ULONGEST const LONGEST len