74 std::vector<struct insn_info> *info,
75 std::vector<int> *to_do,
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 = (
enum dwarf_location_atom) *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:
326 case DW_OP_form_tls_address:
327 (*info)[ndx].is_tls = 1;
336 if (!(*info)[
offset].visited)
337 to_do->push_back (
offset);
339 (*info)[
offset].label = 1;
350 if (!(*info)[
offset].visited)
351 to_do->push_back (
offset);
353 (*info)[
offset].label = 1;
360 error (
_(
"unhandled DWARF op: %s"), get_DW_OP_name (op));
366 #undef SET_CHECK_DEPTH 387 int *need_tempvar,
int *is_tls,
390 std::vector<struct insn_info> *info)
392 std::vector<int> to_do;
395 info->resize (op_end - op_ptr);
398 (*info)[0].depth = initial_depth;
399 (*info)[0].visited = 1;
401 while (!to_do.empty ())
403 int ndx = to_do.back ();
407 byte_order, addr_size,
413 for (i = 0; i < op_end - op_ptr; ++i)
415 if ((*info)[i].depth > stack_depth)
416 stack_depth = (*info)[i].depth;
417 if ((*info)[i].is_tls)
421 return stack_depth + 1;
426 #define GCC_UINTPTR "__gdb_uintptr" 427 #define GCC_INTPTR "__gdb_intptr" 435 "__gdb_stack[++__gdb_tos] = (" GCC_UINTPTR ") %s;\n",
442 static void pushf (
int indent,
string_file &stream,
const char *format, ...)
451 va_start (args, format);
452 stream.vprintf (format, args);
462 static void unary (
int indent,
string_file &stream,
const char *format, ...)
471 va_start (args, format);
472 stream.vprintf (format, args);
488 va_start (args, format);
489 stream.vprintf (format, args);
511 unsigned char *registers_used,
516 registers_used[
regnum] = 1;
517 pushf (indent, stream,
529 unsigned char *registers_used,
534 registers_used[
regnum] = 1;
539 pushf (indent, stream,
575 const char *type_name,
576 const char *result_name,
579 unsigned char *registers_used,
580 unsigned int addr_size,
587 static unsigned int scope;
590 const gdb_byte *
const base = op_ptr;
591 int need_tempvar = 0;
593 std::vector<struct insn_info> info;
599 type_name, result_name);
604 &need_tempvar, &is_tls,
605 op_ptr, op_end, initial != NULL,
621 error (
_(
"Symbol \"%s\" cannot be used because " 622 "there is no selected frame"),
627 error (
_(
"Symbol \"%s\" cannot be used for compilation evaluation " 628 "as its address has not been found."),
631 warning (
_(
"Symbol \"%s\" is thread-local and currently can only " 632 "be referenced from the current thread in " 653 while (op_ptr < op_end)
655 enum dwarf_location_atom op = (
enum dwarf_location_atom) *op_ptr;
656 uint64_t uoffset,
reg;
660 if (info[op_ptr - base].label)
665 stream.
printf (
"/* %s */\n", get_DW_OP_name (op));
708 push (indent, stream, op - DW_OP_lit0);
718 if (op_ptr >= op_end || *op_ptr != DW_OP_GNU_push_tls_address)
720 push (indent, stream, uoffset);
724 push (indent, stream,
729 push (indent, stream,
734 push (indent, stream,
739 push (indent, stream,
744 push (indent, stream,
749 push (indent, stream,
754 push (indent, stream,
759 push (indent, stream,
765 push (indent, stream, uoffset);
807 (arch, op - DW_OP_reg0));
867 const struct block *b;
874 error (
_(
"No block found for address"));
879 error (
_(
"No function found for block"));
882 &datastart, &datalen);
888 xsnprintf (fb_name,
sizeof (fb_name),
"__frame_base_%ld",
889 (
long) (op_ptr - base));
894 arch, registers_used, addr_size,
895 datastart, datastart + datalen,
903 pushf (indent, stream,
"__gdb_stack[__gdb_tos]");
912 pushf (indent, stream,
"__gdb_stack[__gdb_tos - %s]",
918 "__gdb_tmp = __gdb_stack[__gdb_tos - 1];\n");
920 "__gdb_stack[__gdb_tos - 1] = " 921 "__gdb_stack[__gdb_tos];\n");
927 pushf (indent, stream,
"__gdb_stack[__gdb_tos - 1]");
932 "__gdb_stack[__gdb_tos];\n"));
934 "__gdb_stack[__gdb_tos] = " 935 "__gdb_stack[__gdb_tos - 1];\n");
937 "__gdb_stack[__gdb_tos - 1] = " 938 "__gdb_stack[__gdb_tos -2];\n");
944 case DW_OP_deref_size:
949 if (op == DW_OP_deref_size)
956 error (
_(
"Unsupported size %d in %s"),
957 size, get_DW_OP_name (op));
962 "__gdb_stack[__gdb_tos] = " 963 "*((__gdb_int_%s *) " 964 "__gdb_stack[__gdb_tos]);\n",
970 unary (indent, stream,
971 "((" GCC_INTPTR ") __gdb_stack[__gdb_tos]) < 0 ? " 972 "-__gdb_stack[__gdb_tos] : __gdb_stack[__gdb_tos]");
976 unary (indent, stream,
"-__gdb_stack[__gdb_tos]");
980 unary (indent, stream,
"~__gdb_stack[__gdb_tos]");
983 case DW_OP_plus_uconst:
985 unary (indent, stream,
"__gdb_stack[__gdb_tos] + %s",
991 ") __gdb_stack[__gdb_tos-1]) / ((" 997 "((" GCC_INTPTR ") __gdb_stack[__gdb_tos-1]) >> " 998 "__gdb_stack[__gdb_tos]");
1001 #define BINARY(OP) \ 1002 binary (indent, stream, "%s", "__gdb_stack[__gdb_tos-1] " #OP \ 1003 " __gdb_stack[__gdb_tos]"); \ 1026 #define COMPARE(OP) \ 1027 binary (indent, stream, \ 1028 "(((" GCC_INTPTR ") __gdb_stack[__gdb_tos-1]) " #OP \ 1030 ") __gdb_stack[__gdb_tos]))"); \ 1047 case DW_OP_call_frame_cfa:
1052 const gdb_byte *cfa_start, *cfa_end;
1056 &text_offset, &cfa_start, &cfa_end))
1070 "__cfa_%ld", (
long) (op_ptr - base));
1074 sym, pc,
arch, registers_used,
1077 &text_offset, per_cu);
1078 pushf (indent, stream,
"%s", cfa_name);
1089 stream.
puts (
";\n");
1097 ") __gdb_stack[__gdb_tos--]) != 0) goto ");
1099 stream.
puts (
";\n");
1106 error (
_(
"unhandled DWARF op: %s"), get_DW_OP_name (op));
1120 struct gdbarch *
arch,
unsigned char *registers_used,
1121 unsigned int addr_size,
1126 arch, registers_used, addr_size, op_ptr, op_end,
1134 const char *result_name,
1137 struct gdbarch *
arch,
unsigned char *registers_used,
1138 unsigned int addr_size,
1143 sym, pc,
arch, registers_used,
1144 addr_size, op_ptr, op_end, NULL, per_cu);
char * hex_string(LONGEST num)
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)
void compile_dwarf_bounds_to_c(string_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)
void warning(const char *fmt,...)
char * plongest(LONGEST l)
void print_spaces(int n, struct ui_file *file)
struct symbol * block_linkage_function(const struct block *bl)
static void push(int indent, string_file &stream, ULONGEST l)
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 void pushf(int indent, string_file &stream, const char *format,...) ATTRIBUTE_PRINTF(3
static void compute_stack_depth_worker(int start, int *need_tempvar, std::vector< struct insn_info > *info, std::vector< int > *to_do, enum bfd_endian byte_order, unsigned int addr_size, const gdb_byte *op_ptr, const gdb_byte *op_end)
const struct block * block_for_pc(CORE_ADDR pc)
static void binary(int indent, string_file &stream, const char *format,...) ATTRIBUTE_PRINTF(3
int dwarf_reg_to_regnum_or_error(struct gdbarch *arch, ULONGEST dwarf_reg)
struct value::@186::@187 reg
struct value * read_var_value(struct symbol *var, const struct block *var_block, struct frame_info *frame)
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
static void print_label(string_file &stream, unsigned int scope, int target)
#define COMPILE_I_SIMPLE_REGISTER_ARG_NAME
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
char * pulongest(ULONGEST u)
static void do_compile_dwarf_expr_to_c(int indent, string_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)
static void pushf_register(int indent, string_file &stream, unsigned char *registers_used, struct gdbarch *gdbarch, int regnum, uint64_t offset)
CORE_ADDR dwarf2_per_cu_text_offset(struct dwarf2_per_cu_data *cu)
const char * c_get_mode_for_size(int size)
virtual void puts(const char *str)
const gdb_byte * safe_read_sleb128(const gdb_byte *buf, const gdb_byte *buf_end, int64_t *r)
void fprintfi_filtered(int spaces, struct ui_file *stream, const char *format,...)
void printf(const char *,...) ATTRIBUTE_PRINTF(2
std::string compile_register_name_mangled(struct gdbarch *gdbarch, int regnum)
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)
void compile_dwarf_expr_to_c(string_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)
static LONGEST extract_signed_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
unsigned long long ULONGEST
const char * core_addr_to_string(const CORE_ADDR addr)
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, std::vector< struct insn_info > *info)
CORE_ADDR value_address(const struct value *value)
static void unary(int indent, string_file &stream, const char *format,...) ATTRIBUTE_PRINTF(3
void error(const char *fmt,...)
static void pushf_register_address(int indent, string_file &stream, unsigned char *registers_used, struct gdbarch *gdbarch, int regnum)