30#include "sim/sim-lm32.h"
39#define GDB_CGEN_REMAP_PREFIX lm32
41#include "opcodes/lm32-desc.h"
44#define LM32_OPCODE(insn) ((insn >> 26) & 0x3f)
45#define LM32_REG0(insn) ((insn >> 21) & 0x1f)
46#define LM32_REG1(insn) ((insn >> 16) & 0x1f)
47#define LM32_REG2(insn) ((insn >> 11) & 0x1f)
48#define LM32_IMM16(insn) ((((long)insn & 0xffff) << 16) >> 16)
73 return ((
regnum >= SIM_LM32_R0_REGNUM) && (
regnum <= SIM_LM32_RA_REGNUM))
74 || (
regnum == SIM_LM32_PC_REGNUM);
76 return ((
regnum >= SIM_LM32_BA_REGNUM) && (
regnum <= SIM_LM32_EA_REGNUM))
77 || ((
regnum >= SIM_LM32_EID_REGNUM) && (
regnum <= SIM_LM32_IP_REGNUM));
86 static const char *register_names[] = {
87 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
88 "r8",
"r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15",
89 "r16",
"r17",
"r18",
"r19",
"r20",
"r21",
"r22",
"r23",
90 "r24",
"r25",
"gp",
"fp",
"sp",
"ra",
"ea",
"ba",
91 "PC",
"EID",
"EBA",
"DEBA",
"IE",
"IM",
"IP"
95 return register_names[reg_nr];
111 return (regno == SIM_LM32_R0_REGNUM) || (regno == SIM_LM32_EID_REGNUM);
118 CORE_ADDR pc, CORE_ADDR limit,
122 unsigned long instruction;
127 for (; pc < limit; pc += 4)
134 && (
LM32_REG0 (instruction) == SIM_LM32_SP_REGNUM))
142 && (
LM32_REG1 (instruction) == SIM_LM32_SP_REGNUM))
150 && (
LM32_REG2 (instruction) == SIM_LM32_FP_REGNUM)
151 && (
LM32_REG0 (instruction) == SIM_LM32_FP_REGNUM)
152 && (
LM32_REG1 (instruction) == SIM_LM32_SP_REGNUM))
155 && (
LM32_REG1 (instruction) == SIM_LM32_FP_REGNUM)
156 && (
LM32_REG0 (instruction) == SIM_LM32_R0_REGNUM)))
178 CORE_ADDR func_addr, limit_pc;
187 CORE_ADDR post_prologue_pc
189 if (post_prologue_pc != 0)
190 return std::max (
pc, post_prologue_pc);
219 int nargs,
struct value **args, CORE_ADDR sp,
221 CORE_ADDR struct_addr)
224 int first_arg_reg = SIM_LM32_R1_REGNUM;
225 int num_arg_regs = 8;
242 for (i = 0; i < nargs; i++)
244 struct value *arg = args[i];
250 switch (arg_type->
code ())
255 case TYPE_CODE_RANGE:
257 if (arg_type->
length () < 4)
267 contents = (gdb_byte *) arg->
contents ().data ();
273 if (i < num_arg_regs)
299 CORE_ADDR return_buffer;
301 if (
type->
code () != TYPE_CODE_STRUCT
313 memcpy (valbuf, &l, 4);
315 memcpy (valbuf + 4, &l, 4);
331 const gdb_byte *valbuf)
351 error (_(
"lm32_store_return_value: type length too large."));
358 gdb_byte *readbuf,
const gdb_byte *writebuf)
362 if (
code == TYPE_CODE_STRUCT
363 ||
code == TYPE_CODE_UNION
364 ||
code == TYPE_CODE_ARRAY || valtype->
length () > 8)
384 CORE_ADDR current_pc;
390 if ((*this_prologue_cache))
394 (*this_prologue_cache) = info;
400 info->pc, current_pc, info);
404 prev_sp = this_base + info->size;
405 info->base = this_base;
410 if (info->saved_regs[i].is_addr ())
411 info->saved_regs[i].set_addr (this_base + info->saved_regs[i].addr ());
418 info->saved_regs[SIM_LM32_PC_REGNUM] = info->saved_regs[SIM_LM32_RA_REGNUM];
422 info->saved_regs[SIM_LM32_SP_REGNUM].set_value (prev_sp);
434 if (cache->
base == 0)
442 void **this_prologue_cache,
int regnum)
gdb_static_assert(sizeof(splay_tree_key) >=sizeof(CORE_ADDR *))
void gdbarch_register(enum bfd_architecture bfd_architecture, gdbarch_init_ftype *init, gdbarch_dump_tdep_ftype *dump_tdep, gdbarch_supports_arch_info_ftype *supports_arch_info)
static std::vector< const char * > arches
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
struct gdbarch_list * gdbarch_list_lookup_by_info(struct gdbarch_list *arches, const struct gdbarch_info *info)
#define BP_MANIPULATION(BREAK_INSN)
bool find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr, const struct block **block)
void write_memory_unsigned_integer(CORE_ADDR addr, int len, enum bfd_endian byte_order, ULONGEST value)
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
LONGEST read_memory_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
@ RETURN_VALUE_REGISTER_CONVENTION
@ RETURN_VALUE_STRUCT_CONVENTION
void frame_base_set_default(struct gdbarch *gdbarch, const struct frame_base *default_base)
int default_frame_sniffer(const struct frame_unwind *self, frame_info_ptr this_frame, void **this_prologue_cache)
enum unwind_stop_reason default_frame_unwind_stop_reason(frame_info_ptr this_frame, void **this_cache)
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
ULONGEST get_frame_register_unsigned(frame_info_ptr frame, int regnum)
CORE_ADDR get_frame_pc(frame_info_ptr frame)
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
CORE_ADDR get_frame_func(frame_info_ptr this_frame)
#define FRAME_OBSTACK_ZALLOC(TYPE)
void set_gdbarch_long_long_bit(struct gdbarch *gdbarch, int long_long_bit)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
void set_gdbarch_breakpoint_kind_from_pc(struct gdbarch *gdbarch, gdbarch_breakpoint_kind_from_pc_ftype *breakpoint_kind_from_pc)
void set_gdbarch_frame_align(struct gdbarch *gdbarch, gdbarch_frame_align_ftype *frame_align)
void set_gdbarch_skip_prologue(struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype *skip_prologue)
void set_gdbarch_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype *register_name)
void set_gdbarch_int_bit(struct gdbarch *gdbarch, int int_bit)
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype *return_value)
void set_gdbarch_decr_pc_after_break(struct gdbarch *gdbarch, CORE_ADDR decr_pc_after_break)
void set_gdbarch_have_nonsteppable_watchpoint(struct gdbarch *gdbarch, int have_nonsteppable_watchpoint)
int gdbarch_num_regs(struct gdbarch *gdbarch)
void set_gdbarch_double_bit(struct gdbarch *gdbarch, int double_bit)
void set_gdbarch_inner_than(struct gdbarch *gdbarch, gdbarch_inner_than_ftype *inner_than)
void set_gdbarch_sp_regnum(struct gdbarch *gdbarch, int sp_regnum)
void set_gdbarch_register_reggroup_p(struct gdbarch *gdbarch, gdbarch_register_reggroup_p_ftype *register_reggroup_p)
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype *register_type)
void set_gdbarch_float_bit(struct gdbarch *gdbarch, int float_bit)
void set_gdbarch_short_bit(struct gdbarch *gdbarch, int short_bit)
void set_gdbarch_long_bit(struct gdbarch *gdbarch, int long_bit)
void set_gdbarch_ptr_bit(struct gdbarch *gdbarch, int ptr_bit)
void set_gdbarch_cannot_store_register(struct gdbarch *gdbarch, gdbarch_cannot_store_register_ftype *cannot_store_register)
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
void set_gdbarch_long_double_bit(struct gdbarch *gdbarch, int long_double_bit)
void set_gdbarch_sw_breakpoint_from_kind(struct gdbarch *gdbarch, gdbarch_sw_breakpoint_from_kind_ftype *sw_breakpoint_from_kind)
void set_gdbarch_push_dummy_call(struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype *push_dummy_call)
void set_gdbarch_frame_args_skip(struct gdbarch *gdbarch, CORE_ADDR frame_args_skip)
struct gdbarch * gdbarch_alloc(const struct gdbarch_info *info, gdbarch_tdep_up tdep)
std::unique_ptr< gdbarch_tdep_base > gdbarch_tdep_up
function_call_return_method
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
struct type * check_typedef(struct type *type)
static int lm32_cannot_store_register(struct gdbarch *gdbarch, int regno)
static void lm32_frame_this_id(frame_info_ptr this_frame, void **this_cache, struct frame_id *this_id)
static CORE_ADDR lm32_frame_base_address(frame_info_ptr this_frame, void **this_cache)
static const char * lm32_register_name(struct gdbarch *gdbarch, int reg_nr)
static struct type * lm32_register_type(struct gdbarch *gdbarch, int reg_nr)
static CORE_ADDR lm32_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
static const struct frame_unwind lm32_frame_unwind
static struct gdbarch * lm32_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
static CORE_ADDR lm32_frame_align(struct gdbarch *gdbarch, CORE_ADDR sp)
constexpr gdb_byte lm32_break_insn[4]
static struct value * lm32_frame_prev_register(frame_info_ptr this_frame, void **this_prologue_cache, int regnum)
static void lm32_extract_return_value(struct type *type, struct regcache *regcache, gdb_byte *valbuf)
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)
static CORE_ADDR lm32_analyze_prologue(struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR limit, struct lm32_frame_cache *info)
static struct lm32_frame_cache * lm32_frame_cache(frame_info_ptr this_frame, void **this_prologue_cache)
void _initialize_lm32_tdep()
static void lm32_store_return_value(struct type *type, struct regcache *regcache, const gdb_byte *valbuf)
static const struct frame_base lm32_frame_base
static int lm32_register_reggroup_p(struct gdbarch *gdbarch, int regnum, const struct reggroup *group)
#define LM32_OPCODE(insn)
void regcache_cooked_write_signed(struct regcache *regcache, int regnum, LONGEST val)
enum register_status regcache_cooked_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
const reggroup *const general_reggroup
int default_register_reggroup_p(struct gdbarch *gdbarch, int regnum, const struct reggroup *group)
const reggroup *const system_reggroup
struct type * builtin_int32
trad_frame_saved_reg * saved_regs
gdb::array_view< const gdb_byte > contents()
struct type * type() const
CORE_ADDR skip_prologue_using_sal(struct gdbarch *gdbarch, CORE_ADDR func_addr)
trad_frame_saved_reg * trad_frame_alloc_saved_regs(struct gdbarch *gdbarch)
struct value * trad_frame_get_prev_register(frame_info_ptr this_frame, trad_frame_saved_reg this_saved_regs[], int regnum)
struct value * value_cast(struct type *type, struct value *arg2)