104 struct type *from,
struct type *to);
121 struct type *result_type);
127 enum agent_op op_unsigned,
int may_carry,
130 struct type *result_type);
135 struct type *
type,
int start,
int end);
146 const char *operator_name,
147 const char *operand_name);
154 struct type *size_type);
183 static struct value *
206 static struct value *
217 LONGEST k = (*pc)[2].longconst;
249 static struct value *
324 if (
value.optimized_out)
349 for (i = 0; i < nbases; i++)
363 int string_trace = 0;
512 _(
"gen_fetch: strange size"));
522 error (
_(
"gen_fetch: Unsupported type code `%s'."),
539 else if (distance < 0)
559 ax->
scope, &frame_reg, &frame_offset);
574 ax->
scope, &frame_reg, &frame_offset);
622 value->optimized_out = 0;
645 _(
"gen_var_ref: LOC_CONST_BYTES " 646 "symbols are not supported"));
677 error (
_(
"Cannot compute value of typedef `%s'."),
725 value->optimized_out = 1;
729 error (
_(
"Cannot find value of botched symbol `%s'."),
746 value->optimized_out =
false;
782 error (
_(
"Value not scalar: cannot be an rvalue."));
931 nontrivial = ax->len > 0;
1019 error (
_(
"Invalid type cast: intended type must be scalar."));
1042 error (
_(
"Casts to requested type are not yet implemented."));
1103 struct type *result_type)
1111 First argument of `-' is a pointer, but second argument is neither\n\ 1112 an integer nor a pointer of the same type."));
1123 struct type *result_type)
1129 aop_equal, aop_equal, 0,
"equal");
1137 struct type *result_type)
1143 aop_less_signed, aop_less_unsigned, 0,
"less than");
1158 int may_carry,
const char *
name)
1163 error (
_(
"Invalid combination of types in %s."),
name);
1176 struct type *result_type)
1180 error (
_(
"Invalid type of operand to `!'."));
1191 error (
_(
"Invalid type of operand to `~'."));
1209 _(
"gen_deref: expected a pointer"));
1218 error (
_(
"Attempt to dereference a generic pointer."));
1236 switch (
value->kind)
1239 error (
_(
"Operand of `&' is an rvalue, which has no address."));
1242 error (
_(
"Operand of `&' is in a register, and has no address."));
1257 struct type *
type,
int start,
int end)
1261 = {aop_ref8, aop_ref16, aop_ref32, aop_ref64};
1262 static int num_ops = (
sizeof (ops) /
sizeof (ops[0]));
1311 if ((end - start) > ((1 << num_ops) * 8))
1313 _(
"gen_bitfield_ref: bitfield too wide"));
1319 for (op = num_ops - 1; op >= 0; op--)
1322 int op_size = 8 << op;
1328 if (
offset + op_size <= bound_end)
1331 int last_frag = (
offset + op_size == bound_end);
1398 while (fragment_count-- > 1)
1453 if (strcmp (
field, this_name) == 0)
1462 if (
value->optimized_out)
1463 error (
_(
"static field `%s' has been " 1464 "optimized out, cannot use"),
1473 if (this_name[0] ==
'\0')
1475 _(
"find_field: anonymous unions not supported"));
1481 for (i = 0; i < nbases; i++)
1504 const char *
field,
const char *operator_name,
1505 const char *operand_name)
1523 error (
_(
"The left operand of `%s' is not a %s."),
1524 operator_name, operand_name);
1529 error (
_(
"Structure does not live in memory."));
1535 error (
_(
"Couldn't find member named `%s' in struct/union/class `%s'"),
1541 const struct type *curtype,
char *
name);
1544 const struct type *curtype,
char *
name);
1555 value->optimized_out = 0;
1574 value->optimized_out = 1;
1581 struct type *
type,
char *fieldname)
1589 _(
"non-aggregate type to gen_struct_elt_for_reference"));
1595 if (t_field_name && strcmp (t_field_name, fieldname) == 0)
1600 if (
value->optimized_out)
1601 error (
_(
"static field `%s' has been " 1602 "optimized out, cannot use"),
1607 error (
_(
"pointers to bitfield members not allowed"));
1611 error (
_(
"Cannot reference non-static field \"%s\""), fieldname);
1626 const struct type *curtype,
char *
name)
1631 error (
_(
"No symbol \"%s\" in namespace \"%s\"."),
1645 const struct type *curtype,
char *
name)
1654 if (sym.symbol == NULL)
1659 if (
value->optimized_out)
1660 error (
_(
"`%s' has been optimized out, cannot use"),
1682 _(
"non-aggregate type in gen_aggregate_elt_ref"));
1709 error (
_(
"Left operand of `@' must be an object in memory."));
1717 error (
_(
"Right operand of `@' must be a " 1718 "constant, in agent expressions."));
1720 error (
_(
"Right operand of `@' must be an integer."));
1723 error (
_(
"Right operand of `@' must be positive."));
1746 struct type *size_type)
1753 int start = ax->
len;
1772 struct type *to_type)
1779 if (op == OP_VAR_MSYM_VALUE || op == OP_VAR_VALUE)
1781 if (op == OP_VAR_VALUE)
1785 if (
value->optimized_out)
1786 error (
_(
"`%s' has been optimized out, cannot use"),
1810 struct axs_value value1, value2, value3;
1812 int if1, go1, if2, go2, end;
1839 case BINOP_SUBSCRIPT:
1840 case BINOP_BITWISE_AND:
1841 case BINOP_BITWISE_IOR:
1842 case BINOP_BITWISE_XOR:
1844 case BINOP_NOTEQUAL:
1855 case BINOP_LOGICAL_AND:
1860 if1 =
ax_goto (ax, aop_if_goto);
1865 if2 =
ax_goto (ax, aop_if_goto);
1878 case BINOP_LOGICAL_OR:
1883 if1 =
ax_goto (ax, aop_if_goto);
1886 if2 =
ax_goto (ax, aop_if_goto);
1906 if1 =
ax_goto (ax, aop_if_goto);
1921 if ((*pc)[0].opcode == OP_INTERNALVAR)
1936 error (
_(
"$%s is not a trace state variable, " 1937 "may not assign to it"),
name);
1940 error (
_(
"May only assign to trace state variables"));
1943 case BINOP_ASSIGN_MODIFY:
1945 op2 = (*pc)[0].opcode;
1948 if ((*pc)[0].opcode == OP_INTERNALVAR)
1972 error (
_(
"$%s is not a trace state variable, " 1973 "may not assign to it"),
name);
1976 error (
_(
"May only assign to trace state variables"));
1999 LONGEST k = (*pc)[2].longconst;
2009 if (
value->optimized_out)
2010 error (
_(
"`%s' has been optimized out, cannot use"),
2019 case OP_VAR_MSYM_VALUE:
2030 const char *
name = &(*pc)[2].string;
2037 _(
"Register $%s not available"),
name);
2041 error (
_(
"'%s' is a user-register; " 2042 "GDB cannot yet trace user-register contents."),
2050 case OP_INTERNALVAR:
2068 error (
_(
"$%s is not a trace state variable; GDB agent " 2069 "expressions cannot use convenience variables."),
name);
2089 case UNOP_CAST_TYPE:
2122 case UNOP_MEMVAL_TYPE:
2163 gen_binop (ax,
value, &value1, &value2, aop_sub, aop_sub, 1,
"negation");
2166 case UNOP_LOGICAL_NOT:
2173 case UNOP_COMPLEMENT:
2186 error (
_(
"Argument of unary `*' is not a pointer."));
2205 case STRUCTOP_STRUCT:
2208 int length = (*pc)[1].longconst;
2209 char *
name = &(*pc)[2].string;
2213 if (op == STRUCTOP_STRUCT)
2215 else if (op == STRUCTOP_PTR)
2217 "pointer to a structure or union");
2222 _(
"gen_expr: unhandled struct case"));
2229 const struct block *b;
2242 if (
value->optimized_out)
2243 error (
_(
"`%s' has been optimized out, cannot use"),
2254 char *
name = &(*pc)[3].string;
2259 error (
_(
"There is no field named %s"),
name);
2267 error (
_(
"Attempt to use a type name as an expression."));
2270 error (
_(
"Unsupported operator %s (%d) in expression."),
2305 aop_add, aop_add, 1,
"addition");
2318 aop_sub, aop_sub, 1,
"subtraction");
2322 aop_mul, aop_mul, 1,
"multiplication");
2326 aop_div_signed, aop_div_unsigned, 1,
"division");
2330 aop_rem_signed, aop_rem_unsigned, 1,
"remainder");
2334 aop_lsh, aop_lsh, 1,
"left shift");
2338 aop_rsh_signed, aop_rsh_unsigned, 1,
"right shift");
2340 case BINOP_SUBSCRIPT:
2346 error (
_(
"cannot subscript requested type: " 2347 "cannot call user defined functions"));
2359 error (
_(
"cannot subscript something of type `%s'"),
2362 error (
_(
"cannot subscript requested type"));
2367 error (
_(
"Argument to arithmetic operation " 2368 "not a number or boolean."));
2374 case BINOP_BITWISE_AND:
2376 aop_bit_and, aop_bit_and, 0,
"bitwise and");
2379 case BINOP_BITWISE_IOR:
2381 aop_bit_or, aop_bit_or, 0,
"bitwise or");
2384 case BINOP_BITWISE_XOR:
2386 aop_bit_xor, aop_bit_xor, 0,
"bitwise exclusive-or");
2393 case BINOP_NOTEQUAL:
2422 _(
"gen_expr: op case sets don't match"));
2434 struct symbol *var,
int trace_string)
2440 ax->trace_string = trace_string;
2445 if (
value.optimized_out)
2475 ax->trace_string = trace_string;
2476 value.optimized_out = 0;
2504 value.optimized_out = 0;
2523 ax->trace_string = trace_string;
2543 const char *format,
int fmtlen,
2556 for (tem = nargs - 1; tem >= 0; --tem)
2558 pc = exprs[tem]->
elts;
2559 value.optimized_out = 0;
2583 int trace_string = 0;
2594 if (!eval && strcmp (arg,
"$_ret") == 0)
2629 error (
_(
"GDB can't do agent expression translation with overlays."));
2643 (
struct symtab *) NULL, 0, &canonical,
2651 for (
const auto &lsal : canonical.
lsals)
2652 for (
const auto &sal : lsal.sals)
2684 const char *format_start, *format_end;
2691 error (
_(
"GDB can't do agent expression translation with overlays."));
2698 if (*cmdrest++ !=
'"')
2699 error (
_(
"Must start with a format string."));
2701 format_start = cmdrest;
2705 format_end = cmdrest;
2707 if (*cmdrest++ !=
'"')
2708 error (
_(
"Bad format string, non-terminated '\"'."));
2712 if (*cmdrest !=
',' && *cmdrest != 0)
2713 error (
_(
"Invalid argument syntax"));
2715 if (*cmdrest ==
',')
2719 std::vector<struct expression *> argvec;
2720 while (*cmdrest !=
'\0')
2726 argvec.push_back (expr.release ());
2728 if (*cmdrest ==
',')
2736 format_start, format_end - format_start,
2737 argvec.size (), argvec.
data ());
2754 Translate an expression into remote agent bytecode for tracing.\n\ 2755 Usage: maint agent [-at location,] EXPRESSION\n\ 2756 If -at is given, generate remote agent bytecode for this location.\n\ 2757 If not, generate remote agent bytecode for current frame pc address."),
2762 Translate an expression into remote agent bytecode for evaluation.\n\ 2763 Usage: maint agent-eval [-at location,] EXPRESSION\n\ 2764 If -at is given, generate remote agent bytecode for this location.\n\ 2765 If not, generate remote agent bytecode for current frame pc address."),
2769 _(
"Translate an expression into remote " 2770 "agent bytecode for evaluation and display the bytecodes."),
void error_no_arg(const char *why)
static void agent_command_1(const char *exp, int eval)
#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n)
static void gen_logical_not(struct agent_expr *ax, struct axs_value *value, struct type *result_type)
union exp_element elts[1]
static void gen_conversion(struct agent_expr *ax, struct type *from, struct type *to)
struct type * lookup_array_range_type(struct type *element_type, LONGEST low_bound, LONGEST high_bound)
int ax_goto(struct agent_expr *x, enum agent_op op)
const char * op_name(struct expression *exp, enum exp_opcode opcode)
static void gen_extend(struct agent_expr *, struct type *)
static void gen_var_ref(struct agent_expr *ax, struct axs_value *value, struct symbol *var)
CORE_ADDR get_frame_pc(struct frame_info *frame)
#define SYMBOL_PRINT_NAME(symbol)
std::unique_ptr< agent_expr > agent_expr_up
struct frame_info * get_current_frame(void)
void ax_reqs(struct agent_expr *ax)
#define TYPE_FIELD_NAME(thistype, n)
static void gen_ptradd(struct agent_expr *ax, struct axs_value *value, struct axs_value *value1, struct axs_value *value2)
struct type * builtin_unsigned_int
#define TYPE_N_BASECLASSES(thistype)
gdb::unique_xmalloc_ptr< expression > expression_up
void ax_reg_mask(struct agent_expr *ax, int reg)
int pointer_type(struct type *type)
LONGEST value_as_long(struct value *val)
static void gen_less(struct agent_expr *ax, struct axs_value *value, struct axs_value *value1, struct axs_value *value2, struct type *result_type)
#define BMSYMBOL_VALUE_ADDRESS(symbol)
const char * decode_agent_options(const char *exp, int *trace_string)
#define TYPE_NAME(thistype)
int compile_internalvar_to_ax(struct internalvar *var, struct agent_expr *expr, struct axs_value *value)
event_location_up new_linespec_location(const char **linespec, symbol_name_match_type match_type)
static void gen_frame_args_address(struct agent_expr *)
struct block_symbol cp_lookup_symbol_namespace(const char *scope, const char *name, const struct block *block, const domain_enum domain)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
static int gen_namespace_elt(struct agent_expr *ax, struct axs_value *value, const struct type *curtype, char *name)
#define SYMBOL_CLASS(symbol)
void internal_error(const char *file, int line, const char *fmt,...)
static int gen_maybe_namespace_elt(struct agent_expr *ax, struct axs_value *value, const struct type *curtype, char *name)
int binop_types_user_defined_p(enum exp_opcode op, struct type *type1, struct type *type2)
static void gen_offset(struct agent_expr *ax, int offset)
const struct language_defn * language_def(enum language lang)
static void agent_eval_command_one(const char *exp, int eval, CORE_ADDR pc)
static void gen_sym_offset(struct agent_expr *, struct symbol *)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
struct symbol * block_linkage_function(const struct block *bl)
expression_up parse_exp_1(const char **, CORE_ADDR pc, const struct block *, int)
struct block_symbol lookup_symbol(const char *name, const struct block *block, domain_enum domain, struct field_of_this_result *is_a_field_of_this)
void ax_reg(struct agent_expr *x, int reg)
int gdbarch_num_regs(struct gdbarch *gdbarch)
char * skip_spaces(char *chp)
static void gen_fetch(struct agent_expr *, struct type *)
event_location_up location
#define TYPE_FIELD(thistype, n)
agent_expr_up gen_printf(CORE_ADDR scope, struct gdbarch *gdbarch, CORE_ADDR function, LONGEST channel, const char *format, int fmtlen, int nargs, struct expression **exprs)
#define bits(obj, st, fn)
static void gen_primitive_field(struct agent_expr *ax, struct axs_value *value, int offset, int fieldno, struct type *type)
#define BYTES_TO_EXP_ELEM(bytes)
#define TYPE_FIELD_TYPE(thistype, n)
void error_unknown_type(const char *sym_print_name)
const struct block * block_for_pc(CORE_ADDR pc)
void ax_tsv(struct agent_expr *x, enum agent_op op, int num)
const char * la_name_of_this
int longest_to_int(LONGEST)
static struct value * maybe_const_expr(union exp_element **pc)
static void gen_ptrsub(struct agent_expr *ax, struct axs_value *value, struct axs_value *value1, struct axs_value *value2)
int gdbarch_num_pseudo_regs(struct gdbarch *gdbarch)
#define MSYMBOL_PRINT_NAME(symbol)
static int gen_struct_ref_recursive(struct agent_expr *ax, struct axs_value *value, const char *field, int offset, struct type *type)
static void gen_trace_static_fields(struct agent_expr *ax, struct type *type)
struct type * check_typedef(struct type *type)
#define SYMBOL_VALUE_ADDRESS(symbol)
type * find_minsym_type_and_address(minimal_symbol *msymbol, objfile *objf, CORE_ADDR *address_p)
static int is_nontrivial_conversion(struct type *from, struct type *to)
static void gen_equal(struct agent_expr *ax, struct axs_value *value, struct axs_value *value1, struct axs_value *value2, struct type *result_type)
static struct type * max_type(struct type *type1, struct type *type2)
static void agent_command(const char *exp, int from_tty)
static void gen_expr_for_cast(struct expression *exp, union exp_element **pc, struct agent_expr *ax, struct axs_value *value, struct type *to_type)
int field_is_static(struct field *f)
struct value::@186::@187 reg
static void gen_address_of(struct axs_value *)
void gdbarch_gen_return_address(struct gdbarch *gdbarch, struct agent_expr *ax, struct axs_value *value, CORE_ADDR scope)
struct type * register_type(struct gdbarch *gdbarch, int regnum)
#define gdb_assert_not_reached(message)
int is_integral_type(struct type *t)
static void gen_static_field(struct agent_expr *ax, struct axs_value *value, struct type *type, int fieldno)
#define SYMBOL_REGISTER_OPS(symbol)
#define SYMBOL_COMPUTED_OPS(symbol)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
static int gen_aggregate_elt_ref(struct agent_expr *ax, struct axs_value *value, struct type *type, char *field)
char * internalvar_name(const struct internalvar *var)
void ax_ext(struct agent_expr *x, int n)
static void gen_scale(struct agent_expr *ax, enum agent_op op, struct type *type)
void ax_string(struct agent_expr *x, const char *str, int slen)
void ax_label(struct agent_expr *x, int patch, int target)
static struct value * const_var_ref(struct symbol *var)
struct gdbarch * get_current_arch(void)
static void gen_deref(struct axs_value *)
static int gen_struct_elt_for_reference(struct agent_expr *ax, struct axs_value *value, struct type *type, char *fieldname)
struct value * value_from_longest(struct type *type, LONGEST num)
#define SYMBOL_LINKAGE_NAME(symbol)
void ax_simple(struct agent_expr *x, enum agent_op op)
void decode_line_full(const struct event_location *location, int flags, struct program_space *search_pspace, struct symtab *default_symtab, int default_line, struct linespec_result *canonical, const char *select_mode, const char *filter)
struct type * builtin_long
std::unique_ptr< event_location, event_location_deleter > event_location_up
static void gen_integral_promotions(struct agent_expr *ax, struct axs_value *value)
static void gen_left_shift(struct agent_expr *, int)
#define TYPE_BASECLASS(thistype, index)
#define TYPE_FIELD_PACKED(thistype, n)
static struct value * const_expr(union exp_element **pc)
std::vector< linespec_sals > lsals
int user_reg_map_name_to_regnum(struct gdbarch *gdbarch, const char *name, int len)
static const char * namespace_name(struct die_info *die, int *is_anonymous, struct dwarf2_cu *)
agent_expr_up gen_trace_for_expr(CORE_ADDR scope, struct expression *expr, int trace_string)
#define TYPE_FIELD_BITSIZE(thistype, n)
#define TYPE_FIELD_BITPOS(thistype, n)
void gen_expr(struct expression *exp, union exp_element **pc, struct agent_expr *ax, struct axs_value *value)
#define SYMBOL_VALUE(symbol)
agent_expr_up gen_trace_for_return_address(CORE_ADDR scope, struct gdbarch *gdbarch, int trace_string)
static void gen_binop(struct agent_expr *ax, struct axs_value *value, struct axs_value *value1, struct axs_value *value2, enum agent_op op, enum agent_op op_unsigned, int may_carry, const char *name)
static void gen_complement(struct agent_expr *ax, struct axs_value *value)
void ax_print(struct ui_file *f, struct agent_expr *x)
static void gen_msym_var_ref(agent_expr *ax, axs_value *value, minimal_symbol *msymbol, objfile *objf)
static void gen_sign_extend(struct agent_expr *, struct type *)
struct value * value_from_pointer(struct type *type, CORE_ADDR addr)
#define TYPE_TARGET_TYPE(thistype)
struct value * value_neg(struct value *arg1)
static void gen_usual_arithmetic(struct agent_expr *ax, struct axs_value *value1, struct axs_value *value2)
static void gen_cast(struct agent_expr *ax, struct axs_value *value, struct type *type)
agent_expr_up gen_trace_for_var(CORE_ADDR scope, struct gdbarch *gdbarch, struct symbol *var, int trace_string)
#define SYMBOL_BLOCK_VALUE(symbol)
#define TYPE_CODE(thistype)
void _initialize_ax_gdb(void)
struct type * builtin_data_ptr
struct minimal_symbol * minsym
#define TYPE_NFIELDS(thistype)
struct value * evaluate_subexp(struct type *expect_type, struct expression *exp, int *pos, enum noside noside)
#define SYMBOL_LANGUAGE(symbol)
void require_rvalue(struct agent_expr *ax, struct axs_value *value)
static void gen_int_literal(struct agent_expr *ax, struct axs_value *value, LONGEST k, struct type *type)
static int type_wider_than(struct type *type1, struct type *type2)
int c_textual_element_type(struct type *, char)
static void gen_traced_pop(struct agent_expr *, struct axs_value *)
static void gen_struct_ref(struct agent_expr *ax, struct axs_value *value, const char *field, const char *operator_name, const char *operand_name)
#define TYPE_TAG_NAME(type)
struct block_symbol lookup_language_this(const struct language_defn *lang, const struct block *block)
void ax_trace_quick(struct agent_expr *x, int n)
void ax_const_l(struct agent_expr *x, LONGEST l)
enum overlay_debugging_state overlay_debugging
static void gen_ptrdiff(struct agent_expr *ax, struct axs_value *value, struct axs_value *value1, struct axs_value *value2, struct type *result_type)
static void gen_frame_locals_address(struct agent_expr *)
struct type * builtin_long_long
static void gen_sizeof(struct expression *exp, union exp_element **pc, struct agent_expr *ax, struct axs_value *value, struct type *size_type)
static void gen_bitfield_ref(struct agent_expr *ax, struct axs_value *value, struct type *type, int start, int end)
struct trace_state_variable * find_trace_state_variable(const char *name)
struct type * value_type(const struct value *value)
#define SYMBOL_TYPE(symbol)
static void maint_agent_printf_command(const char *cmdrest, int from_tty)
struct cmd_list_element * maintenancelist
agent_expr_up gen_eval_for_expr(CORE_ADDR scope, struct expression *expr)
#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n)
void ax_zero_ext(struct agent_expr *x, int n)
static void agent_eval_command(const char *exp, int from_tty)
#define TYPE_LENGTH(thistype)
#define TYPE_BASECLASS_BITPOS(thistype, index)
#define TYPE_FIELD_LOC_KIND(thistype, n)
static void gen_repeat(struct expression *exp, union exp_element **pc, struct agent_expr *ax, struct axs_value *value)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
enum axs_lvalue_kind kind
void gdbarch_virtual_frame_pointer(struct gdbarch *gdbarch, CORE_ADDR pc, int *frame_regnum, LONGEST *frame_offset)
static void gen_expr_binop_rest(struct expression *exp, enum exp_opcode op, union exp_element **pc, struct agent_expr *ax, struct axs_value *value, struct axs_value *value1, struct axs_value *value2)
void error(const char *fmt,...)
void ax_raw_byte(struct agent_expr *x, gdb_byte byte)
int check_for_argument(const char **str, const char *arg, int arg_len)
struct type * lookup_pointer_type(struct type *type)
static void gen_usual_unary(struct agent_expr *ax, struct axs_value *value)
struct type * builtin_int