summaryrefslogtreecommitdiff
path: root/gdb/value.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2005-02-20 01:19:24 +0000
committerMark Kettenis <kettenis@gnu.org>2005-02-20 01:19:24 +0000
commita838e74a2ea7048ae18e36716b517747be1a0e95 (patch)
tree550e4fca4daf02813b6aac11bfb4d76010a27dee /gdb/value.c
parenta9bd2a700f1da95b477ccea6e41ff58f056ad9b1 (diff)
downloadgdb-a838e74a2ea7048ae18e36716b517747be1a0e95.tar.gz
* value.h (value_contents_equal): New prototype.
* value.c (value_contents_equal): New function. * varobj.c: Include "exceptions.h" and "gdb_assert.h". Don't include <math.h>. (varobj_set_value): Initialize error to zero. (varobj_update): Rename error2 to error and initialize it to zero. Slightly change the wording of some comments. (my_value_equal): Reimplement using TRY_CATCH and value_contents_equal.
Diffstat (limited to 'gdb/value.c')
-rw-r--r--gdb/value.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/value.c b/gdb/value.c
index eb0cc2c8633..1ab5f79de07 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -358,6 +358,26 @@ value_contents_writeable (struct value *value)
return value->aligner.contents;
}
+/* Return non-zero if VAL1 and VAL2 have the same contents. Note that
+ this function is different from value_equal; in C the operator ==
+ can return 0 even if the two values being compared are equal. */
+
+int
+value_contents_equal (struct value *val1, struct value *val2)
+{
+ struct type *type1;
+ struct type *type2;
+ int len;
+
+ type1 = check_typedef (value_type (val1));
+ type2 = check_typedef (value_type (val2));
+ len = TYPE_LENGTH (type1);
+ if (len != TYPE_LENGTH (type2))
+ return 0;
+
+ return (memcmp (value_contents (val1), value_contents (val2), len) == 0);
+}
+
int
value_optimized_out (struct value *value)
{