76 error (
_(
"Unsupported address size in DWARF expressions: %d bits"),
83 0,
"<signed DWARF address type>");
96 max_recursion_depth (0x100),
126 error (
_(
"dwarf expression stack underflow"));
136 if (
stack.size () <= n)
137 error (
_(
"Asked for position %d of stack, " 138 "stack only has %zu elements on it."),
151 error (
_(
"integral type expected in DWARF expression"));
171 error (
_(
"no unsigned variant found for type, while evaluating " 172 "DWARF expression"));
193 error (
_(
"no signed variant found for type, while evaluating " 194 "DWARF expression"));
236 if (
stack.size () <= n)
237 error (
_(
"Asked for position %d of stack, " 238 "stack only has %zu elements on it."),
240 return stack[
stack.size () - (1 + n)].in_stack_memory;
248 return stack.empty ();
255 this->
pieces.emplace_back ();
283 p.
v.
ptr.die_sect_off = (sect_offset) this->
len;
316 error (
_(
"DWARF expression error: ran off end of buffer reading uleb128 value"));
328 error (
_(
"DWARF expression error: ran off end of buffer reading sleb128 value"));
337 error (
_(
"DWARF expression error: ran off end of buffer reading leb128 value"));
350 if (op_ptr != op_end && *op_ptr != DW_OP_piece && *op_ptr != DW_OP_bit_piece
351 && *op_ptr != DW_OP_GNU_uninit)
352 error (
_(
"DWARF-2 expression error: `%s' operations must be " 353 "used either alone or in conjunction with DW_OP_piece " 354 "or DW_OP_bit_piece."),
382 if (*buf >= DW_OP_reg0 && *buf <= DW_OP_reg31)
384 if (buf_end - buf != 1)
386 return *buf - DW_OP_reg0;
389 if (*buf == DW_OP_regval_type || *buf == DW_OP_GNU_regval_type)
399 else if (*buf == DW_OP_regx)
408 if (buf != buf_end || (
int) dwarf_reg != dwarf_reg)
428 if (*buf >= DW_OP_breg0 && *buf <= DW_OP_breg31)
430 dwarf_reg = *buf - DW_OP_breg0;
435 else if (*buf == DW_OP_bregx)
441 if ((
int) dwarf_reg != dwarf_reg)
453 if (*buf == DW_OP_deref)
456 *deref_size_return = -1;
458 else if (*buf == DW_OP_deref_size)
463 *deref_size_return = *buf++;
486 if (*buf != DW_OP_fbreg)
493 *fb_offset_return = fb_offset;
494 if (buf != buf_end || fb_offset != (
LONGEST) *fb_offset_return)
513 if (*buf >= DW_OP_breg0 && *buf <= DW_OP_breg31)
515 dwarf_reg = *buf - DW_OP_breg0;
520 if (*buf != DW_OP_bregx)
535 *sp_offset_return = sp_offset;
536 if (buf != buf_end || sp_offset != (
LONGEST) *sp_offset_return)
563 error (
_(
"DWARF-2 expression error: Loop detected (%d)."),
567 while (op_ptr < op_end)
569 enum dwarf_location_atom op = (
enum dwarf_location_atom) *op_ptr++;
577 bool in_stack_memory =
false;
578 uint64_t uoffset,
reg;
580 struct value *result_val = NULL;
620 result = op - DW_OP_lit0;
632 if (op_ptr >= op_end || *op_ptr != DW_OP_GNU_push_tls_address)
637 case DW_OP_GNU_addr_index:
643 case DW_OP_GNU_const_index:
736 result = op - DW_OP_reg0;
750 case DW_OP_implicit_value:
755 if (op_ptr +
len > op_end)
756 error (
_(
"DW_OP_implicit_value: too few bytes available."));
762 "DW_OP_implicit_value");
766 case DW_OP_stack_value:
771 case DW_OP_implicit_pointer:
772 case DW_OP_GNU_implicit_pointer:
777 error (
_(
"DWARF-2 expression error: DW_OP_implicit_pointer " 778 "is not allowed in frame context"));
792 "DW_OP_implicit_pointer");
855 std::vector<dwarf_stack_value> saved_stack = std::move (
stack);
862 eval (datastart, datalen);
868 error (
_(
"Not implemented: computing frame " 869 "base using explicit value operator"));
872 in_stack_memory =
true;
875 stack = std::move (saved_stack);
882 result_val =
fetch (0);
898 if (
stack.size () < 2)
899 error (
_(
"Not enough elements for " 900 "DW_OP_swap. Need 2, have %zu."),
910 result_val =
fetch (1);
916 if (
stack.size () < 3)
917 error (
_(
"Not enough elements for " 918 "DW_OP_rot. Need 3, have %zu."),
929 case DW_OP_deref_size:
930 case DW_OP_deref_type:
931 case DW_OP_GNU_deref_type:
940 if (op == DW_OP_deref_type || op == DW_OP_GNU_deref_type)
943 cu_offset type_die_cu_off = (cu_offset) uoffset;
970 case DW_OP_plus_uconst:
973 result_val =
fetch (0);
990 case DW_OP_plus_uconst:
1020 struct value *first, *second;
1029 error (
_(
"Incompatible types on DWARF stack"));
1036 result_val =
value_binop (first, second, BINOP_BITWISE_AND);
1039 result_val =
value_binop (first, second, BINOP_DIV);
1042 result_val =
value_binop (first, second, BINOP_SUB);
1063 result_val =
value_binop (first, second, BINOP_MOD);
1065 result_val =
value_cast (orig_type, result_val);
1069 result_val =
value_binop (first, second, BINOP_MUL);
1074 result_val =
value_binop (first, second, BINOP_BITWISE_IOR);
1077 result_val =
value_binop (first, second, BINOP_ADD);
1082 result_val =
value_binop (first, second, BINOP_LSH);
1095 result_val =
value_binop (first, second, BINOP_RSH);
1112 result_val =
value_binop (first, second, BINOP_RSH);
1121 result_val =
value_binop (first, second, BINOP_BITWISE_XOR);
1152 _(
"Can't be reached."));
1157 case DW_OP_call_frame_cfa:
1160 in_stack_memory =
true;
1163 case DW_OP_GNU_push_tls_address:
1164 case DW_OP_form_tls_address:
1219 case DW_OP_bit_piece:
1237 case DW_OP_GNU_uninit:
1238 if (op_ptr != op_end)
1239 error (
_(
"DWARF-2 expression error: DW_OP_GNU_uninit must always " 1240 "be the very last op."));
1263 case DW_OP_entry_value:
1264 case DW_OP_GNU_entry_value:
1271 if (op_ptr +
len > op_end)
1272 error (
_(
"DW_OP_entry_value: too few bytes available."));
1289 if (deref_size == -1)
1293 kind_u, deref_size);
1297 error (
_(
"DWARF-2 expression error: DW_OP_entry_value is " 1298 "supported only for single DW_OP_reg* " 1299 "or for DW_OP_breg*(0)+DW_OP_deref*"));
1302 case DW_OP_GNU_parameter_ref:
1315 case DW_OP_const_type:
1316 case DW_OP_GNU_const_type:
1323 cu_offset type_die_cu_off = (cu_offset) uoffset;
1334 case DW_OP_regval_type:
1335 case DW_OP_GNU_regval_type:
1341 cu_offset type_die_cu_off = (cu_offset) uoffset;
1349 case DW_OP_GNU_convert:
1350 case DW_OP_reinterpret:
1351 case DW_OP_GNU_reinterpret:
1356 cu_offset type_die_cu_off = (cu_offset) uoffset;
1363 result_val =
fetch (0);
1366 if (op == DW_OP_convert || op == DW_OP_GNU_convert)
1374 error (
_(
"DW_OP_reinterpret has wrong size"));
1382 case DW_OP_push_object_address:
1389 error (
_(
"Unhandled dwarf expression opcode 0x%x"), op);
1394 push (result_val, in_stack_memory);
CORE_ADDR gdbarch_integer_to_address(struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf)
struct value * value_zero(struct type *type, enum lval_type lv)
virtual void read_mem(gdb_byte *buf, CORE_ADDR addr, size_t length)=0
static int base_types_equal_p(struct type *t1, struct type *t2)
const char * op_name(struct expression *exp, enum exp_opcode opcode)
struct value * value_from_contents_and_address(struct type *type, const gdb_byte *valaddr, CORE_ADDR address)
virtual struct value * get_reg_value(struct type *type, int regnum)=0
static struct type * get_signed_type(struct gdbarch *gdbarch, struct type *type)
struct type * dw_types[3]
union dwarf_expr_piece::@38 v
struct value * value_from_contents(struct type *type, const gdb_byte *contents)
LONGEST value_as_long(struct value *val)
void push(struct value *value, bool in_stack_memory)
virtual CORE_ADDR get_tls_address(CORE_ADDR offset)=0
struct value * fetch(int n)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
constexpr std::underlying_type< E >::type to_underlying(E val) noexcept
void internal_error(const char *file, int line, const char *fmt,...)
virtual CORE_ADDR get_object_address()=0
struct type * builtin_uint8
virtual void push_dwarf_reg_entry_value(enum call_site_parameter_kind kind, union call_site_parameter_u kind_u, int deref_size)=0
struct type * builtin_uint16
void dwarf_expr_require_composition(const gdb_byte *op_ptr, const gdb_byte *op_end, const char *op_name)
const gdb_byte * safe_read_uleb128(const gdb_byte *buf, const gdb_byte *buf_end, uint64_t *r)
static const gdb_byte * gdb_skip_leb128(const gdb_byte *buf, const gdb_byte *buf_end)
virtual struct type * get_base_type(cu_offset die_cu_off, int size)
struct dwarf_expr_piece::@38::@39 mem
struct type * builtin_int32
int gdbarch_integer_to_address_p(struct gdbarch *gdbarch)
#define GDBARCH_OBSTACK_ZALLOC(GDBARCH, TYPE)
struct type * arch_integer_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
const gdb_byte * safe_skip_leb128(const gdb_byte *buf, const gdb_byte *buf_end)
void execute_stack_op(const gdb_byte *op_ptr, const gdb_byte *op_end)
const gdb_byte * value_contents(struct value *value)
int gdbarch_sp_regnum(struct gdbarch *gdbarch)
struct value::@186::@187 reg
static struct gdbarch_data * dwarf_arch_cookie
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
void push_address(CORE_ADDR value, bool in_stack_memory)
const gdb_byte * value_contents_all(struct value *value)
struct type * builtin_int16
static void dwarf_require_integral(struct type *type)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
std::vector< dwarf_expr_piece > pieces
void eval(const gdb_byte *addr, size_t len)
static const gdb_byte * gdb_read_uleb128(const gdb_byte *buf, const gdb_byte *buf_end, uint64_t *r)
struct type * builtin_uint32
struct value * value_cast(struct type *type, struct value *arg2)
int dwarf_reg_to_regnum(struct gdbarch *arch, int dwarf_reg)
bool stack_empty_p() const
struct dwarf_expr_piece::@38::@41 ptr
int value_equal(struct value *arg1, struct value *arg2)
enum dwarf_value_location location
const gdb_byte * safe_read_sleb128(const gdb_byte *buf, const gdb_byte *buf_end, int64_t *r)
virtual void dwarf_call(cu_offset die_cu_off)=0
struct dwarf_expr_piece::@38::@40 literal
int dwarf_block_to_dwarf_reg(const gdb_byte *buf, const gdb_byte *buf_end)
static struct type * get_unsigned_type(struct gdbarch *gdbarch, struct type *type)
struct value * value_neg(struct value *arg1)
virtual void get_frame_base(const gdb_byte **start, size_t *length)=0
virtual CORE_ADDR read_addr_from_reg(int regnum)=0
#define TYPE_CODE(thistype)
CORE_ADDR fetch_address(int n)
int value_less(struct value *arg1, struct value *arg2)
struct value * value_complement(struct value *arg1)
void add_piece(ULONGEST size, ULONGEST offset)
static void * dwarf_gdbarch_types_init(struct gdbarch *gdbarch)
static LONGEST extract_signed_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
void _initialize_dwarf2expr(void)
struct value * value_binop(struct value *arg1, struct value *arg2, enum exp_opcode op)
virtual CORE_ADDR get_frame_cfa()=0
enum dwarf_value_location location
unsigned long long ULONGEST
struct type * value_type(const struct value *value)
static const gdb_byte * gdb_read_sleb128(const gdb_byte *buf, const gdb_byte *buf_end, int64_t *r)
struct type * builtin_int64
struct value * value_from_ulongest(struct type *type, ULONGEST num)
#define TYPE_LENGTH(thistype)
int dwarf_block_to_dwarf_reg_deref(const gdb_byte *buf, const gdb_byte *buf_end, CORE_ADDR *deref_size_return)
bool fetch_in_stack_memory(int n)
struct type * builtin_uint64
struct type * address_type() const
struct type * builtin_int8
int dwarf_block_to_sp_offset(struct gdbarch *gdbarch, const gdb_byte *buf, const gdb_byte *buf_end, CORE_ADDR *sp_offset_return)
void error(const char *fmt,...)
struct gdbarch_data * gdbarch_data_register_post_init(gdbarch_data_post_init_ftype *post_init)
int dwarf_block_to_fb_offset(const gdb_byte *buf, const gdb_byte *buf_end, CORE_ADDR *fb_offset_return)
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
virtual CORE_ADDR get_addr_index(unsigned int index)=0
std::vector< dwarf_stack_value > stack