void UpdateVariable(IVariable variable) { TreeRowReference row = (TreeRowReference)variable_rows[variable]; if (row == null) { /* the variable isn't presently displayed */ if (!variable.IsAlive (current_frame.TargetAddress)) /* it's not displayed and not alive, just return */ return; AddVariable (variable); } else { /* the variable is presently displayed */ // XXX we need a obj.IsValid check in this branch if (!variable.IsAlive (current_frame.TargetAddress)) { /* it's in the display but no longer alive. remove it */ RemoveVariable (variable); return; } /* it's still alive - make sure the display is up to date */ TreeIter iter; if (store.GetIter (out iter, row.Path)) { try { ITargetObject obj = variable.GetObject (current_frame); /* make sure the Value column is correct */ string current_value = (string)store.GetValue (iter, VALUE_COL); string new_value = GetObjectValueString (obj); if (current_value != new_value) store.SetValue (iter, VALUE_COL, new_value); /* update the children */ UpdateVariableChildren (variable, obj, row.Path, iter); } catch (Exception e) { Console.WriteLine ("can't update variable: {0} {1}", variable, e); store.SetValue (iter, VALUE_COL, ""); } } } }
void AddVariable(IVariable variable) { try { /* it's alive, add it to the display */ ITargetObject obj = variable.GetObject (current_frame); TreeIter iter; if (!obj.IsValid) return; store.Append (out iter); variable_rows.Add (variable, new TreeRowReference (store, store.GetPath (iter))); AddObject (variable.Name, GetIcon (obj), obj, iter); } catch (LocationInvalidException) { // Do nothing } catch (Exception e) { Console.WriteLine ("can't add variable: {0} {1}", variable, e); } }