Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Nick Roberts <nickrob@snap.net.nz>
To: Vladimir Prus <ghost@cs.msu.su>
Cc: Daniel Jacobowitz <drow@false.org>, 	gdb-patches@sources.redhat.com
Subject: Re: RFC: MI - Detecting change of string contents with variable objects
Date: Fri, 05 Jan 2007 04:46:00 -0000	[thread overview]
Message-ID: <17821.55336.12928.800849@kahikatea.snap.net.nz> (raw)
In-Reply-To: <200701042358.59475.ghost@cs.msu.su>

 > > I'm not sure if we'll do that any more after your patch, e.g. if something
 > > beyond the limit of "set print elements" changes.  So, do you think any
 > > front end relies on the parent being marked updated if any of its children
 > > are?  Vlad, any opinion?
 > 
 > I think the code in question is never executed for structures or arrays --
 > only for "changeable" values.

I agree.  Below is my latest patch, incorporating some of your suggestions.


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


*** varobj.c	05 Jan 2007 13:16:30 +1300	1.74
--- varobj.c	05 Jan 2007 15:41:23 +1300	
*************** struct varobj
*** 132,137 ****
--- 132,140 ----
  
    /* Was this variable updated via a varobj_set_value operation */
    int updated;
+ 
+   /* Last print value.  */
+   char *print_value;
  };
  
  struct cpstack
