This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Allow DW_OP_GNU_uninit in dwarf_expr_require_composition


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f206f69cb43e420f92a63464036b342386963261

commit f206f69cb43e420f92a63464036b342386963261
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
Date:   Wed Oct 5 12:36:29 2016 +0200

    Allow DW_OP_GNU_uninit in dwarf_expr_require_composition
    
    In DWARF expression handling, some operators are required to be either
    at the end of an expression or followed by a composition operator.  So
    far only the operators DW_OP_reg0-31 were allowed to be followed by
    DW_OP_GNU_uninit instead, and particularly DW_OP_regx was not, which is
    obviously inconsistent.
    
    This patch allows DW_OP_GNU_uninit after all operators requiring a
    composition, to simplify the code and make it more consistent.  This
    policy may be more permissive than necessary, but in the worst case just
    leads to a DWARF location description resulting in an uninitialized
    value instead of an error message.
    
    gdb/ChangeLog:
    
    	* dwarf2expr.c (dwarf_expr_require_composition): Allow
    	DW_OP_GNU_uninit.
    	(execute_stack_op): Use dwarf_expr_require_composition instead of
    	copying its logic.

Diff:
---
 gdb/ChangeLog    |  7 +++++++
 gdb/dwarf2expr.c | 17 +++++------------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 357f648..eaef0b0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2016-10-05  Andreas Arnez  <arnez@linux.vnet.ibm.com>
+
+	* dwarf2expr.c (dwarf_expr_require_composition): Allow
+	DW_OP_GNU_uninit.
+	(execute_stack_op): Use dwarf_expr_require_composition instead of
+	copying its logic.
+
 2016-10-05  Anton Kolesov  <anton.kolesov@synopsys.com>
 
 	arc-tdep.c (arc_frame_prev_register): Remove annoying log message.
diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
index 7eb1982..90e4e25 100644
--- a/gdb/dwarf2expr.c
+++ b/gdb/dwarf2expr.c
@@ -401,16 +401,15 @@ safe_skip_leb128 (const gdb_byte *buf, const gdb_byte *buf_end)
 
 
 /* Check that the current operator is either at the end of an
-   expression, or that it is followed by a composition operator.  */
+   expression, or that it is followed by a composition operator or by
+   DW_OP_GNU_uninit (which should terminate the expression).  */
 
 void
 dwarf_expr_require_composition (const gdb_byte *op_ptr, const gdb_byte *op_end,
 				const char *op_name)
 {
-  /* It seems like DW_OP_GNU_uninit should be handled here.  However,
-     it doesn't seem to make sense for DW_OP_*_value, and it was not
-     checked at the other place that this function is called.  */
-  if (op_ptr != op_end && *op_ptr != DW_OP_piece && *op_ptr != DW_OP_bit_piece)
+  if (op_ptr != op_end && *op_ptr != DW_OP_piece && *op_ptr != DW_OP_bit_piece
+      && *op_ptr != DW_OP_GNU_uninit)
     error (_("DWARF-2 expression error: `%s' operations must be "
 	     "used either alone or in conjunction with DW_OP_piece "
 	     "or DW_OP_bit_piece."),
@@ -818,13 +817,7 @@ execute_stack_op (struct dwarf_expr_context *ctx,
 	case DW_OP_reg29:
 	case DW_OP_reg30:
 	case DW_OP_reg31:
-	  if (op_ptr != op_end 
-	      && *op_ptr != DW_OP_piece
-	      && *op_ptr != DW_OP_bit_piece
-	      && *op_ptr != DW_OP_GNU_uninit)
-	    error (_("DWARF-2 expression error: DW_OP_reg operations must be "
-		     "used either alone or in conjunction with DW_OP_piece "
-		     "or DW_OP_bit_piece."));
+	  dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_reg");
 
 	  result = op - DW_OP_reg0;
 	  result_val = value_from_ulongest (address_type, result);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]