[Ada] New GDB/MI command: -ada-tasks-info
[deliverable/binutils-gdb.git] / gdb / mi / mi-main.c
index 6410e97b8a6b0d1e593bec0ca0708d82455a09e6..a9c7652b0c2acd06c76c14552ee22dc35633fd2a 100644 (file)
@@ -52,6 +52,7 @@
 #include "osdata.h"
 #include "splay-tree.h"
 #include "tracepoint.h"
+#include "ada-lang.h"
 
 #include <ctype.h>
 #include <sys/time.h>
@@ -117,7 +118,7 @@ mi_cmd_gdb_exit (char *command, char **argv, int argc)
   if (current_token)
     fputs_unfiltered (current_token, raw_stdout);
   fputs_unfiltered ("^exit\n", raw_stdout);
-  mi_out_put (uiout, raw_stdout);
+  mi_out_put (current_uiout, raw_stdout);
   gdb_flush (raw_stdout);
   /* FIXME: The function called is not yet a formal libgdb function.  */
   quit_force (NULL, FROM_TTY);
@@ -285,9 +286,6 @@ exec_reverse_continue (char **argv, int argc)
   enum exec_direction_kind dir = execution_direction;
   struct cleanup *old_chain;
 
-  if (dir == EXEC_ERROR)
-    error (_("Target %s does not support this command."), target_shortname);
-
   if (dir == EXEC_REVERSE)
     error (_("Already in reverse mode."));
 
@@ -473,7 +471,7 @@ mi_cmd_thread_select (char *command, char **argv, int argc)
   if (argc != 1)
     error (_("-thread-select: USAGE: threadnum."));
 
