39#include "elf/msp430.h"
40#include "opcode/msp430-decode.h"
190 static const char *
const reg_names[] = {
192 "",
"",
"",
"",
"",
"",
"",
"",
193 "",
"",
"",
"",
"",
"",
"",
"",
195 "pc",
"sp",
"sr",
"cg",
"r4",
"r5",
"r6",
"r7",
196 "r8",
"r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15"
201 return reg_names[regnr];
222static enum register_status
225 int regnum, gdb_byte *buffer)
229 enum register_status
status;
242 gdb_assert_not_reached (
"invalid pseudo register number");
250 int regnum,
const gdb_byte *buffer)
265 gdb_assert_not_reached (
"invalid pseudo register number");
287struct msp430_get_opcode_byte_handle
301 struct msp430_get_opcode_byte_handle *opcdata
302 = (
struct msp430_get_opcode_byte_handle *) handle;
342 CORE_ADDR pc, next_pc;
345 CORE_ADDR after_last_frame_setup_insn = start_pc;
350 memset (result, 0,
sizeof (*result));
366 while (pc < limit_pc)
369 struct msp430_get_opcode_byte_handle opcode_handle;
370 MSP430_Opcode_Decoded opc;
372 opcode_handle.pc = pc;
375 next_pc = pc + bytes_read;
377 if (opc.id == MSO_push && opc.op[0].type == MSP430_Operand_Register)
379 int rsrc = opc.op[0].reg;
383 after_last_frame_setup_insn = next_pc;
385 else if (opc.id == MSO_push
386 && opc.op[0].type == MSP430_Operand_None
387 && opc.op[1].type == MSP430_Operand_Register)
389 int rsrc = opc.op[1].reg;
390 int count = opc.repeats + 1;
391 int size = opc.size == 16 ? 2 : 4;
401 after_last_frame_setup_insn = next_pc;
403 else if (opc.id == MSO_sub
404 && opc.op[0].type == MSP430_Operand_Register
405 && opc.op[0].reg == MSR_SP
406 && opc.op[1].type == MSP430_Operand_Immediate)
408 int addend = opc.op[1].addend;
412 after_last_frame_setup_insn = next_pc;
414 else if (opc.id == MSO_mov
415 && opc.op[0].type == MSP430_Operand_Immediate
416 && 12 <= opc.op[0].reg && opc.op[0].reg <= 15)
417 after_last_frame_setup_insn = next_pc;
443 CORE_ADDR func_addr, func_end;
461 void **this_prologue_cache)
463 if (!*this_prologue_cache)
465 CORE_ADDR func_start, stop_addr;
475 stop_addr = func_start;
501 void **this_prologue_cache,
struct frame_id *this_id)
504 this_prologue_cache),
512 void **this_prologue_cache,
int regnum)
568 struct value *function,
569 struct type *valtype,
571 gdb_byte *readbuf,
const gdb_byte *writebuf)
574 LONGEST valtype_len = valtype->
length ();
578 if (valtype->
length () > 8
579 || valtype->
code () == TYPE_CODE_STRUCT
580 || valtype->
code () == TYPE_CODE_UNION)
589 while (valtype_len > 0)
594 && valtype->
code () == TYPE_CODE_PTR)
613 while (valtype_len > 0)
618 && valtype->
code () == TYPE_CODE_PTR)
640 return align_down (sp, 2);
648 int nargs,
struct value **args, CORE_ADDR sp,
650 CORE_ADDR struct_addr)
662 while (
func_type->code () == TYPE_CODE_PTR)
666 gdb_assert (
func_type->code () == TYPE_CODE_FUNC
667 ||
func_type->code () == TYPE_CODE_METHOD);
671 for (write_pass = 0; write_pass <= 1; write_pass++)
675 int args_on_stack = 0;
678 sp = align_down (sp - sp_off, 4);
689 for (i = 0; i < nargs; i++)
691 struct value *arg = args[i];
692 const gdb_byte *arg_bits = arg->
contents_all ().data ();
694 ULONGEST arg_size = arg_type->
length ();
696 int current_arg_on_stack;
697 gdb_byte struct_addr_buf[4];
699 current_arg_on_stack = 0;
701 if (arg_type->
code () == TYPE_CODE_STRUCT
702 || arg_type->
code () == TYPE_CODE_UNION)
707 arg_bits = struct_addr_buf;
715 current_arg_on_stack = 1;
719 for (offset = 0; offset < arg_size; offset += 2)
724 if (!current_arg_on_stack
726 + ((arg_size == 8 || args_on_stack)
727 ? ((arg_size - offset) / 2 - 1)
733 && (arg_type->
code () == TYPE_CODE_PTR
735 || arg_type->
code () == TYPE_CODE_STRUCT
736 || arg_type->
code () == TYPE_CODE_UNION))
751 (arg_bits + offset,
size,
763 current_arg_on_stack = 1;
810 const char *stub_name;
838 int elf_flags, isa, code_model;
841 if (
info.abfd != NULL
842 && bfd_get_flavour (
info.abfd) == bfd_target_elf_flavour)
843 elf_flags = elf_elfheader (
info.abfd)->e_flags;
847 if (
info.abfd != NULL)
848 switch (bfd_elf_get_obj_attr_int (
info.abfd, OBJ_ATTR_PROC,
849 OFBA_MSPABI_Tag_ISA))
857 switch (bfd_elf_get_obj_attr_int (
info.abfd, OBJ_ATTR_PROC,
858 OFBA_MSPABI_Tag_Code_Model))
867 internal_error (_(
"Unknown msp430x code memory model"));
880 = gdbarch_tdep<msp430_gdbarch_tdep> (ca);
890 error (_(
"Unknown msp430 isa"));
907 = gdbarch_tdep<msp430_gdbarch_tdep> (
arches->gdbarch);
909 if (candidate_tdep->
elf_flags != elf_flags
910 || candidate_tdep->
isa != isa
969 msp430_breakpoint::kind_from_pc);
971 msp430_breakpoint::bp_from_kind);
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)
struct gdbarch * get_current_arch(void)
struct gdbarch * target_gdbarch(void)
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 scan(void(*func)(void *closure, pv_t addr, CORE_ADDR size, pv_t value), void *closure)
void store(pv_t addr, CORE_ADDR size, pv_t value)
enum register_status raw_read(int regnum, gdb_byte *buf)
void write_memory(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
void write_memory_unsigned_integer(CORE_ADDR addr, int len, enum bfd_endian byte_order, ULONGEST value)
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 dwarf2_append_unwinders(struct gdbarch *gdbarch)
int default_frame_sniffer(const struct frame_unwind *self, frame_info_ptr this_frame, void **this_prologue_cache)
struct value * frame_unwind_got_memory(frame_info_ptr frame, int regnum, CORE_ADDR addr)
struct value * frame_unwind_got_register(frame_info_ptr frame, int regnum, int new_regnum)
enum unwind_stop_reason default_frame_unwind_stop_reason(frame_info_ptr this_frame, void **this_cache)
struct value * frame_unwind_got_constant(frame_info_ptr frame, int regnum, ULONGEST val)
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)
void set_gdbarch_addr_bit(struct gdbarch *gdbarch, int addr_bit)
void set_gdbarch_char_signed(struct gdbarch *gdbarch, int char_signed)
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_register_sim_regno(struct gdbarch *gdbarch, gdbarch_register_sim_regno_ftype *register_sim_regno)
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)
int gdbarch_addr_bit(struct gdbarch *gdbarch)
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_skip_trampoline_code(struct gdbarch *gdbarch, gdbarch_skip_trampoline_code_ftype *skip_trampoline_code)
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_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_long_double_format(struct gdbarch *gdbarch, const struct floatformat **long_double_format)
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_pseudo_register_write(struct gdbarch *gdbarch, gdbarch_pseudo_register_write_ftype *pseudo_register_write)
void set_gdbarch_num_pseudo_regs(struct gdbarch *gdbarch, int num_pseudo_regs)
void set_gdbarch_dwarf2_addr_size(struct gdbarch *gdbarch, int dwarf2_addr_size)
void set_gdbarch_dwarf2_reg_to_regnum(struct gdbarch *gdbarch, gdbarch_dwarf2_reg_to_regnum_ftype *dwarf2_reg_to_regnum)
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_pseudo_register_read(struct gdbarch *gdbarch, gdbarch_pseudo_register_read_ftype *pseudo_register_read)
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
const struct bfd_arch_info * gdbarch_bfd_arch_info(struct gdbarch *gdbarch)
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_double_format(struct gdbarch *gdbarch, const struct floatformat **double_format)
void set_gdbarch_in_solib_return_trampoline(struct gdbarch *gdbarch, gdbarch_in_solib_return_trampoline_ftype *in_solib_return_trampoline)
void set_gdbarch_float_format(struct gdbarch *gdbarch, const struct floatformat **float_format)
void set_gdbarch_push_dummy_call(struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype *push_dummy_call)
void set_gdbarch_vbit_in_delta(struct gdbarch *gdbarch, int vbit_in_delta)
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 floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
struct type * check_typedef(struct type *type)
#define TYPE_IS_REFERENCE(t)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
static int msp430_get_opcode_byte(void *handle)
static struct value * msp430_prev_register(frame_info_ptr this_frame, void **this_prologue_cache, int regnum)
static struct msp430_prologue * msp430_analyze_frame_prologue(frame_info_ptr this_frame, void **this_prologue_cache)
static CORE_ADDR msp430_push_dummy_call(struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, function_call_return_method return_method, CORE_ADDR struct_addr)
static void msp430_pseudo_register_write(struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buffer)
static void check_for_saved(void *result_untyped, pv_t addr, CORE_ADDR size, pv_t value)
static CORE_ADDR msp430_skip_trampoline_code(frame_info_ptr frame, CORE_ADDR pc)
static enum register_status msp430_pseudo_register_read(struct gdbarch *gdbarch, readable_regcache *regcache, int regnum, gdb_byte *buffer)
static struct gdbarch * msp430_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
static struct type * msp430x_register_type(struct gdbarch *gdbarch, int reg_nr)
constexpr gdb_byte msp430_break_insn[]
static void msp430_analyze_prologue(struct gdbarch *gdbarch, CORE_ADDR start_pc, CORE_ADDR limit_pc, struct msp430_prologue *result)
void _initialize_msp430_tdep()
static const struct frame_unwind msp430_unwind
static int msp430_dwarf2_reg_to_regnum(struct gdbarch *gdbarch, int reg)
static enum return_value_convention msp430_return_value(struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
static CORE_ADDR msp430_frame_align(struct gdbarch *gdbarch, CORE_ADDR sp)
static void msp430_this_id(frame_info_ptr this_frame, void **this_prologue_cache, struct frame_id *this_id)
static struct type * msp430_register_type(struct gdbarch *gdbarch, int reg_nr)
static const char msp430_epilog_name_prefix[]
static int msp430_register_sim_regno(struct gdbarch *gdbarch, int regnum)
static int msp430_in_return_stub(struct gdbarch *gdbarch, CORE_ADDR pc, const char *name)
static CORE_ADDR msp430_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
static const char * msp430_register_name(struct gdbarch *gdbarch, int regnr)
static CORE_ADDR msp430_frame_base(frame_info_ptr this_frame, void **this_prologue_cache)
static int msp430_register_reggroup_p(struct gdbarch *gdbarch, int regnum, const struct reggroup *group)
pv_t pv_register(int reg, CORE_ADDR k)
pv_t pv_add_constant(pv_t v, CORE_ADDR k)
int pv_is_register(pv_t a, int r)
int register_size(struct gdbarch *gdbarch, int regnum)
enum register_status regcache_cooked_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
void regcache_raw_write_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
const reggroup *const save_reggroup
const reggroup *const all_reggroup
const reggroup *const restore_reggroup
struct minimal_symbol * minsym
struct type * builtin_uint16
struct type * builtin_func_ptr
struct type * builtin_uint32
const char * linkage_name() const
int reg_offset[MSP430_NUM_TOTAL_REGS]
gdb::array_view< const gdb_byte > contents_all()
struct type * type() const
struct value::@203::@204 reg
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
LONGEST value_as_long(struct value *val)