+ struct frame_info *frame;
+ struct dwarf2_per_cu_data *per_cu;
+ CORE_ADDR obj_address;
+
+ /* Helper function for dwarf2_evaluate_loc_desc. Computes the CFA for
+ the frame in BATON. */
+
+ CORE_ADDR get_frame_cfa () override
+ {
+ return dwarf2_frame_cfa (frame);
+ }
+
+ /* Helper function for dwarf2_evaluate_loc_desc. Computes the PC for
+ the frame in BATON. */
+
+ CORE_ADDR get_frame_pc () override
+ {
+ return get_frame_address_in_block (frame);
+ }
+
+ /* Using the objfile specified in BATON, find the address for the
+ current thread's thread-local storage with offset OFFSET. */
+ CORE_ADDR get_tls_address (CORE_ADDR offset) override
+ {
+ struct objfile *objfile = dwarf2_per_cu_objfile (per_cu);
+
+ return target_translate_tls_address (objfile, offset);
+ }
+
+ /* Helper interface of per_cu_dwarf_call for
+ dwarf2_evaluate_loc_desc. */
+
+ void dwarf_call (cu_offset die_offset) override
+ {
+ per_cu_dwarf_call (this, die_offset, per_cu);
+ }
+
+ /* Helper interface of sect_variable_value for
+ dwarf2_evaluate_loc_desc. */
+
+ struct value *dwarf_variable_value (sect_offset sect_off) override
+ {
+ return sect_variable_value (this, sect_off, per_cu);
+ }
+
+ struct type *get_base_type (cu_offset die_offset, int size) override
+ {
+ struct type *result = dwarf2_get_die_type (die_offset, per_cu);
+ if (result == NULL)
+ error (_("Could not find type for DW_OP_const_type"));
+ if (size != 0 && TYPE_LENGTH (result) != size)
+ error (_("DW_OP_const_type has different sizes for type and data"));
+ return result;
+ }
+
+ /* Callback function for dwarf2_evaluate_loc_desc.
+ Fetch the address indexed by DW_OP_addrx or DW_OP_GNU_addr_index. */
+
+ CORE_ADDR get_addr_index (unsigned int index) override
+ {
+ return dwarf2_read_addr_index (per_cu, index);
+ }
+
+ /* Callback function for get_object_address. Return the address of the VLA
+ object. */
+
+ CORE_ADDR get_object_address () override
+ {
+ if (obj_address == 0)
+ error (_("Location address is not set."));
+ return obj_address;
+ }
+
+ /* Execute DWARF block of call_site_parameter which matches KIND and
+ KIND_U. Choose DEREF_SIZE value of that parameter. Search
+ caller of this objects's frame.
+
+ The caller can be from a different CU - per_cu_dwarf_call
+ implementation can be more simple as it does not support cross-CU
+ DWARF executions. */
+
+ void push_dwarf_reg_entry_value (enum call_site_parameter_kind kind,
+ union call_site_parameter_u kind_u,
+ int deref_size) override
+ {
+ struct frame_info *caller_frame;
+ struct dwarf2_per_cu_data *caller_per_cu;
+ struct call_site_parameter *parameter;
+ const gdb_byte *data_src;
+ size_t size;
+
+ caller_frame = get_prev_frame (frame);
+
+ parameter = dwarf_expr_reg_to_entry_parameter (frame, kind, kind_u,
+ &caller_per_cu);
+ data_src = deref_size == -1 ? parameter->value : parameter->data_value;
+ size = deref_size == -1 ? parameter->value_size : parameter->data_value_size;
+
+ /* DEREF_SIZE size is not verified here. */
+ if (data_src == NULL)
+ throw_error (NO_ENTRY_VALUE_ERROR,
+ _("Cannot resolve DW_AT_call_data_value"));
+
+ scoped_restore save_frame = make_scoped_restore (&this->frame,
+ caller_frame);
+ scoped_restore save_per_cu = make_scoped_restore (&this->per_cu,
+ caller_per_cu);
+ scoped_restore save_obj_addr = make_scoped_restore (&this->obj_address,
+ (CORE_ADDR) 0);
+
+ scoped_restore save_arch = make_scoped_restore (&this->gdbarch);
+ this->gdbarch
+ = get_objfile_arch (dwarf2_per_cu_objfile (per_cu));
+ scoped_restore save_addr_size = make_scoped_restore (&this->addr_size);
+ this->addr_size = dwarf2_per_cu_addr_size (per_cu);
+ scoped_restore save_offset = make_scoped_restore (&this->offset);
+ this->offset = dwarf2_per_cu_text_offset (per_cu);
+
+ this->eval (data_src, size);
+ }
+
+ /* Using the frame specified in BATON, find the location expression
+ describing the frame base. Return a pointer to it in START and
+ its length in LENGTH. */
+ void get_frame_base (const gdb_byte **start, size_t * length) override
+ {
+ /* FIXME: cagney/2003-03-26: This code should be using
+ get_frame_base_address(), and then implement a dwarf2 specific
+ this_base method. */
+ struct symbol *framefunc;
+ const struct block *bl = get_frame_block (frame, NULL);
+
+ if (bl == NULL)
+ error (_("frame address is not available."));
+
+ /* Use block_linkage_function, which returns a real (not inlined)
+ function, instead of get_frame_function, which may return an
+ inlined function. */
+ framefunc = block_linkage_function (bl);
+
+ /* If we found a frame-relative symbol then it was certainly within
+ some function associated with a frame. If we can't find the frame,
+ something has gone wrong. */
+ gdb_assert (framefunc != NULL);
+
+ func_get_frame_base_dwarf_block (framefunc,
+ get_frame_address_in_block (frame),
+ start, length);
+ }
+
+ /* Read memory at ADDR (length LEN) into BUF. */
+
+ void read_mem (gdb_byte *buf, CORE_ADDR addr, size_t len) override
+ {
+ read_memory (addr, buf, len);
+ }
+
+ /* Using the frame specified in BATON, return the value of register
+ REGNUM, treated as a pointer. */
+ CORE_ADDR read_addr_from_reg (int dwarf_regnum) override
+ {
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ int regnum = dwarf_reg_to_regnum_or_error (gdbarch, dwarf_regnum);
+
+ return address_from_register (regnum, frame);
+ }
+
+ /* Implement "get_reg_value" callback. */
+
+ struct value *get_reg_value (struct type *type, int dwarf_regnum) override
+ {
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ int regnum = dwarf_reg_to_regnum_or_error (gdbarch, dwarf_regnum);
+
+ return value_from_register (type, regnum, frame);
+ }
+};