value *
dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
- LONGEST subobj_offset)
+ LONGEST subobj_offset, bool as_lval)
{
value *retval = nullptr;
gdbarch *arch = this->m_per_objfile->objfile->arch ();
}
else
{
+ /* If AS_LVAL is false, means that the implicit conversion
+ from a location description to value is expected. */
+ if (!as_lval)
+ this->m_location = DWARF_VALUE_STACK;
+
switch (this->m_location)
{
case DWARF_VALUE_REGISTER:
/* See expr.h. */
value *
-dwarf_expr_context::evaluate (const gdb_byte *addr, size_t len,
+dwarf_expr_context::evaluate (const gdb_byte *addr, size_t len, bool as_lval,
dwarf2_per_cu_data *per_cu, frame_info *frame,
const struct property_addr_info *addr_info,
struct type *type, struct type *subobj_type,
this->m_addr_info = addr_info;
eval (addr, len);
- return fetch_result (type, subobj_type, subobj_offset);
+ return fetch_result (type, subobj_type, subobj_offset, as_lval);
}
/* Require that TYPE be an integral type; throw an exception if not. */
void push_address (CORE_ADDR value, bool in_stack_memory);
/* Evaluate the expression at ADDR (LEN bytes long) in a given PER_CU
- and FRAME context. TYPE, SUBOBJ_TYPE and SUBOBJ_OFFSET describe
- the expected struct value representation of the evaluation
- result. The ADDR_INFO property can be specified to override the
- range of memory addresses with the passed in buffer. */
- value *evaluate (const gdb_byte *addr, size_t len,
+ and FRAME context.
+
+ AS_LVAL defines if the returned struct value is expected to be a
+ value (false) or a location description (true).
+
+ TYPE, SUBOBJ_TYPE and SUBOBJ_OFFSET describe the expected struct
+ value representation of the evaluation result.
+
+ The ADDR_INFO property can be specified to override the range of
+ memory addresses with the passed in buffer. */
+ value *evaluate (const gdb_byte *addr, size_t len, bool as_lval,
dwarf2_per_cu_data *per_cu, frame_info *frame,
const struct property_addr_info *addr_info = nullptr,
struct type *type = nullptr,
/* Fetch the result of the expression evaluation in a form of
a struct value, where TYPE, SUBOBJ_TYPE and SUBOBJ_OFFSET
- describe the source level representation of that result. */
+ describe the source level representation of that result.
+ AS_LVAL defines if the fetched struct value is expected to
+ be a value or a location description. */
value *fetch_result (struct type *type, struct type *subobj_type,
- LONGEST subobj_offset);
+ LONGEST subobj_offset, bool as_lval);
/* Return the location expression for the frame base attribute, in
START and LENGTH. The result must be live until the current
scoped_value_mark free_values;
ctx.push_address (initial, initial_in_stack_memory);
- value *result_val = ctx.evaluate (exp, len, nullptr, this_frame);
+ value *result_val = ctx.evaluate (exp, len, true, nullptr, this_frame);
if (VALUE_LVAL (result_val) == lval_memory)
return value_address (result_val);
static struct value *dwarf2_evaluate_loc_desc_full
(struct type *type, struct frame_info *frame, const gdb_byte *data,
size_t size, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile,
- struct type *subobj_type, LONGEST subobj_byte_offset);
+ struct type *subobj_type, LONGEST subobj_byte_offset, bool as_lval = true);
/* Until these have formal names, we define these here.
ref: http://gcc.gnu.org/wiki/DebugFission
dwarf2_per_objfile *per_objfile)
{
const gdb_byte *data_src;
- gdb_byte *data;
size_t size;
data_src = deref_size == -1 ? parameter->value : parameter->data_value;
throw_error (NO_ENTRY_VALUE_ERROR,
_("Cannot resolve DW_AT_call_data_value"));
- /* DW_AT_call_value is a DWARF expression, not a DWARF
- location. Postprocessing of DWARF_VALUE_MEMORY would lose the type from
- DWARF block. */
- data = (gdb_byte *) alloca (size + 1);
- memcpy (data, data_src, size);
- data[size] = DW_OP_stack_value;
-
- return dwarf2_evaluate_loc_desc (type, caller_frame, data, size + 1, per_cu,
- per_objfile);
+ return dwarf2_evaluate_loc_desc (type, caller_frame, data_src, size, per_cu,
+ per_objfile, false);
}
/* VALUE must be of type lval_computed with entry_data_value_funcs. Perform
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile,
struct type *subobj_type,
- LONGEST subobj_byte_offset)
+ LONGEST subobj_byte_offset,
+ bool as_lval)
{
if (subobj_type == NULL)
{
try
{
- retval = ctx.evaluate (data, size, per_cu, frame, nullptr, type,
- subobj_type, subobj_byte_offset);
+ retval = ctx.evaluate (data, size, as_lval, per_cu, frame, nullptr,
+ type, subobj_type, subobj_byte_offset);
}
catch (const gdb_exception_error &ex)
{
dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
const gdb_byte *data, size_t size,
dwarf2_per_cu_data *per_cu,
- dwarf2_per_objfile *per_objfile)
+ dwarf2_per_objfile *per_objfile, bool as_lval)
{
return dwarf2_evaluate_loc_desc_full (type, frame, data, size, per_cu,
- per_objfile, NULL, 0);
+ per_objfile, NULL, 0, as_lval);
}
/* Evaluates a dwarf expression and stores the result in VAL,
try
{
result = ctx.evaluate (dlbaton->data, dlbaton->size,
- per_cu, frame, addr_stack);
+ true, per_cu, frame, addr_stack);
}
catch (const gdb_exception_error &ex)
{
/* Evaluate a location description, starting at DATA and with length
SIZE, to find the current location of variable of TYPE in the context
- of FRAME. */
+ of FRAME. AS_LVAL defines if the resulting struct value is expected to
+ be a value or a location description. */
struct value *dwarf2_evaluate_loc_desc (struct type *type,
struct frame_info *frame,
const gdb_byte *data,
size_t size,
dwarf2_per_cu_data *per_cu,
- dwarf2_per_objfile *per_objfile);
+ dwarf2_per_objfile *per_objfile,
+ bool as_lval = true);
/* A chain of addresses that might be needed to resolve a dynamic
property. */