]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/mi/mi-interp.c
Switch the license of all .c files to GPLv3.
[thirdparty/binutils-gdb.git] / gdb / mi / mi-interp.c
index 71abb75565c4c61ff865dff3969b520dc95668c6..b49a464fb6ca7a3e9e7cd2e799a9d6bba12cb5fe 100644 (file)
@@ -1,12 +1,12 @@
 /* MI Interpreter Definitions and Commands for GDB, the GNU debugger.
 
-   Copyright 2002, 2003, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -15,9 +15,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "gdb_string.h"
@@ -27,7 +25,7 @@
 #include "inferior.h"
 #include "ui-out.h"
 #include "top.h"
-
+#include "exceptions.h"
 #include "mi-main.h"
 #include "mi-cmds.h"
 #include "mi-out.h"
@@ -55,7 +53,8 @@ static void mi_command_loop (int mi_version);
 /* These are hooks that we put in place while doing interpreter_exec
    so we can report interesting things that happened "behind the mi's
    back" in this command */
-static int mi_interp_query_hook (const char *ctlstr, va_list ap);
+static int mi_interp_query_hook (const char *ctlstr, va_list ap)
+     ATTR_FORMAT (printf, 1, 0);
 
 static void mi3_command_loop (void);
 static void mi2_command_loop (void);
@@ -69,10 +68,6 @@ mi_interpreter_init (void)
 {
   struct mi_interp *mi = XMALLOC (struct mi_interp);
 
-  /* Why is this a part of the mi architecture? */
-
-  mi_setup_architecture_data ();
-
   /* HACK: We need to force stdout/stderr to point at the console.  This avoids
      any potential side effects caused by legacy code that is still
      using the TUI / fputs_unfiltered_hook.  So we set up output channels for
@@ -118,6 +113,8 @@ mi_interpreter_resume (void *data)
   gdb_stdlog = mi->log;
   /* Route target output through the MI. */
   gdb_stdtarg = mi->targ;
+  /* Route target error through the MI as well. */
+  gdb_stdtargerr = mi->targ;
 
   /* Replace all the hooks that we know about.  There really needs to
      be a better way of doing this... */
@@ -145,13 +142,14 @@ mi_interpreter_suspend (void *data)
   return 1;
 }
 
-static int
+static struct gdb_exception
 mi_interpreter_exec (void *data, const char *command)
 {
+  static struct gdb_exception ok;
   char *tmp = alloca (strlen (command) + 1);
   strcpy (tmp, command);
   mi_execute_command_wrapper (tmp);
-  return 1;
+  return exception_none;
 }
 
 /* Never display the default gdb prompt in mi case.  */
@@ -218,31 +216,21 @@ mi_cmd_interpreter_exec (char *command, char **argv, int argc)
 
   for (i = 1; i < argc; i++)
     {
-      char *buff = NULL;
-      /* Do this in a cleaner way...  We want to force execution to be
-         asynchronous for commands that run the target.  */
-      if (target_can_async_p () && (strcmp (argv[0], "console") == 0))
-       {
-         int len = strlen (argv[i]);
-         buff = xmalloc (len + 2);
-         memcpy (buff, argv[i], len);
-         buff[len] = '&';
-         buff[len + 1] = '\0';
-       }
-
       /* We had to set sync_execution = 0 for the mi (well really for Project
          Builder's use of the mi - particularly so interrupting would work.
          But for console commands to work, we need to initialize it to 1 -
          since that is what the cli expects - before running the command,
          and then set it back to 0 when we are done. */
       sync_execution = 1;
-      if (interp_exec (interp_to_use, argv[i]) < 0)
-       {
-         mi_error_message = error_last_message ();
-         result = MI_CMD_ERROR;
-         break;
-       }
-      xfree (buff);
+      {
+       struct gdb_exception e = interp_exec (interp_to_use, argv[i]);
+       if (e.reason < 0)
+         {
+           mi_error_message = xstrdup (e.message);
+           result = MI_CMD_ERROR;
+           break;
+         }
+      }
       do_exec_error_cleanups (ALL_CLEANUPS);
       sync_execution = 0;
     }
@@ -342,7 +330,6 @@ mi_command_loop (int mi_version)
   deprecated_delete_breakpoint_hook = 0;
   deprecated_modify_breakpoint_hook = 0;
   deprecated_interactive_hook = 0;
-  deprecated_registers_changed_hook = 0;
   deprecated_readline_begin_hook = 0;
   deprecated_readline_hook = 0;
   deprecated_readline_end_hook = 0;