-  rc = gdb_thread_select (uiout, argv[0], &mi_error_message);
+  rc = gdb_thread_select (current_uiout, argv[0], &mi_error_message);
 
   if (rc == GDB_RC_FAIL)
     {
@@ -491,7 +489,7 @@ mi_cmd_thread_list_ids (char *command, char **argv, int argc)
   if (argc != 0)
     error (_("-thread-list-ids: No arguments required."));
 
-  rc = gdb_list_thread_ids (uiout, &mi_error_message);
+  rc = gdb_list_thread_ids (current_uiout, &mi_error_message);
 
   if (rc == GDB_RC_FAIL)
     {
@@ -506,7 +504,7 @@ mi_cmd_thread_info (char *command, char **argv, int argc)
   if (argc != 0 && argc != 1)
     error (_("Invalid MI command"));
 
-  print_thread_info (uiout, argv[0], -1);
+  print_thread_info (current_uiout, argv[0], -1);
 }
 
 struct collect_cores_data
@@ -553,6 +551,7 @@ static int
 print_one_inferior (struct inferior *inferior, void *xdata)
 {
   struct print_one_inferior_data *top_data = xdata;
+  struct ui_out *uiout = current_uiout;
 
   if (VEC_empty (int, top_data->inferiors)
       || bsearch (&(inferior->pid), VEC_address (int, top_data->inferiors),
@@ -673,6 +672,7 @@ list_available_thread_groups (VEC (int) *ids, int recurse)
   struct osdata *data;
   struct osdata_item *item;
   int ix_items;
+  struct ui_out *uiout = current_uiout;
 
   /* This keeps a map from integer (pid) to VEC (struct osdata_item *)*
      The vector contains information about all threads for the given pid.
@@ -790,6 +790,7 @@ list_available_thread_groups (VEC (int) *ids, int recurse)
 void
 mi_cmd_list_thread_groups (char *command, char **argv, int argc)
 {
+  struct ui_out *uiout = current_uiout;
   struct cleanup *back_to;
   int available = 0;
   int recurse = 0;
@@ -799,7 +800,7 @@ mi_cmd_list_thread_groups (char *command, char **argv, int argc)
     {
       AVAILABLE_OPT, RECURSE_OPT
     };
-  static struct mi_opt opts[] =
+  static const struct mi_opt opts[] =
   {
     {"-available", AVAILABLE_OPT, 0},
     {"-recurse", RECURSE_OPT, 1},
@@ -892,6 +893,7 @@ void
 mi_cmd_data_list_register_names (char *command, char **argv, int argc)
 {
   struct gdbarch *gdbarch;
+  struct ui_out *uiout = current_uiout;
   int regnum, numregs;
   int i;
   struct cleanup *cleanup;
@@ -943,6 +945,7 @@ void
 mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
 {
   static struct regcache *this_regs = NULL;
+  struct ui_out *uiout = current_uiout;
   struct regcache *prev_regs;
   struct gdbarch *gdbarch;
   int regnum, numregs, changed;
@@ -1047,6 +1050,7 @@ register_changed_p (int regnum, struct regcache *prev_regs,
 void
 mi_cmd_data_list_register_values (char *command, char **argv, int argc)
 {
+  struct ui_out *uiout = current_uiout;
   struct frame_info *frame;
   struct gdbarch *gdbarch;
   int regnum, numregs, format;
@@ -1113,9 +1117,10 @@ static void
 get_register (struct frame_info *frame, int regnum, int format)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct ui_out *uiout = current_uiout;
   CORE_ADDR addr;
   enum lval_type lval;
-  static struct ui_stream *stb = NULL;
+  struct ui_stream *stb;
   struct value *val;
 
   stb = ui_out_stream_new (uiout);
@@ -1232,6 +1237,7 @@ mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
   struct value *val;
   struct ui_stream *stb = NULL;
   struct value_print_options opts;
+  struct ui_out *uiout = current_uiout;
 
   stb = ui_out_stream_new (uiout);
 
@@ -1282,6 +1288,7 @@ void
 mi_cmd_data_read_memory (char *command, char **argv, int argc)
 {
   struct gdbarch *gdbarch = get_current_arch ();
+  struct ui_out *uiout = current_uiout;
   struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
   CORE_ADDR addr;
   long total_bytes;
@@ -1301,7 +1308,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
     {
       OFFSET_OPT
     };
-  static struct mi_opt opts[] =
+  static const struct mi_opt opts[] =
   {
     {"o", OFFSET_OPT, 1},
     { 0, 0, 0 }
@@ -1473,6 +1480,7 @@ void
 mi_cmd_data_read_memory_bytes (char *command, char **argv, int argc)
 {
   struct gdbarch *gdbarch = get_current_arch ();
+  struct ui_out *uiout = current_uiout;
   struct cleanup *cleanups;
   CORE_ADDR addr;
   LONGEST length;
@@ -1486,7 +1494,7 @@ mi_cmd_data_read_memory_bytes (char *command, char **argv, int argc)
     {
       OFFSET_OPT
     };
-  static struct mi_opt opts[] =
+  static const struct mi_opt opts[] =
   {
     {"o", OFFSET_OPT, 1},
     { 0, 0, 0 }
@@ -1553,7 +1561,7 @@ mi_cmd_data_read_memory_bytes (char *command, char **argv, int argc)
 
 /* DATA-MEMORY-WRITE:
 
-   COLUMN_OFFSET: optional argument. Must be preceeded by '-o'. The
+   COLUMN_OFFSET: optional argument. Must be preceded by '-o'. The
    offset from the beginning of the memory grid row where the cell to
    be written is.
    ADDR: start address of the row in the memory grid where the memory
@@ -1587,7 +1595,7 @@ mi_cmd_data_write_memory (char *command, char **argv, int argc)
     {
       OFFSET_OPT
     };
-  static struct mi_opt opts[] =
+  static const struct mi_opt opts[] =
   {
     {"o", OFFSET_OPT, 1},
     { 0, 0, 0 }
@@ -1705,12 +1713,15 @@ mi_cmd_list_features (char *command, char **argv, int argc)
   if (argc == 0)
     {
       struct cleanup *cleanup = NULL;
+      struct ui_out *uiout = current_uiout;
 
       cleanup = make_cleanup_ui_out_list_begin_end (uiout, "features");      
       ui_out_field_string (uiout, NULL, "frozen-varobjs");
       ui_out_field_string (uiout, NULL, "pending-breakpoints");
       ui_out_field_string (uiout, NULL, "thread-info");
       ui_out_field_string (uiout, NULL, "data-read-memory-bytes");
+      ui_out_field_string (uiout, NULL, "breakpoint-notifications");
+      ui_out_field_string (uiout, NULL, "ada-task-info");
       
 #if HAVE_PYTHON
       ui_out_field_string (uiout, NULL, "python");
@@ -1729,6 +1740,7 @@ mi_cmd_list_target_features (char *command, char **argv, int argc)
   if (argc == 0)
     {
       struct cleanup *cleanup = NULL;
+      struct ui_out *uiout = current_uiout;
 
       cleanup = make_cleanup_ui_out_list_begin_end (uiout, "features");      
       if (target_can_async_p ())
@@ -1753,7 +1765,7 @@ mi_cmd_add_inferior (char *command, char **argv, int argc)
 
   inf = add_inferior_with_spaces ();
 
-  ui_out_field_fmt (uiout, "inferior", "i%d", inf->num);
+  ui_out_field_fmt (current_uiout, "inferior", "i%d", inf->num);
 }
 
 /* Callback used to find the first inferior other than the
@@ -1960,14 +1972,14 @@ mi_execute_command (char *cmd, int from_tty)
 
       TRY_CATCH (result, RETURN_MASK_ALL)
        {
-         captured_mi_execute_command (uiout, command);
+         captured_mi_execute_command (current_uiout, command);
        }
       if (result.reason < 0)
        {
          /* The command execution failed and error() was called
             somewhere.  */
          mi_print_exception (command->token, result);
-         mi_out_rewind (uiout);
+         mi_out_rewind (current_uiout);
        }
 
       bpstat_do_actions ();
@@ -2025,9 +2037,7 @@ mi_cmd_execute (struct mi_parse *parse)
 {
   struct cleanup *cleanup;
 
-  prepare_execute_command ();
-
-  cleanup = make_cleanup (null_cleanup, NULL);
+  cleanup = prepare_execute_command ();
 
   if (parse->all && parse->thread_group != -1)
     error (_("Cannot specify --thread-group together with --all"));
@@ -2088,8 +2098,16 @@ mi_cmd_execute (struct mi_parse *parse)
 
   current_context = parse;
 
+  if (strncmp (parse->command, "break-", sizeof ("break-") - 1 ) == 0)
+    {
+      make_cleanup_restore_integer (&mi_suppress_breakpoint_notifications);
+      mi_suppress_breakpoint_notifications = 1;
+    }
+
   if (parse->cmd->argv_func != NULL)
-    parse->cmd->argv_func (parse->command, parse->argv, parse->argc);
+    {
+      parse->cmd->argv_func (parse->command, parse->argv, parse->argc);
+    }
   else if (parse->cmd->cli.cmd != 0)
     {
       /* FIXME: DELETE THIS. */
@@ -2156,18 +2174,9 @@ mi_execute_async_cli_command (char *cli_command, char **argv, int argc)
 
   execute_command ( /*ui */ run, 0 /*from_tty */ );
 
-  if (target_can_async_p ())
-    {
-      /* If we're not executing, an exception should have been throw.  */
-      gdb_assert (is_running (inferior_ptid));
-      do_cleanups (old_cleanups);
-    }
-  else
-    {
-      /* Do this before doing any printing.  It would appear that some
-         print code leaves garbage around in the buffer.  */
-      do_cleanups (old_cleanups);
-    }
+  /* Do this before doing any printing.  It would appear that some
+     print code leaves garbage around in the buffer.  */
+  do_cleanups (old_cleanups);
 }
 
 void
@@ -2182,22 +2191,25 @@ mi_load_progress (const char *section_name,
   static char *previous_sect_name = NULL;
   int new_section;
   struct ui_out *saved_uiout;
+  struct ui_out *uiout;
 
   /* This function is called through deprecated_show_load_progress
      which means uiout may not be correct.  Fix it for the duration
      of this function.  */
-  saved_uiout = uiout;
+  saved_uiout = current_uiout;
 
   if (current_interp_named_p (INTERP_MI)
       || current_interp_named_p (INTERP_MI2))
-    uiout = mi_out_new (2);
+    current_uiout = mi_out_new (2);
   else if (current_interp_named_p (INTERP_MI1))
-    uiout = mi_out_new (1);
+    current_uiout = mi_out_new (1);
   else if (current_interp_named_p (INTERP_MI3))
-    uiout = mi_out_new (3);
+    current_uiout = mi_out_new (3);
   else
     return;
 
+  uiout = current_uiout;
+
   update_threshold.tv_sec = 0;
   update_threshold.tv_usec = 500000;
   gettimeofday (&time_now, NULL);
@@ -2256,7 +2268,7 @@ mi_load_progress (const char *section_name,
     }
 
   xfree (uiout);
-  uiout = saved_uiout;
+  current_uiout = saved_uiout;
 }
 
 static void 
@@ -2493,3 +2505,14 @@ mi_cmd_trace_stop (char *command, char **argv, int argc)
   stop_tracing ();
   trace_status_mi (1);
 }
+
+/* Implement the "-ada-task-info" GDB/MI command.  */
+
+void
+mi_cmd_ada_task_info (char *command, char **argv, int argc)
+{
+  if (argc != 0 && argc != 1)
+    error (_("Invalid MI command"));
+
+  print_ada_task_info (current_uiout, argv[0], current_inferior ());
+}
This page took 0.028138 seconds and 4 git commands to generate.