This is the mail archive of the gdb-patches@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]

[commit value_one] Re: [patch] Fix crash on lval_computed value_zero/value_one


On Wed, 27 Jul 2011 20:56:29 +0200, Pedro Alves wrote:
> We should just remove the `lv' parameter and
> replace that VALUE_LVAL assignment by:
> 
>   gdb_assert (VALUE_LVAL (val) == not_lval);
> 
> (allocate_value creates values already as not_lval)
> 
> (I'd prefer that cleanup to be a separate patch.)

OK, implemented it, a nice cleanup.  Gave a ChangeLog line as I have just
"installed" it.

No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2011-07/msg00230.html

--- src/gdb/ChangeLog	2011/07/27 19:25:54	1.13235
+++ src/gdb/ChangeLog	2011/07/27 19:31:30	1.13236
@@ -1,4 +1,13 @@
 2011-07-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
+	    Pedro Alves  <pedro@codesourcery.com>
+
+	* eval.c (evaluate_subexp_standard): Remove not_lval from all calls of
+	value_one.
+	* valops.c (value_one): Remove parameter lv.  Do not pass it to itself.
+	Assert the result kind.
+	* value.h (value_one): Remove parameter lv.
+
+2011-07-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
 	Fix crash on lval_computed values.
 	* valops.c (value_zero): Use not_lval for lval_computed.
--- src/gdb/eval.c	2011/06/17 20:35:09	1.151
+++ src/gdb/eval.c	2011/07/27 19:31:30	1.152
@@ -2198,7 +2198,7 @@
 	    {
 	      struct value *v_one, *retval;
 
-	      v_one = value_one (value_type (arg2), not_lval);
+	      v_one = value_one (value_type (arg2));
 	      binop_promote (exp->language_defn, exp->gdbarch, &arg1, &v_one);
 	      retval = value_binop (arg1, v_one, op);
 	      return retval;
@@ -2742,7 +2742,7 @@
 	    {
 	      struct value *tmp = arg1;
 
-	      arg2 = value_one (value_type (arg1), not_lval);
+	      arg2 = value_one (value_type (arg1));
 	      binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
 	      arg2 = value_binop (tmp, arg2, BINOP_ADD);
 	    }
@@ -2766,7 +2766,7 @@
 	    {
 	      struct value *tmp = arg1;
 
-	      arg2 = value_one (value_type (arg1), not_lval);
+	      arg2 = value_one (value_type (arg1));
 	      binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
 	      arg2 = value_binop (tmp, arg2, BINOP_SUB);
 	    }
@@ -2792,7 +2792,7 @@
 	    {
 	      struct value *tmp = arg1;
 
-	      arg2 = value_one (value_type (arg1), not_lval);
+	      arg2 = value_one (value_type (arg1));
 	      binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
 	      arg2 = value_binop (tmp, arg2, BINOP_ADD);
 	    }
@@ -2819,7 +2819,7 @@
 	    {
 	      struct value *tmp = arg1;
 
-	      arg2 = value_one (value_type (arg1), not_lval);
+	      arg2 = value_one (value_type (arg1));
 	      binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
 	      arg2 = value_binop (tmp, arg2, BINOP_SUB);
 	    }
--- src/gdb/valops.c	2011/07/27 19:25:56	1.283
+++ src/gdb/valops.c	2011/07/27 19:31:30	1.284
@@ -864,10 +864,10 @@
   return val;
 }
 
-/* Create a value of numeric type TYPE that is one, and return it.  */
+/* Create a not_lval value of numeric type TYPE that is one, and return it.  */
 
 struct value *
-value_one (struct type *type, enum lval_type lv)
+value_one (struct type *type)
 {
   struct type *type1 = check_typedef (type);
   struct value *val;
@@ -901,7 +901,7 @@
       val = allocate_value (type);
       for (i = 0; i < high_bound - low_bound + 1; i++)
 	{
-	  tmp = value_one (eltype, lv);
+	  tmp = value_one (eltype);
 	  memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype),
 		  value_contents_all (tmp), TYPE_LENGTH (eltype));
 	}
@@ -911,7 +911,9 @@
       error (_("Not a numeric type."));
     }
 
-  VALUE_LVAL (val) = lv;
+  /* value_one result is never used for assignments to.  */
+  gdb_assert (VALUE_LVAL (val) == not_lval);
+
   return val;
 }
 
--- src/gdb/value.h	2011/07/14 15:00:20	1.183
+++ src/gdb/value.h	2011/07/27 19:31:30	1.184
@@ -615,7 +615,7 @@
 
 extern struct value *value_zero (struct type *type, enum lval_type lv);
 
-extern struct value *value_one (struct type *type, enum lval_type lv);
+extern struct value *value_one (struct type *type);
 
 extern struct value *value_repeat (struct value *arg1, int count);
 


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