public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* [PATCH]: Fix varobj.c array element handling.
@ 2000-03-30 11:47 Fernando Nasser
  0 siblings, 0 replies; only message in thread
From: Fernando Nasser @ 2000-03-30 11:47 UTC (permalink / raw)
  To: gdb-patches, insight

As soon as Michael Snyder gets his change to wrapper.c in I will check an adjusted version of the following patch.

This updates the code that handles array elements.  The old code works for arrays that reside in memory but breaks for
arrays that live in registers.


-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@cygnus.com
2323 Yonge Street, Suite #300           Tel:  416-482-2661 ext. 311
Toronto, Ontario   M4P 2C9              Fax:  416-482-6299


Index: varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/varobj.c,v
retrieving revision 1.2
diff -c -p -r1.2 varobj.c
*** varobj.c    2000/03/13 21:51:45     1.2
--- varobj.c    2000/03/30 19:44:23
*************** c_value_of_child (parent, index)
*** 1954,1960 ****
       struct varobj *parent;
       int index;
  {
!   value_ptr value, temp;
    struct type *type, *target;
    char *name;
  
--- 1954,1960 ----
       struct varobj *parent;
       int index;
  {
!   value_ptr value, temp, indval;
    struct type *type, *target;
    char *name;
  
*************** c_value_of_child (parent, index)
*** 1969,1977 ****
--- 1969,1983 ----
        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:
Index: wrapper.c
===================================================================
RCS file: /cvs/src/src/gdb/wrapper.c,v
retrieving revision 1.2
diff -c -p -r1.2 wrapper.c
*** wrapper.c   2000/03/13 21:51:45     1.2
--- wrapper.c   2000/03/30 19:44:23
*************** int wrap_value_fetch_lazy PARAMS ((char 
*** 46,51 ****
--- 46,54 ----
  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));
  
*************** wrap_value_equal (a)
*** 169,174 ****
--- 172,213 ----
    val2 = (value_ptr) (args)->args[1];
  
    (args)->result = (char *) value_equal (val1, val2);
+   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] = (char *) val1;
+   args.args[1] = (char *) val2;
+ 
+   if (!catch_errors ((catch_errors_ftype *) wrap_value_subscript, &args,
+                    "", RETURN_MASK_ERROR))
+     {
+       /* An error occurred */
+       return 0;
+     }
+ 
+   *rval = (value_ptr) args.result;
+   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];
+   val2 = (value_ptr) (args)->args[1];
+ 
+   (args)->result = (char *) value_subscript (val1, val2);
    return 1;
  }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-03-30 11:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-30 11:47 [PATCH]: Fix varobj.c array element handling Fernando Nasser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).