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] Lazy value fix


One of the changes I made for lazy register support was clearly bogus.
The alternative branch uses value_contents_raw, which won't fetch the
value, so taking a field of a structure held in a lazy register would
read uninitialized data.

I've tested the patch below on x86_64-linux and arm-eabi and committed
it; this makes it clearer why registers are special here.

-- 
Daniel Jacobowitz
CodeSourcery

2008-06-11  Daniel Jacobowitz  <dan@codesourcery.com>

	* value.c (value_primitive_field): Fetch lazy register values.

Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.63
diff -u -p -r1.63 value.c
--- value.c	19 May 2008 15:50:10 -0000	1.63
+++ value.c	11 Jun 2008 19:36:41 -0000
@@ -1354,7 +1354,12 @@ value_primitive_field (struct value *arg
          bases, etc.  */
       v = allocate_value (value_enclosing_type (arg1));
       v->type = type;
-      if (VALUE_LVAL (arg1) == lval_memory && value_lazy (arg1))
+
+      /* Lazy register values with offsets are not supported.  */
+      if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1))
+	value_fetch_lazy (arg1);
+
+      if (value_lazy (arg1))
 	set_value_lazy (v, 1);
       else
 	memcpy (value_contents_all_raw (v), value_contents_all_raw (arg1),
@@ -1368,7 +1373,12 @@ value_primitive_field (struct value *arg
       /* Plain old data member */
       offset += TYPE_FIELD_BITPOS (arg_type, fieldno) / 8;
       v = allocate_value (type);
-      if (VALUE_LVAL (arg1) == lval_memory && value_lazy (arg1))
+
+      /* Lazy register values with offsets are not supported.  */
+      if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1))
+	value_fetch_lazy (arg1);
+
+      if (value_lazy (arg1))
 	set_value_lazy (v, 1);
       else
 	memcpy (value_contents_raw (v),


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