struct type *get_base_type (cu_offset die_offset, int size) override
{
- struct type *result = dwarf2_get_die_type (die_offset, per_cu);
+ struct type *result = dwarf2_get_die_type (die_offset, per_cu, per_objfile);
if (result == NULL)
error (_("Could not find type for DW_OP_const_type"));
if (size != 0 && TYPE_LENGTH (result) != size)
data_src = deref_size == -1 ? parameter->value : parameter->data_value;
size = deref_size == -1 ? parameter->value_size : parameter->data_value_size;
- gdb_assert (this->per_objfile == caller_per_objfile);
-
/* DEREF_SIZE size is not verified here. */
if (data_src == NULL)
throw_error (NO_ENTRY_VALUE_ERROR,
_("Cannot resolve DW_AT_call_data_value"));
+ /* We are about to evaluate an expression in the context of the caller
+ of the current frame. This evaluation context may be different from
+ the current (callee's) context), so temporarily set the caller's context.
+
+ It is possible for the caller to be from a different objfile from the
+ callee if the call is made through a function pointer. */
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_per_objfile = make_scoped_restore (&this->per_objfile,
+ caller_per_objfile);
scoped_restore save_arch = make_scoped_restore (&this->gdbarch);
this->gdbarch = this->per_objfile->objfile->arch ();
scoped_restore save_addr_size = make_scoped_restore (&this->addr_size);
- this->addr_size = per_cu->addr_size ();
+ this->addr_size = this->per_cu->addr_size ();
this->eval (data_src, size);
}
data = safe_read_uleb128 (data, end, &ul);
cu_offset offset = (cu_offset) ul;
- type = dwarf2_get_die_type (offset, per_cu);
+ type = dwarf2_get_die_type (offset, per_cu, per_objfile);
fprintf_filtered (stream, "<");
type_print (type, "", stream, -1);
fprintf_filtered (stream, " [0x%s]> %d",
data = safe_read_uleb128 (data, end, &ul);
cu_offset type_die = (cu_offset) ul;
- type = dwarf2_get_die_type (type_die, per_cu);
+ type = dwarf2_get_die_type (type_die, per_cu, per_objfile);
fprintf_filtered (stream, "<");
type_print (type, "", stream, -1);
fprintf_filtered (stream, " [0x%s]>",
data = safe_read_uleb128 (data, end, &ul);
cu_offset type_die = (cu_offset) ul;
- type = dwarf2_get_die_type (type_die, per_cu);
+ type = dwarf2_get_die_type (type_die, per_cu, per_objfile);
fprintf_filtered (stream, "<");
type_print (type, "", stream, -1);
fprintf_filtered (stream, " [0x%s]> [$%s]",
{
struct type *type;
- type = dwarf2_get_die_type (type_die, per_cu);
+ type = dwarf2_get_die_type (type_die, per_cu, per_objfile);
fprintf_filtered (stream, "<");
type_print (type, "", stream, -1);
fprintf_filtered (stream, " [0x%s]>",