Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* {commit: gdb/mi] -stack-list-locals and -var-list-children
@ 2004-01-20  1:27 Nick Roberts
  2004-01-20  5:49 ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Roberts @ 2004-01-20  1:27 UTC (permalink / raw)
  To: gdb-patches

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 15524 bytes --]


I've comitted the patches below. Testcases don't work for me but I've kept the
status quo so they should work for others. Diff's have been made with Emacs
backup files - sorry, should have made the patches before committing, done
off-line - 64k modem, family to feed etc. I hope they work... Well they
compile anyway.


    Nick                                         http://www.nick.uklinux.net



2004-01-20  Nick Roberts  <nick at nick dot uklinux dot net>

	* mi/mi-cmds.h (enum print_values): Add definition.

	* mi/mi-cmd-stack.c (mi_cmd_stack_list_locals): Print the name,
	type and value for simple data types and just the name and type
	for complex ones, if required.

	* mi/mi-cmd-var.c (mi_cmd_var_list_children): Print the values of the
	children, if required.

2004-01-19  Nick Roberts  <nick at nick dot uklinux dot net>

	* gdb.texinfo (GDB/MI Stack Manipulation): Describe extension to
	-stack-list-locals.
	(GDB/MI Variable Objects): Describe extension to
	-var-list-children.

2004-01-20  Nick Roberts  <nick at nick dot uklinux dot net>

	* gdb.mi/mi-stack.exp (test_stack_locals_listing): Test for
	case "-stack-list-locals 2".
	* gdb.mi/mi-var-child.exp: Test for case
	"-var-list-children --all-values NAME".

*** /home/nick/gdb/gdb/mi/mi-cmds.h~	2003-08-05 00:18:50.000000000 +0100
--- /home/nick/gdb/gdb/mi/mi-cmds.h	2004-01-19 23:25:52.000000000 +0000
***************
*** 48,53 ****
--- 48,59 ----
      MI_CMD_QUIET
    };
  
