]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* mi-cmds.h (mi_execute_command): Add "extern".
authorKeith Seitz <keiths@redhat.com>
Tue, 25 Jun 2002 00:05:34 +0000 (00:05 +0000)
committerKeith Seitz <keiths@redhat.com>
Tue, 25 Jun 2002 00:05:34 +0000 (00:05 +0000)
        (mi_error_last_message): New function.
        * mi-main.c (mi_error_last_message): New function.
        * mi-interp.c (mi_event_handlers): New static global.
        (mi_interpreter_init): Don't install mi event handlers here.
        (mi_interpreter_resume): Install mi event handlers here.
        (mi_interpreter_exec): Don't actually switch interpreters.
        Update error messages.
        exec_proc will return <0 if an error occurs.

gdb/mi/ChangeLog
gdb/mi/mi-cmds.h
gdb/mi/mi-interp.c
gdb/mi/mi-main.c

index af1ea989e7d63e617571a53aa48f538bb891cf48..901278f865f190bf51c096ef792f29f22142b995 100644 (file)
@@ -1,3 +1,15 @@
+2002-06-24  Keith Seitz  <keiths@redhat.com>
+
+       * mi-cmds.h (mi_execute_command): Add "extern".
+       (mi_error_last_message): New function.
+       * mi-main.c (mi_error_last_message): New function.
+       * mi-interp.c (mi_event_handlers): New static global.
+       (mi_interpreter_init): Don't install mi event handlers here.
+       (mi_interpreter_resume): Install mi event handlers here.
+       (mi_interpreter_exec): Don't actually switch interpreters.
+       Update error messages.
+       exec_proc will return <0 if an error occurs.
+
 2002-06-19  Keith Seitz  <keiths@redhat.com>
 
        * mi-cmd-break.c (breakpoint_notify): Only query the breakpoint
index 8c650fc91e1b9b00d073dd4e7ea1e28a9b54ee97..00961315007ff9a0247ea5780f9b9fb405697e52 100644 (file)
@@ -125,5 +125,6 @@ extern int mi_debug_p;
 extern struct ui_file *raw_stdout;
 
 extern char *mi_error_message;
-void mi_execute_command (char *cmd, int from_tty);
+extern void mi_error_last_message (void);
+extern void mi_execute_command (char *cmd, int from_tty);
 #endif
index 72385a9223820a16ad72fa87f4339aeec5c912f6..16dd3d69600f9c1317b78b0edd77ce29d6e83e14 100644 (file)
@@ -69,6 +69,17 @@ static void mi1_command_loop (void);
 static void mi_insert_notify_hooks (void);
 static void mi_remove_notify_hooks (void);
 
+static struct gdb_events mi_event_handlers =
+  {
+    mi_create_breakpoint,
+    mi_delete_breakpoint,
+    mi_modify_breakpoint,
+    mi_create_tracepoint,
+    mi_delete_tracepoint,
+    mi_modify_tracepoint,
+    mi_architecture_changed
+  };
+
 static int
 mi_interpreter_init (void *data)
 {
@@ -92,16 +103,6 @@ mi_interpreter_init (void *data)
   mi_stdtarg = mi_console_file_new (raw_stdout, "@", '"');
   mi_event_channel = mi_console_file_new (raw_stdout, "=", 0);
 
-  /* Add global event handlers */
-  handlers.breakpoint_create = mi_create_breakpoint;
-  handlers.breakpoint_modify = mi_modify_breakpoint;
-  handlers.breakpoint_delete = mi_delete_breakpoint;
-  handlers.tracepoint_create = mi_create_tracepoint;
-  handlers.tracepoint_modify = mi_modify_tracepoint;
-  handlers.tracepoint_delete = mi_delete_tracepoint;
-  handlers.architecture_changed = mi_architecture_changed;
-  set_gdb_event_hooks (&handlers);
-
   return 1;
 }
 
@@ -140,6 +141,7 @@ mi_interpreter_resume (void *data)
   /* Replace all the hooks that we know about.  There really needs to be a better way
      of doing this... */
   clear_interpreter_hooks ();
