This is the mail archive of the gdb-patches@sources.redhat.com 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: gdb/mi + doco] -var-update


This patch is very similar to ones that I have previously contributed for
-var-list-children and -stack-list-locals. Testcases to follow
(assuming the patch is favourably received).

Nick


Purpose:  

Currently the MI command "-var-update" gives the names of the variable objects
but not their value which must be accessed individually (using the MI command
-var-evaluate-expression). This means that a front end can take too long
processing a separate MI command for variable object. This patch adapts
"-var-update" so that it gives values, if required. The existing behaviour is
preserved for backward compatibility.

*** /home/nick/src/gdb/mi/mi-cmd-var.c.~1.21.~	2005-02-13 00:36:20.000000000 +1300
--- /home/nick/src/gdb/mi/mi-cmd-var.c	2005-02-19 22:49:18.000000000 +1300
***************
*** 32,38 ****
  
  extern int varobjdebug;		/* defined in varobj.c */
  
! static int varobj_update_one (struct varobj *var);
  
  /* VAROBJ operations */
  
--- 32,39 ----
  
  extern int varobjdebug;		/* defined in varobj.c */
  
! static int varobj_update_one (struct varobj *var,
! 			      enum print_values print_values);
  
  /* VAROBJ operations */
  
***************
*** 426,436 ****
    struct cleanup *cleanup;
    char *name;
    int nv;
  
!   if (argc != 1)
!     error (_("mi_cmd_var_update: Usage: NAME."));
  
!   name = argv[0];
  
    /* Check if the parameter is a "*" which means that we want
       to update all variables */
--- 427,450 ----
    struct cleanup *cleanup;
    char *name;
    int nv;
+   enum print_values print_values;
  
!   if (argc != 1 && argc != 2)
!     error (_("mi_cmd_var_update: Usage: [PRINT_VALUES] NAME."));
  
!   if (argc == 1)  name = argv[0];
!   else name = (argv[1]);
!  
!   if (argc == 2)
!     if (strcmp (argv[0], "0") == 0
! 	|| strcmp (argv[0], "--no-values") == 0)
!       print_values = PRINT_NO_VALUES;
!     else if (strcmp (argv[0], "1") == 0
! 	     || strcmp (argv[0], "--all-values") == 0)
!       print_values = PRINT_ALL_VALUES;
!     else
!      error (_("Unknown value for PRINT_VALUES: must be: 0 or \"--no-values\", 1 or \"--all-values\""));
!   else print_values = PRINT_NO_VALUES;
  
    /* Check if the parameter is a "*" which means that we want
       to update all variables */
***************
*** 450,456 ****
        cr = rootlist;
        while (*cr != NULL)
  	{
! 	  varobj_update_one (*cr);
  	  cr++;
  	}
        xfree (rootlist);
--- 464,470 ----
        cr = rootlist;
        while (*cr != NULL)
  	{
! 	  varobj_update_one (*cr, print_values);
  	  cr++;
  	}
        xfree (rootlist);
***************
*** 467,473 ****
          cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "changelist");
        else
          cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist");
!       varobj_update_one (var);
        do_cleanups (cleanup);
      }
      return MI_CMD_DONE;
--- 481,487 ----
          cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "changelist");
        else
          cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist");
!       varobj_update_one (var, print_values);
        do_cleanups (cleanup);
      }
      return MI_CMD_DONE;
***************
*** 478,484 ****
     scope), and 1 if it succeeds. */
  
  static int
! varobj_update_one (struct varobj *var)
  {
    struct varobj **changelist;
    struct varobj **cc;
--- 492,498 ----
     scope), and 1 if it succeeds. */
  
  static int
! varobj_update_one (struct varobj *var, enum print_values print_values)
  {
    struct varobj **changelist;
    struct varobj **cc;
***************
*** 524,529 ****
--- 538,545 ----
  	  if (mi_version (uiout) > 1)
  	    cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
  	  ui_out_field_string (uiout, "name", varobj_get_objname (*cc));
+ 	  if (print_values)
+ 	    ui_out_field_string (uiout, "value", varobj_get_value (*cc));
  	  ui_out_field_string (uiout, "in_scope", "true");
  	  ui_out_field_string (uiout, "type_changed", "false");
  	  if (mi_version (uiout) > 1)


*** /home/nick/src/gdb/doc/gdb.texinfo.~1.232.~	2005-02-13 00:36:20.000000000 +1300
--- /home/nick/src/gdb/doc/gdb.texinfo	2005-02-19 23:50:12.000000000 +1300
***************
*** 18921,18933 ****
  @subsubheading Synopsis
  
  @smallexample
!  -var-update @{@var{name} | "*"@}
  @end smallexample
  
  Update the value of the variable object @var{name} by evaluating its
  expression after fetching all the new values from memory or registers.
! A @samp{*} causes all existing variable objects to be updated.
  
  
  @node Annotations
  @chapter @value{GDBN} Annotations
--- 18921,18949 ----
  @subsubheading Synopsis
  
  @smallexample
!  -var-update [@var{print-values}] @{@var{name} | "*"@}
  @end smallexample
  
  Update the value of the variable object @var{name} by evaluating its
  expression after fetching all the new values from memory or registers.
! A @samp{*} causes all existing variable objects to be updated.  With
! just a single argument or with an optional preceding argument of 0 or
! @code{--no-values}, prints only the names of the variables.  With an
! optional preceding argument of 1 or @code{--all-values}, also prints
! their values.
  
+ @subsubheading Example
+ 
+ @smallexample
+ (@value{GDBP})
+ -var-assign var1 3
+ ^done,value="3"
+ (@value{GDBP})
+ -var-update --all-values *
+ ^done,changelist=[@{name="var1",value="3",in_scope="true",
+ type_changed="false"@}]
+ (@value{GDBP})
+ @end smallexample
  
  @node Annotations
  @chapter @value{GDBN} Annotations


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