37#include "opcode/riscv.h"
46#include "floatformat.h"
52#include "gdbsupport/common-defs.h"
53#include "opcode/riscv-opc.h"
59#include "gdbsupport/gdb-safe-ctype.h"
62#define SP_ALIGNMENT 16
65#define BIGGEST_ALIGNMENT 16
69#define DECLARE_INSN(INSN_NAME, INSN_MATCH, INSN_MASK) \
70static inline bool is_ ## INSN_NAME ## _insn (long insn) \
72 return (insn & INSN_MASK) == INSN_MATCH; \
74#include "opcode/riscv-opc.h"
84#define riscv_breakpoints_debug_printf(fmt, ...) \
85 debug_prefixed_printf_cond (riscv_debug_breakpoints, \
86 "riscv-breakpoints", \
96#define riscv_infcall_debug_printf(fmt, ...) \
97 debug_prefixed_printf_cond (riscv_debug_infcall, "riscv-infcall", \
102#define RISCV_INFCALL_SCOPED_DEBUG_START_END(fmt, ...) \
103 scoped_debug_start_end (riscv_debug_infcall, "riscv-infcall", \
113#define riscv_unwinder_debug_printf(fmt, ...) \
114 debug_prefixed_printf_cond (riscv_debug_unwinder, "riscv-unwinder", \
124#define riscv_gdbarch_debug_printf(fmt, ...) \
125 debug_prefixed_printf_cond (riscv_debug_gdbarch, "riscv-gdbarch", \
170 const int *reg_p = (
const int *) baton;
234 bool prefer_first_name_p,
235 std::vector<riscv_pending_register_alias> *aliases)
const;
268 const struct tdesc_feature *feature,
269 bool prefer_first_name_p,
270 std::vector<riscv_pending_register_alias> *aliases)
const
282 int start_index = prefer_first_name_p ? 1 : 0;
283 for (
int i = start_index; i < this->
names.size (); ++i)
286 if (
alias ==
name && !prefer_first_name_p)
288 aliases->emplace_back (
alias, (
void *) &this->
regnum);
346 return m_registers[
regnum].names[0];
353 std::vector<riscv_pending_register_alias> *aliases,
356 const struct tdesc_feature *feature_cpu = tdesc_feature (tdesc);
358 if (feature_cpu ==
nullptr)
361 bool seen_an_optional_reg_p =
false;
362 for (
const auto ® : m_registers)
364 bool found = reg.check (
tdesc_data, feature_cpu,
true, aliases);
369 if (!found && (!is_optional_reg_p || seen_an_optional_reg_p))
371 else if (found && is_optional_reg_p)
372 seen_an_optional_reg_p =
true;
379 for (
auto &tdesc_reg : feature_cpu->registers)
380 valid_p &= (tdesc_reg->bitsize == xlen_bitsize);
382 features->
xlen = (xlen_bitsize / 8);
383 features->
embedded = !seen_an_optional_reg_p;
433 { RISCV_CSR_FFLAGS_REGNUM, {
"fflags",
"csr1" } },
434 { RISCV_CSR_FRM_REGNUM, {
"frm",
"csr2" } },
435 { RISCV_CSR_FCSR_REGNUM, {
"fcsr",
"csr3" } },
448 return m_registers[
regnum].names[0];
455 std::vector<riscv_pending_register_alias> *aliases,
458 const struct tdesc_feature *feature_fpu = tdesc_feature (tdesc);
462 if (feature_fpu ==
nullptr)
471 for (
const auto ® : m_registers)
473 bool found = reg.check (
tdesc_data, feature_fpu,
true, aliases);
477 if (!found && !is_ctrl_reg_p)
485 for (
const auto ® : m_registers)
492 int reg_bitsize = -1;
493 for (
const char *
name : reg.names)
501 gdb_assert (reg_bitsize != -1);
502 if (fp_bitsize == -1)
503 fp_bitsize = reg_bitsize;
504 else if (fp_bitsize != reg_bitsize)
508 features->
flen = (fp_bitsize / 8);
535 std::vector<riscv_pending_register_alias> *aliases,
538 const struct tdesc_feature *feature_virtual = tdesc_feature (tdesc);
541 if (feature_virtual ==
nullptr)
546 for (
const auto ® : m_registers)
547 reg.check (
tdesc_data, feature_virtual,
true, aliases);
565#define DECLARE_CSR(NAME,VALUE,CLASS,DEFINE_VER,ABORT_VER) \
566 { RISCV_ ## VALUE ## _REGNUM, { # NAME } },
567#include "opcode/riscv-opc.h"
570 riscv_create_csr_aliases ();
575 std::vector<riscv_pending_register_alias> *aliases,
578 const struct tdesc_feature *feature_csr = tdesc_feature (tdesc);
581 if (feature_csr ==
nullptr)
586 for (
const auto ® : m_registers)
587 reg.check (
tdesc_data, feature_csr,
true, aliases);
600 for (
auto ® : m_registers)
603 gdb::unique_xmalloc_ptr<char>
alias = xstrprintf (
"csr%d", csr_num);
604 reg.names.push_back (
alias.release ());
664 return m_registers[
regnum].names[0];
671 std::vector<riscv_pending_register_alias> *aliases,
674 const struct tdesc_feature *feature_vector = tdesc_feature (tdesc);
678 if (feature_vector ==
nullptr)
685 for (
const auto ® : m_registers)
687 if (!reg.check (
tdesc_data, feature_vector,
true, aliases))
694 int vector_bitsize = -1;
695 for (
const auto ® : m_registers)
697 int reg_bitsize = -1;
698 for (
const char *
name : reg.names)
706 gdb_assert (reg_bitsize != -1);
707 if (vector_bitsize == -1)
708 vector_bitsize = reg_bitsize;
709 else if (vector_bitsize != reg_bitsize)
713 features->
vlen = (vector_bitsize / 8);
736 _(
"Debugger's use of compressed breakpoints is set "
758 _(
"RiscV debug variable `%s' is set to: %s\n"),
840 bool unaligned_p =
false;
863 const char *
bp = (unaligned_p || riscv_insn_length (buf[0]) == 2
864 ?
"C.EBREAK" :
"EBREAK");
868 suffix =
"(unaligned address)";
870 suffix = string_printf (
"(instruction length %d)",
871 riscv_insn_length (buf[0]));
876 if (unaligned_p || riscv_insn_length (buf[0]) == 2)
889static const gdb_byte *
892 static const gdb_byte ebreak[] = { 0x73, 0x00, 0x10, 0x00, };
893 static const gdb_byte c_ebreak[] = { 0x02, 0x90 };
903 gdb_assert_not_reached (
"unhandled breakpoint kind");
918 gdb_assert (
name !=
nullptr);
973static enum register_status
976 int regnum, gdb_byte *buf)
987 enum register_status
status
997 buf[0] = (buf[0] >> 5) & 0x7;
1012 const gdb_byte *buf)
1018 int fcsr_regnum = RISCV_CSR_FCSR_REGNUM;
1024 raw_buf[0] = (raw_buf[0] & ~0x1f) | (buf[0] & 0x1f);
1026 raw_buf[0] = (raw_buf[0] & ~(0x7 << 5)) | ((buf[0] & 0x7) << 5);
1031 gdb_assert_not_reached (
"unknown pseudo register %d",
regnum);
1056 union __gdb_builtin_type_fpreg_d
1066 "__gdb_builtin_type_fpreg_d", TYPE_CODE_UNION);
1070 t->
set_name (
"builtin_type_fpreg_d");
1102 && (strcmp (
type->
name (),
"builtin_type_ieee_double") == 0
1103 || strcmp (
type->
name (),
"double") == 0))
1143 struct type *regtype;
1144 int print_raw_format;
1145 enum tab_stops { value_column_1 = 15 };
1153 regtype = val->
type ();
1155 catch (
const gdb_exception_error &ex)
1166 if (regtype->
code () == TYPE_CODE_FLT
1167 || (regtype->
code () == TYPE_CODE_UNION
1171 || (regtype->
code () == TYPE_CODE_UNION
1182 opts.deref_ref =
true;
1186 if (print_raw_format)
1201 opts.deref_ref =
true;
1204 if (print_raw_format)
1206 if (
regnum == RISCV_CSR_MSTATUS_REGNUM)
1217 "\tSD:%X VM:%02X MXR:%X PUM:%X MPRV:%X XS:%X "
1218 "FS:%X MPP:%x HPP:%X SPP:%X MPIE:%X HPIE:%X "
1219 "SPIE:%X UPIE:%X MIE:%X HIE:%X SIE:%X UIE:%X",
1220 (
int) ((d >> (xlen - 1)) & 0x1),
1221 (
int) ((d >> 24) & 0x1f),
1222 (
int) ((d >> 19) & 0x1),
1223 (
int) ((d >> 18) & 0x1),
1224 (
int) ((d >> 17) & 0x1),
1225 (
int) ((d >> 15) & 0x3),
1226 (
int) ((d >> 13) & 0x3),
1227 (
int) ((d >> 11) & 0x3),
1228 (
int) ((d >> 9) & 0x3),
1229 (
int) ((d >> 8) & 0x1),
1230 (
int) ((d >> 7) & 0x1),
1231 (
int) ((d >> 6) & 0x1),
1232 (
int) ((d >> 5) & 0x1),
1233 (
int) ((d >> 4) & 0x1),
1234 (
int) ((d >> 3) & 0x1),
1235 (
int) ((d >> 2) & 0x1),
1236 (
int) ((d >> 1) & 0x1),
1237 (
int) ((d >> 0) & 0x1));
1239 else if (
regnum == RISCV_CSR_MISA_REGNUM)
1250 base = (d >> ((
size * 8) - 2)) & 0x3;
1253 for (; base > 0; base--)
1257 for (i = 0; i < 26; i++)
1263 else if (
regnum == RISCV_CSR_FCSR_REGNUM
1264 ||
regnum == tdep->fflags_regnum
1265 ||
regnum == tdep->frm_regnum)
1270 if (
regnum != tdep->frm_regnum)
1272 "NV:%d DZ:%d OF:%d UF:%d NX:%d",
1273 (
int) ((d >> 4) & 0x1),
1274 (
int) ((d >> 3) & 0x1),
1275 (
int) ((d >> 2) & 0x1),
1276 (
int) ((d >> 1) & 0x1),
1277 (
int) ((d >> 0) & 0x1));
1279 if (
regnum != tdep->fflags_regnum)
1281 static const char *
const sfrm[] =
1283 _(
"RNE (round to nearest; ties to even)"),
1284 _(
"RTZ (Round towards zero)"),
1285 _(
"RDN (Round down towards -INF)"),
1286 _(
"RUP (Round up towards +INF)"),
1287 _(
"RMM (Round to nearest; ties to max magnitude)"),
1293 _(
"INVALID[7] (Dynamic rounding mode)"),
1295 int frm = ((
regnum == RISCV_CSR_FCSR_REGNUM)
1296 ? (d >> 5) : d) & 0x7;
1299 (
regnum == RISCV_CSR_FCSR_REGNUM
1314 static const char *
const sprv[] =
1325 gdb_printf (file,
"\tprv:%d [INVALID]", priv);
1334 opts.deref_ref =
true;
1355#define DECLARE_CSR(name, num, class, define_ver, abort_ver) case RISCV_ ## num ## _REGNUM:
1356#include "opcode/riscv-opc.h"
1431 ||
regnum == RISCV_CSR_FCSR_REGNUM
1440 ||
regnum == RISCV_CSR_FCSR_REGNUM
1474 gdb_assert_not_reached (
"unknown pseudo register number %d",
regnum);
1487 gdb_assert_not_reached (
"unknown pseudo register number %d",
regnum);
1508 int regnum,
int print_all)
1514 error (_(
"Not a valid register for the current processor type"));
1605 {
return m_length; }
1609 {
return m_opcode; }
1638 return (
opcode >> offset) & 0x1F;
1644 return ((
opcode >> offset) & 0x7) + 8;
1651 m_rd = decode_register_index (ival, OP_SH_RD);
1652 m_rs1 = decode_register_index (ival, OP_SH_RS1);
1653 m_rs2 = decode_register_index (ival, OP_SH_RS2);
1660 m_rd = m_rs1 = decode_register_index (ival, OP_SH_CRS1S);
1661 m_rs2 = decode_register_index (ival, OP_SH_CRS2);
1668 m_rd = decode_register_index (ival, OP_SH_RD);
1669 m_rs1 = decode_register_index (ival, OP_SH_RS1);
1670 m_imm.s = EXTRACT_ITYPE_IMM (ival);
1679 gdb::optional<int> rs1_regnum = {})
1682 m_rd = decode_register_index (ival, OP_SH_CRS1S);
1683 if (rs1_regnum.has_value ())
1684 m_rs1 = *rs1_regnum;
1687 m_imm.s = EXTRACT_CITYPE_IMM (ival);
1694 m_rd = decode_register_index_short (ival, OP_SH_CRS2S);
1695 m_rs1 = decode_register_index_short (ival, OP_SH_CRS1S);
1696 m_imm.s = EXTRACT_CLTYPE_IMM (ival);
1703 m_rs1 = decode_register_index (ival, OP_SH_RS1);
1704 m_rs2 = decode_register_index (ival, OP_SH_RS2);
1705 m_imm.s = EXTRACT_STYPE_IMM (ival);
1716 m_rs1 = decode_register_index_short (ival, OP_SH_CRS1S);
1717 m_rs2 = decode_register_index_short (ival, OP_SH_CRS2S);
1730 m_rs2 = decode_register_index (ival, OP_SH_CRS2);
1737 m_rd = decode_register_index (ival, OP_SH_RD);
1738 m_imm.s = EXTRACT_UTYPE_IMM (ival);
1745 m_rd = decode_register_index (ival, OP_SH_RD);
1746 m_imm.s = EXTRACT_JTYPE_IMM (ival);
1753 m_imm.s = EXTRACT_CJTYPE_IMM (ival);
1759 m_rs1 = decode_register_index (ival, OP_SH_RS1);
1760 m_rs2 = decode_register_index (ival, OP_SH_RS2);
1761 m_imm.s = EXTRACT_BTYPE_IMM (ival);
1767 m_rs1 = decode_register_index_short (ival, OP_SH_CRS1S);
1768 m_imm.s = EXTRACT_CBTYPE_IMM (ival);
1774 CORE_ADDR addr,
int *len);
1813 CORE_ADDR addr,
int *len)
1815 gdb_byte buf[RISCV_MAX_INSN_LEN];
1824 instlen = riscv_insn_length (buf[0]);
1825 gdb_assert (instlen <=
sizeof (buf));
1853 if (is_add_insn (ival))
1854 decode_r_type_insn (
ADD, ival);
1855 else if (is_addw_insn (ival))
1856 decode_r_type_insn (ADDW, ival);
1857 else if (is_addi_insn (ival))
1858 decode_i_type_insn (ADDI, ival);
1859 else if (is_addiw_insn (ival))
1860 decode_i_type_insn (ADDIW, ival);
1861 else if (is_auipc_insn (ival))
1862 decode_u_type_insn (AUIPC, ival);
1863 else if (is_lui_insn (ival))
1864 decode_u_type_insn (LUI, ival);
1865 else if (is_sd_insn (ival))
1866 decode_s_type_insn (SD, ival);
1867 else if (is_sw_insn (ival))
1868 decode_s_type_insn (SW, ival);
1869 else if (is_jal_insn (ival))
1870 decode_j_type_insn (JAL, ival);
1871 else if (is_jalr_insn (ival))
1872 decode_i_type_insn (JALR, ival);
1873 else if (is_beq_insn (ival))
1874 decode_b_type_insn (BEQ, ival);
1875 else if (is_bne_insn (ival))
1876 decode_b_type_insn (BNE, ival);
1877 else if (is_blt_insn (ival))
1878 decode_b_type_insn (BLT, ival);
1879 else if (is_bge_insn (ival))
1880 decode_b_type_insn (BGE, ival);
1881 else if (is_bltu_insn (ival))
1882 decode_b_type_insn (BLTU, ival);
1883 else if (is_bgeu_insn (ival))
1884 decode_b_type_insn (BGEU, ival);
1885 else if (is_lr_w_insn (ival))
1886 decode_r_type_insn (LR, ival);
1887 else if (is_lr_d_insn (ival))
1888 decode_r_type_insn (LR, ival);
1889 else if (is_sc_w_insn (ival))
1890 decode_r_type_insn (SC, ival);
1891 else if (is_sc_d_insn (ival))
1892 decode_r_type_insn (SC, ival);
1893 else if (is_ecall_insn (ival))
1894 decode_i_type_insn (ECALL, ival);
1895 else if (is_ld_insn (ival))
1896 decode_i_type_insn (LD, ival);
1897 else if (is_lw_insn (ival))
1898 decode_i_type_insn (LW, ival);
1903 else if (m_length == 2)
1910 if (is_c_jalr_insn (ival))
1911 decode_cr_type_insn (JALR, ival);
1912 else if (is_c_add_insn (ival))
1913 decode_cr_type_insn (
ADD, ival);
1915 else if (xlen != 4 && is_c_addw_insn (ival))
1916 decode_cr_type_insn (ADDW, ival);
1917 else if (is_c_addi_insn (ival))
1918 decode_ci_type_insn (ADDI, ival);
1921 else if (xlen != 4 && is_c_addiw_insn (ival))
1922 decode_ci_type_insn (ADDIW, ival);
1923 else if (xlen == 4 && is_c_jal_insn (ival))
1924 decode_cj_type_insn (JAL, ival);
1928 else if (is_c_addi16sp_insn (ival))
1931 m_rd = m_rs1 = decode_register_index (ival, OP_SH_RD);
1932 m_imm.s = EXTRACT_CITYPE_ADDI16SP_IMM (ival);
1934 else if (is_c_addi4spn_insn (ival))
1937 m_rd = decode_register_index_short (ival, OP_SH_CRS2S);
1939 m_imm.s = EXTRACT_CIWTYPE_ADDI4SPN_IMM (ival);
1941 else if (is_c_lui_insn (ival))
1944 m_rd = decode_register_index (ival, OP_SH_CRS1S);
1945 m_imm.s = EXTRACT_CITYPE_LUI_IMM (ival);
1947 else if (is_c_li_insn (ival))
1948 decode_ci_type_insn (LI, ival);
1951 else if (xlen != 4 && is_c_sd_insn (ival))
1952 decode_cs_type_insn (SD, ival, EXTRACT_CLTYPE_LD_IMM (ival));
1953 else if (is_c_sw_insn (ival))
1954 decode_cs_type_insn (SW, ival, EXTRACT_CLTYPE_LW_IMM (ival));
1955 else if (is_c_swsp_insn (ival))
1956 decode_css_type_insn (SW, ival, EXTRACT_CSSTYPE_SWSP_IMM (ival));
1957 else if (xlen != 4 && is_c_sdsp_insn (ival))
1958 decode_css_type_insn (SD, ival, EXTRACT_CSSTYPE_SDSP_IMM (ival));
1961 else if (is_c_jr_insn (ival))
1962 decode_cr_type_insn (JALR, ival);
1963 else if (is_c_mv_insn (ival))
1964 decode_cr_type_insn (MV, ival);
1965 else if (is_c_j_insn (ival))
1966 decode_cj_type_insn (JAL, ival);
1967 else if (is_c_beqz_insn (ival))
1968 decode_cb_type_insn (BEQ, ival);
1969 else if (is_c_bnez_insn (ival))
1970 decode_cb_type_insn (BNE, ival);
1971 else if (is_c_ld_insn (ival))
1972 decode_cl_type_insn (LD, ival);
1973 else if (is_c_lw_insn (ival))
1974 decode_cl_type_insn (LW, ival);
1975 else if (is_c_ldsp_insn (ival))
1977 else if (is_c_lwsp_insn (ival))
1988 gdb_assert (m_length > 0 && m_length % 2 == 0);
2042 gdb_assert (insn.
length () > 0);
2047 gdb_assert (insn.
length () > 0);
2054 (
"previous instruction at %s (length %d) was 'ld'",
2055 core_addr_to_string (pc - insn.
length ()), insn.
length ());
2079 gdb_assert (insn.
length () > 0);
2084 gdb_assert (insn.
length () > 0);
2091 (
"previous instruction at %s (length %d) was 'add'",
2092 core_addr_to_string (pc - insn.
length ()), insn.
length ());
2093 *prev_pc = pc - insn.
length ();
2145 for (
int i = 0; i < 3; ++i)
2149 gdb_assert (insn.
length () > 0);
2154 core_addr_to_string (pc));
2162 core_addr_to_string (pc));
2180 core_addr_to_string (pc));
2181 gdb_assert (i != 1);
2211 CORE_ADDR start_pc, CORE_ADDR end_pc,
2214 CORE_ADDR cur_pc, next_pc, after_prologue_pc;
2215 CORE_ADDR original_end_pc = end_pc;
2216 CORE_ADDR end_prologue_addr = 0;
2222 if (after_prologue_pc == 0)
2223 after_prologue_pc = start_pc + 100;
2224 if (after_prologue_pc < end_pc)
2225 end_pc = after_prologue_pc;
2233 core_addr_to_string (start_pc),
2234 core_addr_to_string (end_pc));
2236 for (next_pc = cur_pc = start_pc; cur_pc < end_pc; cur_pc = next_pc)
2243 gdb_assert (insn.
length () > 0);
2244 next_pc = cur_pc + insn.
length ();
2330 regs[insn.
rd ()] =
pv_add (regs[insn.
rs1 ()], regs[insn.
rs2 ()]);
2351 gdb_assert (insn.
rs2 () > 0);
2352 regs[insn.
rd ()] = regs[insn.
rs2 ()];
2356 end_prologue_addr = cur_pc;
2361 if (end_prologue_addr == 0)
2362 end_prologue_addr = cur_pc;
2365 core_addr_to_string (end_prologue_addr));
2399 (
"in function epilogue at %s, stack offset is %d",
2400 core_addr_to_string (original_end_pc), sp_offset);
2421 plongest ((LONGEST) offset));
2427 return end_prologue_addr;
2435 CORE_ADDR func_addr;
2442 CORE_ADDR post_prologue_pc
2445 if (post_prologue_pc != 0)
2446 return std::max (pc, post_prologue_pc);
2459 CORE_ADDR funaddr,
struct value **args,
int nargs,
2460 struct type *value_type, CORE_ADDR *real_pc,
2464 static const gdb_byte nop_insn[] = { 0x13, 0x00, 0x00, 0x00 };
2495 plongest (
sizeof (nop_insn)),
2497 (
status == 0 ?
"success" :
"failed"));
2597 : next_regnum (first),
2659 float_regs.next_regnum = float_regs.last_regnum + 1;
2704 int length,
int offset)
2711 loc->c_length = length;
2712 loc->c_offset = offset;
2730 int length,
int align)
2734 = align_up (memory->arg_offset, align);
2735 loc->loc_data.offset = memory->arg_offset;
2736 memory->arg_offset += length;
2737 loc->c_length = length;
2786 int len = std::min (ainfo->
length, cinfo->
xlen);
2787 int align = std::max (ainfo->
align, cinfo->
xlen);
2798 &cinfo->
memory, len, align);
2800 if (len < ainfo->length)
2802 len = ainfo->
length - len;
2843 int len = ainfo->
length / 2;
2847 gdb_assert (result);
2851 gdb_assert (result);
2866 : m_number_of_fields (0),
2877 analyse_inner (
type, 0);
2886 {
return m_number_of_fields; }
2894 gdb_assert (index < (
sizeof (m_types) /
sizeof (m_types[0])));
2895 return m_types[index];
2904 gdb_assert (index < (
sizeof (m_offsets) /
sizeof (m_offsets[0])));
2905 return m_offsets[index];
2923 void analyse_inner (
struct type *
type,
int offset);
2934 for (i = 0; i < count; ++i)
2944 switch (field_type->
code ())
2946 case TYPE_CODE_STRUCT:
2947 analyse_inner (field_type, field_offset);
2956 if (m_number_of_fields < 2)
2958 m_types[m_number_of_fields] = field_type;
2959 m_offsets[m_number_of_fields] = field_offset;
2961 m_number_of_fields++;
2970 if (m_number_of_fields > 2)
3008 gdb_assert (result);
3013 gdb_assert (result);
3054 error (_(
"failed during argument setup"));
3064 error (_(
"failed during argument setup"));
3079 error (_(
"failed during argument setup"));
3083 gdb_assert (len1 <= cinfo->xlen);
3086 error (_(
"failed during argument setup"));
3100 gdb_assert (len0 <= cinfo->xlen);
3101 gdb_assert (len1 <= cinfo->flen);
3106 error (_(
"failed during argument setup"));
3112 error (_(
"failed during argument setup"));
3137 struct type *
type,
bool is_unnamed)
3150 case TYPE_CODE_BOOL:
3151 case TYPE_CODE_CHAR:
3152 case TYPE_CODE_RANGE:
3153 case TYPE_CODE_ENUM:
3155 case TYPE_CODE_FIXED_POINT:
3176 case TYPE_CODE_COMPLEX:
3180 case TYPE_CODE_STRUCT:
3202 CORE_ADDR sp_refs, CORE_ADDR sp_args)
3204 gdb_printf (stream,
"type: '%s', length: 0x%x, alignment: 0x%x",
3206 switch (info->argloc[0].loc_type)
3210 (stream,
", register %s",
3212 if (info->argloc[0].c_length < info->length)
3214 switch (info->argloc[1].loc_type)
3218 (stream,
", register %s",
3220 info->argloc[1].loc_data.regno));
3224 gdb_printf (stream,
", on stack at offset 0x%x",
3225 info->argloc[1].loc_data.offset);
3233 error (_(
"invalid argument location"));
3237 if (info->argloc[1].c_offset > info->argloc[0].c_length)
3239 info->argloc[1].c_offset);
3244 gdb_printf (stream,
", on stack at offset 0x%x",
3245 info->argloc[0].loc_data.offset);
3250 (stream,
", by reference, data at offset 0x%x (%s)",
3251 info->argloc[0].loc_data.offset,
3252 core_addr_to_string (sp_refs + info->argloc[0].loc_data.offset));
3253 if (info->argloc[1].loc_type
3256 (stream,
", address in register %s",
3260 gdb_assert (info->argloc[1].loc_type
3263 (stream,
", address on stack at offset 0x%x (%s)",
3264 info->argloc[1].loc_data.offset,
3265 core_addr_to_string (sp_args + info->argloc[1].loc_data.offset));
3270 gdb_assert_not_reached (
"unknown argument location type");
3283 gdb_byte tmp [
sizeof (ULONGEST)];
3287 memset (tmp, -1,
sizeof (tmp));
3289 memset (tmp, 0,
sizeof (tmp));
3290 memcpy (tmp, data, len);
3298 struct value *function,
3302 struct value **args,
3305 CORE_ADDR struct_addr)
3308 CORE_ADDR sp_args, sp_refs;
3320 if (ftype->
code () == TYPE_CODE_PTR)
3327 for (i = 0; i < nargs; ++i)
3329 struct value *arg_value;
3330 struct type *arg_type;
3333 arg_value = args[i];
3339 if (info->type != arg_type)
3340 arg_value =
value_cast (info->type, arg_value);
3341 info->contents = arg_value->
contents ().data ();
3353 ?
"is" :
"is not"));
3358 (
"[**] struct return pointer in register $A0");
3359 for (i = 0; i < nargs; ++i)
3371 core_addr_to_string (osp));
3377 core_addr_to_string_nz (osp - sp));
3385 gdb_byte buf[
sizeof (LONGEST)];
3391 for (i = 0; i < nargs; ++i)
3394 int second_arg_length = 0;
3395 const gdb_byte *second_arg_data;
3398 gdb_assert (info->length > 0);
3400 switch (info->argloc[0].loc_type)
3404 gdb_assert (info->argloc[0].c_length <= info->length);
3408 + info->argloc[0].c_offset),
3409 info->argloc[0].c_length,
3412 (((info->argloc[0].c_length + info->argloc[0].c_offset) < info->length)
3413 ? info->argloc[1].c_length : 0);
3414 second_arg_data = info->contents + info->argloc[1].c_offset;
3419 dst = sp_args + info->argloc[0].loc_data.offset;
3421 second_arg_length = 0;
3425 dst = sp_refs + info->argloc[0].loc_data.offset;
3428 second_arg_length = call_info.
xlen;
3429 second_arg_data = (gdb_byte *) &dst;
3433 gdb_assert_not_reached (
"unknown argument location type");
3436 if (second_arg_length > 0)
3438 switch (info->argloc[1].loc_type)
3443 && second_arg_length <= call_info.
flen)
3444 || second_arg_length <= call_info.
xlen);
3456 arg_addr = sp_args + info->argloc[1].loc_data.offset;
3457 write_memory (arg_addr, second_arg_data, second_arg_length);
3466 error (_(
"invalid argument location"));
3476 core_addr_to_string (bp_addr));
3491 struct value *function,
3494 struct value **read_value,
3495 const gdb_byte *writebuf)
3499 struct type *arg_type;
3511 if (read_value !=
nullptr || writebuf !=
nullptr)
3513 unsigned int arg_len;
3514 struct value *abi_val;
3515 gdb_byte *readbuf =
nullptr;
3519 gdb_assert (read_value ==
nullptr || writebuf ==
nullptr);
3529 if (writebuf !=
nullptr)
3531 struct value *arg_val;
3541 unscaled.
read (gdb::make_array_view (writebuf,
3548 info.type->is_unsigned ());
3562 arg_len = info.type->length ();
3564 switch (info.argloc[0].loc_type)
3569 regnum = info.argloc[0].loc_data.regno;
3570 gdb_assert (info.argloc[0].c_length <= arg_len);
3571 gdb_assert (info.argloc[0].c_length
3576 gdb_byte *ptr = readbuf + info.argloc[0].c_offset;
3578 info.argloc[0].c_length,
3584 const gdb_byte *ptr = writebuf + info.argloc[0].c_offset;
3586 info.argloc[0].c_length,
3592 if (info.argloc[1].c_length > 0)
3594 switch (info.argloc[1].loc_type)
3597 regnum = info.argloc[1].loc_data.regno;
3599 gdb_assert ((info.argloc[0].c_length
3600 + info.argloc[1].c_length) <= arg_len);
3601 gdb_assert (info.argloc[1].c_length
3606 readbuf += info.argloc[1].c_offset;
3608 info.argloc[1].c_length,
3615 = writebuf + info.argloc[1].c_offset;
3617 (
regnum, ptr, info.argloc[1].c_length,
3625 error (_(
"invalid argument location"));
3639 if (read_value !=
nullptr)
3648 arg_type = abi_val->
type ();
3650 if (writebuf !=
nullptr)
3657 error (_(
"invalid argument location"));
3664 if (read_value !=
nullptr)
3675 info.type->is_unsigned ());
3677 unscaled.
write ((*read_value)->contents_raw (),
3682 *read_value =
value_cast (arg_type, abi_val);
3686 switch (info.argloc[0].loc_type)
3694 error (_(
"invalid argument location"));
3703 return align_down (addr, 16);
3712 CORE_ADDR pc, start_addr;
3717 if ((*this_cache) != NULL)
3722 (*this_cache) = cache;
3745 for (regno = 0; regno < numregs; ++regno)
3771 void **prologue_cache,
3781 catch (
const gdb_exception_error &ex)
3790static struct value *
3792 void **prologue_cache,
3832 if (abfd !=
nullptr && bfd_get_flavour (abfd) == bfd_target_elf_flavour)
3834 unsigned char eclass = elf_elfheader (abfd)->e_ident[EI_CLASS];
3835 int e_flags = elf_elfheader (abfd)->e_flags;
3837 if (eclass == ELFCLASS32)
3839 else if (eclass == ELFCLASS64)
3842 internal_error (_(
"unknown ELF header class %d"), eclass);
3844 if (e_flags & EF_RISCV_FLOAT_ABI_DOUBLE)
3846 else if (e_flags & EF_RISCV_FLOAT_ABI_SINGLE)
3849 if (e_flags & EF_RISCV_RVE)
3851 if (features.
xlen == 8)
3853 warning (_(
"64-bit ELF with RV32E flag set! Assuming 32-bit"));
3878 if (features.
xlen == 0)
3879 features.
xlen = info.bfd_arch_info->bits_per_word == 32 ? 4 : 8;
3925 std::string target_options;
3927 target_options =
"-march=rv";
3929 target_options +=
"64";
3931 target_options +=
"32";
3933 target_options +=
"gc";
3934 else if (isa_flen == 4)
3935 target_options +=
"imafc";
3937 target_options +=
"imac";
3939 target_options +=
" -mabi=";
3941 target_options +=
"lp64";
3943 target_options +=
"ilp32";
3945 target_options +=
"d";
3946 else if (abi_flen == 4)
3947 target_options +=
"f";
3950 target_options +=
" -mno-relax";
3952 return target_options;
3963 const char *reg_name,
int possible_regnum)
3992 int *regnum_ptr =
nullptr;
3994 if (strcmp (reg_name,
"fflags") == 0)
3996 else if (strcmp (reg_name,
"frm") == 0)
3998 else if (strcmp (reg_name,
"fcsr") == 0)
4001 if (regnum_ptr !=
nullptr)
4007 if (*regnum_ptr != -1)
4012 *regnum_ptr = possible_regnum;
4013 return possible_regnum;
4028 return possible_regnum;
4044 return "riscv(32|64)?";
4053 return (ISDIGIT (*s)
4086 const struct target_desc *tdesc = info.target_desc;
4091 gdb_assert (tdesc !=
nullptr);
4096 std::vector<riscv_pending_register_alias> pending_aliases;
4099 &pending_aliases, &features)
4101 &pending_aliases, &features)
4103 &pending_aliases, &features)
4105 &pending_aliases, &features)
4107 &pending_aliases, &features));
4130 if (abi_features.
xlen == 0)
4131 abi_features = features;
4136 if (abi_features.
xlen != features.
xlen)
4137 error (_(
"bfd requires xlen %d, but target has xlen %d"),
4142 if (abi_features.
flen > features.
flen)
4143 error (_(
"bfd requires flen %d, but target has flen %d"),
4155 = gdbarch_tdep<riscv_gdbarch_tdep> (
arches->gdbarch);
4254 int num_pseudo_regs = 0;
4262 pending_aliases.emplace_back (
"csr1", (
void *) &tdep->
fflags_regnum);
4263 next_pseudo_regnum++;
4272 pending_aliases.emplace_back (
"csr2", (
void *) &tdep->
frm_regnum);
4273 next_pseudo_regnum++;
4300 for (
const auto &
alias : pending_aliases)
4309 disassembler_options_riscv ());
4335 = gdbarch_tdep<riscv_gdbarch_tdep> (
gdbarch);
4340 next_pc = pc + insn.
length ();
4348 next_pc = (source + insn.
imm_signed ()) & ~(CORE_ADDR) 0x1;
4384 ULONGEST src1, src2;
4392 ULONGEST src1, src2;
4416 CORE_ADDR cur_step_pc = pc;
4417 CORE_ADDR last_addr = 0;
4423 cur_step_pc = cur_step_pc + insn.
length ();
4429 last_addr = cur_step_pc + insn.
imm_signed ();
4430 cur_step_pc = cur_step_pc + insn.
length ();
4436 cur_step_pc = cur_step_pc + insn.
length ();
4442 if (pc != (cur_step_pc + insn.
imm_signed ()))
4444 cur_step_pc = cur_step_pc + insn.
length ();
4447 if (cur_step_pc != last_addr)
4450 *next_pc = cur_step_pc;
4458std::vector<CORE_ADDR>
4461 CORE_ADDR pc, next_pc;
4486 const void *regs,
size_t len)
4500 int fcsr_regnum = RISCV_CSR_FCSR_REGNUM;
4522 ULONGEST fflags_val = fcsr_val & 0x1f;
4523 ULONGEST frm_val = (fcsr_val >> 5) & 0x7;
4531 (gdb_byte *) &fflags_val,
4532 sizeof (fflags_val),
4538 (gdb_byte *)&frm_val,
4539 sizeof (fflags_val),
4556 _(
"RISC-V specific debug commands."),
4557 _(
"RISC-V specific debug commands."),
4563Set riscv breakpoint debugging."), _(
"\
4564Show riscv breakpoint debugging."), _(
"\
4565When non-zero, print debugging information for the riscv specific parts\n\
4566of the breakpoint mechanism."),
4573Set riscv inferior call debugging."), _(
"\
4574Show riscv inferior call debugging."), _(
"\
4575When non-zero, print debugging information for the riscv specific parts\n\
4576of the inferior call mechanism."),
4583Set riscv stack unwinding debugging."), _(
"\
4584Show riscv stack unwinding debugging."), _(
"\
4585When on, print debugging information for the riscv specific parts\n\
4586of the stack unwinding mechanism."),
4593Set riscv gdbarch initialisation debugging."), _(
"\
4594Show riscv gdbarch initialisation debugging."), _(
"\
4595When non-zero, print debugging information for the riscv gdbarch\n\
4596initialisation process."),
4603 _(
"RISC-V specific commands."),
4604 _(
"RISC-V specific commands."),
4613Set debugger's use of compressed breakpoints."), _(
" \
4614Show debugger's use of compressed breakpoints."), _(
"\
4615Debugging compressed code requires compressed breakpoints to be used. If\n\
4616left to 'auto' then gdb will use them if the existing instruction is a\n\
4617compressed instruction. If that doesn't give the correct behavior, then\n\
4618this option can be used."),
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)
bool find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr, const struct block **block)
pv_t fetch(pv_t addr, CORE_ADDR size)
bool find_reg(struct gdbarch *gdbarch, int reg, CORE_ADDR *offset_p)
void store(pv_t addr, CORE_ADDR size, pv_t value)
enum register_status raw_read(int regnum, gdb_byte *buf)
enum register_status cooked_read_part(int regnum, int offset, int len, gdb_byte *buf)
enum register_status raw_read_part(int regnum, int offset, int len, gdb_byte *buf)
enum register_status cooked_read(int regnum, gdb_byte *buf)
void raw_supply_integer(int regnum, const gdb_byte *addr, int addr_len, bool is_signed)
enum register_status get_register_status(int regnum) const override
void raw_supply_zeroed(int regnum)
void cooked_write(int regnum, const gdb_byte *buf)
void raw_write(int regnum, const gdb_byte *buf)
void supply_regset(const struct regset *regset, int regbase, int regnum, const void *buf, size_t size)
void decode_ci_type_insn(enum opcode opcode, ULONGEST ival, gdb::optional< int > rs1_regnum={})
void decode_cj_type_insn(enum opcode opcode, ULONGEST ival)
void decode_s_type_insn(enum opcode opcode, ULONGEST ival)
void decode_b_type_insn(enum opcode opcode, ULONGEST ival)
void decode_u_type_insn(enum opcode opcode, ULONGEST ival)
void decode_cr_type_insn(enum opcode opcode, ULONGEST ival)
void decode_i_type_insn(enum opcode opcode, ULONGEST ival)
int decode_register_index(unsigned long opcode, int offset)
void decode_j_type_insn(enum opcode opcode, ULONGEST ival)
enum opcode opcode() const
void decode_r_type_insn(enum opcode opcode, ULONGEST ival)
void decode_cb_type_insn(enum opcode opcode, ULONGEST ival)
void decode_cs_type_insn(enum opcode opcode, ULONGEST ival, int imm)
static ULONGEST fetch_instruction(struct gdbarch *gdbarch, CORE_ADDR addr, int *len)
void decode_css_type_insn(enum opcode opcode, ULONGEST ival, int imm)
void decode(struct gdbarch *gdbarch, CORE_ADDR pc)
void decode_cl_type_insn(enum opcode opcode, ULONGEST ival)
int decode_register_index_short(unsigned long opcode, int offset)
void create(struct gdbarch *gdbarch) const
riscv_pending_register_alias(const char *name, const void *baton)
void analyse_inner(struct type *type, int offset)
void analyse(struct type *type)
int number_of_fields() const
int field_offset(int index) const
struct type * field_type(int index) const
const std::string & string()
struct cmd_list_element * showlist
struct cmd_list_element * setlist
struct cmd_list_element * showdebuglist
struct cmd_list_element * setdebuglist
set_show_commands add_setshow_prefix_cmd(const char *name, command_class theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, cmd_list_element **set_list, cmd_list_element **show_list)
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)
set_show_commands add_setshow_auto_boolean_cmd(const char *name, enum command_class theclass, enum auto_boolean *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 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_REGISTER_CONVENTION
@ RETURN_VALUE_ABI_PRESERVES_ADDRESS
void dwarf2_append_unwinders(struct gdbarch *gdbarch)
struct value * value_of_register(int regnum, frame_info_ptr frame)
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)
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)
frame_info_ptr get_current_frame(void)
#define FRAME_OBSTACK_ZALLOC(TYPE)
void set_gdbarch_long_long_bit(struct gdbarch *gdbarch, int long_long_bit)
int gdbarch_pc_regnum(struct gdbarch *gdbarch)
void set_gdbarch_char_signed(struct gdbarch *gdbarch, int char_signed)
void set_gdbarch_return_value_as_value(struct gdbarch *gdbarch, gdbarch_return_value_as_value_ftype *return_value_as_value)
void set_gdbarch_disassembler_options(struct gdbarch *gdbarch, char **disassembler_options)
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)
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
void set_gdbarch_valid_disassembler_options(struct gdbarch *gdbarch, const disasm_options_and_args_t *valid_disassembler_options)
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_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_stap_is_single_operand(struct gdbarch *gdbarch, gdbarch_stap_is_single_operand_ftype *stap_is_single_operand)
void set_gdbarch_have_nonsteppable_watchpoint(struct gdbarch *gdbarch, int have_nonsteppable_watchpoint)
void set_gdbarch_gnu_triplet_regexp(struct gdbarch *gdbarch, gdbarch_gnu_triplet_regexp_ftype *gnu_triplet_regexp)
void set_gdbarch_print_registers_info(struct gdbarch *gdbarch, gdbarch_print_registers_info_ftype *print_registers_info)
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_stap_register_indirection_prefixes(struct gdbarch *gdbarch, const char *const *stap_register_indirection_prefixes)
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)
int gdbarch_sp_regnum(struct gdbarch *gdbarch)
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)
int gdbarch_num_pseudo_regs(struct gdbarch *gdbarch)
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype *register_type)
void set_gdbarch_gcc_target_options(struct gdbarch *gdbarch, gdbarch_gcc_target_options_ftype *gcc_target_options)
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)
int gdbarch_register_reggroup_p(struct gdbarch *gdbarch, int regnum, const struct reggroup *reggroup)
void set_gdbarch_type_align(struct gdbarch *gdbarch, gdbarch_type_align_ftype *type_align)
void set_gdbarch_cannot_store_register(struct gdbarch *gdbarch, gdbarch_cannot_store_register_ftype *cannot_store_register)
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_stap_register_indirection_suffixes(struct gdbarch *gdbarch, const char *const *stap_register_indirection_suffixes)
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
static int gdbarch_num_cooked_regs(gdbarch *arch)
function_call_return_method
enum bfd_endian type_byte_order(const struct type *type)
int is_integral_type(struct type *t)
struct type * arch_composite_type(struct gdbarch *gdbarch, const char *name, enum type_code code)
const struct floatformat * floatformats_ieee_quad[BFD_ENDIAN_UNKNOWN]
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
unsigned type_align(struct type *type)
void append_composite_type_field(struct type *t, const char *name, struct type *field)
bool is_fixed_point_type(struct type *type)
struct type * check_typedef(struct type *type)
#define TYPE_SAFE_NAME(type)
#define TYPE_HAS_DYNAMIC_LENGTH(t)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
static CORE_ADDR fetch_instruction(CORE_ADDR addr, ia64_instruction_type *it, long long *instr)
const struct language_defn * current_language
void gdbarch_init_osabi(struct gdbarch_info info, struct gdbarch *gdbarch)
pv_t pv_constant(CORE_ADDR k)
pv_t pv_register(int reg, CORE_ADDR k)
pv_t pv_add(pv_t a, pv_t b)
pv_t pv_add_constant(pv_t v, CORE_ADDR k)
int pv_is_register(pv_t a, int r)
CORE_ADDR regcache_read_pc(struct regcache *regcache)
int register_size(struct gdbarch *gdbarch, int regnum)
enum register_status regcache_cooked_read_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
int default_register_reggroup_p(struct gdbarch *gdbarch, int regnum, const struct reggroup *group)
const reggroup * reggroup_new(const char *name, enum reggroup_type type)
const reggroup *const system_reggroup
const reggroup *const float_reggroup
const reggroup *const save_reggroup
const reggroup *const all_reggroup
void reggroup_add(struct gdbarch *gdbarch, const reggroup *group)
const reggroup *const restore_reggroup
const reggroup *const vector_reggroup
void register_riscv_ravenscar_ops(struct gdbarch *gdbarch)
static int riscv_pseudo_register_reggroup_p(struct gdbarch *gdbarch, int regnum, const struct reggroup *reggroup)
static struct cmd_list_element * setriscvcmdlist
static ULONGEST riscv_type_align(gdbarch *gdbarch, type *type)
static void riscv_assign_stack_location(struct riscv_arg_info::location *loc, struct riscv_memory_offsets *memory, int length, int align)
static void riscv_init_reggroups()
bool riscv_abi_embedded(struct gdbarch *gdbarch)
static const struct target_desc * riscv_find_default_target_description(const struct gdbarch_info info)
static void riscv_call_arg_scalar_int(struct riscv_arg_info *ainfo, struct riscv_call_info *cinfo)
static bool riscv_is_regnum_a_named_csr(int regnum)
static bool previous_insn_is_load_fp_from_stack(struct gdbarch *gdbarch, CORE_ADDR pc)
static enum auto_boolean use_compressed_breakpoints
static void riscv_regcache_cooked_write(int regnum, const gdb_byte *data, int len, struct regcache *regcache, int flen)
#define riscv_breakpoints_debug_printf(fmt,...)
int riscv_abi_flen(struct gdbarch *gdbarch)
static bool riscv_debug_infcall
static const char * riscv_feature_name_virtual
static CORE_ADDR riscv_scan_prologue(struct gdbarch *gdbarch, CORE_ADDR start_pc, CORE_ADDR end_pc, struct riscv_unwind_cache *cache)
static CORE_ADDR riscv_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
static struct gdbarch * riscv_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
static void riscv_print_arg_location(ui_file *stream, struct gdbarch *gdbarch, struct riscv_arg_info *info, CORE_ADDR sp_refs, CORE_ADDR sp_args)
static void riscv_call_arg_complex_float(struct riscv_arg_info *ainfo, struct riscv_call_info *cinfo)
static struct cmd_list_element * showriscvcmdlist
static CORE_ADDR riscv_frame_align(struct gdbarch *gdbarch, CORE_ADDR addr)
static const char *const stap_register_indirection_prefixes[]
static bool riscv_is_unknown_csr(struct gdbarch *gdbarch, int regnum)
#define riscv_infcall_debug_printf(fmt,...)
static bool riscv_assign_reg_location(struct riscv_arg_info::location *loc, struct riscv_arg_reg *reg, int length, int offset)
static const char *const stap_register_indirection_suffixes[]
static bool riscv_is_fp_regno_p(int regno)
static int riscv_arg_regs_available(struct riscv_arg_reg *reg)
void riscv_supply_regset(const struct regset *regset, struct regcache *regcache, int regnum, const void *regs, size_t len)
static void riscv_print_one_register_info(struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, int regnum)
static const char * riscv_feature_name_fpu
static bool is_insn_load_of_fp_from_sp(const struct riscv_insn &insn)
static void riscv_pseudo_register_write(struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buf)
static int riscv_register_reggroup_p(struct gdbarch *gdbarch, int regnum, const struct reggroup *reggroup)
int riscv_abi_xlen(struct gdbarch *gdbarch)
static enum register_status riscv_pseudo_register_read(struct gdbarch *gdbarch, readable_regcache *regcache, int regnum, gdb_byte *buf)
static int riscv_breakpoint_kind_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr)
static struct cmd_list_element * setdebugriscvcmdlist
static const gdb_byte * riscv_sw_breakpoint_from_kind(struct gdbarch *gdbarch, int kind, int *size)
static void show_use_compressed_breakpoints(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
int riscv_isa_xlen(struct gdbarch *gdbarch)
static bool riscv_has_fp_abi(struct gdbarch *gdbarch)
#define RISCV_INFCALL_SCOPED_DEBUG_START_END(fmt,...)
static bool riscv_has_fp_regs(struct gdbarch *gdbarch)
static void riscv_print_registers_info(struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, int regnum, int print_all)
static bool riscv_debug_gdbarch
#define BIGGEST_ALIGNMENT
static char * riscv_disassembler_options
static bool riscv_detect_end_of_function(struct gdbarch *gdbarch, CORE_ADDR pc, int *offset)
static const char * riscv_gnu_triplet_regexp(struct gdbarch *gdbarch)
static const char * riscv_feature_name_vector
const char * riscv_feature_name_csr
static bool is_insn_addi_of_sp_to_sp(const struct riscv_insn &insn)
static struct type * riscv_pseudo_register_type(struct gdbarch *gdbarch, int regnum)
#define riscv_gdbarch_debug_printf(fmt,...)
static struct value * riscv_frame_prev_register(frame_info_ptr this_frame, void **prologue_cache, int regnum)
int riscv_isa_flen(struct gdbarch *gdbarch)
static const struct frame_unwind riscv_frame_unwind
static void show_riscv_debug_variable(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void riscv_add_reggroups(struct gdbarch *gdbarch)
static int riscv_cannot_store_register(struct gdbarch *gdbarch, int regnum)
static struct type * riscv_fpreg_d_type(struct gdbarch *gdbarch)
static const reggroup * csr_reggroup
static bool riscv_debug_breakpoints
static int riscv_dwarf_reg_to_regnum(struct gdbarch *gdbarch, int reg)
static struct riscv_gdbarch_features riscv_features_from_bfd(const bfd *abfd)
static void riscv_call_arg_struct(struct riscv_arg_info *ainfo, struct riscv_call_info *cinfo)
void _initialize_riscv_tdep()
static enum return_value_convention riscv_return_value(struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, struct value **read_value, const gdb_byte *writebuf)
static CORE_ADDR riscv_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 riscv_arg_location(struct gdbarch *gdbarch, struct riscv_arg_info *ainfo, struct riscv_call_info *cinfo, struct type *type, bool is_unnamed)
static const char * riscv_pseudo_register_name(struct gdbarch *gdbarch, int regnum)
static std::string riscv_gcc_target_options(struct gdbarch *gdbarch)
static struct type * riscv_register_type(struct gdbarch *gdbarch, int regnum)
std::vector< CORE_ADDR > riscv_software_single_step(struct regcache *regcache)
static const char * riscv_register_name(struct gdbarch *gdbarch, int regnum)
static void riscv_call_arg_scalar_float(struct riscv_arg_info *ainfo, struct riscv_call_info *cinfo)
static int riscv_tdesc_unknown_reg(struct gdbarch *gdbarch, tdesc_feature *feature, const char *reg_name, int possible_regnum)
static bool previous_insn_is_add_imm_to_sp(struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR *prev_pc)
static bool riscv_next_pc_atomic_sequence(struct regcache *regcache, CORE_ADDR pc, CORE_ADDR *next_pc)
static void riscv_frame_this_id(frame_info_ptr this_frame, void **prologue_cache, struct frame_id *this_id)
static struct riscv_unwind_cache * riscv_frame_cache(frame_info_ptr this_frame, void **this_cache)
#define riscv_unwinder_debug_printf(fmt,...)
static CORE_ADDR riscv_push_dummy_code(struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache)
static struct value * value_of_riscv_user_reg(frame_info_ptr frame, const void *baton)
static int riscv_stap_is_single_operand(struct gdbarch *gdbarch, const char *s)
static CORE_ADDR riscv_next_pc(struct regcache *regcache, CORE_ADDR pc)
static struct cmd_list_element * showdebugriscvcmdlist
static bool riscv_debug_unwinder
static const char * riscv_feature_name_cpu
const target_desc * riscv_lookup_target_description(const struct riscv_gdbarch_features features)
struct type * builtin_long_long
struct type * builtin_func_ptr
struct type * builtin_long
struct type * builtin_data_ptr
struct type * builtin_int32
LONGEST loc_bitpos() const
field_loc_kind loc_kind() const
struct type * type() const
void read(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order, bool unsigned_p)
void write(gdb::array_view< gdb_byte > buf, enum bfd_endian byte_order, bool unsigned_p) const
enum riscv_arg_info::location::location_type loc_type
union riscv_arg_info::location::@166 loc_data
struct riscv_arg_info::location argloc[2]
const gdb_byte * contents
riscv_arg_reg(int first, int last)
struct riscv_memory_offsets memory
struct riscv_arg_reg float_regs
struct riscv_arg_reg int_regs
riscv_call_info(struct gdbarch *gdbarch)
void riscv_create_csr_aliases()
bool check(const struct target_desc *tdesc, struct tdesc_arch_data *tdesc_data, std::vector< riscv_pending_register_alias > *aliases, struct riscv_gdbarch_features *features) const
const char * register_name(int regnum) const
bool check(const struct target_desc *tdesc, struct tdesc_arch_data *tdesc_data, std::vector< riscv_pending_register_alias > *aliases, struct riscv_gdbarch_features *features) const
struct type * riscv_fpreg_d_type
int duplicate_fcsr_regnum
int unknown_csrs_first_regnum
int duplicate_fflags_regnum
CORE_ADDR(* syscall_next_pc)(frame_info_ptr frame)
struct riscv_gdbarch_features abi_features
struct riscv_gdbarch_features isa_features
std::vector< const char * > names
bool check(struct tdesc_arch_data *tdesc_data, const struct tdesc_feature *feature, bool prefer_first_name_p, std::vector< riscv_pending_register_alias > *aliases) const
std::vector< struct register_info > m_registers
const char * name() const
riscv_register_feature()=delete
riscv_register_feature(const char *feature_name)
const char * m_feature_name
const struct tdesc_feature * tdesc_feature(const struct target_desc *tdesc) const
DISABLE_COPY_AND_ASSIGN(riscv_register_feature)
trad_frame_saved_reg * regs
bool check(const struct target_desc *tdesc, struct tdesc_arch_data *tdesc_data, std::vector< riscv_pending_register_alias > *aliases, struct riscv_gdbarch_features *features) const
const char * register_name(int regnum) const
bool check(const struct target_desc *tdesc, struct tdesc_arch_data *tdesc_data, std::vector< riscv_pending_register_alias > *aliases, struct riscv_gdbarch_features *features) const
bool check(const struct target_desc *tdesc, struct tdesc_arch_data *tdesc_data, std::vector< riscv_pending_register_alias > *aliases, struct riscv_gdbarch_features *features) const
const char * register_name(int regnum) const
void set_addr(LONGEST addr)
void set_value(LONGEST val)
struct type * target_type() const
struct field & field(int idx) const
unsigned int num_fields() const
void set_name(const char *name)
void set_is_vector(bool is_vector)
const char * name() const
static struct value * allocate(struct type *type)
gdb::array_view< const gdb_byte > contents()
bool entirely_available()
gdb::array_view< gdb_byte > contents_raw()
struct type * type() const
gdb::array_view< const gdb_byte > contents_for_printing()
CORE_ADDR skip_prologue_using_sal(struct gdbarch *gdbarch, CORE_ADDR func_addr)
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)
void set_tdesc_pseudo_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype *pseudo_name)
int tdesc_has_registers(const struct target_desc *target_desc)
const char * tdesc_feature_name(const struct tdesc_feature *feature)
void set_tdesc_pseudo_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype *pseudo_type)
struct type * tdesc_register_type(struct gdbarch *gdbarch, int regno)
int tdesc_register_bitsize(const struct tdesc_feature *feature, const char *name)
const char * tdesc_register_name(struct gdbarch *gdbarch, int regno)
int tdesc_unnumbered_register(const struct tdesc_feature *feature, const char *name)
bool tdesc_found_register(struct tdesc_arch_data *data, int regno)
int tdesc_register_in_reggroup_p(struct gdbarch *gdbarch, int regno, const struct reggroup *reggroup)
void set_tdesc_pseudo_register_reggroup_p(struct gdbarch *gdbarch, gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p)
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)
int target_write_memory(CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
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)
void user_reg_add(struct gdbarch *gdbarch, const char *name, user_reg_read_ftype *xread, const void *baton)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void print_spaces(int n, struct ui_file *stream)
void gdb_printf(struct ui_file *stream, const char *format,...)
void gdb_puts(const char *linebuffer, struct ui_file *stream)
struct value * value_at_non_lval(struct type *type, CORE_ADDR addr)
struct value * value_cast(struct type *type, struct value *arg2)
void get_formatted_print_options(struct value_print_options *opts, char format)
void get_user_print_options(struct value_print_options *opts)
void print_hex_chars(struct ui_file *stream, const gdb_byte *valaddr, unsigned len, enum bfd_endian byte_order, bool zero_pad)
void common_val_print(struct value *value, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
struct value * value_from_contents(struct type *type, const gdb_byte *contents)
LONGEST value_as_long(struct value *val)