80#define AVR_TYPE_ADDRESS_CLASS_FLASH TYPE_ADDRESS_CLASS_1
81#define AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH \
82 TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1
149 AVR_EMEM_START = 0x00810000,
211 static const char *
const register_names[] = {
212 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
213 "r8",
"r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15",
214 "r16",
"r17",
"r18",
"r19",
"r20",
"r21",
"r22",
"r23",
215 "r24",
"r25",
"r26",
"r27",
"r28",
"r29",
"r30",
"r31",
221 return register_names[
regnum];
259 return ((x) & 0xffffffff);
277 return ((x) & 0xffffffff);
308 struct type *
type, gdb_byte *buf, CORE_ADDR addr)
338 struct type *
type,
const gdb_byte *buf)
365 struct type *
type,
const gdb_byte *buf)
391static enum register_status
393 int regnum, gdb_byte *buf)
396 enum register_status
status;
408 internal_error (_(
"invalid regnum"));
414 int regnum,
const gdb_byte *buf)
426 internal_error (_(
"invalid regnum"));
538 len = pc_end - pc_beg;
557 static const unsigned char img[] = {
564 if ((insn & 0xf0f0) == 0xe0c0)
566 locals = (insn & 0xf) | ((insn & 0x0f00) >> 4);
569 if ((insn & 0xf0f0) == 0xe0d0)
571 locals |= ((insn & 0xf) | ((insn & 0x0f00) >> 4)) << 8;
572 if (vpc + 4 +
sizeof (img) < len
573 && memcmp (prologue + vpc + 4, img,
sizeof (img)) == 0)
600 if ((insn & 0xf0f0) != 0xe0a0)
602 loc_size = (insn & 0xf) | ((insn & 0x0f00) >> 4);
607 if ((insn & 0xf0f0) != 0xe0b0)
609 loc_size |= ((insn & 0xf) | ((insn & 0x0f00) >> 4)) << 8;
614 if ((insn & 0xf0f0) != 0xe0e0)
616 body_addr = (insn & 0xf) | ((insn & 0x0f00) >> 4);
621 if ((insn & 0xf0f0) != 0xe0f0)
623 body_addr |= ((insn & 0xf) | ((insn & 0x0f00) >> 4)) << 8;
632 if ((insn & 0xf000) == 0xc000)
635 i = (insn & 0xfff) | (insn & 0x800 ? (-1 ^ 0xfff) : 0);
641 if (body_addr != (pc_beg + 10)/2)
646 else if ((insn & 0xfe0e) == 0x940c)
649 i = (((insn & 0x1) | ((insn & 0x1f0) >> 3) << 16)
655 if (body_addr != (pc_beg + 12)/2)
685 info->saved_regs [from].set_addr (++i);
687 info->size = loc_size + num_pushes;
690 return pc_beg + pc_offset;
700 static const unsigned char img[] = {
708 if (len >=
sizeof (img)
709 && memcmp (prologue, img,
sizeof (img)) == 0)
714 info->saved_regs[0].set_addr (2);
715 info->saved_regs[1].set_addr (1);
718 else if (len >=
sizeof (img) - 2
719 && memcmp (img + 2, prologue,
sizeof (img) - 2) == 0)
722 vpc +=
sizeof (img) - 2;
724 info->saved_regs[0].set_addr (2);
725 info->saved_regs[1].set_addr (1);
733 for (; vpc < len; vpc += 2)
736 if ((insn & 0xfe0f) == 0x920f)
739 int regno = (insn & 0x1f0) >> 4;
741 info->saved_regs[regno].set_addr (info->size);
752 while (scan_stage == 1 && vpc < len)
760 else if (insn == 0x920f || insn == 0x921f)
774 if (scan_stage == 1 && vpc < len)
776 static const unsigned char img[] = {
781 if (vpc +
sizeof (img) < len
782 && memcmp (prologue + vpc, img,
sizeof (img)) == 0)
799 if (scan_stage == 2 && vpc < len)
802 static const unsigned char img[] = {
809 static const unsigned char img_sig[] = {
813 static const unsigned char img_int[] = {
821 if ((insn & 0xff30) == 0x9720)
823 locals_size = (insn & 0xf) | ((insn & 0xc0) >> 2);
826 else if ((insn & 0xf0f0) == 0x50c0)
828 locals_size = (insn & 0xf) | ((insn & 0xf00) >> 4);
832 locals_size += ((insn & 0xf) | ((insn & 0xf00) >> 4)) << 8;
841 if (vpc +
sizeof (img_sig) < len
842 && memcmp (prologue + vpc, img_sig,
sizeof (img_sig)) == 0)
844 vpc +=
sizeof (img_sig);
846 else if (vpc +
sizeof (img_int) < len
847 && memcmp (prologue + vpc, img_int,
sizeof (img_int)) == 0)
849 vpc +=
sizeof (img_int);
851 if (vpc +
sizeof (img) < len
852 && memcmp (prologue + vpc, img,
sizeof (img)) == 0)
858 info->size += locals_size;
866 for (; vpc < len; vpc += 2)
869 if ((insn & 0xff00) == 0x0100)
871 else if ((insn & 0xfc00) == 0x2c00)
883 CORE_ADDR func_addr, func_end;
884 CORE_ADDR post_prologue_pc;
892 if (post_prologue_pc != 0)
893 return std::max (pc, post_prologue_pc);
896 CORE_ADDR prologue_end = pc;
936 gdb_byte *readbuf,
const gdb_byte *writebuf)
944 if ((valtype->
code () == TYPE_CODE_STRUCT
945 || valtype->
code () == TYPE_CODE_UNION
946 || valtype->
code () == TYPE_CODE_ARRAY)
947 && valtype->
length () > 8)
950 if (valtype->
length () <= 2)
952 else if (valtype->
length () <= 4)
954 else if (valtype->
length () <= 8)
957 gdb_assert_not_reached (
"unexpected type length");
959 if (writebuf != NULL)
961 for (i = 0; i < valtype->
length (); i++)
967 for (i = 0; i < valtype->
length (); i++)
983 void **this_prologue_cache)
985 CORE_ADDR start_pc, current_pc;
992 if (*this_prologue_cache)
996 *this_prologue_cache =
info;
1004 if ((start_pc > 0) && (start_pc <= current_pc))
1006 start_pc, current_pc,
info);
1018 this_base += (high_base << 8);
1022 prev_sp = this_base +
info->size;
1029 prev_sp = this_base +
info->size;
1042 if (
info->saved_regs[i].is_addr ())
1043 info->saved_regs[i].set_addr (
info->prev_sp
1044 -
info->saved_regs[i].addr ());
1086 void **this_prologue_cache,
1101 base = info->prev_sp;
1109static struct value *
1111 void **this_prologue_cache,
int regnum)
1144 pc = (pc << 8) | buf[i];
1216 memcpy (si->
data, contents,
len);
1272 int nargs,
struct value **args, CORE_ADDR sp,
1274 CORE_ADDR struct_addr)
1292 if (sp == struct_addr)
1296 for (i = 0; i < nargs; i++)
1300 struct value *arg = args[i];
1302 const bfd_byte *contents = arg->
contents ().data ();
1308 last_regnum =
regnum - (len + (len & 1)) + 1;
1320 for (j = 0; j < len; j++)
1344 for (i = 1; i <= call_length; i++)
1346 buf[call_length - i] = return_pc & 0xff;
1360 return sp + call_length;
1368 if (reg >= 0 && reg < 32)
1380static type_instance_flags
1387 if (dwarf2_addr_class == 1 && byte_size == 2)
1398 type_instance_flags type_flags)
1413 type_instance_flags *type_flags_ptr)
1415 if (strcmp (
name,
"flash") == 0)
1433 switch (info.bfd_arch_info->mach)
1436 case bfd_mach_avrxmega1:
1438 case bfd_mach_avrxmega2:
1440 case bfd_mach_avrxmega3:
1442 case bfd_mach_avrxmega4:
1444 case bfd_mach_avrxmega5:
1449 case bfd_mach_avrxmega6:
1450 case bfd_mach_avrxmega7:
1461 = gdbarch_tdep<avr_gdbarch_tdep> (best_arch->
gdbarch);
1565 unsigned int nreg = 0;
1569 gdb::optional<gdb::byte_vector> buf
1576 _(
"ERR: info io_registers NOT supported "
1577 "by current target\n"));
1581 const char *bufstr = (
const char *) buf->data ();
1583 if (sscanf (bufstr,
"%x", &nreg) != 1)
1586 _(
"Error fetching number of io registers\n"));
1590 gdb_printf (_(
"Target has %u io registers:\n\n"), nreg);
1595 for (
int i = 0; i < nreg; i += step)
1602 snprintf (
query,
sizeof (
query) - 1,
"avr.io_reg:%x,%x", i, j);
1609 _(
"ERR: error reading avr.io_reg:%x,%x\n"),
1614 const char *p = (
const char *) buf->data ();
1615 for (
int k = i; k < (i + j); k++)
1617 if (sscanf (p,
"%[^,],%x;",
query, &val) == 2)
1620 while ((*p !=
';') && (*p !=
'\0'))
1644 _(
"Query remote AVR target for I/O space register values."));
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)
static CORE_ADDR avr_make_iaddr(CORE_ADDR x)
static void avr_frame_this_id(frame_info_ptr this_frame, void **this_prologue_cache, struct frame_id *this_id)
static struct gdbarch * avr_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
#define AVR_TYPE_ADDRESS_CLASS_FLASH
constexpr gdb_byte avr_break_insn[]
static CORE_ADDR avr_integer_to_address(struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf)
static struct value * avr_frame_prev_register(frame_info_ptr this_frame, void **this_prologue_cache, int regnum)
static const struct frame_unwind avr_frame_unwind
static CORE_ADDR avr_unwind_pc(struct gdbarch *gdbarch, frame_info_ptr next_frame)
static void avr_pseudo_register_write(struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buf)
static const struct frame_base avr_frame_base
static type_instance_flags avr_address_class_type_flags(int byte_size, int dwarf2_addr_class)
static CORE_ADDR avr_pointer_to_address(struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf)
static void avr_io_reg_read_command(const char *args, int from_tty)
static CORE_ADDR avr_make_saddr(CORE_ADDR x)
static const char * avr_address_class_type_flags_to_name(struct gdbarch *gdbarch, type_instance_flags type_flags)
static CORE_ADDR avr_scan_prologue(struct gdbarch *gdbarch, CORE_ADDR pc_beg, CORE_ADDR pc_end, struct avr_unwind_cache *info)
void _initialize_avr_tdep()
static CORE_ADDR avr_read_pc(readable_regcache *regcache)
static bool avr_address_class_name_to_type_flags(struct gdbarch *gdbarch, const char *name, type_instance_flags *type_flags_ptr)
static CORE_ADDR avr_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 int avr_dwarf_reg_to_regnum(struct gdbarch *gdbarch, int reg)
static struct avr_unwind_cache * avr_frame_unwind_cache(frame_info_ptr this_frame, void **this_prologue_cache)
static const char * avr_register_name(struct gdbarch *gdbarch, int regnum)
static void avr_write_pc(struct regcache *regcache, CORE_ADDR val)
static CORE_ADDR avr_unwind_sp(struct gdbarch *gdbarch, frame_info_ptr next_frame)
static CORE_ADDR avr_convert_iaddr_to_raw(CORE_ADDR x)
static struct avr_stack_item * push_stack_item(struct avr_stack_item *prev, const bfd_byte *contents, int len)
#define AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH
static enum register_status avr_pseudo_register_read(struct gdbarch *gdbarch, readable_regcache *regcache, int regnum, gdb_byte *buf)
static struct avr_stack_item * pop_stack_item(struct avr_stack_item *si)
static CORE_ADDR avr_frame_base_address(frame_info_ptr this_frame, void **this_cache)
static void avr_address_to_pointer(struct gdbarch *gdbarch, struct type *type, gdb_byte *buf, CORE_ADDR addr)
static CORE_ADDR avr_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
static struct frame_id avr_dummy_id(struct gdbarch *gdbarch, frame_info_ptr this_frame)
static CORE_ADDR avr_convert_saddr_to_raw(CORE_ADDR x)
static struct type * avr_register_type(struct gdbarch *gdbarch, int reg_nr)
bool find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr, const struct block **block)
enum register_status raw_read(int regnum, gdb_byte *buf)
enum register_status cooked_read(int regnum, gdb_byte *buf)
void cooked_write(int regnum, const gdb_byte *buf)
struct cmd_list_element * add_info(const char *name, cmd_simple_func_ftype *fun, const char *doc)
void write_memory(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
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)
struct value * frame_unwind_got_optimized(frame_info_ptr frame, int 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)
ULONGEST frame_unwind_register_unsigned(frame_info_ptr next_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_address_to_pointer(struct gdbarch *gdbarch, gdbarch_address_to_pointer_ftype *address_to_pointer)
void set_gdbarch_unwind_pc(struct gdbarch *gdbarch, gdbarch_unwind_pc_ftype *unwind_pc)
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_write_pc(struct gdbarch *gdbarch, gdbarch_write_pc_ftype *write_pc)
void set_gdbarch_integer_to_address(struct gdbarch *gdbarch, gdbarch_integer_to_address_ftype *integer_to_address)
void set_gdbarch_skip_prologue(struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype *skip_prologue)
void set_gdbarch_address_class_type_flags_to_name(struct gdbarch *gdbarch, gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name)
void set_gdbarch_wchar_bit(struct gdbarch *gdbarch, int wchar_bit)
void set_gdbarch_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype *register_name)
void set_gdbarch_address_class_type_flags(struct gdbarch *gdbarch, gdbarch_address_class_type_flags_ftype *address_class_type_flags)
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_wchar_signed(struct gdbarch *gdbarch, int wchar_signed)
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_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_address_class_name_to_type_flags(struct gdbarch *gdbarch, gdbarch_address_class_name_to_type_flags_ftype *address_class_name_to_type_flags)
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_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)
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_dummy_id(struct gdbarch *gdbarch, gdbarch_dummy_id_ftype *dummy_id)
void set_gdbarch_read_pc(struct gdbarch *gdbarch, gdbarch_read_pc_ftype *read_pc)
void set_gdbarch_unwind_sp(struct gdbarch *gdbarch, gdbarch_unwind_sp_ftype *unwind_sp)
void set_gdbarch_double_format(struct gdbarch *gdbarch, const struct floatformat **double_format)
void set_gdbarch_pointer_to_address(struct gdbarch *gdbarch, gdbarch_pointer_to_address_ftype *pointer_to_address)
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)
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
struct type * init_pointer_type(type_allocator &alloc, int bit, const char *name, struct type *target_type)
const struct floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
struct type * check_typedef(struct type *type)
struct type * make_function_type(struct type *type, struct type **typeptr)
#define TYPE_DATA_SPACE(t)
#define TYPE_CODE_SPACE(t)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
struct inferior * current_inferior(void)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
void regcache_raw_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
void(* func)(remote_target *remote, char *)
struct type * func_void_type
struct avr_stack_item * prev
trad_frame_saved_reg * saved_regs
CORE_ADDR value_address() const
struct minimal_symbol * minsym
struct type * builtin_data_ptr
struct type * builtin_uint32
struct type * builtin_uint8
struct gdbarch_list * next
struct type * target_type() const
gdb::array_view< const gdb_byte > contents()
struct type * type() const
CORE_ADDR skip_prologue_using_sal(struct gdbarch *gdbarch, CORE_ADDR func_addr)
gdb::optional< gdb::byte_vector > target_read_alloc(struct target_ops *ops, enum target_object object, const char *annex)
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)
int query(const char *ctlstr,...)
void gdb_printf(struct ui_file *stream, const char *format,...)
LONGEST unpack_long(struct type *type, const gdb_byte *valaddr)