+ enum print_values {
+    PRINT_NO_VALUES,
+    PRINT_ALL_VALUES,
+    PRINT_SIMPLE_VALUES
+ };
+ 
  typedef enum mi_cmd_result (mi_cmd_argv_ftype) (char *command, char **argv, int argc);
  
  /* Older MI commands have this interface. Retained until all old

*** /home/nick/gdb/gdb/mi/mi-cmd-stack.c~	2003-06-12 00:29:49.000000000 +0100
--- /home/nick/gdb/gdb/mi/mi-cmd-stack.c	2004-01-19 23:27:51.000000000 +0000
***************
*** 29,34 ****
--- 29,35 ----
  #include "block.h"
  #include "stack.h"
  #include "dictionary.h"
+ #include "gdb_string.h"
  
  static void list_args_or_locals (int locals, int values, struct frame_info *fi);
  
***************
*** 137,146 ****
  enum mi_cmd_result
  mi_cmd_stack_list_locals (char *command, char **argv, int argc)
  {
    if (argc != 1)
      error ("mi_cmd_stack_list_locals: Usage: PRINT_VALUES");
  
!   list_args_or_locals (1, atoi (argv[0]), deprecated_selected_frame);
    return MI_CMD_DONE;
  }
  
--- 138,163 ----
  enum mi_cmd_result
  mi_cmd_stack_list_locals (char *command, char **argv, int argc)
  {
+   struct frame_info *frame;
+   enum print_values print_values;
+ 
    if (argc != 1)
      error ("mi_cmd_stack_list_locals: Usage: PRINT_VALUES");
  
!    frame = get_selected_frame ();
! 
!    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 if (strcmp (argv[0], "2") == 0
! 	    || strcmp (argv[0], "--simple-values") == 0)
!      print_values = PRINT_SIMPLE_VALUES;
!    else
!      error ("Unknown value for PRINT_VALUES: must be: 0 or \"--no-values\", 1 or \"--all-values\", 2 or \"--simple-values\"");
!   list_args_or_locals (1, print_values, frame);
    return MI_CMD_DONE;
  }
  
***************
*** 218,223 ****
--- 235,241 ----
    int nsyms;
    struct cleanup *cleanup_list;
    static struct ui_stream *stb = NULL;
+   struct type *type;
  
    stb = ui_out_stream_new (uiout);
  
***************
*** 268,291 ****
  	  if (print_me)
  	    {
  	      struct cleanup *cleanup_tuple = NULL;
! 	      if (values)
! 		cleanup_tuple = 
  		  make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
! 	      ui_out_field_string (uiout, "name", DEPRECATED_SYMBOL_NAME (sym));
  
! 	      if (values)
! 		{
! 		  struct symbol *sym2;
! 		  if (!locals)
! 		    sym2 = lookup_symbol (DEPRECATED_SYMBOL_NAME (sym),
! 					  block, VAR_DOMAIN,
! 					  (int *) NULL,
! 					  (struct symtab **) NULL);
! 		  else
  		    sym2 = sym;
  		  print_variable_value (sym2, fi, stb->stream);
  		  ui_out_field_stream (uiout, "value", stb);
  		  do_cleanups (cleanup_tuple);
  		}
  	    }
  	}
--- 286,324 ----
  	  if (print_me)
  	    {
  	      struct cleanup *cleanup_tuple = NULL;
! 	      if (values != PRINT_NO_VALUES)
! 		cleanup_tuple =
  		  make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
! 	      ui_out_field_string (uiout, "name", SYMBOL_PRINT_NAME (sym));
  
! 	      struct symbol *sym2;
! 	      if (!locals)
! 		sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym),
! 				      block, VAR_DOMAIN,
! 				      (int *) NULL,
! 				      (struct symtab **) NULL);
! 	      else
  		    sym2 = sym;
+ 	      switch (values)
+ 		{
+ 		case PRINT_SIMPLE_VALUES:
+ 		  type = check_typedef (sym2->type);
+ 		  type_print (sym2->type, "", stb->stream, -1);
+ 		  ui_out_field_stream (uiout, "type", stb);
+ 		  if (TYPE_CODE (type) != TYPE_CODE_ARRAY
+ 		      && TYPE_CODE (type) != TYPE_CODE_STRUCT
+ 		      && TYPE_CODE (type) != TYPE_CODE_UNION)
+ 		    {
+ 		      print_variable_value (sym2, fi, stb->stream);
+ 		      ui_out_field_stream (uiout, "value", stb);
+ 		    }
+ 		  do_cleanups (cleanup_tuple);
+ 		  break;
+ 		case PRINT_ALL_VALUES:
  		  print_variable_value (sym2, fi, stb->stream);
  		  ui_out_field_stream (uiout, "value", stb);
  		  do_cleanups (cleanup_tuple);
+ 		  break;
  		}
  	    }
  	}

*** /home/nick/gdb/gdb/mi/mi-cmd-stack.c~	2003-06-12 00:29:49.000000000 +0100
--- /home/nick/gdb/gdb/mi/mi-cmd-stack.c	2004-01-19 23:27:51.000000000 +0000
***************
*** 29,34 ****
--- 29,35 ----
  #include "block.h"
  #include "stack.h"
  #include "dictionary.h"
+ #include "gdb_string.h"
  
  static void list_args_or_locals (int locals, int values, struct frame_info *fi);
  
***************
*** 137,146 ****
  enum mi_cmd_result
  mi_cmd_stack_list_locals (char *command, char **argv, int argc)
  {
    if (argc != 1)
      error ("mi_cmd_stack_list_locals: Usage: PRINT_VALUES");
  
!   list_args_or_locals (1, atoi (argv[0]), deprecated_selected_frame);
    return MI_CMD_DONE;
  }
  
--- 138,163 ----
  enum mi_cmd_result
  mi_cmd_stack_list_locals (char *command, char **argv, int argc)
  {
+   struct frame_info *frame;
+   enum print_values print_values;
+ 
    if (argc != 1)
      error ("mi_cmd_stack_list_locals: Usage: PRINT_VALUES");
  
!    frame = get_selected_frame ();
! 
!    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 if (strcmp (argv[0], "2") == 0
! 	    || strcmp (argv[0], "--simple-values") == 0)
!      print_values = PRINT_SIMPLE_VALUES;
!    else
!      error ("Unknown value for PRINT_VALUES: must be: 0 or \"--no-values\", 1 or \"--all-values\", 2 or \"--simple-values\"");
!   list_args_or_locals (1, print_values, frame);
    return MI_CMD_DONE;
  }
  
***************
*** 218,223 ****
--- 235,241 ----
    int nsyms;
    struct cleanup *cleanup_list;
    static struct ui_stream *stb = NULL;
+   struct type *type;
  
    stb = ui_out_stream_new (uiout);
  
***************
*** 268,291 ****
  	  if (print_me)
  	    {
  	      struct cleanup *cleanup_tuple = NULL;
! 	      if (values)
! 		cleanup_tuple = 
  		  make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
! 	      ui_out_field_string (uiout, "name", DEPRECATED_SYMBOL_NAME (sym));
  
! 	      if (values)
! 		{
! 		  struct symbol *sym2;
! 		  if (!locals)
! 		    sym2 = lookup_symbol (DEPRECATED_SYMBOL_NAME (sym),
! 					  block, VAR_DOMAIN,
! 					  (int *) NULL,
! 					  (struct symtab **) NULL);
! 		  else
  		    sym2 = sym;
  		  print_variable_value (sym2, fi, stb->stream);
  		  ui_out_field_stream (uiout, "value", stb);
  		  do_cleanups (cleanup_tuple);
  		}
  	    }
  	}
--- 286,324 ----
  	  if (print_me)
  	    {
  	      struct cleanup *cleanup_tuple = NULL;
! 	      if (values != PRINT_NO_VALUES)
! 		cleanup_tuple =
  		  make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
! 	      ui_out_field_string (uiout, "name", SYMBOL_PRINT_NAME (sym));
  
! 	      struct symbol *sym2;
! 	      if (!locals)
! 		sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym),
! 				      block, VAR_DOMAIN,
! 				      (int *) NULL,
! 				      (struct symtab **) NULL);
! 	      else
  		    sym2 = sym;
+ 	      switch (values)
+ 		{
+ 		case PRINT_SIMPLE_VALUES:
+ 		  type = check_typedef (sym2->type);
+ 		  type_print (sym2->type, "", stb->stream, -1);
+ 		  ui_out_field_stream (uiout, "type", stb);
+ 		  if (TYPE_CODE (type) != TYPE_CODE_ARRAY
+ 		      && TYPE_CODE (type) != TYPE_CODE_STRUCT
+ 		      && TYPE_CODE (type) != TYPE_CODE_UNION)
+ 		    {
+ 		      print_variable_value (sym2, fi, stb->stream);
+ 		      ui_out_field_stream (uiout, "value", stb);
+ 		    }
+ 		  do_cleanups (cleanup_tuple);
+ 		  break;
+ 		case PRINT_ALL_VALUES:
  		  print_variable_value (sym2, fi, stb->stream);
  		  ui_out_field_stream (uiout, "value", stb);
  		  do_cleanups (cleanup_tuple);
+ 		  break;
  		}
  	    }
  	}
*** /home/nick/gdb/gdb/doc/gdb.texinfo~	2004-01-19 23:11:48.000000000 +0000
--- /home/nick/gdb/gdb/doc/gdb.texinfo	2004-01-19 23:25:02.000000000 +0000
***************
*** 17206,17213 ****
  @end smallexample
  
  Display the local variable names for the current frame.  With an
! argument of 0 prints only the names of the variables, with argument of 1
! prints also their values.
  
  @subsubheading @value{GDBN} Command
  
--- 17206,17219 ----
  @end smallexample
  
  Display the local variable names for the current frame.  With an
! argument of 0 or @code{--no-values}, prints only the names of the variables.
! With argument of 1 or @code{--all-values}, prints also their values.  With
! argument of 2 or @code{--simple-values}, prints the name, type and value for
! simple data types and the name and type for arrays, structures and
! unions.  In this last case, the idea is that the user can see the
! value of simple data types immediately and he can create variable
! objects for other data types if he wishes to explore their values in
! more detail.
  
  @subsubheading @value{GDBN} Command
  
***************
*** 17220,17228 ****
  -stack-list-locals 0
  ^done,locals=[name="A",name="B",name="C"]
  (@value{GDBP})
! -stack-list-locals 1
  ^done,locals=[@{name="A",value="1"@},@{name="B",value="2"@},
!   @{name="C",value="3"@}]
  (@value{GDBP})
  @end smallexample
  
--- 17226,17237 ----
  -stack-list-locals 0
  ^done,locals=[name="A",name="B",name="C"]
  (@value{GDBP})
! -stack-list-locals --all-values
  ^done,locals=[@{name="A",value="1"@},@{name="B",value="2"@},
!   @{name="C",value="@{1, 2, 3@}"@}]
! -stack-list-locals --simple-values
! ^done,locals=[@{name="A",type="int",value="1"@},
!   @{name="B",type="int",value="2"@},@{name="C",type="int [3]"@}]
  (@value{GDBP})
  @end smallexample
  
***************
*** 18166,18179 ****
  @subsubheading Synopsis
  
  @smallexample
!  -var-list-children @var{name}
  @end smallexample
  
! Returns a list of the children of the specified variable object:
  
  @smallexample
   numchild=@var{n},children=[@{name=@var{name},
   numchild=@var{n},type=@var{type}@},@r{(repeats N times)}]
  @end smallexample
  
  
--- 18175,18200 ----
  @subsubheading Synopsis
  
  @smallexample
!  -var-list-children [@var{print-values}] @var{name}
  @end smallexample
  
! Returns a list of the children of the specified variable object.  With
! just the variable object name as an 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-list-children n
   numchild=@var{n},children=[@{name=@var{name},
   numchild=@var{n},type=@var{type}@},@r{(repeats N times)}]
+ (@value{GDBP})
+  -var-list-children --all-values n
+  numchild=@var{n},children=[@{name=@var{name},
+  numchild=@var{n},value=@var{value},type=@var{type}@},@r{(repeats N times)}]
  @end smallexample
  
*** /home/nick/gdb/gdb/testsuite/gdb.mi/mi-stack.exp~	2002-11-05 15:43:18.000000000 +0000
--- /home/nick/gdb/gdb/testsuite/gdb.mi/mi-stack.exp	2004-01-19 23:14:32.000000000 +0000
***************
*** 149,154 ****
--- 149,155 ----
      # Tests:
      # -stack-list-locals 0
      # -stack-list-locals 1
+     # -stack-list-locals 2
      # -stack-list-arguments 
  
      mi_gdb_test "232-stack-list-locals 0" \
***************
*** 168,173 ****
--- 169,178 ----
  	    "232\\^done,locals=\\\[\{name=\"A\",value=\"1\"\},\{name=\"B\",value=\"2\"\},\{name=\"C\",value=\"3\"\}\\\]" \
                  "stack locals listing 1"
  
+     mi_gdb_test "232-stack-list-locals 2" \
+ 	    "232\\^done,locals=\\\[\{name=\"A\",type=\"int\",value=\"1\"\},\{name=\"B\",type=\"int\",value=\"2\"\},\{name=\"C\",type=\"int\",value=\"3\"\}\\\]" \
+                 "stack locals listing 2"
+ 
      mi_gdb_test "234-stack-list-locals" \
  	    "234\\^error,msg=\"mi_cmd_stack_list_locals: Usage.*PRINT_VALUES.*\"" \
  	    "stack locals listing wrong"

*** /home/nick/gdb/gdb/testsuite/gdb.mi/mi-var-child.exp~	2004-01-19 23:15:54.000000000 +0000
--- /home/nick/gdb/gdb/testsuite/gdb.mi/mi-var-child.exp	2004-01-20 00:01:51.000000000 +0000
***************
*** 827,832 ****
--- 827,836 ----
  set line 208
  mi_execute_to "exec-step 7" "end-stepping-range" do_children_tests {} {.*var-cmd.c} $line {} "step $line"
  
+ mi_gdb_test "-var-list-children --all-values struct_declarations.long_array" \
+         "\\^done,numchild=\"10\",children=\\\[child=\{name=\"struct_declarations.long_array.0\",exp=\"0\",numchild=\"0\",value=\"1234\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.1\",exp=\"1\",numchild=\"0\",value=\"2345\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.2\",exp=\"2\",numchild=\"0\",value=\"3456\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.3\",exp=\"3\",numchild=\"0\",value=\"4567\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.4\",exp=\"4\",numchild=\"0\",value=\"5678\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.5\",exp=\"5\",numchild=\"0\",value=\"6789\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.6\",exp=\"6\",numchild=\"0\",value=\"7890\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.7\",exp=\"7\",numchild=\"0\",value=\"8901\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.8\",exp=\"8\",numchild=\"0\",value=\"9012\",type=\"long int\"\},child=\{name=\"struct_declarations.long_array.9\",exp=\"9\",numchild=\"0\",value=\"1234\",type=\"long int\"\}\\\]" \
+                 "listing of names and values of children"
+ 
  # Test: c_variable-5.8
  # Desc: check that long_array[3-9] changed
  mi_gdb_test "-var-update *" \
\x16º&Öéj×!zÊÞ¶êçßM9öX¬µªÜ†\a[¥«\…ë

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-01-23 22:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1074880622.7069.ezmlm@sources.redhat.com>
2004-01-23 19:02 ` {commit: gdb/mi] -stack-list-locals and -var-list-children Jim Ingham
2004-01-20  1:27 Nick Roberts
2004-01-20  5:49 ` Daniel Jacobowitz
2004-01-23 17:05   ` Daniel Jacobowitz
2004-01-23 21:27     ` Nick Roberts
2004-01-23 22:46       ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox