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]
Other format: [Raw text]

[patch] variable window bug


Fixes a bug when updating a variable's value causes an error.  For
example, dereferencing a null pointer.

2002-12-03  Martin M. Hunt  <hunt@redhat.com>

	* library/vartree.itb (buildlayer): Check for error when
	updating a variable's value.
	(update_var): Ditto.



Index: vartree.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/vartree.itb,v
retrieving revision 1.2
diff -p -r1.2 vartree.itb
*** vartree.itb	11 Nov 2002 22:29:24 -0000	1.2
--- vartree.itb	3 Dec 2002 23:44:20 -0000
*************** itcl::body  VarTree::buildlayer {tlist i
*** 71,77 ****
      set x [expr [lindex [$c bbox $j1] 2] + 5]
      set j2 [$c create text $x $y -text "([$var type])" -fill $colors(type) -anchor w -font global/fixed]
      set x [expr [lindex [$c bbox $j2] 2] + 5]
!     set j3 [$c create text $x $y -text "[$var value]" -fill $colors(value) -anchor w -font global/fixed]
  
      set var_to_items($var) [list $j1 $j2 $j3]
      set item_to_var($j1) $var
--- 71,82 ----
      set x [expr [lindex [$c bbox $j1] 2] + 5]
      set j2 [$c create text $x $y -text "([$var type])" -fill $colors(type) -anchor w -font global/fixed]
      set x [expr [lindex [$c bbox $j2] 2] + 5]
!     if {[catch {$var value} val]} {
!       # error accessing memory, etc.
!       set j3 [$c create text $x $y -text $val -fill $colors(error) -anchor w -font global/fixed]      
!     } else {
!       set j3 [$c create text $x $y -text $val -fill $colors(value) -anchor w -font global/fixed]
!     }
  
      set var_to_items($var) [list $j1 $j2 $j3]
      set item_to_var($j1) $var
*************** itcl::body  VarTree::update_var {var ena
*** 126,136 ****
    if {$enabled} {
      $c itemconfigure $nam -fill $colors(name)
      $c itemconfigure $typ -fill $colors(type)
!     if {[$c itemcget $val -text] != [$var value]} {
!       $c itemconfigure $val -text [$var value] -fill $colors(change)
      } else {
!       $c itemconfigure $val -text [$var value] -fill $colors(value)
      }
    } else {
      $c itemconfigure $nam -fill $colors(disabled)
      $c itemconfigure $typ -fill $colors(disabled)
--- 131,145 ----
    if {$enabled} {
      $c itemconfigure $nam -fill $colors(name)
      $c itemconfigure $typ -fill $colors(type)
! 
!     if {[catch {$var value} value]} {
!       set color $colors(error)      
!     } elseif {[$c itemcget $val -text] != $value} {
!       set color $colors(change)
      } else {
!       set color $colors(value)
      }
+     $c itemconfigure $val -text $value -fill $color
    } else {
      $c itemconfigure $nam -fill $colors(disabled)
      $c itemconfigure $typ -fill $colors(disabled)
*************** itcl::body  VarTree::_compare {a b} {
*** 381,386 ****
--- 390,396 ----
  itcl::body  VarTree::_init_data {} {
    set colors(name) "\#0000C0"
    set colors(type) "red"
+   set colors(error) "red"
    set colors(value) "black"
    set colors(change) "green"
    set colors(disabled) "gray50"

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