]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Simplify case DW_OP_GNU_uninit in dwarf_expr_context::execute_stack_op
authorKevin Buettner <kevinb@redhat.com>
Mon, 12 Jun 2023 22:21:06 +0000 (15:21 -0700)
committerKevin Buettner <kevinb@redhat.com>
Mon, 12 Jun 2023 23:02:40 +0000 (16:02 -0700)
Tom Tromey pointed out that the test and call to error() for the
DW_OP_GNU_uninit case in dwarf_expr_context::execute_stack_op (in
gdb/dwarf2/expr.c)...

  if (op_ptr != op_end && *op_ptr != DW_OP_piece
      && *op_ptr != DW_OP_bit_piece)
    error (_("DWARF-2 expression error: DW_OP_GNU_uninit must always "
   "be the very last op in a DWARF expression or "
   "DW_OP_piece/DW_OP_bit_piece piece."));

...could be replaced by a call to dwarf_expr_require_composition which
performs a similar check and outputs a suitable error message.

gdb/dwarf2/expr.c

index 7e1666165d7c1f8fb2bf625872c24838a1da5e12..b21016eb38bb89e0e247a59112fec9a6bd484cad 100644 (file)
@@ -2200,12 +2200,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
          goto no_push;
 
        case DW_OP_GNU_uninit:
-         if (op_ptr != op_end && *op_ptr != DW_OP_piece
-             && *op_ptr != DW_OP_bit_piece)
-           error (_("DWARF-2 expression error: DW_OP_GNU_uninit must always "
-                  "be the very last op in a DWARF expression or "
-                  "DW_OP_piece/DW_OP_bit_piece piece."));
-
+         dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_GNU_uninit");
          this->m_initialized = false;
          goto no_push;