[PATCH 37/43] Add frame info check to DW_OP_reg operations

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

After enabling location description to be on a DWARF stack, it is now
needed to check the frame context information validity when creating a
register location description.

gdb/ChangeLog:

* dwarf2/expr.c (dwarf_expr_context::execute_stack_op): Add
check_frame_info call for DW_OP_reg operations.
---
gdb/dwarf2/expr.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index b5f408fead1..977ac64dd68 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -3072,6 +3072,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
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;
result_entry
@@ -3081,6 +3082,7 @@ 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;
result_entry = std::make_shared<dwarf_register> (this->gdbarch, reg);
--
2.17.1