* mi/mi-cmds.h (mi_cmd_stack_list_variables): Declare.
authorVladimir Prus <vladimir@codesourcery.com>
Sat, 19 Sep 2009 09:59:29 +0000 (09:59 +0000)
committerVladimir Prus <vladimir@codesourcery.com>
Sat, 19 Sep 2009 09:59:29 +0000 (09:59 +0000)
* mi/mi-cmds.c (mi_cmds): Register -stack-list-variables.
* mi/mi-cmd-stack.c (enum what_to_list): New.
(list_args_or_locals): Accept what_to_list parameter.
Use 'variables' as output name of all are requested.
(mi_cmd_stack_list_variables): New.
(mi_cmd_stack_list_locals, mi_cmd_stack_list_args): Adjust.

gdb/ChangeLog
gdb/mi/mi-cmd-stack.c
gdb/mi/mi-cmds.c
gdb/mi/mi-cmds.h

index eff95fe8dbf223158545a87ea9022ed82f0db388..35349da8b937115db74bfeedeea10d204e315896 100644 (file)
@@ -1,3 +1,13 @@
+2009-09-19  Vladimir Prus  <vladimir@codesourcery.com>
+
+       * mi/mi-cmds.h (mi_cmd_stack_list_variables): Declare.
+       * mi/mi-cmds.c (mi_cmds): Register -stack-list-variables.
+       * mi/mi-cmd-stack.c (enum what_to_list): New.
+       (list_args_or_locals): Accept what_to_list parameter.
+       Use 'variables' as output name of all are requested.
+       (mi_cmd_stack_list_variables): New.
+       (mi_cmd_stack_list_locals, mi_cmd_stack_list_args): Adjust.
+
 2009-09-19  Eli Zaretskii  <eliz@gnu.org>
 
        * config/djgpp/fnchange.lst: Add missing edits.
index dd0626940b88316f5f4ce47a967d7f053194f5f4..4bcbe986e00183c2a6ebbc55aa6eea490a1d77bd 100644 (file)
 #include "language.h"
 #include "valprint.h"
 
-static void list_args_or_locals (int locals, int values, struct frame_info *fi);
+
+enum what_to_list { locals, arguments, all };
+
+static void list_args_or_locals (enum what_to_list what, 
+                                int values, struct frame_info *fi);
 
 /* Print a list of the stack frames. Args can be none, in which case
    we want to print the whole backtrace, or a pair of numbers
@@ -148,7 +152,7 @@ mi_cmd_stack_list_locals (char *command, char **argv, int argc)
 
    frame = get_selected_frame (NULL);
 
-   list_args_or_locals (1, parse_print_values (argv[0]), frame);
+   list_args_or_locals (locals, parse_print_values (argv[0]), frame);
 }
 
 /* Print a list of the arguments for the current frame. With argument
@@ -204,19 +208,37 @@ mi_cmd_stack_list_args (char *command, char **argv, int argc)
       QUIT;
       cleanup_frame = make_cleanup_ui_out_tuple_begin_end (uiout, "frame");
       ui_out_field_int (uiout, "level", i);
-      list_args_or_locals (0, print_values, fi);
+      list_args_or_locals (arguments, print_values, fi);
       do_cleanups (cleanup_frame);
     }
 
   do_cleanups (cleanup_stack_args);
 }
 
+/* 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. */
+void
+mi_cmd_stack_list_variables (char *command, char **argv, int argc)
+{
+  struct frame_info *frame;
+  enum print_values print_values;
+
+  if (argc != 1)
+    error (_("Usage: PRINT_VALUES"));
+
+   frame = get_selected_frame (NULL);
+
+   list_args_or_locals (all, parse_print_values (argv[0]), frame);
+}
+
+
 /* Print a list of the locals or the arguments for the currently
    selected frame.  If the argument passed is 0, printonly the names
    of the variables, if an argument of 1 is passed, print the values
    as well. */
 static void
-list_args_or_locals (int locals, int values, struct frame_info *fi)
+list_args_or_locals (enum what_to_list what, int values, struct frame_info *fi)
 {
   struct block *block;
   struct symbol *sym;
@@ -225,12 +247,23 @@ list_args_or_locals (int locals, int values, struct frame_info *fi)
   struct cleanup *cleanup_list;
   static struct ui_stream *stb = NULL;
   struct type *type;
+  char *name_of_result;
 
   stb = ui_out_stream_new (uiout);
 
   block = get_frame_block (fi, 0);
 
-  cleanup_list = make_cleanup_ui_out_list_begin_end (uiout, locals ? "locals" : "args");
+  switch (what)
+    {
+    case locals:
+      name_of_result = "locals"; break;
+    case arguments:
+      name_of_result = "args"; break;
+    case all:
+      name_of_result = "variables"; break;
+    }
+
+  cleanup_list = make_cleanup_ui_out_list_begin_end (uiout, name_of_result);
 
   while (block != 0)
     {
@@ -259,8 +292,12 @@ list_args_or_locals (int locals, int values, struct frame_info *fi)
            case LOC_STATIC:    /* static                */
            case LOC_REGISTER:  /* register              */
            case LOC_COMPUTED:  /* computed location     */
-             if (SYMBOL_IS_ARGUMENT (sym) ? !locals : locals)
+             if (what == all)
                print_me = 1;
+             else if (what == locals)
+               print_me = !SYMBOL_IS_ARGUMENT (sym);
+             else
+               print_me = SYMBOL_IS_ARGUMENT (sym);
              break;
            }
          if (print_me)
@@ -273,7 +310,7 @@ list_args_or_locals (int locals, int values, struct frame_info *fi)
                  make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
              ui_out_field_string (uiout, "name", SYMBOL_PRINT_NAME (sym));
 
-             if (!locals)
+             if (SYMBOL_IS_ARGUMENT (sym))
                sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym),
                                      block, VAR_DOMAIN,
                                      (int *) NULL);
index 8ba086c62b315d4fc5225a81220e813dd035d809..2c425b714827ef7219f4db6c0a84a27f9e5ffdf8 100644 (file)
@@ -89,6 +89,7 @@ struct mi_cmd mi_cmds[] =
   { "stack-list-arguments", { NULL, 0 }, mi_cmd_stack_list_args},
   { "stack-list-frames", { NULL, 0 }, mi_cmd_stack_list_frames},
   { "stack-list-locals", { NULL, 0 }, mi_cmd_stack_list_locals},
+  { "stack-list-variables", { NULL, 0 }, mi_cmd_stack_list_variables},
   { "stack-select-frame", { NULL, 0 }, mi_cmd_stack_select_frame},
   { "symbol-list-lines", { NULL, 0 }, mi_cmd_symbol_list_lines},
   { "target-attach", { "attach", 1 }, NULL },
index dfab411c6db5169bfb6c39f96e72cd359f362d9e..491c1f293d6ec03aee6054490b67393bc8ca3d8f 100644 (file)
@@ -75,6 +75,7 @@ extern mi_cmd_argv_ftype mi_cmd_stack_info_frame;
 extern mi_cmd_argv_ftype mi_cmd_stack_list_args;
 extern mi_cmd_argv_ftype mi_cmd_stack_list_frames;
 extern mi_cmd_argv_ftype mi_cmd_stack_list_locals;
+extern mi_cmd_argv_ftype mi_cmd_stack_list_variables;
 extern mi_cmd_argv_ftype mi_cmd_stack_select_frame;
 extern mi_cmd_argv_ftype mi_cmd_symbol_list_lines;
 extern mi_cmd_argv_ftype mi_cmd_target_detach;
This page took 0.039612 seconds and 4 git commands to generate.