dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton,
size_t *locexpr_length, CORE_ADDR pc)
{
- struct objfile *objfile = baton->per_cu->objfile ();
+ dwarf2_per_objfile *per_objfile = baton->per_objfile;
+ struct objfile *objfile = per_objfile->objfile;
struct gdbarch *gdbarch = objfile->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int addr_size = baton->per_cu->addr_size ();
/* Note: Things still work when the following test is removed. This
test and error is here to conform to the proposed specification. */
- if (TYPE_CODE (die_type) != TYPE_CODE_INT
- && TYPE_CODE (die_type) != TYPE_CODE_PTR)
+ if (die_type->code () != TYPE_CODE_INT
+ && die_type->code () != TYPE_CODE_PTR)
error (_("Type of DW_OP_GNU_variable_value DIE must be an integer or pointer."));
struct type *type = lookup_pointer_type (die_type);
class dwarf_evaluate_loc_desc : public dwarf_expr_context
{
- public:
+public:
+ dwarf_evaluate_loc_desc (dwarf2_per_objfile *per_objfile)
+ : dwarf_expr_context (per_objfile)
+ {}
struct frame_info *frame;
struct dwarf2_per_cu_data *per_cu;
this->gdbarch = per_cu->objfile ()->arch ();
scoped_restore save_addr_size = make_scoped_restore (&this->addr_size);
this->addr_size = per_cu->addr_size ();
- scoped_restore save_offset = make_scoped_restore (&this->offset);
- this->offset = per_cu->text_offset ();
this->eval (data_src, size);
}
paddress (gdbarch, addr));
type = SYMBOL_TYPE (sym);
- gdb_assert (TYPE_CODE (type) == TYPE_CODE_FUNC);
+ gdb_assert (type->code () == TYPE_CODE_FUNC);
gdb_assert (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_FUNC);
return sym;
/* Reference count. */
int refc = 0;
+ /* The objfile from which this closure's expression came. */
+ dwarf2_per_objfile *per_objfile = nullptr;
+
/* The CU from which this closure's expression came. */
struct dwarf2_per_cu_data *per_cu = NULL;
struct piece_closure *c = new piece_closure;
c->refc = 1;
+ /* We must capture this here due to sharing of DWARF state. */
+ c->per_objfile = per_cu->dwarf2_per_objfile;
c->per_cu = per_cu;
c->pieces = std::move (pieces);
if (frame == NULL)
enum bfd_endian byte_order;
type = check_typedef (value_type (value));
- if (TYPE_CODE (type) != TYPE_CODE_PTR)
+ if (type->code () != TYPE_CODE_PTR)
return NULL;
bit_length = 8 * TYPE_LENGTH (type);
if (size == 0)
return allocate_optimized_out_value (subobj_type);
- dwarf_evaluate_loc_desc ctx;
+ dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+ dwarf_evaluate_loc_desc ctx (per_objfile);
ctx.frame = frame;
ctx.per_cu = per_cu;
ctx.obj_address = 0;
ctx.gdbarch = objfile->arch ();
ctx.addr_size = per_cu->addr_size ();
ctx.ref_addr_size = per_cu->ref_addr_size ();
- ctx.offset = per_cu->text_offset ();
try
{
the operation. Therefore, we do the conversion here
since the type is readily available. */
- switch (TYPE_CODE (subobj_type))
+ switch (subobj_type->code ())
{
case TYPE_CODE_FUNC:
case TYPE_CODE_METHOD:
struct evaluate_for_locexpr_baton : public dwarf_evaluate_loc_desc
{
+ evaluate_for_locexpr_baton (dwarf2_per_objfile *per_objfile)
+ : dwarf_evaluate_loc_desc (per_objfile)
+ {}
+
/* The data that was passed in. */
gdb::array_view<const gdb_byte> data_view;
CORE_ADDR *valp,
bool push_initial_value)
{
- struct objfile *objfile;
-
if (dlbaton == NULL || dlbaton->size == 0)
return 0;
- evaluate_for_locexpr_baton ctx;
+ dwarf2_per_objfile *per_objfile = dlbaton->per_objfile;
+ evaluate_for_locexpr_baton ctx (per_objfile);
ctx.frame = frame;
ctx.per_cu = dlbaton->per_cu;
ctx.data_view = addr_stack->valaddr;
}
- objfile = dlbaton->per_cu->objfile ();
-
- ctx.gdbarch = objfile->arch ();
+ ctx.gdbarch = per_objfile->objfile->arch ();
ctx.addr_size = dlbaton->per_cu->addr_size ();
ctx.ref_addr_size = dlbaton->per_cu->ref_addr_size ();
- ctx.offset = dlbaton->per_cu->text_offset ();
if (push_initial_value)
ctx.push_address (ctx.obj_address, false);
class symbol_needs_eval_context : public dwarf_expr_context
{
- public:
+public:
+ symbol_needs_eval_context (dwarf2_per_objfile *per_objfile)
+ : dwarf_expr_context (per_objfile)
+ {}
enum symbol_needs_kind needs;
struct dwarf2_per_cu_data *per_cu;
scoped_value_mark free_values;
- symbol_needs_eval_context ctx;
+ symbol_needs_eval_context ctx (get_dwarf2_per_objfile (objfile));
ctx.needs = SYMBOL_NEEDS_NONE;
ctx.per_cu = per_cu;
ctx.gdbarch = objfile->arch ();
ctx.addr_size = per_cu->addr_size ();
ctx.ref_addr_size = per_cu->ref_addr_size ();
- ctx.offset = per_cu->text_offset ();
ctx.eval (data, size);
{
struct dwarf2_locexpr_baton *dlbaton
= (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol);
- struct objfile *objfile = dlbaton->per_cu->objfile ();
+ dwarf2_per_objfile *per_objfile = dlbaton->per_objfile;
+ struct objfile *objfile = per_objfile->objfile;
unsigned int addr_size = dlbaton->per_cu->addr_size ();
int offset_size = dlbaton->per_cu->offset_size ();
struct dwarf2_loclist_baton *dlbaton
= (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (symbol);
const gdb_byte *loc_ptr, *buf_end;
- struct objfile *objfile = dlbaton->per_cu->objfile ();
+ dwarf2_per_objfile *per_objfile = dlbaton->per_objfile;
+ struct objfile *objfile = per_objfile->objfile;
struct gdbarch *gdbarch = objfile->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int addr_size = dlbaton->per_cu->addr_size ();