aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorFernando Nasser <fnasser@redhat.com>2000-03-30 20:15:35 +0000
committerFernando Nasser <fnasser@redhat.com>2000-03-30 20:15:35 +0000
commit8310b29b55fa6a6d33400670331d3e6506773293 (patch)
tree32e7167635c5de4b5180eec16cd5b7b14ebfd2ee /gdb
parent1d1358b6679fee0ea559723c6c9b06c900e7c330 (diff)
downloadgdb-8310b29b55fa6a6d33400670331d3e6506773293.zip
gdb-8310b29b55fa6a6d33400670331d3e6506773293.tar.gz
gdb-8310b29b55fa6a6d33400670331d3e6506773293.tar.bz2
2000-03-30 Fernando Nasser <fnasser@cygnus.com>
* wrapper.c (gdb_value_subscript, wrap_value_subscript): New functions. Safe version of value_subscript. * varobj.c (): Use gdb_value_subscript() to get an array element value.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/varobj.c8
-rw-r--r--gdb/wrapper.c39
3 files changed, 52 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index af463a0..41c1d0b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2000-03-30 Fernando Nasser <fnasser@cygnus.com>
+
+ * wrapper.c (gdb_value_subscript, wrap_value_subscript): New functions.
+ Safe version of value_subscript.
+ * varobj.c (): Use gdb_value_subscript() to get an array element value.
+
2000-03-30 Michael Snyder <msnyder@cleaver.cygnus.com>
* ui-file.c: Include "gdb_string.h"
diff --git a/gdb/varobj.c b/gdb/varobj.c
index e2a2419..fd61203 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -1954,7 +1954,7 @@ c_value_of_child (parent, index)
struct varobj *parent;
int index;
{
- value_ptr value, temp;
+ value_ptr value, temp, indval;
struct type *type, *target;
char *name;
@@ -1969,9 +1969,15 @@ c_value_of_child (parent, index)
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
+#if 0
+ /* This breaks if the array lives in a (vector) register. */
value = value_slice (temp, index, 1);
temp = value_coerce_array (value);
gdb_value_ind (temp, &value);
+#else
+ indval = value_from_longest (builtin_type_int, (LONGEST) index);
+ gdb_value_subscript (temp, indval, &value);
+#endif
break;
case TYPE_CODE_STRUCT:
diff --git a/gdb/wrapper.c b/gdb/wrapper.c
index 07ac39a..83405e5 100644
--- a/gdb/wrapper.c
+++ b/gdb/wrapper.c
@@ -55,6 +55,9 @@ int wrap_value_fetch_lazy PARAMS ((char *));
int gdb_value_equal PARAMS ((value_ptr, value_ptr, int *));
int wrap_value_equal PARAMS ((char *));
+int gdb_value_subscript PARAMS ((value_ptr, value_ptr, value_ptr * rval));
+int wrap_value_subscript PARAMS ((char *));
+
int gdb_value_ind PARAMS ((value_ptr val, value_ptr * rval));
int wrap_value_ind PARAMS ((char *opaque_arg));
@@ -182,6 +185,42 @@ wrap_value_equal (a)
}
int
+gdb_value_subscript (val1, val2, rval)
+ value_ptr val1;
+ value_ptr val2;
+ value_ptr * rval;
+{
+ struct gdb_wrapper_arguments args;
+
+ args.args[0].pointer = val1;
+ args.args[1].pointer = val2;
+
+ if (!catch_errors ((catch_errors_ftype *) wrap_value_subscript, &args,
+ "", RETURN_MASK_ERROR))
+ {
+ /* An error occurred */
+ return 0;
+ }
+
+ *rval = (value_ptr) args.result.pointer;
+ return 1;
+}
+
+int
+wrap_value_subscript (a)
+ char *a;
+{
+ struct gdb_wrapper_arguments *args = (struct gdb_wrapper_arguments *) a;
+ value_ptr val1, val2;
+
+ val1 = (value_ptr) (args)->args[0].pointer;
+ val2 = (value_ptr) (args)->args[1].pointer;
+
+ (args)->result.pointer = value_subscript (val1, val2);
+ return 1;
+}
+
+int
gdb_value_ind (val, rval)
value_ptr val;
value_ptr *rval;