38 #include "elf/msp430.h"
39 #include "opcode/msp430-decode.h"
189 static const char *
const reg_names[] = {
191 "",
"",
"",
"",
"",
"",
"",
"",
192 "",
"",
"",
"",
"",
"",
"",
"",
194 "pc",
"sp",
"sr",
"cg",
"r4",
"r5",
"r6",
"r7",
195 "r8",
"r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15"
198 return reg_names[regnr];
289 *lenptr =
sizeof breakpoint;
354 CORE_ADDR after_last_frame_setup_insn = start_pc;
358 memset (result, 0,
sizeof (*result));
375 while (pc < limit_pc)
379 MSP430_Opcode_Decoded opc;
381 opcode_handle.
pc =
pc;
384 next_pc = pc + bytes_read;
386 if (opc.id == MSO_push && opc.op[0].type == MSP430_Operand_Register)
388 int rsrc = opc.op[0].reg;
392 after_last_frame_setup_insn = next_pc;
394 else if (opc.id == MSO_push
395 && opc.op[0].type == MSP430_Operand_None
396 && opc.op[1].type == MSP430_Operand_Register)
398 int rsrc = opc.op[1].reg;
399 int count = opc.repeats + 1;
400 int size = opc.size == 16 ? 2 : 4;
406 pv_area_store (stack, reg[MSP430_SP_REGNUM], size, reg[rsrc]);
410 after_last_frame_setup_insn = next_pc;
412 else if (opc.id == MSO_sub
413 && opc.op[0].type == MSP430_Operand_Register
414 && opc.op[0].reg == MSR_SP
415 && opc.op[1].type == MSP430_Operand_Immediate)
417 int addend = opc.op[1].addend;
421 after_last_frame_setup_insn = next_pc;
423 else if (opc.id == MSO_mov
424 && opc.op[0].type == MSP430_Operand_Immediate
425 && 12 <= opc.op[0].reg && opc.op[0].reg <= 15)
426 after_last_frame_setup_insn = next_pc;
488 void **this_prologue_cache)
490 if (!*this_prologue_cache)
502 stop_addr = func_start;
505 stop_addr, *this_prologue_cache);
508 return *this_prologue_cache;
527 void **this_prologue_cache,
struct frame_id *this_id)
530 this_prologue_cache),
536 static struct value *
538 void **this_prologue_cache,
int regnum)
588 warning (
_(
"Unmapped DWARF Register #%d encountered."), reg);
597 struct value *
function,
598 struct type *valtype,
617 while (valtype_len > 0)
641 while (valtype_len > 0)
710 for (write_pass = 0; write_pass <= 1; write_pass++)
714 int args_on_stack = 0;
728 for (i = 0; i < nargs; i++)
730 struct value *arg = args[i];
735 int current_arg_on_stack;
737 current_arg_on_stack = 0;
747 arg_bits = struct_addr;
755 current_arg_on_stack = 1;
759 for (offset = 0; offset < arg_size; offset += 2)
764 if (!current_arg_on_stack
766 + ((arg_size == 8 || args_on_stack)
767 ? ((arg_size - offset) / 2 - 1)
785 (arg_bits + offset, size,
797 current_arg_on_stack = 1;
845 const char *stub_name;
869 static struct gdbarch *
872 struct gdbarch *gdbarch;
877 if (info.
abfd != NULL
878 && bfd_get_flavour (info.
abfd) == bfd_target_elf_flavour)
879 elf_flags = elf_elfheader (info.
abfd)->e_flags;
883 if (info.
abfd != NULL)
884 switch (bfd_elf_get_obj_attr_int (info.
abfd, OBJ_ATTR_PROC,
885 OFBA_MSPABI_Tag_ISA))
893 switch (bfd_elf_get_obj_attr_int (info.
abfd, OBJ_ATTR_PROC,
894 OFBA_MSPABI_Tag_Code_Model))
904 _(
"Unknown msp430x code memory model"));
926 error (
_(
"Unknown msp430 isa"));
944 if (candidate_tdep->
elf_flags != elf_flags
945 || candidate_tdep->
isa != isa
struct gdbarch * target_gdbarch(void)
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
static CORE_ADDR msp430_frame_base(struct frame_info *this_frame, void **this_prologue_cache)
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_float_format(struct gdbarch *gdbarch, const struct floatformat **float_format)
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
static int msp430_register_reggroup_p(struct gdbarch *gdbarch, int regnum, struct reggroup *group)
static struct type * msp430x_register_type(struct gdbarch *gdbarch, int reg_nr)
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
struct type * builtin_func_ptr
void set_gdbarch_float_bit(struct gdbarch *gdbarch, int float_bit)
void set_gdbarch_dwarf2_addr_size(struct gdbarch *gdbarch, int dwarf2_addr_size)
CORE_ADDR get_frame_pc(struct frame_info *frame)
#define MSYMBOL_LINKAGE_NAME(symbol)
static struct value * msp430_prev_register(struct frame_info *this_frame, void **this_prologue_cache, int regnum)
pv_t pv_add_constant(pv_t v, CORE_ADDR k)
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
LONGEST value_as_long(struct value *val)
struct value * frame_unwind_got_memory(struct frame_info *frame, int regnum, CORE_ADDR addr)
void write_memory_unsigned_integer(CORE_ADDR addr, int len, enum bfd_endian byte_order, ULONGEST value)
void set_gdbarch_skip_trampoline_code(struct gdbarch *gdbarch, gdbarch_skip_trampoline_code_ftype skip_trampoline_code)
void warning(const char *fmt,...)
struct cleanup * make_cleanup_free_pv_area(struct pv_area *area)
ULONGEST align_down(ULONGEST v, int n)
ULONGEST frame_unwind_register_unsigned(struct frame_info *frame, int regnum)
void set_gdbarch_short_bit(struct gdbarch *gdbarch, int short_bit)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
int pv_is_register(pv_t a, int r)
void internal_error(const char *file, int line, const char *fmt,...)
struct type * builtin_uint16
void set_gdbarch_register_reggroup_p(struct gdbarch *gdbarch, gdbarch_register_reggroup_p_ftype register_reggroup_p)
enum prologue_value_kind kind
struct gdbarch_list * gdbarch_list_lookup_by_info(struct gdbarch_list *arches, const struct gdbarch_info *info)
struct gdbarch_list * next
struct reggroup *const restore_reggroup
struct reggroup *const all_reggroup
static int msp430_register_sim_regno(struct gdbarch *gdbarch, int regnum)
void set_gdbarch_dwarf2_reg_to_regnum(struct gdbarch *gdbarch, gdbarch_dwarf2_reg_to_regnum_ftype dwarf2_reg_to_regnum)
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
#define FRAME_OBSTACK_ZALLOC(TYPE)
void store_unsigned_integer(gdb_byte *, int, enum bfd_endian, ULONGEST)
struct value * frame_unwind_got_constant(struct frame_info *frame, int regnum, ULONGEST val)
void set_gdbarch_addr_bit(struct gdbarch *gdbarch, int addr_bit)
static const char msp430_epilog_name_prefix[]
void set_gdbarch_pseudo_register_write(struct gdbarch *gdbarch, gdbarch_pseudo_register_write_ftype pseudo_register_write)
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype register_type)
static CORE_ADDR msp430_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
struct type * check_typedef(struct type *type)
LONGEST read_memory_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
static int msp430_in_return_stub(struct gdbarch *gdbarch, CORE_ADDR pc, const char *name)
struct reggroup *const general_reggroup
void initialize_file_ftype(void)
enum register_status regcache_cooked_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
void set_gdbarch_sp_regnum(struct gdbarch *gdbarch, int sp_regnum)
static CORE_ADDR msp430_frame_align(struct gdbarch *gdbarch, CORE_ADDR sp)
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)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int status
void set_gdbarch_in_solib_return_trampoline(struct gdbarch *gdbarch, gdbarch_in_solib_return_trampoline_ftype in_solib_return_trampoline)
const gdb_byte * value_contents_all(struct value *value)
#define gdb_assert_not_reached(message)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
void set_gdbarch_register_sim_regno(struct gdbarch *gdbarch, gdbarch_register_sim_regno_ftype register_sim_regno)
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)
static CORE_ADDR msp430_unwind_sp(struct gdbarch *arch, struct frame_info *next_frame)
void set_gdbarch_breakpoint_from_pc(struct gdbarch *gdbarch, gdbarch_breakpoint_from_pc_ftype breakpoint_from_pc)
static const gdb_byte * msp430_breakpoint_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
struct type * builtin_uint32
struct gdbarch * get_current_arch(void)
int default_frame_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache)
void pv_area_store(struct pv_area *area, pv_t addr, CORE_ADDR size, pv_t value)
static void check_for_saved(void *result_untyped, pv_t addr, CORE_ADDR size, pv_t value)
static int startswith(const char *string, const char *pattern)
enum register_status regcache_raw_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
int gdbarch_addr_bit(struct gdbarch *gdbarch)
void set_gdbarch_unwind_sp(struct gdbarch *gdbarch, gdbarch_unwind_sp_ftype unwind_sp)
int reg_offset[MSP430_NUM_TOTAL_REGS]
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, int struct_return, CORE_ADDR struct_addr)
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
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)
void pv_area_scan(struct pv_area *area, void(*func)(void *closure, pv_t addr, CORE_ADDR size, pv_t value), void *closure)
void set_gdbarch_long_long_bit(struct gdbarch *gdbarch, int long_long_bit)
static CORE_ADDR msp430_unwind_pc(struct gdbarch *arch, struct frame_info *next_frame)
static void msp430_pseudo_register_write(struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buffer)
const struct floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
struct pv_area * make_pv_area(int base_reg, int addr_bit)
static int msp430_dwarf2_reg_to_regnum(struct gdbarch *gdbarch, int reg)
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
void set_gdbarch_pseudo_register_read(struct gdbarch *gdbarch, gdbarch_pseudo_register_read_ftype pseudo_register_read)
void set_gdbarch_char_signed(struct gdbarch *gdbarch, int char_signed)
#define TYPE_TARGET_TYPE(thistype)
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
static const char * msp430_register_name(struct gdbarch *gdbarch, int regnr)
#define TYPE_CODE(thistype)
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
struct value * frame_unwind_got_register(struct frame_info *frame, int regnum, int new_regnum)
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
void set_gdbarch_int_bit(struct gdbarch *gdbarch, int int_bit)
struct minimal_symbol * minsym
void regcache_raw_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
void set_gdbarch_num_pseudo_regs(struct gdbarch *gdbarch, int num_pseudo_regs)
void dwarf2_append_unwinders(struct gdbarch *gdbarch)
static struct gdbarch * msp430_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
static void msp430_this_id(struct frame_info *this_frame, void **this_prologue_cache, struct frame_id *this_id)
void set_gdbarch_double_format(struct gdbarch *gdbarch, const struct floatformat **double_format)
unsigned long long ULONGEST
enum unwind_stop_reason default_frame_unwind_stop_reason(struct frame_info *this_frame, void **this_cache)
static enum register_status msp430_pseudo_register_read(struct gdbarch *gdbarch, struct regcache *regcache, int regnum, gdb_byte *buffer)
int register_size(struct gdbarch *gdbarch, int regnum)
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)
const struct bfd_arch_info * gdbarch_bfd_arch_info(struct gdbarch *gdbarch)
initialize_file_ftype _initialize_msp430_tdep
void set_gdbarch_long_double_format(struct gdbarch *gdbarch, const struct floatformat **long_double_format)
static struct type * msp430_register_type(struct gdbarch *gdbarch, int reg_nr)
struct reggroup *const save_reggroup
#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)
static struct frame_id msp430_dummy_id(struct gdbarch *gdbarch, struct frame_info *this_frame)
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 int msp430_get_opcode_byte(void *handle)
static void msp430_analyze_prologue(struct gdbarch *gdbarch, CORE_ADDR start_pc, CORE_ADDR limit_pc, struct msp430_prologue *result)
CORE_ADDR value_address(const struct value *value)
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
static struct msp430_prologue * msp430_analyze_frame_prologue(struct frame_info *this_frame, void **this_prologue_cache)
void set_gdbarch_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype register_name)
CORE_ADDR get_frame_func(struct frame_info *this_frame)
static CORE_ADDR msp430_skip_trampoline_code(struct frame_info *frame, CORE_ADDR pc)
void error(const char *fmt,...)
pv_t pv_register(int reg, CORE_ADDR k)
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)
void do_cleanups(struct cleanup *old_chain)
void set_gdbarch_print_insn(struct gdbarch *gdbarch, gdbarch_print_insn_ftype print_insn)
void set_gdbarch_vbit_in_delta(struct gdbarch *gdbarch, int vbit_in_delta)