aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/expr.c
diff options
context:
space:
mode:
authorZoran Zaric <Zoran.Zaric@amd.com>2020-09-22 10:44:45 +0100
committerZoran Zaric <zoran.zaric@amd.com>2021-08-05 16:41:05 +0100
commit70454ee70ad63c77d39768f057d722214adef658 (patch)
treea299c5b3c18f61a9ec4a98b52e314ad006bb10eb /gdb/dwarf2/expr.c
parent0579205aec4369375dccb8566ba37eefee2be912 (diff)
downloadbinutils-70454ee70ad63c77d39768f057d722214adef658.zip
binutils-70454ee70ad63c77d39768f057d722214adef658.tar.gz
binutils-70454ee70ad63c77d39768f057d722214adef658.tar.bz2
Add as_lval argument to expression evaluator
There are cases where the result of the expression evaluation is expected to be in a form of a value and not location description. One place that has this requirement is dwarf_entry_parameter_to_value function, but more are expected in the future. Until now, this requirement was fulfilled by extending the evaluated expression with a DW_OP_stack_value operation at the end. New implementation, introduces a new evaluation argument instead. * dwarf2/expr.c (dwarf_expr_context::fetch_result): Add as_lval argument. (dwarf_expr_context::eval_exp): Add as_lval argument. * dwarf2/expr.h (struct dwarf_expr_context): Add as_lval argument to fetch_result and eval_exp methods. * dwarf2/frame.c (execute_stack_op): Add as_lval argument. * dwarf2/loc.c (dwarf_entry_parameter_to_value): Remove DWARF expression extension. (dwarf2_evaluate_loc_desc_full): Add as_lval argument support. (dwarf2_evaluate_loc_desc): Add as_lval argument support. (dwarf2_locexpr_baton_eval): Add as_lval argument support.
Diffstat (limited to 'gdb/dwarf2/expr.c')
-rw-r--r--gdb/dwarf2/expr.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 1e67ffa..9e5a356 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -886,7 +886,7 @@ dwarf_expr_context::push_dwarf_reg_entry_value (call_site_parameter_kind kind,
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 ();
@@ -917,6 +917,11 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
}
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:
@@ -1037,7 +1042,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type,
/* 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,
@@ -1048,7 +1053,7 @@ dwarf_expr_context::evaluate (const gdb_byte *addr, size_t len,
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. */