+  set_gdb_event_hooks (&mi_event_handlers);
 
   show_load_progress = mi_load_progress;
 
@@ -203,26 +205,24 @@ mi_interpreter_exec_continuation (struct continuation_arg *arg)
 enum mi_cmd_result
 mi_cmd_interpreter_exec (char *command, char **argv, int argc)
 {
-  struct gdb_interpreter *old_interp, *interp_to_use;
+  struct gdb_interpreter *interp_to_use;
   enum mi_cmd_result result = MI_CMD_DONE;
-  int i, old_quiet;
+  int i;
   struct gdb_interpreter_procs *procs;
 
   if (argc < 2)
     {
       xasprintf (&mi_error_message,
-                "Wrong # or arguments, should be \"%s interp cmd <cmd ...>\".",
-                command);
+                "mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command");
       return MI_CMD_ERROR;
     }
 
-  old_interp = gdb_current_interpreter ();
-
   interp_to_use = gdb_lookup_interpreter (argv[0]);
   if (interp_to_use == NULL)
     {
       xasprintf (&mi_error_message,
-                "Could not find interpreter \"%s\".", argv[0]);
+                "mi_cmd_interpreter_exec: could not find interpreter \"%s\"",
+                argv[0]);
       return MI_CMD_ERROR;
     }
 
@@ -230,18 +230,10 @@ mi_cmd_interpreter_exec (char *command, char **argv, int argc)
   if (!procs->exec_proc)
     {
       xasprintf (&mi_error_message,
-                "Interpreter \"%s\" does not support command execution.",
+                "mi_cmd_interpreter_exec: interpreter \"%s\" does not support command execution",
                 argv[0]);
       return MI_CMD_ERROR;
     }
-  old_quiet = gdb_interpreter_set_quiet (interp_to_use, 1);
-
-  if (!gdb_set_interpreter (interp_to_use))
-    {
-      xasprintf (&mi_error_message,
-                "Could not switch to interpreter \"%s\".", argv[0]);
-      return MI_CMD_ERROR;
-    }
 
   /* Insert the MI out hooks, making sure to also call the interpreter's hooks
      if it has any. */
@@ -271,12 +263,9 @@ mi_cmd_interpreter_exec (char *command, char **argv, int argc)
          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 (!procs->exec_proc (gdb_interpreter_get_data (interp_to_use), argv[i]))
+      if (procs->exec_proc (gdb_interpreter_get_data (interp_to_use), argv[i]) < 0)
        {
-         xasprintf (&mi_error_message,
-                    "mi_interpreter_execute: error in command: \"%s\".",
-                    argv[i]);
-
+         mi_error_last_message ();
          result = MI_CMD_ERROR;
          break;
        }
@@ -285,11 +274,7 @@ mi_cmd_interpreter_exec (char *command, char **argv, int argc)
       sync_execution = 0;
     }
 
-  /* Now do the switch... */
-
-  gdb_set_interpreter (old_interp);
   mi_remove_notify_hooks ();
-  gdb_interpreter_set_quiet (interp_to_use, old_quiet);
 
   /* Okay, now let's see if the command set the inferior going...
      Tricky point - have to do this AFTER resetting the interpreter, since
index 84f85ce9c39d4b9c03e701003d96c7708fef6056..7a6b2cdd755c14c0098564c950211356043b6152 100644 (file)
@@ -104,6 +104,15 @@ void mi_load_progress (const char *section_name,
 extern void interrupt_target_command_wrapper (char *, int);
 extern void return_command_wrapper (char *, int);
 
+/* A helper function which will set mi_error_message to error_last_message. */
+void
+mi_error_last_message (void)
+{
+  char *s = error_last_message ();
+  xasprintf (&mi_error_message, s);
+  xfree (s);
+}
+
 /* Command implementations. FIXME: Is this libgdb? No.  This is the MI
    layer that calls libgdb.  Any operation used in the below should be
    formalized. */