32#include "gdbsupport/gdb-safe-ctype.h"
99 va_start (ap, format);
101 for (i = 0; 0 != format[i];)
103 const char *start_ptr;
120 if ((format[i] -
'0') !=
bits)
129 start_ptr = &(format[i]);
130 width = strtoul (start_ptr, &end_ptr, 10);
133 if (start_ptr == end_ptr)
134 error (_(
"bitstring \"%s\" at offset %d has no length field."),
137 i += end_ptr - start_ptr;
142 if (
'b' != format[i++])
143 error (_(
"bitstring \"%s\" at offset %d has no terminating 'b'."),
154 arg_ptr = va_arg (ap, uint32_t *);
160 error (_(
"invalid character in bitstring \"%s\" at offset %d."),
184 unsigned int *ra_ptr,
int *simm_ptr)
192 *rd_ptr = (
unsigned int) rd;
193 *ra_ptr = (
unsigned int) ra;
194 *simm_ptr = (int) (((i & 0x8000) == 0x8000) ? 0xffff0000 | i : i);
215 unsigned int *rb_ptr)
218 uint32_t ihi, ilo, ra, rb;
225 *simm_ptr = (int) ((ihi << 11) | ilo);
226 *simm_ptr |= ((ihi & 0x10) == 0x10) ? 0xffff0000 : 0;
228 *ra_ptr = (
unsigned int) ra;
229 *rb_ptr = (
unsigned int) rb;
245 gdb_byte *readbuf,
const gdb_byte *writebuf)
249 unsigned int rv_size = valtype->
length ();
257 if ((TYPE_CODE_STRUCT == rv_type) || (TYPE_CODE_UNION == rv_type)
258 || ((TYPE_CODE_ARRAY == rv_type) && (rv_size > bpw))
259 || (rv_size > 2 * bpw))
268 if (writebuf != NULL)
290 if (writebuf != NULL)
292 gdb_byte *buf = XCNEWVEC(gdb_byte, bpw);
294 if (BFD_ENDIAN_BIG == byte_order)
295 memcpy (buf + (
sizeof (gdb_byte) * bpw) - rv_size, writebuf,
298 memcpy (buf, writebuf, rv_size);
318 tmp = (tmp_hi << (bpw * 8)) | tmp_lo;
322 if (writebuf != NULL)
324 gdb_byte *buf_lo = XCNEWVEC(gdb_byte, bpw);
325 gdb_byte *buf_hi = XCNEWVEC(gdb_byte, bpw);
330 memcpy (buf_hi, writebuf, rv_size - bpw);
331 memcpy (buf_lo, writebuf + bpw, bpw);
353 const CGEN_INSN *insn;
354 CGEN_FIELDS tmp_fields;
360 NULL, 32, &tmp_fields, 0);
369 return ((CGEN_INSN_NUM (insn) == OR1K_INSN_L_J)
370 || (CGEN_INSN_NUM (insn) == OR1K_INSN_L_JAL)
371 || (CGEN_INSN_NUM (insn) == OR1K_INSN_L_JR)
372 || (CGEN_INSN_NUM (insn) == OR1K_INSN_L_JALR)
373 || (CGEN_INSN_NUM (insn) == OR1K_INSN_L_BNF)
374 || (CGEN_INSN_NUM (insn) == OR1K_INSN_L_BF));
391 ppc = (CORE_ADDR) val;
393 npc = (CORE_ADDR) val;
395 if (0x4 != (npc - ppc))
398 return or1k_delay_slot_p (
gdbarch, ppc);
407std::vector<CORE_ADDR>
411 CORE_ADDR pc, next_pc;
416 if (or1k_delay_slot_p (
gdbarch, pc))
426 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
427 "r8",
"r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15",
428 "r16",
"r17",
"r18",
"r19",
"r20",
"r21",
"r22",
"r23",
429 "r24",
"r25",
"r26",
"r27",
"r28",
"r29",
"r30",
"r31",
457 unsigned int ra, rb, rd;
469 if (0 != prologue_end)
474 const char *debug_format = compunit->
debugformat ();
476 if ((NULL != debug_format)
477 && (strlen (
"dwarf") <= strlen (debug_format))
478 && (0 == strncasecmp (
"dwarf", debug_format, strlen (
"dwarf"))))
479 return (prologue_end > pc) ? prologue_end : pc;
493 && (simm < 0) && (0 == (simm % 4)))
503 && (simm >= 0) && (0 == (simm % 4)))
510 && (simm == frame_size));
519 && (simm >= 0) && (0 == (simm % 4)))
535 && (0 == (simm % 4)))
602 CORE_ADDR function,
struct value **args,
int nargs,
603 struct type *value_type, CORE_ADDR * real_pc,
625 int nargs,
struct value **args, CORE_ADDR sp,
627 CORE_ADDR struct_addr)
633 int stack_offset = 0;
635 CORE_ADDR heap_sp = sp - 128;
658 for (argnum = 0; argnum < nargs; argnum++)
661 gdb_byte valbuf[
sizeof (ULONGEST)];
663 struct value *arg = args[argnum];
665 int len = arg_type->
length ();
672 if ((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode)
675 CORE_ADDR valaddr = arg->
address ();
685 heap_offset += align_up (len, bpw);
686 valaddr = heap_sp + heap_offset;
713 unsigned int bits_per_word = bpw * 8;
714 ULONGEST mask = (((ULONGEST) 1) << bits_per_word) - 1;
715 ULONGEST lo = regval & mask;
716 ULONGEST hi = regval >> bits_per_word;
743 first_stack_arg = argnum;
751 for (argnum = first_stack_arg; argnum < nargs; argnum++)
753 struct value *arg = args[argnum];
755 int len = arg_type->
length ();
758 if ((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode)
768 sp -= align_up (len, bpw);
773 gdb_assert (heap_offset == 0 || ((heap_sp + heap_offset) < sp));
780 for (argnum = first_stack_arg; argnum < nargs; argnum++)
783 gdb_byte valbuf[
sizeof (ULONGEST)];
785 struct value *arg = args[argnum];
787 int len = arg_type->
length ();
791 if ((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode)
804 int partial_len = (len < bpw ? len : bpw);
807 stack_offset += align_up (partial_len, bpw);
899 CORE_ADDR this_sp_for_id;
902 CORE_ADDR start_addr;
907 "or1k_frame_cache, prologue_cache = %s\n",
908 host_address_to_string (*prologue_cache));
911 if (NULL != *prologue_cache)
916 *prologue_cache = info;
949 this_sp_for_id = this_sp;
966 if (end_addr < start_addr)
967 error (_(
"end addr %s is less than start addr %s"),
970 if (end_addr == start_addr)
975 CORE_ADDR addr = start_addr;
978 unsigned int ra, rb, rd;
984 && (simm < 0) && (0 == (simm % 4)))
1000 this_sp_for_id = this_sp + frame_size;
1010 this_sp + frame_size);
1016 end_addr = (this_pc < end_addr) ? this_pc : end_addr;
1019 if ((addr < end_addr)
1022 && (simm >= 0) && (0 == (simm % 4)))
1032 if ((addr < end_addr)
1035 && (simm == frame_size))
1048 if ((addr < end_addr)
1051 && (simm >= 0) && (0 == (simm % 4)))
1068 while (addr < end_addr)
1074 && (0 == (simm % 4)))
1116static struct value *
1118 void **prologue_cache,
int regnum)
1144 const struct bfd_arch_info *binfo;
1146 const struct target_desc *tdesc = info.target_desc;
1157 binfo = info.bfd_arch_info;
1162 tdep->
bytes_per_word = binfo->bits_per_word / binfo->bits_per_byte;
1183 or1k_breakpoint::kind_from_pc);
1185 or1k_breakpoint::bp_from_kind);
1219 const char *mach_name = binfo->printable_name;
1220 enum cgen_endian endian = (info.byte_order == BFD_ENDIAN_BIG
1221 ? CGEN_ENDIAN_BIG : CGEN_ENDIAN_LITTLE);
1224 or1k_cgen_cpu_open (CGEN_CPU_OPEN_BFDMACH, mach_name,
1225 CGEN_CPU_OPEN_ENDIAN, endian, CGEN_CPU_OPEN_END);
1231 if (binfo->mach == bfd_mach_or1k)
1242 const struct tdesc_feature *feature;
1247 if (feature == NULL)
1281 gdb_printf (file,
"or1k_dump_tdep: %d bytes per word\n",
1283 gdb_printf (file,
"or1k_dump_tdep: %d bytes per address\n",
1299 _(
"Set OpenRISC debugging."),
1300 _(
"Show OpenRISC debugging."),
1301 _(
"When on, OpenRISC specific debugging is enabled."),
#define bits(obj, st, fn)
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 cooked_write(int regnum, const gdb_byte *buf)
struct cmd_list_element * showdebuglist
struct cmd_list_element * setdebuglist
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
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)
void memory_error(enum target_xfer_status err, CORE_ADDR memaddr)
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_ABI_RETURNS_ADDRESS
@ RETURN_VALUE_REGISTER_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)
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)
int frame_relative_level(frame_info_ptr fi)
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)
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)
void set_gdbarch_unwind_pc(struct gdbarch *gdbarch, gdbarch_unwind_pc_ftype *unwind_pc)
void set_gdbarch_ps_regnum(struct gdbarch *gdbarch, int ps_regnum)
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)
CORE_ADDR gdbarch_frame_align(struct gdbarch *gdbarch, CORE_ADDR address)
void set_gdbarch_push_dummy_code(struct gdbarch *gdbarch, gdbarch_push_dummy_code_ftype *push_dummy_code)
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_single_step_through_delay(struct gdbarch *gdbarch, gdbarch_single_step_through_delay_ftype *single_step_through_delay)
void set_gdbarch_have_nonsteppable_watchpoint(struct gdbarch *gdbarch, int have_nonsteppable_watchpoint)
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_call_dummy_location(struct gdbarch *gdbarch, enum call_dummy_location_type call_dummy_location)
void set_gdbarch_frame_red_zone_size(struct gdbarch *gdbarch, int frame_red_zone_size)
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_num_pseudo_regs(struct gdbarch *gdbarch, int num_pseudo_regs)
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_deprecated_fp_regnum(struct gdbarch *gdbarch, int deprecated_fp_regnum)
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_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_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
const struct floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
struct type * check_typedef(struct type *type)
void _initialize_or1k_tdep()
static int or1k_is_arg_reg(unsigned int regnum)
static CORE_ADDR or1k_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
static CORE_ADDR or1k_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)
constexpr gdb_byte or1k_break_insn[]
static struct trad_frame_cache * or1k_frame_cache(frame_info_ptr this_frame, void **prologue_cache)
static int or1k_is_callee_saved_reg(unsigned int regnum)
static bool or1k_analyse_l_sw(uint32_t inst, int *simm_ptr, unsigned int *ra_ptr, unsigned int *rb_ptr)
static const struct frame_unwind or1k_frame_unwind
static void show_or1k_debug(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static enum return_value_convention or1k_return_value(struct gdbarch *gdbarch, struct value *functype, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
std::vector< CORE_ADDR > or1k_software_single_step(struct regcache *regcache)
static void or1k_dump_tdep(struct gdbarch *gdbarch, struct ui_file *file)
static const char *const or1k_reg_names[OR1K_NUM_REGS]
static ULONGEST or1k_fetch_instruction(struct gdbarch *gdbarch, CORE_ADDR addr)
static CORE_ADDR or1k_unwind_sp(struct gdbarch *gdbarch, frame_info_ptr next_frame)
static CORE_ADDR or1k_unwind_pc(struct gdbarch *gdbarch, frame_info_ptr next_frame)
static struct gdbarch * or1k_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
static bool or1k_analyse_l_addi(uint32_t inst, unsigned int *rd_ptr, unsigned int *ra_ptr, int *simm_ptr)
static CORE_ADDR or1k_frame_align(struct gdbarch *gdbarch, CORE_ADDR sp)
static bool or1k_analyse_inst(uint32_t inst, const char *format,...)
static int or1k_single_step_through_delay(struct gdbarch *gdbarch, frame_info_ptr this_frame)
static struct value * or1k_frame_prev_register(frame_info_ptr this_frame, void **prologue_cache, int regnum)
static CORE_ADDR or1k_push_dummy_code(struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR function, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache)
static void or1k_frame_this_id(frame_info_ptr this_frame, void **prologue_cache, struct frame_id *this_id)
#define OR1K_NUM_PSEUDO_REGS
#define OR1K_FIRST_ARG_REGNUM
#define OR1K_FIRST_SAVED_REGNUM
#define OR1K_LAST_ARG_REGNUM
#define OR1K_FRAME_RED_ZONE_SIZE
static void initialize_tdesc_or1k(void)
const struct target_desc * tdesc_or1k
void gdbarch_init_osabi(struct gdbarch_info info, struct gdbarch *gdbarch)
CORE_ADDR regcache_read_pc(struct regcache *regcache)
enum register_status regcache_cooked_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
struct regcache * get_current_regcache(void)
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
const char * debugformat() const
CGEN_CPU_DESC gdb_cgen_cpu_desc
struct compunit_symtab * compunit() const
frame_info_ptr this_frame
gdb::array_view< const gdb_byte > contents()
struct type * type() const
CORE_ADDR skip_prologue_using_sal(struct gdbarch *gdbarch, CORE_ADDR func_addr)
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
tdesc_arch_data_up tdesc_data_alloc(void)
const struct tdesc_feature * tdesc_find_feature(const struct target_desc *target_desc, const char *name)
int tdesc_numbered_register(const struct tdesc_feature *feature, struct tdesc_arch_data *data, int regno, const char *name)
static const registry< gdbarch >::key< tdesc_arch_data > tdesc_data
void tdesc_use_registers(struct gdbarch *gdbarch, const struct target_desc *target_desc, tdesc_arch_data_up &&early_data, tdesc_unknown_register_ftype unk_reg_cb)
int tdesc_has_registers(const struct target_desc *target_desc)
std::unique_ptr< tdesc_arch_data, tdesc_arch_data_deleter > tdesc_arch_data_up
int target_read_code(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
void trad_frame_set_reg_realreg(struct trad_frame_cache *this_trad_cache, int regnum, int realreg)
struct trad_frame_cache * trad_frame_cache_zalloc(frame_info_ptr this_frame)
void trad_frame_set_reg_addr(struct trad_frame_cache *this_trad_cache, int regnum, CORE_ADDR addr)
void trad_frame_get_id(struct trad_frame_cache *this_trad_cache, struct frame_id *this_id)
void trad_frame_set_id(struct trad_frame_cache *this_trad_cache, struct frame_id this_id)
void trad_frame_set_this_base(struct trad_frame_cache *this_trad_cache, CORE_ADDR this_base)
void trad_frame_set_reg_value(struct trad_frame_cache *this_trad_cache, int regnum, LONGEST val)
struct value * trad_frame_get_register(struct trad_frame_cache *this_trad_cache, frame_info_ptr this_frame, int regnum)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void gdb_printf(struct ui_file *stream, const char *format,...)