+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"
struct varobj *parent;
int index;
{
- value_ptr value, temp;
+ value_ptr value, temp, indval;
struct type *type, *target;
char *name;
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:
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));
return 1;
}
+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;