This is the mail archive of the insight@sources.redhat.com mailing list for the Insight project.


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

Re: Variable errors


Keith Seitz wrote:
> 
> On Wed, 11 Apr 2001, Fernando Nasser wrote:
> 
> > I guess you're right, I forgot the scalars.  Try this patch (*UNTESTED*)
> > for now.  I will flag the varobj name if the type has changed over the
> > weekend.  Until I do this, variables that change type from scalar to
> > scalar (different types) will be highlighted.
> 

Well, it took a while, but I now have the patch to address Keith's concerns.

The indication that the type of the variable has changed (well, it is another variable with the same name actually) is now returned and can be tested regardless of the old variable being a scalar or a complex type.  It seems to work in all cases now.

Please give it a spin and let me know if you like it.

Cheers,
Fernando


-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9
Index: gdbtk/generic/gdbtk-varobj.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-varobj.c,v
retrieving revision 1.6
diff -c -p -r1.6 gdbtk-varobj.c
*** gdbtk-varobj.c	2001/03/29 22:17:45	1.6
--- gdbtk-varobj.c	2001/05/08 00:27:16
*************** variable_update (interp, var)
*** 463,475 ****
    Tcl_Obj *changed;
    struct varobj **changelist;
    struct varobj **vc;
  
    changed = Tcl_NewListObj (0, NULL);
  
    /* varobj_update() can return -1 if the variable is no longer around,
       i.e. we stepped out of the frame in which a local existed. */
!   if (varobj_update (var, &changelist) == -1)
      return changed;
  
    vc = changelist;
    while (*vc != NULL)
--- 463,487 ----
    Tcl_Obj *changed;
    struct varobj **changelist;
    struct varobj **vc;
+   int numchanged;
  
    changed = Tcl_NewListObj (0, NULL);
+   
+   numchanged = varobj_update (var, &changelist);
  
    /* varobj_update() can return -1 if the variable is no longer around,
       i.e. we stepped out of the frame in which a local existed. */
!   if (numchanged == -1)
      return changed;
+     
+   /* varobj_update() can return -2 if the variable type changed,
+      i.e. we are looking at a different variable with the same name. */
+   if (numchanged == -2)
+     {
+       /* Add a type changed mark to the result list */
+       Tcl_ListObjAppendElement (NULL, changed,
+ 			   Tcl_NewStringObj ("*", -1));
+     }
  
    vc = changelist;
    while (*vc != NULL)
Index: gdbtk/library/variables.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/variables.tcl,v
retrieving revision 1.8
diff -c -p -r1.8 variables.tcl
*** variables.tcl	2001/04/17 16:14:23	1.8
--- variables.tcl	2001/05/08 00:27:17
*************** class VariableWin {
*** 827,846 ****
  	    # debug "VARIABLE: $var ($Update($this,$var))"
              set numchild [$var numChildren]
  	    set UpdatedList [$var update]
!             # FIXME: For now, we can only infer that the type has changed
!             # if the variable is not a scalar; the varobj code will have to
!             # give us an indication that this happened.
!             if {([lindex $UpdatedList 0] == $var)
!                 && ($numchild > 0)} {
                debug "Type changed."
                # We must fix the tree entry to correspond to the new type
!               $Hlist delete offsprings $var
                $Hlist entryconfigure $var -text [label $var]
                if {[$var numChildren] > 0} {
                  $Tree setmode $var open
                } else {
                  $Tree setmode $var none
                }
              } else {
  	      set ChangeList [concat $ChangeList $UpdatedList]
  	      # debug "ChangeList=$ChangeList"
--- 827,852 ----
  	    # debug "VARIABLE: $var ($Update($this,$var))"
              set numchild [$var numChildren]
  	    set UpdatedList [$var update]
! 	    
!             # A '*' indicates the the type of the following variable has changed.
! 	    if {[lindex $UpdatedList 0] == "*"} {
                debug "Type changed."
+ 
                # We must fix the tree entry to correspond to the new type
! 	      if {$numchild > 0} {
! 	        # If previous type had children remove them.
!                 $Hlist delete offsprings $var
! 	      }
                $Hlist entryconfigure $var -text [label $var]
                if {[$var numChildren] > 0} {
                  $Tree setmode $var open
                } else {
                  $Tree setmode $var none
                }
+ 	      
+ 	      # Must remove the type changed indicator
+ 	      set ChangeList [concat $ChangeList [lrange $UpdatedList 1 end]]
+ 
              } else {
  	      set ChangeList [concat $ChangeList $UpdatedList]
  	      # debug "ChangeList=$ChangeList"

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