with LENGTH bits of VAL2's contents starting at OFFSET2 bits.
Return true if the available bits match. */
-static bool
-value_contents_bits_eq (const struct value *val1, int offset1,
- const struct value *val2, int offset2,
- int length)
+bool
+value::contents_bits_eq (int offset1, const struct value *val2, int offset2,
+ int length) const
{
/* Each array element corresponds to a ranges source (unavailable,
optimized out). '1' is for VAL1, '2' for VAL2. */
struct ranges_and_idx rp1[2], rp2[2];
/* See function description in value.h. */
- gdb_assert (!val1->m_lazy && !val2->m_lazy);
+ gdb_assert (!m_lazy && !val2->m_lazy);
/* We shouldn't be trying to compare past the end of the values. */
gdb_assert (offset1 + length
- <= val1->m_enclosing_type->length () * TARGET_CHAR_BIT);
+ <= m_enclosing_type->length () * TARGET_CHAR_BIT);
gdb_assert (offset2 + length
<= val2->m_enclosing_type->length () * TARGET_CHAR_BIT);
memset (&rp1, 0, sizeof (rp1));
memset (&rp2, 0, sizeof (rp2));
- rp1[0].ranges = &val1->m_unavailable;
+ rp1[0].ranges = &m_unavailable;
rp2[0].ranges = &val2->m_unavailable;
- rp1[1].ranges = &val1->m_optimized_out;
+ rp1[1].ranges = &m_optimized_out;
rp2[1].ranges = &val2->m_optimized_out;
while (length > 0)
}
/* Compare the available/valid contents. */
- if (memcmp_with_bit_offsets (val1->m_contents.get (), offset1,
+ if (memcmp_with_bit_offsets (m_contents.get (), offset1,
val2->m_contents.get (), offset2, l) != 0)
return false;
return true;
}
+/* See value.h. */
+
bool
-value_contents_eq (const struct value *val1, LONGEST offset1,
- const struct value *val2, LONGEST offset2,
- LONGEST length)
+value::contents_eq (LONGEST offset1,
+ const struct value *val2, LONGEST offset2,
+ LONGEST length) const
{
- return value_contents_bits_eq (val1, offset1 * TARGET_CHAR_BIT,
- val2, offset2 * TARGET_CHAR_BIT,
- length * TARGET_CHAR_BIT);
+ return contents_bits_eq (offset1 * TARGET_CHAR_BIT,
+ val2, offset2 * TARGET_CHAR_BIT,
+ length * TARGET_CHAR_BIT);
}
/* See value.h. */
bool
-value_contents_eq (const struct value *val1, const struct value *val2)
+value::contents_eq (const struct value *val2) const
{
- ULONGEST len1 = check_typedef (val1->enclosing_type ())->length ();
+ ULONGEST len1 = check_typedef (enclosing_type ())->length ();
ULONGEST len2 = check_typedef (val2->enclosing_type ())->length ();
if (len1 != len2)
return false;
- return value_contents_eq (val1, 0, val2, 0, len1);
+ return contents_eq (0, val2, 0, len1);
}
/* The value-history records all the values printed by print commands
it. */
void fetch_lazy ();
+ /* Compare LENGTH bytes of this value's contents starting at OFFSET1
+ with 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 = check_typedef (val->enclosing_type ())->length ();
+ val->contents_eq (0, val, 0, len);
+
+ Returns true iff the set of available/valid contents match.
+
+ Optimized-out contents are equal to optimized-out contents, and are
+ not equal to non-optimized-out contents.
+
+ Unavailable contents are equal to unavailable contents, and are not
+ equal to non-unavailable contents.
+
+ For example, if 'x's represent an unavailable byte, and 'V' and 'Z'
+ represent different available/valid bytes, in a value with length
+ 16:
+
+ offset: 0 4 8 12 16
+ contents: xxxxVVVVxxxxVVZZ
+
+ then:
+
+ val->contents_eq(0, val, 8, 6) => true
+ val->contents_eq(0, val, 4, 4) => false
+ val->contents_eq(0, val, 8, 8) => false
+ val->contents_eq(4, val, 12, 2) => true
+ val->contents_eq(4, val, 12, 4) => true
+ val->contents_eq(3, val, 4, 4) => true
+
+ If 'x's represent an unavailable byte, 'o' represents an optimized
+ out byte, in a value with length 8:
+
+ offset: 0 4 8
+ contents: xxxxoooo
+
+ then:
+
+ val->contents_eq(0, val, 2, 2) => true
+ val->contents_eq(4, val, 6, 2) => true
+ val->contents_eq(0, val, 4, 4) => true
+
+ We only know whether a value chunk is unavailable or optimized out
+ if we've tried to read it. As this routine is used by printing
+ routines, which may be printing values in the value history, long
+ after the inferior is gone, it works with const values. Therefore,
+ this routine must not be called with lazy values. */
+
+ bool contents_eq (LONGEST offset1, const struct value *val2, LONGEST offset2,
+ LONGEST length) const;
+
+ /* An overload of contents_eq that compares the entirety of both
+ values. */
+ bool contents_eq (const struct value *val2) const;
+
/* Type of value; either not an lval, or one of the various
different possible kinds of lval. */
yet. If CHECK_SIZE is true, then apply the usual max-value-size
checks. */
void allocate_contents (bool check_size);
+
+private:
+
+ /* Helper function for value_contents_eq. The only difference is that
+ this function is bit rather than byte based.
+
+ Compare LENGTH bits of this value's contents starting at OFFSET1
+ bits with LENGTH bits of VAL2's contents starting at OFFSET2
+ bits. Return true if the available bits match. */
+ bool contents_bits_eq (int offset1, const struct value *val2, int offset2,
+ int length) const;
};
/* Returns value_type or value_enclosing_type depending on
extern void mark_value_bits_unavailable (struct value *value,
LONGEST offset, ULONGEST length);
-/* Compare LENGTH bytes of VAL1's contents starting at OFFSET1 with
- 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 = check_typedef (val->enclosing_type ())->length ();
- value_contents_eq (val, 0, val, 0, len);
-
- Returns true iff the set of available/valid contents match.
-
- Optimized-out contents are equal to optimized-out contents, and are
- not equal to non-optimized-out contents.
-
- Unavailable contents are equal to unavailable contents, and are not
- equal to non-unavailable contents.
-
- For example, if 'x's represent an unavailable byte, and 'V' and 'Z'
- represent different available/valid bytes, in a value with length
- 16:
-
- offset: 0 4 8 12 16
- contents: xxxxVVVVxxxxVVZZ
-
- then:
-
- value_contents_eq(val, 0, val, 8, 6) => true
- value_contents_eq(val, 0, val, 4, 4) => false
- value_contents_eq(val, 0, val, 8, 8) => false
- value_contents_eq(val, 4, val, 12, 2) => true
- value_contents_eq(val, 4, val, 12, 4) => true
- value_contents_eq(val, 3, val, 4, 4) => true
-
- If 'x's represent an unavailable byte, 'o' represents an optimized
- out byte, in a value with length 8:
-
- offset: 0 4 8
- contents: xxxxoooo
-
- then:
-
- value_contents_eq(val, 0, val, 2, 2) => true
- value_contents_eq(val, 4, val, 6, 2) => true
- value_contents_eq(val, 0, val, 4, 4) => true
-
- We only know whether a value chunk is unavailable or optimized out
- if we've tried to read it. As this routine is used by printing
- routines, which may be printing values in the value history, long
- after the inferior is gone, it works with const values. Therefore,
- this routine must not be called with lazy values. */
-
-extern bool value_contents_eq (const struct value *val1, LONGEST offset1,
- const struct value *val2, LONGEST offset2,
- LONGEST length);
-
-/* An overload of value_contents_eq that compares the entirety of both
- values. */
-
-extern bool value_contents_eq (const struct value *val1,
- const struct value *val2);
-
/* Read LENGTH addressable memory units starting at MEMADDR into BUFFER,
which is (or will be copied to) VAL's contents buffer offset by
BIT_OFFSET bits. Marks value contents ranges as unavailable if