24 #include "floatformat.h"
64 #define floatformats_sparc_quad floatformats_ia64_quad
73 #define X_OP(i) (((i) >> 30) & 0x3)
74 #define X_RD(i) (((i) >> 25) & 0x1f)
75 #define X_A(i) (((i) >> 29) & 1)
76 #define X_COND(i) (((i) >> 25) & 0xf)
77 #define X_OP2(i) (((i) >> 22) & 0x7)
78 #define X_IMM22(i) ((i) & 0x3fffff)
79 #define X_OP3(i) (((i) >> 19) & 0x3f)
80 #define X_RS1(i) (((i) >> 14) & 0x1f)
81 #define X_RS2(i) ((i) & 0x1f)
82 #define X_I(i) (((i) >> 13) & 1)
84 #define X_DISP22(i) ((X_IMM22 (i) ^ 0x200000) - 0x200000)
85 #define X_DISP19(i) ((((i) & 0x7ffff) ^ 0x40000) - 0x40000)
86 #define X_DISP10(i) ((((((i) >> 11) && 0x300) | (((i) >> 5) & 0xff)) ^ 0x200) - 0x200)
87 #define X_SIMM13(i) ((((i) & 0x1fff) ^ 0x1000) - 0x1000)
90 #define X_RETTURN(i) ((X_OP (i) == 0x2) && (X_OP3 (i) == 0x39))
107 for (i = 0; i <
sizeof (buf); i++)
108 insn = (insn << 8) | buf[i];
121 return ((insn & 0xc1c00000) == 0);
145 const unsigned op2 =
X_OP2 (insn);
147 if ((
X_OP (insn) == 0)
148 && ((op2 == 1) || (op2 == 2) || (op2 == 5) || (op2 == 6)
149 || ((op2 == 3) && ((insn & 0x10000000) == 0))))
225 return (len == 1 || len == 2 || len == 4 || len == 8);
229 return (len == 4 || len == 8);
247 return (len == 4 || len == 8 || len == 16);
266 return (len == 8 || len == 16 || len == 32);
301 "g0",
"g1",
"g2",
"g3",
"g4",
"g5",
"g6",
"g7",
302 "o0",
"o1",
"o2",
"o3",
"o4",
"o5",
"sp",
"o7",
303 "l0",
"l1",
"l2",
"l3",
"l4",
"l5",
"l6",
"l7",
304 "i0",
"i1",
"i2",
"i3",
"i4",
"i5",
"fp",
"i7",
306 "f0",
"f1",
"f2",
"f3",
"f4",
"f5",
"f6",
"f7",
307 "f8",
"f9",
"f10",
"f11",
"f12",
"f13",
"f14",
"f15",
308 "f16",
"f17",
"f18",
"f19",
"f20",
"f21",
"f22",
"f23",
309 "f24",
"f25",
"f26",
"f27",
"f28",
"f29",
"f30",
"f31",
311 "y",
"psr",
"wim",
"tbr",
"pc",
"npc",
"fsr",
"csr"
315 #define SPARC32_NUM_REGS ARRAY_SIZE (sparc32_register_names)
322 "d0",
"d2",
"d4",
"d6",
"d8",
"d10",
"d12",
"d14",
323 "d16",
"d18",
"d20",
"d22",
"d24",
"d26",
"d28",
"d30"
327 #define SPARC32_NUM_PSEUDO_REGS ARRAY_SIZE (sparc32_pseudo_register_names)
483 return address & ~0x7;
489 struct value **args,
int nargs,
521 int num_elements = 0;
525 for (i = 0; i < nargs; i++)
549 num_elements += (len / 4);
559 num_elements += ((len + 3) / 4);
564 sp -=
max (6, num_elements) * 4;
575 for (i = 0; i < nargs; i++)
588 if (len > 4 && element < 5)
616 CORE_ADDR call_pc = (struct_return ? (bp_addr - 12) : (bp_addr - 8));
623 struct_return, struct_addr);
647 static const gdb_byte break_insn[] = { 0x91, 0xd0, 0x20, 0x01 };
649 *len =
sizeof (break_insn);
687 int offset_stack_checking_sequence = 0;
688 int probing_loop = 0;
714 if (!(
X_OP (insn) == 0 &&
X_OP2 (insn) == 0x4 &&
X_RD (insn) == 1))
720 if (
X_OP (insn) == 0 &&
X_OP2 (insn) == 0x4 &&
X_RD (insn) == 4)
728 if (!(
X_OP (insn) == 2 &&
X_OP3 (insn) == 0x4 && !
X_I(insn)
736 if (
X_OP (insn) == 0 &&
X_OP2 (insn) == 0x4 &&
X_RD (insn) == 4)
749 &&
X_RS1 (insn) == 1 &&
X_RD (insn) == 0)
764 else if (
X_OP (insn) == 3 &&
X_OP3(insn) == 0x4 && !
X_I(insn)
765 &&
X_RS1 (insn) == 1 &&
X_RD (insn) == 0)
773 &&
X_RS1 (insn) == 1 &&
X_RD (insn) == 1))
779 if (!(
X_OP (insn) == 3 &&
X_OP3(insn) == 0x4 && !
X_I(insn)
780 &&
X_RD (insn) == 0 &&
X_RS1 (insn) == 1))
785 if (!(
X_OP (insn) == 3 &&
X_OP3(insn) == 0x4 &&
X_I(insn)
786 &&
X_RS1 (insn) == 1 &&
X_RD (insn) == 0))
809 if (!(
X_OP (insn) == 2 &&
X_OP3 (insn) == 0x4 && !
X_I(insn)
816 if (!(
X_OP (insn) == 2 &&
X_OP3 (insn) == 0x14 && !
X_I(insn)
823 if (!(
X_OP (insn) == 0 &&
X_COND (insn) == 0x1))
830 &&
X_RS1 (insn) == 1 &&
X_RD (insn) == 1))
836 if (!(
X_OP (insn) == 0 &&
X_COND (insn) == 0x8))
842 if (!(
X_OP (insn) == 3 &&
X_OP3(insn) == 0x4
852 if (!(
X_OP (insn) == 3 &&
X_OP3(insn) == 0x4 &&
X_I(insn)
853 &&
X_RS1 (insn) == 4 &&
X_RD (insn) == 0))
899 if (current_pc <= pc)
918 while (
X_OP (insn) == 3
919 && (
X_OP3 (insn) == 0x4
920 ||
X_OP3 (insn) == 0x7
921 ||
X_OP3 (insn) == 0xe)
935 if (
X_OP3 (insn) == 0x7)
945 if (
X_OP (insn) == 0 &&
X_OP2 (insn) == 0x04)
954 if (
X_OP (insn) == 2 &&
X_I (insn)
955 && (
X_RD (insn) == 1 ||
X_RD (insn) == dest))
963 if (
X_OP (insn) == 2 &&
X_OP3 (insn) == 0x3c)
979 if (
X_OP3 (insn) == 0)
1003 if (
X_OP (insn) == 2
1004 &&
X_OP3 (insn) == 0x2
1043 if (sal.
end < func_end
1044 && start_pc <= sal.
end)
1065 if (
X_OP (insn) == 3 && (
X_OP3 (insn) & 0x3c) == 0x04
1106 *this_cache = cache;
1131 if (cache->
base & 1)
1198 if (cache->
base == 0)
1204 static struct value *
1206 void **this_cache,
int regnum)
1287 sparc32_frame_base_address
1333 memcpy (valbuf, buf, len);
1345 memcpy (valbuf, buf, 8);
1351 memcpy (valbuf, buf + 4 - len, len);
1373 memcpy (buf, valbuf, len);
1398 memcpy (buf, valbuf, 8);
1404 memcpy (buf + 4 - len, valbuf, len);
1514 int conditional_p =
X_COND (insn) & 0x7;
1515 int branch_p = 0, fused_p = 0;
1518 if (
X_OP (insn) == 0 &&
X_OP2 (insn) == 3)
1520 if ((insn & 0x10000000) == 0)
1534 else if (
X_OP (insn) == 0 &&
X_OP2 (insn) == 6)
1540 else if (
X_OP (insn) == 0 &&
X_OP2 (insn) == 5)
1547 else if (
X_OP (insn) == 0 &&
X_OP2 (insn) == 2)
1553 else if (
X_OP (insn) == 0 &&
X_OP2 (insn) == 1)
1559 else if (
X_OP (insn) == 2 &&
X_OP3 (insn) == 0x3a)
1578 else if (conditional_p)
1582 return (
X_A (insn) ? *npc + 4 : 0);
1590 if (
X_COND (insn) == 0x0)
1591 pc = *npc, offset = 4;
1632 gdb_assert (npc != 0 || nnpc != 0 || orig_npc == 0);
1663 static struct gdbarch *
1667 struct gdbarch *gdbarch;
1765 if (regnum == i || regnum == -1)
1800 if (regnum == i || regnum == -1)
1896 int regnum,
const void *gregs)
1927 if (regnum == i || regnum == -1)
1950 if (regnum == i || regnum == -1)
1989 if (regnum == i || regnum == -1)
2005 if (regnum == i || regnum == -1)
2016 int regnum,
const void *fpregs)
2021 for (i = 0; i < 32; i++)
2036 int regnum,
void *fpregs)
2041 for (i = 0; i < 32; i++)
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
void set_gdbarch_frame_align(struct gdbarch *gdbarch, gdbarch_frame_align_ftype frame_align)
static const char * sparc32_register_name(struct gdbarch *gdbarch, int regnum)
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
int sparc_stack_frame_destroyed_p(struct gdbarch *gdbarch, CORE_ADDR pc)
CORE_ADDR get_frame_address_in_block(struct frame_info *this_frame)
static void sparc32_store_return_value(struct type *type, struct regcache *regcache, const gdb_byte *valbuf)
struct type * builtin_func_ptr
CORE_ADDR get_frame_pc(struct frame_info *frame)
void set_gdbarch_fp0_regnum(struct gdbarch *gdbarch, int fp0_regnum)
void gdbarch_init_osabi(struct gdbarch_info info, struct gdbarch *gdbarch)
int target_write_memory(CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
static void sparc_write_pc(struct regcache *regcache, CORE_ADDR pc)
void sparc32_supply_gregset(const struct sparc_gregmap *gregmap, struct regcache *regcache, int regnum, const void *gregs)
struct gdbarch * get_regcache_arch(const struct regcache *regcache)
struct value * frame_unwind_got_memory(struct frame_info *frame, int regnum, CORE_ADDR addr)
void sparc_record_save_insn(struct sparc_frame_cache *cache)
struct type * arch_flags_type(struct gdbarch *gdbarch, char *name, int length)
void set_gdbarch_write_pc(struct gdbarch *gdbarch, gdbarch_write_pc_ftype write_pc)
const struct regset * gregset
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
static int sparc32_struct_return_from_sym(struct symbol *sym)
static struct value * sparc32_frame_prev_register(struct frame_info *this_frame, void **this_cache, int regnum)
struct sparc_frame_cache * sparc_frame_cache(struct frame_info *this_frame, void **this_cache)
ULONGEST frame_unwind_register_unsigned(struct frame_info *frame, int regnum)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
static int sparc_integral_or_pointer_p(const struct type *type)
void register_sparc_ravenscar_ops(struct gdbarch *gdbarch)
void append_flags_type_flag(struct type *type, int bitpos, char *name)
static CORE_ADDR sparc_unwind_pc(struct gdbarch *gdbarch, struct frame_info *this_frame)
union dwarf2_frame_state_reg::@51 loc
void set_gdbarch_stabs_argument_has_addr(struct gdbarch *gdbarch, gdbarch_stabs_argument_has_addr_ftype stabs_argument_has_addr)
static CORE_ADDR sparc32_frame_base_address(struct frame_info *this_frame, void **this_cache)
struct gdbarch_list * gdbarch_list_lookup_by_info(struct gdbarch_list *arches, const struct gdbarch_info *info)
CORE_ADDR(* step_trap)(struct frame_info *frame, unsigned long insn)
void sparc32_collect_fpregset(const struct sparc_fpregmap *fpregmap, const struct regcache *regcache, int regnum, void *fpregs)
struct address_space * get_frame_address_space(struct frame_info *frame)
#define SPARC32_NUM_PSEUDO_REGS
ULONGEST get_frame_memory_unsigned(struct frame_info *this_frame, CORE_ADDR addr, int len)
static const struct frame_unwind sparc32_frame_unwind
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
static struct type * sparc_fsr_type(struct gdbarch *gdbarch)
void sparc_supply_rwindow(struct regcache *regcache, CORE_ADDR sp, int regnum)
static struct sparc_frame_cache * sparc_alloc_frame_cache(void)
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
struct type * builtin_int32
static int sparc_structure_or_union_p(const struct type *type)
#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)
static void sparc32_extract_return_value(struct type *type, struct regcache *regcache, gdb_byte *valbuf)
ULONGEST sparc_fetch_wcookie(struct gdbarch *gdbarch)
static int sparc_complex_floating_p(const struct type *type)
void frame_base_set_default(struct gdbarch *gdbarch, const struct frame_base *default_base)
static struct frame_id sparc_dummy_id(struct gdbarch *gdbarch, struct frame_info *this_frame)
void set_gdbarch_pseudo_register_write(struct gdbarch *gdbarch, gdbarch_pseudo_register_write_ftype pseudo_register_write)
static void sparc32_pseudo_register_write(struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buf)
static int sparc32_stabs_argument_has_addr(struct gdbarch *gdbarch, struct type *type)
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype register_type)
struct type * check_typedef(struct type *type)
const gdb_byte * value_contents(struct value *value)
static CORE_ADDR sparc32_store_arguments(struct regcache *regcache, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr)
void dwarf2_frame_set_init_reg(struct gdbarch *gdbarch, void(*init_reg)(struct gdbarch *, int, struct dwarf2_frame_state_reg *, struct frame_info *))
struct target_ops current_target
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
int sparc_software_single_step(struct frame_info *frame)
unsigned short int saved_regs_mask
unsigned long sparc_fetch_instruction(CORE_ADDR pc)
struct symbol * find_pc_function(CORE_ADDR pc)
void sparc_collect_rwindow(const struct regcache *regcache, CORE_ADDR sp, int regnum)
static CORE_ADDR sparc32_frame_align(struct gdbarch *gdbarch, CORE_ADDR address)
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 sparc_skip_stack_check(const CORE_ADDR start_pc)
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
int using_struct_return(struct gdbarch *gdbarch, struct value *function, struct type *value_type)
void insert_single_step_breakpoint(struct gdbarch *gdbarch, struct address_space *aspace, CORE_ADDR next_pc)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
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)
void set_gdbarch_breakpoint_from_pc(struct gdbarch *gdbarch, gdbarch_breakpoint_from_pc_ftype breakpoint_from_pc)
static int sparc_is_unimp_insn(CORE_ADDR pc)
int default_frame_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache)
void sparc32_supply_fpregset(const struct sparc_fpregmap *fpregmap, struct regcache *regcache, int regnum, const void *fpregs)
struct value * value_cast(struct type *type, struct value *arg2)
static const char * sparc32_pseudo_register_names[]
static void sparc32_frame_this_id(struct frame_info *this_frame, void **this_cache, struct frame_id *this_id)
struct sparc_frame_cache * sparc32_frame_cache(struct frame_info *this_frame, void **this_cache)
static CORE_ADDR sparc_step_trap(struct frame_info *frame, unsigned long insn)
void sparc32_collect_gregset(const struct sparc_gregmap *gregmap, const struct regcache *regcache, int regnum, void *gregs)
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
void( iterate_over_regset_sections_cb)(const char *sect_name, int size, const struct regset *regset, const char *human_name, void *cb_data)
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
void set_gdbarch_frame_args_skip(struct gdbarch *gdbarch, CORE_ADDR frame_args_skip)
static int sparc32_dwarf2_struct_return_p(struct frame_info *this_frame)
void _initialize_sparc_tdep(void)
#define floatformats_sparc_quad
int sparc_is_annulled_branch_insn(CORE_ADDR pc)
static CORE_ADDR sparc32_push_dummy_code(struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funcaddr, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache)
void set_gdbarch_software_single_step(struct gdbarch *gdbarch, gdbarch_software_single_step_ftype software_single_step)
CORE_ADDR sparc_analyze_prologue(struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR current_pc, struct sparc_frame_cache *cache)
void set_gdbarch_push_dummy_code(struct gdbarch *gdbarch, gdbarch_push_dummy_code_ftype push_dummy_code)
struct type * sparc_fsr_type
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
struct type * sparc_psr_type
struct value * value_from_pointer(struct type *type, CORE_ADDR addr)
void set_gdbarch_pseudo_register_read(struct gdbarch *gdbarch, gdbarch_pseudo_register_read_ftype pseudo_register_read)
#define TYPE_TARGET_TYPE(thistype)
struct type * builtin_double
static struct type * sparc32_register_type(struct gdbarch *gdbarch, int regnum)
static CORE_ADDR sparc_analyze_control_transfer(struct frame_info *frame, CORE_ADDR pc, CORE_ADDR *npc)
#define TYPE_CODE(thistype)
unsigned char copied_regs_mask
enum register_status regcache_raw_read(struct regcache *regcache, int regnum, gdb_byte *buf)
struct value * frame_unwind_got_register(struct frame_info *frame, int regnum, int new_regnum)
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
struct type * builtin_data_ptr
static int in_plt_section(CORE_ADDR pc)
void set_gdbarch_num_pseudo_regs(struct gdbarch *gdbarch, int num_pseudo_regs)
static enum return_value_convention sparc32_return_value(struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
enum register_status regcache_cooked_read(struct regcache *regcache, int regnum, gdb_byte *buf)
static const gdb_byte * sparc_breakpoint_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pc, int *len)
static struct type * sparc_psr_type(struct gdbarch *gdbarch)
const struct regset * fpregset
void regcache_raw_supply(struct regcache *regcache, int regnum, const void *buf)
void set_gdbarch_call_dummy_location(struct gdbarch *gdbarch, int call_dummy_location)
unsigned long long ULONGEST
enum unwind_stop_reason default_frame_unwind_stop_reason(struct frame_info *this_frame, void **this_cache)
void set_gdbarch_long_double_bit(struct gdbarch *gdbarch, int long_double_bit)
struct type * value_type(const struct value *value)
#define SYMBOL_TYPE(symbol)
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype return_value)
LONGEST target_read(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *buf, ULONGEST offset, LONGEST len)
void regcache_raw_collect(const struct regcache *regcache, int regnum, void *buf)
void set_gdbarch_long_double_format(struct gdbarch *gdbarch, const struct floatformat **long_double_format)
#define TYPE_LENGTH(thistype)
void set_gdbarch_push_dummy_call(struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype push_dummy_call)
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
void set_gdbarch_iterate_over_regset_sections(struct gdbarch *gdbarch, gdbarch_iterate_over_regset_sections_ftype iterate_over_regset_sections)
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 void sparc_iterate_over_regset_sections(struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache)
static CORE_ADDR sparc32_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)
static enum register_status sparc32_pseudo_register_read(struct gdbarch *gdbarch, struct regcache *regcache, int regnum, gdb_byte *buf)
static int sparc_floating_p(const struct type *type)
static struct gdbarch * sparc32_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
enum bfd_endian byte_order
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
void set_gdbarch_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype register_name)
CORE_ADDR get_frame_func(struct frame_info *this_frame)
enum dwarf2_frame_reg_rule how
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 type * lookup_pointer_type(struct type *type)
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
static CORE_ADDR sparc32_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR start_pc)
void regcache_cooked_write(struct regcache *regcache, int regnum, const gdb_byte *buf)
void set_gdbarch_print_insn(struct gdbarch *gdbarch, gdbarch_print_insn_ftype print_insn)
static const char * sparc32_register_names[]
struct type * builtin_float
static void sparc32_dwarf2_frame_init_reg(struct gdbarch *gdbarch, int regnum, struct dwarf2_frame_state_reg *reg, struct frame_info *this_frame)
void regcache_raw_write(struct regcache *regcache, int regnum, const gdb_byte *buf)
const ULONGEST const LONGEST len