This is the mail archive of the gdb-patches@sourceware.org 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]

[MI] -stack-list-variables improvements


I've checked in the below patch to:

- Fix some issues Joel noted in original patch (mostly formatting)
- Report if a variable is argument (as requested by Nick)
- Make -stack-list-variables always output a list of tuples (again as
  requested by Nick)

Here's sample output:

(gdb)
-stack-list-variables 0
^done,variables=[{name="line",arg="1"},{name="list",arg="1"},{name="cmdtype",arg="1"},{name="allow_unknown",arg="1"},{name="ignore_help_classes",arg="1"},{name="last_list"},{name="c"}]
(gdb)
-stack-list-variables 1
^done,variables=[{name="line",arg="1",value="0xbfffecb0"},{name="list",arg="1",value="0x84837d0"},{name="cmdtype",arg="1",value="0x833ee8c \"\""},{name="allow_unknown",arg="1",value="0"},{name="ignore_help_classes",arg="1",value="0"},{name="last_list",value="0x0"},{name="c",value="0xbfffecbc"}]


- Volodya

	* mi/mi-cmd-stack.c (mi_cmd_stack_list_locals): Add extra
	whitespace character after a dot in comment.
	(mi_cmd_stack_list_arguments, mi_cmd_stack_list_variables):
	Likewise.
	(list_args_or_locals): For the 'all' (that is
	-stack-list-variables) case, always output list of tuples.
	Output 'arg' field if variable is argument.

Index: mi/mi-cmd-stack.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmd-stack.c,v
retrieving revision 1.48
diff -u -p -r1.48 mi-cmd-stack.c
--- mi/mi-cmd-stack.c	1 Jan 2010 07:31:50 -0000	1.48
+++ mi/mi-cmd-stack.c	10 Feb 2010 22:19:23 -0000
@@ -138,7 +138,7 @@ parse_print_values (char *name)
 	    mi_no_values, mi_all_values, mi_simple_values);
 }
 
-/* Print a list of the locals for the current frame. With argument of
+/* Print a list of the locals for the current frame.  With argument of
    0, print only the names, with argument of 1 print also the
    values. */
 void
@@ -155,7 +155,7 @@ mi_cmd_stack_list_locals (char *command,
    list_args_or_locals (locals, parse_print_values (argv[0]), frame);
 }
 
-/* Print a list of the arguments for the current frame. With argument
+/* Print a list of the arguments for the current frame.  With argument
    of 0, print only the names, with argument of 1 print also the
    values. */
 void
@@ -216,8 +216,9 @@ mi_cmd_stack_list_args (char *command, c
 }
 
 /* Print a list of the local variables (including arguments) for the 
-   current frame. With argument of 0, print only the names, with 
-   argument of 1 print also the values. */
+   current frame.  ARGC must be 1 and ARGV[0] specify if only the names,
+   or both names and values of the variables must be printed.  See 
+   parse_print_value for possible values.  */
 void
 mi_cmd_stack_list_variables (char *command, char **argv, int argc)
 {
@@ -227,9 +228,9 @@ mi_cmd_stack_list_variables (char *comma
   if (argc != 1)
     error (_("Usage: PRINT_VALUES"));
 
-   frame = get_selected_frame (NULL);
+  frame = get_selected_frame (NULL);
 
-   list_args_or_locals (all, parse_print_values (argv[0]), frame);
+  list_args_or_locals (all, parse_print_values (argv[0]), frame);
 }
 
 
@@ -311,10 +312,12 @@ list_args_or_locals (enum what_to_list w
 	      struct cleanup *cleanup_tuple = NULL;
 	      struct symbol *sym2;
 	      struct value *val;
-	      if (values != PRINT_NO_VALUES)
+	      if (values != PRINT_NO_VALUES || what == all)
 		cleanup_tuple =
 		  make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
 	      ui_out_field_string (uiout, "name", SYMBOL_PRINT_NAME (sym));
+	      if (what == all && SYMBOL_IS_ARGUMENT (sym))
+		ui_out_field_int (uiout, "arg", 1);
 
 	      if (SYMBOL_IS_ARGUMENT (sym))
 		sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym),
@@ -341,7 +344,6 @@ list_args_or_locals (enum what_to_list w
 			 language_def (SYMBOL_LANGUAGE (sym2)));
 		      ui_out_field_stream (uiout, "value", stb);
 		    }
-		  do_cleanups (cleanup_tuple);
 		  break;
 		case PRINT_ALL_VALUES:
 		  {
@@ -353,10 +355,12 @@ list_args_or_locals (enum what_to_list w
 		      (val, stb->stream, 0, &opts,
 		       language_def (SYMBOL_LANGUAGE (sym2)));
 		    ui_out_field_stream (uiout, "value", stb);
-		    do_cleanups (cleanup_tuple);
 		  }
 		  break;
 		}
+
+	      if (values != PRINT_NO_VALUES || what == all)
+		do_cleanups (cleanup_tuple);
 	    }
 	}
       if (BLOCK_FUNCTION (block))


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