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]

Re: [unavailable values part 1, 13/17] value unavailable-ness propagation


On Monday 14 February 2011 12:00:28, Jan Kratochvil wrote:
> On Mon, 07 Feb 2011 15:33:53 +0100, Pedro Alves wrote:
> > +/* Copy LENGTH bytes of SRC value's contents starting at SRC_OFFSET,
> > +   into DST value's contents, starting at DST_OFFSET.  If unavailable
> > +   contents are being copied from SRC, the corresponding DST contents
> > +   are marked unavailable accordingly.  Neither DST nor SRC may be
> > +   lazy values.  */
> 
> /* DST_OFFSET and SRC_OFFSET should include possible EMBEDDED_OFFSET,
>    respectively.  */
> 
> The overwritten DST range gets unavailability only ORed in, not replaced.
> AFAICS it does not affect any current callers of it.
> 
> As clearing the unavailability is currently not easy I would prefer at least
>   gdb_assert (value_bytes_available (dst, dst_offset, length));
> (or at least a fat function comment warning)

Thanks, I agree.  I applied the patch below.

-- 
Pedro Alves

2011-02-16  Pedro Alves  <pedro@codesourcery.com>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	gdb/
	* value.c (value_contents_copy_raw): Extend describing comment.
	Assert that the destination contents we're overwriting are wholly
	available.
	(value_contents_copy): Extend describing comment.

---
 gdb/value.c |   35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

Index: src/gdb/value.c
===================================================================
--- src.orig/gdb/value.c	2011-02-16 10:13:12.000000000 +0000
+++ src/gdb/value.c	2011-02-16 11:01:57.056002003 +0000
@@ -844,11 +844,15 @@ value_contents_all (struct value *value)
   return result;
 }
 
-/* Copy LENGTH bytes of SRC value's contents starting at SRC_OFFSET,
-   into DST value's contents, starting at DST_OFFSET.  If unavailable
-   contents are being copied from SRC, the corresponding DST contents
-   are marked unavailable accordingly.  Neither DST nor SRC may be
-   lazy values.  */
+/* Copy LENGTH bytes of SRC value's (all) contents
+   (value_contents_all) starting at SRC_OFFSET, into DST value's (all)
+   contents, starting at DST_OFFSET.  If unavailable contents are
+   being copied from SRC, the corresponding DST contents are marked
+   unavailable accordingly.  Neither DST nor SRC may be lazy
+   values.
+
+   It is assumed the contents of DST in the [DST_OFFSET,
+   DST_OFFSET+LENGTH) range are wholly available.  */
 
 void
 value_contents_copy_raw (struct value *dst, int dst_offset,
@@ -863,6 +867,11 @@ value_contents_copy_raw (struct value *d
      mean we'd be copying garbage.  */
   gdb_assert (!dst->lazy && !src->lazy);
 
+  /* The overwritten DST range gets unavailability ORed in, not
+     replaced.  Make sure to remember to implement replacing if it
+     turns out actually necessary.  */
+  gdb_assert (value_bytes_available (dst, dst_offset, length));
+
   /* Copy the data.  */
   memcpy (value_contents_all_raw (dst) + dst_offset,
 	  value_contents_all_raw (src) + src_offset,
@@ -883,12 +892,16 @@ value_contents_copy_raw (struct value *d
     }
 }
 
-/* Copy LENGTH bytes of SRC value's contents starting at SRC_OFFSET
-   byte, into DST value's contents, starting at DST_OFFSET.  If
-   unavailable contents are being copied from SRC, the corresponding
-   DST contents are marked unavailable accordingly.  DST must not be
-   lazy.  If SRC is lazy, it will be fetched now.  If SRC is not valid
-   (is optimized out), an error is thrown.  */
+/* Copy LENGTH bytes of SRC value's (all) contents
+   (value_contents_all) starting at SRC_OFFSET byte, into DST value's
+   (all) contents, starting at DST_OFFSET.  If unavailable contents
+   are being copied from SRC, the corresponding DST contents are
+   marked unavailable accordingly.  DST must not be lazy.  If SRC is
+   lazy, it will be fetched now.  If SRC is not valid (is optimized
+   out), an error is thrown.
+
+   It is assumed the contents of DST in the [DST_OFFSET,
+   DST_OFFSET+LENGTH) range are wholly available.  */
 
 void
 value_contents_copy (struct value *dst, int dst_offset,


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