This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

[PATCH] Fix variable objects for references to pointers


This is a RFA for the patch below to fix variable objects for references to
pointers as previously discussed.  I've moved the changes into get_type_deref,
as suggested by Vladimir, so that they appear in one rather than four places.

Currently get_type_deref dereferences once for a reference or a pointer.  All
this patch does is dereference twice in the case of a references to a pointer.


-- 
Nick                                           http://www.inet.net.nz/~nickrob


2006-12-14  Nick Roberts  <nickrob@snap.net.nz>

	* varobj.c (get_type_deref): Fix variable objects for references to
	pointers.


*** varobj.c	09 Dec 2006 10:59:12 +1300	1.65
--- varobj.c	14 Dec 2006 17:51:46 +1300	
*************** get_type (struct varobj *var)
*** 1535,1541 ****
    return type;
  }
  
! /* This returns the type of the variable, dereferencing pointers, too. */
  static struct type *
  get_type_deref (struct varobj *var)
  {
--- 1535,1542 ----
    return type;
  }
  
! /* This returns the type of the variable, dereferencing references, pointers
!    and references to pointers, too. */
  static struct type *
  get_type_deref (struct varobj *var)
  {
*************** get_type_deref (struct varobj *var)
*** 1543,1551 ****
  
    type = get_type (var);
  
!   if (type != NULL && (TYPE_CODE (type) == TYPE_CODE_PTR
! 		       || TYPE_CODE (type) == TYPE_CODE_REF))
!     type = get_target_type (type);
  
    return type;
  }
--- 1544,1556 ----
  
    type = get_type (var);
  
!   if (type)
!     {
!       if (TYPE_CODE (type) == TYPE_CODE_REF)
! 	type = get_target_type (type);
!       if (TYPE_CODE (type) == TYPE_CODE_PTR)
! 	type = get_target_type (type);
!     }
  
    return type;
  }
*************** c_number_of_children (struct varobj *var
*** 1848,1856 ****
        break;
  
      case TYPE_CODE_PTR:
!       /* This is where things get compilcated. All pointers have one child.
           Except, of course, for struct and union ptr, which we automagically
!          dereference for the user and function ptrs, which have no children.
           We also don't dereference void* as we don't know what to show.
           We can show char* so we allow it to be dereferenced.  If you decide
           to test for it, please mind that a little magic is necessary to
--- 1853,1861 ----
        break;
  
      case TYPE_CODE_PTR:
!       /* This is where things get complicated. All pointers have one child.
           Except, of course, for struct and union ptr, which we automagically
!          dereference for the user, and function ptrs, which have no children.
           We also don't dereference void* as we don't know what to show.
           We can show char* so we allow it to be dereferenced.  If you decide
           to test for it, please mind that a little magic is necessary to


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