*************** static int variable_editable (struct var
*** 206,211 ****
--- 209,217 ----
  
  static char *my_value_of_variable (struct varobj *var);
  
+ static char *value_get_print_value (struct value *value,
+ 				    enum varobj_display_formats format);
+ 
  static int varobj_value_is_changeable_p (struct varobj *var);
  
  static int is_root_p (struct varobj *var);
*************** install_new_value (struct varobj *var, s
*** 953,959 ****
    /* If the type is changeable, compare the old and the new values.
       If this is the initial assignment, we don't have any old value
       to compare with.  */
!   if (!initial && changeable)
      {
        /* If the value of the varobj was changed by -var-set-value, then the 
  	 value in the varobj and in the target is the same.  However, that value
--- 959,967 ----
    /* If the type is changeable, compare the old and the new values.
       If this is the initial assignment, we don't have any old value
       to compare with.  */
!   if (initial)
!     var->print_value = value_get_print_value (value, var->format);
!   else if (changeable)
      {
        /* If the value of the varobj was changed by -var-set-value, then the 
  	 value in the varobj and in the target is the same.  However, that value
*************** install_new_value (struct varobj *var, s
*** 974,999 ****
  	    changed = 1;
  	  else
  	    {
  	      gdb_assert (!value_lazy (var->value));
! 	      gdb_assert (!value_lazy (value));
! 	      
! 	      if (!value_contents_equal (var->value, value))
! 		changed = 1;
  	    }
  	}
      }
!     
    /* We must always keep the new value, since children depend on it.  */
    if (var->value != NULL)
      value_free (var->value);
    var->value = value;
    var->updated = 0;
!   
    gdb_assert (!var->value || value_type (var->value));
  
    return changed;
  }
-   
  
  /* Update the values for a variable and its children.  This is a
     two-pronged attack.  First, re-parse the value for the root's
--- 982,1013 ----
  	    changed = 1;
  	  else
  	    {
+ 	      char *print_value;
  	      gdb_assert (!value_lazy (var->value));
! 	      print_value = value_get_print_value (value, var->format);
! 
! 	      if (strcmp (var->print_value, print_value))
! 		{
! 		  xfree (var->print_value);
! 		  var->print_value = print_value;
! 		  changed = 1;
! 		}
! 	      else
! 		xfree (print_value);
  	    }
  	}
      }
! 
    /* We must always keep the new value, since children depend on it.  */
    if (var->value != NULL)
      value_free (var->value);
    var->value = value;
    var->updated = 0;
! 
    gdb_assert (!var->value || value_type (var->value));
  
    return changed;
  }
  
  /* Update the values for a variable and its children.  This is a
     two-pronged attack.  First, re-parse the value for the root's
*************** new_variable (void)
*** 1376,1381 ****
--- 1390,1396 ----
    var->format = 0;
    var->root = NULL;
    var->updated = 0;
+   var->print_value = NULL;
  
    return var;
  }
*************** free_variable (struct varobj *var)
*** 1409,1414 ****
--- 1424,1430 ----
  
    xfree (var->name);
    xfree (var->obj_name);
+   xfree (var->print_value);
    xfree (var);
  }
  
*************** my_value_of_variable (struct varobj *var
*** 1666,1671 ****
--- 1682,1701 ----
    return (*var->root->lang->value_of_variable) (var);
  }
  
+ static char *
+ value_get_print_value (struct value *value, enum varobj_display_formats format)
+ {
+   long dummy;
+   struct ui_file *stb = mem_fileopen ();
+   struct cleanup *old_chain = make_cleanup_ui_file_delete (stb);
+   char *thevalue;
+ 	    
+   common_val_print (value, stb, format_code[(int) format], 1, 0, 0);
+   thevalue = ui_file_xstrdup (stb, &dummy);
+   do_cleanups (old_chain);
+   return thevalue;
+ }
+ 
  /* Return non-zero if changes in value of VAR
     must be detected and reported by -var-update.
     Return zero is -var-update should never report
*************** c_value_of_variable (struct varobj *var)
*** 2038,2056 ****
  	  }
  	else
  	  {
- 	    long dummy;
- 	    struct ui_file *stb = mem_fileopen ();
- 	    struct cleanup *old_chain = make_cleanup_ui_file_delete (stb);
- 	    char *thevalue;
- 
  	    gdb_assert (varobj_value_is_changeable_p (var));
  	    gdb_assert (!value_lazy (var->value));
! 	    common_val_print (var->value, stb,
! 			      format_code[(int) var->format], 1, 0, 0);
! 	    thevalue = ui_file_xstrdup (stb, &dummy);
! 	    do_cleanups (old_chain);
! 	return thevalue;
!       }
        }
      }
  }
--- 2068,2077 ----
  	  }
  	else
  	  {
  	    gdb_assert (varobj_value_is_changeable_p (var));
  	    gdb_assert (!value_lazy (var->value));
! 	    return value_get_print_value (var->value, var->format);
! 	  }
        }
      }
  }


  reply	other threads:[~2007-01-05  4:46 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-18  2:42 Nick Roberts
2006-12-18  7:01 ` Vladimir Prus
2006-12-18  8:15   ` Nick Roberts
2006-12-18  8:36     ` Vladimir Prus
2006-12-18 13:38       ` Daniel Jacobowitz
2006-12-18 21:57         ` Nick Roberts
2006-12-21 15:25           ` Vladimir Prus
2006-12-21 22:28             ` Nick Roberts
2006-12-22  6:16               ` Vladimir Prus
2006-12-22  7:16                 ` Nick Roberts
2006-12-22  7:23                   ` Vladimir Prus
2007-01-03 22:46           ` Daniel Jacobowitz
2007-01-04  4:13             ` Nick Roberts
2007-01-04  4:20               ` Daniel Jacobowitz
2007-01-04  6:10                 ` Nick Roberts
2007-01-04 19:40                   ` Daniel Jacobowitz
2007-01-04 20:35                     ` Nick Roberts
2007-01-04 20:50                       ` Daniel Jacobowitz
2007-01-04 21:00                         ` Vladimir Prus
2007-01-05  4:46                           ` Nick Roberts [this message]
2007-01-05 14:49                             ` Daniel Jacobowitz
2007-01-05 21:54                               ` Nick Roberts
2007-01-06  7:07                                 ` Vladimir Prus
2007-01-08 15:51                                 ` Daniel Jacobowitz
2007-01-08 21:30                                   ` Nick Roberts
2007-01-08 21:41                                     ` Daniel Jacobowitz
2007-01-04 20:57                       ` Vladimir Prus
2007-01-05  2:26                         ` Nick Roberts
2007-01-04 21:05                   ` Vladimir Prus
2007-01-05  1:09                     ` Nick Roberts
2007-01-05 14:44                       ` Daniel Jacobowitz
2007-01-05 14:49                         ` Vladimir Prus
2007-01-05 16:04                       ` Jim Blandy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17821.55336.12928.800849@kahikatea.snap.net.nz \
    --to=nickrob@snap.net.nz \
    --cc=drow@false.org \
    --cc=gdb-patches@sources.redhat.com \
    --cc=ghost@cs.msu.su \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox