30 #include "gdb/sim-lm32.h" 31 #include "gdb/callback.h" 32 #include "gdb/remote-sim.h" 38 #include "opcodes/lm32-desc.h" 42 #define LM32_OPCODE(insn) ((insn >> 26) & 0x3f) 43 #define LM32_REG0(insn) ((insn >> 21) & 0x1f) 44 #define LM32_REG1(insn) ((insn >> 16) & 0x1f) 45 #define LM32_REG2(insn) ((insn >> 11) & 0x1f) 46 #define LM32_IMM16(insn) ((((long)insn & 0xffff) << 16) >> 16) 81 return ((
regnum >= SIM_LM32_R0_REGNUM) && (
regnum <= SIM_LM32_RA_REGNUM))
82 || (
regnum == SIM_LM32_PC_REGNUM);
84 return ((
regnum >= SIM_LM32_EA_REGNUM) && (
regnum <= SIM_LM32_BA_REGNUM))
85 || ((
regnum >= SIM_LM32_EID_REGNUM) && (
regnum <= SIM_LM32_IP_REGNUM));
94 static const char *register_names[] = {
95 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
96 "r8",
"r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15",
97 "r16",
"r17",
"r18",
"r19",
"r20",
"r21",
"r22",
"r23",
98 "r24",
"r25",
"gp",
"fp",
"sp",
"ra",
"ea",
"ba",
99 "PC",
"EID",
"EBA",
"DEBA",
"IE",
"IM",
"IP" 102 if ((reg_nr < 0) || (reg_nr >= ARRAY_SIZE (register_names)))
105 return register_names[reg_nr];
121 return (regno == SIM_LM32_R0_REGNUM) || (regno == SIM_LM32_EID_REGNUM);
132 unsigned long instruction;
137 for (; pc < limit; pc += 4)
144 && (
LM32_REG0 (instruction) == SIM_LM32_SP_REGNUM))
153 && (
LM32_REG1 (instruction) == SIM_LM32_SP_REGNUM))
161 && (
LM32_REG2 (instruction) == SIM_LM32_FP_REGNUM)
162 && (
LM32_REG0 (instruction) == SIM_LM32_FP_REGNUM)
163 && (
LM32_REG1 (instruction) == SIM_LM32_SP_REGNUM))
166 && (
LM32_REG1 (instruction) == SIM_LM32_FP_REGNUM)
167 && (
LM32_REG0 (instruction) == SIM_LM32_R0_REGNUM)))
200 if (post_prologue_pc != 0)
201 return std::max (pc, post_prologue_pc);
234 int first_arg_reg = SIM_LM32_R1_REGNUM;
235 int num_arg_regs = 8;
252 for (i = 0; i < nargs; i++)
254 struct value *arg = args[i];
283 if (i < num_arg_regs)
323 memcpy (valbuf, &l, 4);
325 memcpy (valbuf + 4, &l, 4);
361 error (
_(
"lm32_store_return_value: type length too large."));
420 if ((*this_prologue_cache))
424 (*this_prologue_cache) = info;
430 info->
pc, current_pc, info);
434 prev_sp = this_base + info->
size;
435 info->
base = this_base;
464 if (cache->
base == 0)
470 static struct value *
472 void **this_prologue_cache,
int regnum)
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)
static const struct frame_base lm32_frame_base
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)
void write_memory_unsigned_integer(CORE_ADDR addr, int len, enum bfd_endian byte_order, ULONGEST value)
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)
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)
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
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
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)
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)
int default_frame_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache)
constexpr gdb_byte lm32_break_insn[4]
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_breakpoint_kind_from_pc(struct gdbarch *gdbarch, gdbarch_breakpoint_kind_from_pc_ftype breakpoint_kind_from_pc)
struct trad_frame_saved_reg * trad_frame_alloc_saved_regs(struct gdbarch *gdbarch)
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)
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)
typedef BP_MANIPULATION(lm32_break_insn)
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 set_gdbarch_sw_breakpoint_from_kind(struct gdbarch *gdbarch, gdbarch_sw_breakpoint_from_kind_ftype sw_breakpoint_from_kind)
void register_gdbarch_init(enum bfd_architecture bfd_architecture, gdbarch_init_ftype *init)
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)
void _initialize_lm32_tdep(void)
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,...)
#define LM32_OPCODE(insn)
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)
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)