* value.c (value_available_contents_eq): Remove redundant local
authorPedro Alves <palves@redhat.com>
Wed, 16 Feb 2011 10:13:53 +0000 (10:13 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 16 Feb 2011 10:13:53 +0000 (10:13 +0000)
variables.  Fix available contents comparision.
* value.h (value_available_contents_eq): Extend describing
comment.

gdb/ChangeLog
gdb/value.c
gdb/value.h

index 41f7a861d3432ca62035cedf0308dc40e27507ca..f026bad267cb566bbe30434f3158679b77392ce6 100644 (file)
@@ -1,3 +1,11 @@
+2011-02-16  Pedro Alves  <pedro@codesourcery.com>
+           Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * value.c (value_available_contents_eq): Remove redundant local
+       variables.  Fix available contents comparision.
+       * value.h (value_available_contents_eq): Extend describing
+       comment.
+
 2011-02-16  Yao Qi  <yao@codesourcery.com>
 
        * thread.c (info_threads_command): Add missing i18n markup and remove
index 2e07a85cdd120e2526255cb644b458fb5d27a479..d2863db1aa2cd18bbccbf73af5d483e0bbfa1bc7 100644 (file)
@@ -533,21 +533,13 @@ value_available_contents_eq (const struct value *val1, int offset1,
                             const struct value *val2, int offset2,
                             int length)
 {
-  int org_len = length;
-  int org_offset1 = offset1;
-  int org_offset2 = offset2;
   int idx1 = 0, idx2 = 0;
-  int prev_avail;
 
   /* This routine is used by printing routines, where we should
      already have read the value.  Note that we only know whether a
      value chunk is available if we've tried to read it.  */
   gdb_assert (!val1->lazy && !val2->lazy);
 
-  /* The offset from either ORG_OFFSET1 or ORG_OFFSET2 where the
-     available contents we haven't compared yet start.  */
-  prev_avail = 0;
-
   while (length > 0)
     {
       range_s *r1, *r2;
@@ -561,9 +553,9 @@ value_available_contents_eq (const struct value *val1, int offset1,
 
       /* The usual case is for both values to be completely available.  */
       if (idx1 == -1 && idx2 == -1)
-       return (memcmp (val1->contents + org_offset1 + prev_avail,
-                       val2->contents + org_offset2 + prev_avail,
-                       org_len - prev_avail) == 0);
+       return (memcmp (val1->contents + offset1,
+                       val2->contents + offset2,
+                       length) == 0);
       /* The contents only match equal if the available set matches as
         well.  */
       else if (idx1 == -1 || idx2 == -1)
@@ -596,12 +588,11 @@ value_available_contents_eq (const struct value *val1, int offset1,
        return 0;
 
       /* Compare the _available_ contents.  */
-      if (memcmp (val1->contents + org_offset1 + prev_avail,
-                 val2->contents + org_offset2 + prev_avail,
-                 l2 - prev_avail) != 0)
+      if (memcmp (val1->contents + offset1,
+                 val2->contents + offset2,
+                 l1) != 0)
        return 0;
 
-      prev_avail += h1;
       length -= h1;
       offset1 += h1;
       offset2 += h1;
index b8ce97b4a0435efa2f46eab719249be7a1ac1767..e019e56676a3861ec136c4a0d406e9e8e47d69d2 100644 (file)
@@ -379,12 +379,21 @@ extern void mark_value_bytes_unavailable (struct value *value,
                                          int offset, int length);
 
 /* Compare LENGTH bytes of VAL1's contents starting at OFFSET1 with
-   LENGTH bytes of VAL2's contents starting at OFFSET2.  Returns true
-   iff the set of available contents match.  Unavailable contents
-   compare equal with unavailable contents, and different with any
-   available byte.  For example, if 'x's represent an unavailable
-   byte, and 'V' and 'Z' represent different available bytes, in a
-   value with length 16:
+   LENGTH bytes of VAL2's contents starting at OFFSET2.
+
+   Note that "contents" refers to the whole value's contents
+   (value_contents_all), without any embedded offset adjustment.  For
+   example, to compare a complete object value with itself, including
+   its enclosing type chunk, you'd do:
+
+     int len = TYPE_LENGTH (check_typedef (value_enclosing_type (val)));
+     value_available_contents (val, 0, val, 0, len);
+
+   Returns true iff the set of available contents match.  Unavailable
+   contents compare equal with unavailable contents, and different
+   with any available byte.  For example, if 'x's represent an
+   unavailable byte, and 'V' and 'Z' represent different available
+   bytes, in a value with length 16:
 
    offset:   0   4   8   12  16
    contents: xxxxVVVVxxxxVVZZ
This page took 0.031185 seconds and 4 git commands to generate.