This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH]: Fix varobj.c array element handling.


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;
  }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]