[PATCH 38/43] Remove DWARF expression composition check

Zoran Zaric via Gdb-patches
2021-03-01T14:48:08Z

The dwarf_expr_require_composition function reports an error if the
last operation is not a leaf node of the DWARF expression. This was
previously used to prevent location description operations to be used
freely in the DWARF expression.

With the new approach, all operations are treated the same and
everything is composable, so there is no need for the previous
restrictions in the expression evaluator.

gdb/ChangeLog:

* dwarf2/expr.c (dwarf_expr_context::execute_stack_op): Remove
the use of dwarf_expr_require_composition.
---
gdb/dwarf2/expr.c | 9 ---------
1 file changed, 9 deletions(-)

diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 977ac64dd68..871f52acfd8 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -3071,7 +3071,6 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
case DW_OP_reg29:
case DW_OP_reg30:
case DW_OP_reg31:
- dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_reg");
ensure_have_frame (this->frame, "DW_OP_reg");

result = op - DW_OP_reg0;
@@ -3081,7 +3080,6 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,

case DW_OP_regx:
op_ptr = safe_read_uleb128 (op_ptr, op_end, &reg);
- dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_regx");
ensure_have_frame (this->frame, "DW_OP_regx");

result = reg;
@@ -3099,8 +3097,6 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
= std::make_shared<dwarf_implicit> (this->gdbarch, op_ptr, len,
BFD_ENDIAN_UNKNOWN);
op_ptr += len;
- dwarf_expr_require_composition (op_ptr, op_end,
- "DW_OP_implicit_value");
}
break;

@@ -3116,9 +3112,6 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
value->get_contents (),
TYPE_LENGTH (type),
type_byte_order (type));
-
- dwarf_expr_require_composition (op_ptr, op_end,
- "DW_OP_stack_value");
}
break;

@@ -3143,8 +3136,6 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
this->per_cu,
this->addr_size,
die_offset, len);
- dwarf_expr_require_composition (op_ptr, op_end,
- "DW_OP_implicit_pointer");
}
break;

--
2.17.1