From: Fernando Nasser Date: Thu, 30 Mar 2000 20:15:35 +0000 (+0000) Subject: 2000-03-30 Fernando Nasser X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8310b29b55fa6a6d33400670331d3e6506773293;p=binutils-gdb.git 2000-03-30 Fernando Nasser * 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index af463a0bb3b..41c1d0b7b70 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2000-03-30 Fernando Nasser + + * 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 * ui-file.c: Include "gdb_string.h" diff --git a/gdb/varobj.c b/gdb/varobj.c index e2a241982ee..fd6120391a4 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 07ac39a31fe..83405e508a2 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)); @@ -181,6 +184,42 @@ wrap_value_equal (a) 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;