76 enum bfd_endian byte_order,
unsigned int addr_size,
79 const gdb_byte *
const base = op_ptr;
84 stack_depth = info[start].
depth;
86 while (op_ptr < op_end)
88 enum dwarf_location_atom op = *op_ptr;
91 int ndx = op_ptr - base;
93 #define SET_CHECK_DEPTH(WHERE) \
94 if (info[WHERE].visited) \
96 if (info[WHERE].depth != stack_depth) \
97 error (_("inconsistent stack depths")); \
102 info[WHERE].visited = 1; \
103 info[WHERE].depth = stack_depth; \
293 case DW_OP_deref_size:
297 case DW_OP_plus_uconst:
321 case DW_OP_call_frame_cfa:
325 case DW_OP_GNU_push_tls_address:
332 offset = op_ptr + offset - base;
335 if (!info[offset].visited)
345 offset = op_ptr + offset - base;
349 if (!info[offset].visited)
359 error (
_(
"unhandled DWARF op: %s"), get_DW_OP_name (op));
365 #undef SET_CHECK_DEPTH
386 int *need_tempvar,
int *is_tls,
393 VEC (
int) *to_do = NULL;
396 *info = XCNEWVEC (
struct insn_info, op_end - op_ptr);
402 (*info)[0].depth = initial_depth;
403 (*info)[0].visited = 1;
407 int ndx =
VEC_pop (
int, to_do);
410 byte_order, addr_size,
416 for (i = 0; i < op_end - op_ptr; ++i)
418 if ((*info)[i].depth > stack_depth)
419 stack_depth = (*info)[i].depth;
420 if ((*info)[i].is_tls)
426 return stack_depth + 1;
431 #define GCC_UINTPTR "__gdb_uintptr"
432 #define GCC_INTPTR "__gdb_intptr"
440 "__gdb_stack[++__gdb_tos] = (" GCC_UINTPTR ") %s;\n",
447 static void pushf (
int indent,
struct ui_file *stream,
const char *format, ...)
456 va_start (args, format);
467 static void unary (
int indent,
struct ui_file *stream,
const char *format, ...)
476 va_start (args, format);
484 static void binary (
int indent,
struct ui_file *stream,
const char *format, ...)
493 va_start (args, format);
517 unsigned char *registers_used,
523 registers_used[
regnum] = 1;
524 pushf (indent, stream,
538 unsigned char *registers_used,
544 registers_used[
regnum] = 1;
549 pushf (indent, stream,
587 const char *type_name,
588 const char *result_name,
591 unsigned char *registers_used,
592 unsigned int addr_size,
599 static unsigned int scope;
602 const gdb_byte *
const base = op_ptr;
603 int need_tempvar = 0;
612 type_name, result_name);
617 &need_tempvar, &is_tls,
618 op_ptr, op_end, initial != NULL,
635 error (
_(
"Symbol \"%s\" cannot be used because "
636 "there is no selected frame"),
641 error (
_(
"Symbol \"%s\" cannot be used for compilation evaluation "
642 "as its address has not been found."),
645 warning (
_(
"Symbol \"%s\" is thread-local and currently can only "
646 "be referenced from the current thread in "
668 while (op_ptr < op_end)
670 enum dwarf_location_atom op = *op_ptr;
671 uint64_t uoffset,
reg;
675 if (info[op_ptr - base].label)
723 push (indent, stream, op - DW_OP_lit0);
732 if (op_ptr >= op_end || *op_ptr != DW_OP_GNU_push_tls_address)
734 push (indent, stream, uoffset);
738 push (indent, stream,
743 push (indent, stream,
748 push (indent, stream,
753 push (indent, stream,
758 push (indent, stream,
763 push (indent, stream,
768 push (indent, stream,
773 push (indent, stream,
779 push (indent, stream, uoffset);
783 push (indent, stream, offset);
881 const struct block *b;
888 error (
_(
"No block found for address"));
893 error (
_(
"No function found for block"));
896 &datastart, &datalen);
902 xsnprintf (fb_name,
sizeof (fb_name),
"__frame_base_%ld",
903 (
long) (op_ptr - base));
908 arch, registers_used, addr_size,
909 datastart, datastart + datalen,
917 pushf (indent, stream,
"__gdb_stack[__gdb_tos]");
926 pushf (indent, stream,
"__gdb_stack[__gdb_tos - %s]",
932 "__gdb_tmp = __gdb_stack[__gdb_tos - 1];\n");
934 "__gdb_stack[__gdb_tos - 1] = "
935 "__gdb_stack[__gdb_tos];\n");
941 pushf (indent, stream,
"__gdb_stack[__gdb_tos - 1]");
946 "__gdb_stack[__gdb_tos];\n"));
948 "__gdb_stack[__gdb_tos] = "
949 "__gdb_stack[__gdb_tos - 1];\n");
951 "__gdb_stack[__gdb_tos - 1] = "
952 "__gdb_stack[__gdb_tos -2];\n");
958 case DW_OP_deref_size:
963 if (op == DW_OP_deref_size)
970 error (
_(
"Unsupported size %d in %s"),
971 size, get_DW_OP_name (op));
976 "__gdb_stack[__gdb_tos] = "
977 "*((__gdb_int_%s *) "
978 "__gdb_stack[__gdb_tos]);\n",
984 unary (indent, stream,
985 "((" GCC_INTPTR ") __gdb_stack[__gdb_tos]) < 0 ? "
986 "-__gdb_stack[__gdb_tos] : __gdb_stack[__gdb_tos]");
990 unary (indent, stream,
"-__gdb_stack[__gdb_tos]");
994 unary (indent, stream,
"~__gdb_stack[__gdb_tos]");
997 case DW_OP_plus_uconst:
999 unary (indent, stream,
"__gdb_stack[__gdb_tos] + %s",
1005 ") __gdb_stack[__gdb_tos-1]) / (("
1011 "((" GCC_INTPTR
") __gdb_stack[__gdb_tos-1]) >> "
1012 "__gdb_stack[__gdb_tos]");
1015 #define BINARY(OP) \
1016 binary (indent, stream, "%s", "__gdb_stack[__gdb_tos-1] " #OP \
1017 " __gdb_stack[__gdb_tos]"); \
1040 #define COMPARE(OP) \
1041 binary (indent, stream, \
1042 "(((" GCC_INTPTR ") __gdb_stack[__gdb_tos-1]) " #OP \
1044 ") __gdb_stack[__gdb_tos]))"); \
1061 case DW_OP_call_frame_cfa:
1066 const gdb_byte *cfa_start, *cfa_end;
1070 &text_offset, &cfa_start, &cfa_end))
1084 "__cfa_%ld", (
long) (op_ptr - base));
1088 sym, pc, arch, registers_used,
1091 &text_offset, per_cu);
1092 pushf (indent, stream,
"%s", cfa_name);
1102 print_label (stream, scope, op_ptr + offset - base);
1110 "if ((( " GCC_INTPTR
1111 ") __gdb_stack[__gdb_tos--]) != 0) goto ");
1112 print_label (stream, scope, op_ptr + offset - base);
1120 error (
_(
"unhandled DWARF op: %s"), get_DW_OP_name (op));
1136 struct gdbarch *
arch,
unsigned char *registers_used,
1137 unsigned int addr_size,
1142 arch, registers_used, addr_size, op_ptr, op_end,
1150 const char *result_name,
1153 struct gdbarch *
arch,
unsigned char *registers_used,
1154 unsigned int addr_size,
1159 sym, pc, arch, registers_used,
1160 addr_size, op_ptr, op_end, NULL, per_cu);
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
char * hex_string(LONGEST num)
void compile_dwarf_bounds_to_c(struct ui_file *stream, const char *result_name, const struct dynamic_prop *prop, struct symbol *sym, CORE_ADDR pc, struct gdbarch *arch, unsigned char *registers_used, unsigned int addr_size, const gdb_byte *op_ptr, const gdb_byte *op_end, struct dwarf2_per_cu_data *per_cu)
struct frame_info * get_selected_frame(const char *message)
#define SYMBOL_PRINT_NAME(symbol)
int dwarf2_fetch_cfa_info(struct gdbarch *gdbarch, CORE_ADDR pc, struct dwarf2_per_cu_data *data, int *regnum_out, LONGEST *offset_out, CORE_ADDR *text_offset_out, const gdb_byte **cfa_start_out, const gdb_byte **cfa_end_out)
static void pushf_register_address(int indent, struct ui_file *stream, unsigned char *registers_used, struct gdbarch *gdbarch, int regnum)
static void compute_stack_depth_worker(int start, int *need_tempvar, struct insn_info *info, VEC(int)**to_do, enum bfd_endian byte_order, unsigned int addr_size, const gdb_byte *op_ptr, const gdb_byte *op_end)
void warning(const char *fmt,...)
struct type ** const(pascal_builtin_types[])
char * plongest(LONGEST l)
void print_spaces(int n, struct ui_file *file)
struct symbol * block_linkage_function(const struct block *bl)
struct value * read_var_value(struct symbol *var, struct frame_info *frame)
void dwarf_expr_require_composition(const gdb_byte *op_ptr, const gdb_byte *op_end, const char *op_name)
#define VEC_safe_push(T, V, O)
const gdb_byte * safe_read_uleb128(const gdb_byte *buf, const gdb_byte *buf_end, uint64_t *r)
static void print_label(struct ui_file *stream, unsigned int scope, int target)
char * compile_register_name_mangled(struct gdbarch *gdbarch, int regnum)
static void binary(int indent, struct ui_file *stream, const char *format,...) ATTRIBUTE_PRINTF(3
const struct block * block_for_pc(CORE_ADDR pc)
void compile_dwarf_expr_to_c(struct ui_file *stream, const char *result_name, struct symbol *sym, CORE_ADDR pc, struct gdbarch *arch, unsigned char *registers_used, unsigned int addr_size, const gdb_byte *op_ptr, const gdb_byte *op_end, struct dwarf2_per_cu_data *per_cu)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
void vfprintf_filtered(struct ui_file *stream, const char *format, va_list args)
#define COMPILE_I_SIMPLE_REGISTER_ARG_NAME
static void do_compile_dwarf_expr_to_c(int indent, struct ui_file *stream, const char *type_name, const char *result_name, struct symbol *sym, CORE_ADDR pc, struct gdbarch *arch, unsigned char *registers_used, unsigned int addr_size, const gdb_byte *op_ptr, const gdb_byte *op_end, CORE_ADDR *initial, struct dwarf2_per_cu_data *per_cu)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
char * pulongest(ULONGEST u)
CORE_ADDR dwarf2_per_cu_text_offset(struct dwarf2_per_cu_data *cu)
static void unary(int indent, struct ui_file *stream, const char *format,...) ATTRIBUTE_PRINTF(3
const char * c_get_mode_for_size(int size)
const gdb_byte * safe_read_sleb128(const gdb_byte *buf, const gdb_byte *buf_end, int64_t *r)
static void push(int indent, struct ui_file *stream, ULONGEST l)
static void pushf(int indent, struct ui_file *stream, const char *format,...) ATTRIBUTE_PRINTF(3
void fprintfi_filtered(int spaces, struct ui_file *stream, const char *format,...)
void discard_cleanups(struct cleanup *old_chain)
int dwarf2_reg_to_regnum_or_error(struct gdbarch *arch, int dwarf_reg)
void func_get_frame_base_dwarf_block(struct symbol *framefunc, CORE_ADDR pc, const gdb_byte **start, size_t *length)
int xsnprintf(char *str, size_t size, const char *format,...)
#define SET_CHECK_DEPTH(WHERE)
static void pushf_register(int indent, struct ui_file *stream, unsigned char *registers_used, struct gdbarch *gdbarch, int regnum, uint64_t offset)
unsigned long long ULONGEST
static void ATTRIBUTE_PRINTF(6, 0)
static int compute_stack_depth(enum bfd_endian byte_order, unsigned int addr_size, int *need_tempvar, int *is_tls, const gdb_byte *op_ptr, const gdb_byte *op_end, int initial_depth, struct insn_info **info)
const char * core_addr_to_string(const CORE_ADDR addr)
LONGEST extract_signed_integer(const gdb_byte *, int, enum bfd_endian)
CORE_ADDR value_address(const struct value *value)
void error(const char *fmt,...)
void do_cleanups(struct cleanup *old_chain)