* cli/cli-interp.c (struct captured_execute_command_args):
authorTom Tromey <tromey@redhat.com>
Mon, 4 Apr 2011 18:13:05 +0000 (18:13 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 4 Apr 2011 18:13:05 +0000 (18:13 +0000)
Remove.
(do_captured_execute_command): Remove.
(safe_execute_command): Use TRY_CATCH.
* cli/cli-script.c (struct wrapped_read_command_file_args):
Remove.
(wrapped_read_command_file): Remove.
(script_from_file): Use TRY_CATCH.
* exceptions.c (catch_exception): Remove.
* exceptions.h (catch_exception): Remove.
(deprecated_throw_reason): Update comment.
* mi/mi-main.c (captured_mi_execute_command): Change 'data'
argument to 'context'.
(mi_execute_command): Use TRY_CATCH.
* remote.c (struct start_remote_args): Remove.
(remote_start_remote): Update; change arguments.
(remote_open_1): Use TRY_CATCH.

gdb/ChangeLog
gdb/cli/cli-interp.c
gdb/cli/cli-script.c
gdb/exceptions.c
gdb/exceptions.h
gdb/mi/mi-main.c
gdb/remote.c

index 6aca3c3..161f4bf 100644 (file)
@@ -1,5 +1,25 @@
 2011-04-04  Tom Tromey  <tromey@redhat.com>
 
+       * cli/cli-interp.c (struct captured_execute_command_args):
+       Remove.
+       (do_captured_execute_command): Remove.
+       (safe_execute_command): Use TRY_CATCH.
+       * cli/cli-script.c (struct wrapped_read_command_file_args):
+       Remove.
+       (wrapped_read_command_file): Remove.
+       (script_from_file): Use TRY_CATCH.
+       * exceptions.c (catch_exception): Remove.
+       * exceptions.h (catch_exception): Remove.
+       (deprecated_throw_reason): Update comment.
+       * mi/mi-main.c (captured_mi_execute_command): Change 'data'
+       argument to 'context'.
+       (mi_execute_command): Use TRY_CATCH.
+       * remote.c (struct start_remote_args): Remove.
+       (remote_start_remote): Update; change arguments.
+       (remote_open_1): Use TRY_CATCH.
+
+2011-04-04  Tom Tromey  <tromey@redhat.com>
+
        * tracepoint.c (scope_info): Update.
        * symtab.c (decode_line_spec): Update.
        * python/python.c (gdbpy_decode_line): Update.
index 7a517e9..88a570c 100644 (file)
@@ -37,12 +37,6 @@ struct ui_out *cli_uiout;
 static struct gdb_exception safe_execute_command (struct ui_out *uiout,
                                                  char *command, 
                                                  int from_tty);
-struct captured_execute_command_args
-{
-  char *command;
-  int from_tty;
-};
-
 /* These implement the cli out interpreter: */
 
 static void *
@@ -117,25 +111,15 @@ cli_interpreter_exec (void *data, const char *command_str)
   return result;
 }
 
-static void
-do_captured_execute_command (struct ui_out *uiout, void *data)
-{
-  struct captured_execute_command_args *args =
-    (struct captured_execute_command_args *) data;
-
-  execute_command (args->command, args->from_tty);
-}
-
 static struct gdb_exception
 safe_execute_command (struct ui_out *uiout, char *command, int from_tty)
 {
-  struct gdb_exception e;
-  struct captured_execute_command_args args;
+  volatile struct gdb_exception e;
 
-  args.command = command;
-  args.from_tty = from_tty;
-  e = catch_exception (uiout, do_captured_execute_command, &args,
-                      RETURN_MASK_ALL);
+  TRY_CATCH (e, RETURN_MASK_ALL)
+    {
+      execute_command (command, from_tty);
+    }
   /* FIXME: cagney/2005-01-13: This shouldn't be needed.  Instead the
      caller should print the exception.  */
   exception_print (gdb_stderr, e);
index 5903015..2d1afe5 100644 (file)
@@ -1589,19 +1589,6 @@ source_cleanup_lines (void *args)
   source_file_name = p->old_file;
 }
 
-struct wrapped_read_command_file_args
-{
-  FILE *stream;
-};
-
-static void
-wrapped_read_command_file (struct ui_out *uiout, void *data)
-{
-  struct wrapped_read_command_file_args *args = data;
-
-  read_command_file (args->stream);
-}
-
 /* Used to implement source_command.  */
 
 void
@@ -1625,12 +1612,12 @@ script_from_file (FILE *stream, const char *file)
   error_pre_print = "";
 
   {
-    struct gdb_exception e;
-    struct wrapped_read_command_file_args args;
+    volatile struct gdb_exception e;
 
-    args.stream = stream;
-    e = catch_exception (uiout, wrapped_read_command_file, &args,
-                        RETURN_MASK_ERROR);
+    TRY_CATCH (e, RETURN_MASK_ERROR)
+      {
+       read_command_file (stream);
+      }
     switch (e.reason)
       {
       case 0:
index 099ef0d..4eb2f9e 100644 (file)
@@ -458,21 +458,6 @@ catch_exceptions (struct ui_out *uiout,
   return catch_exceptions_with_msg (uiout, func, func_args, NULL, mask);
 }
 
-struct gdb_exception
-catch_exception (struct ui_out *uiout,
-                catch_exception_ftype *func,
-                void *func_args,
-                return_mask mask)
-{
-  volatile struct gdb_exception exception;
-
-  TRY_CATCH (exception, mask)
-    {
-      (*func) (uiout, func_args);
-    }
-  return exception;
-}
-
 int
 catch_exceptions_with_msg (struct ui_out *uiout,
                           catch_exceptions_ftype *func,
index b1c4587..c1bc605 100644 (file)
@@ -182,8 +182,8 @@ extern void throw_vfatal (const char *fmt, va_list ap)
 extern void throw_error (enum errors error, const char *fmt, ...)
      ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 3);
 
-/* Instead of deprecated_throw_reason, code should use catch_exception
-   and throw_exception.  */
+/* Instead of deprecated_throw_reason, code should use
+   throw_exception.  */
 extern void deprecated_throw_reason (enum return_reason reason)
      ATTRIBUTE_NORETURN;
 
@@ -234,14 +234,6 @@ extern int catch_exceptions_with_msg (struct ui_out *uiout,
                                      char **gdberrmsg,
                                      return_mask mask);
 
-/* This function, in addition, suppresses the printing of the captured
-   error message.  It's up to the client to print it.  */
-
-extern struct gdb_exception catch_exception (struct ui_out *uiout,
-                                            catch_exception_ftype *func,
-                                            void *func_args,
-                                            return_mask mask);
-
 /* If CATCH_ERRORS_FTYPE throws an error, catch_errors() returns zero
    otherwize the result from CATCH_ERRORS_FTYPE is returned.  It is
    probably useful for CATCH_ERRORS_FTYPE to always return a non-zero
index ef6bfc3..6410e97 100644 (file)
@@ -1816,10 +1816,9 @@ mi_cmd_remove_inferior (char *command, char **argv, int argc)
    prompt, display error). */
 
 static void
-captured_mi_execute_command (struct ui_out *uiout, void *data)
+captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context)
 {
   struct cleanup *cleanup;
-  struct mi_parse *context = (struct mi_parse *) data;
 
   if (do_timings)
     current_command_ts = context->cmd_start;
@@ -1947,7 +1946,7 @@ mi_execute_command (char *cmd, int from_tty)
     }
   else
     {
-      struct gdb_exception result;
+      volatile struct gdb_exception result;
       ptid_t previous_ptid = inferior_ptid;
 
       command->token = token;
@@ -1959,8 +1958,10 @@ mi_execute_command (char *cmd, int from_tty)
          timestamp (command->cmd_start);
        }
 
-      result = catch_exception (uiout, captured_mi_execute_command, command,
-                               RETURN_MASK_ALL);
+      TRY_CATCH (result, RETURN_MASK_ALL)
+       {
+         captured_mi_execute_command (uiout, command);
+       }
       if (result.reason < 0)
        {
          /* The command execution failed and error() was called
index 0c2d701..ac9d9ce 100644 (file)
@@ -3097,19 +3097,6 @@ set_stop_requested_callback (struct thread_info *thread, void *data)
   return 0;
 }
 
-/* Stub for catch_exception.  */
-
-struct start_remote_args
-{
-  int from_tty;
-
-  /* The current target.  */
-  struct target_ops *target;
-
-  /* Non-zero if this is an extended-remote target.  */
-  int extended_p;
-};
-
 /* Send interrupt_sequence to remote target.  */
 static void
 send_interrupt_sequence (void)
@@ -3130,9 +3117,8 @@ send_interrupt_sequence (void)
 }
 
 static void
-remote_start_remote (struct ui_out *uiout, void *opaque)
+remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
 {
-  struct start_remote_args *args = opaque;
   struct remote_state *rs = get_remote_state ();
   struct packet_config *noack_config;
   char *wait_status = NULL;
@@ -3179,7 +3165,7 @@ remote_start_remote (struct ui_out *uiout, void *opaque)
        rs->noack_mode = 1;
     }
 
-  if (args->extended_p)
+  if (extended_p)
     {
       /* Tell the remote that we are using the extended protocol.  */
       putpkt ("!");
@@ -3197,7 +3183,7 @@ remote_start_remote (struct ui_out *uiout, void *opaque)
   /* On OSs where the list of libraries is global to all
      processes, we fetch them early.  */
   if (gdbarch_has_global_solist (target_gdbarch))
-    solib_add (NULL, args->from_tty, args->target, auto_solib_add);
+    solib_add (NULL, from_tty, target, auto_solib_add);
 
   if (non_stop)
     {
@@ -3215,7 +3201,7 @@ remote_start_remote (struct ui_out *uiout, void *opaque)
         controlling.  We default to adding them in the running state.
         The '?' query below will then tell us about which threads are
         stopped.  */
-      remote_threads_info (args->target);
+      remote_threads_info (target);
     }
   else if (rs->non_stop_aware)
     {
@@ -3236,7 +3222,7 @@ remote_start_remote (struct ui_out *uiout, void *opaque)
     {
       if (rs->buf[0] == 'W' || rs->buf[0] == 'X')
        {
-         if (!args->extended_p)
+         if (!extended_p)
            error (_("The target is not running (try extended-remote?)"));
 
          /* We're connected, but not running.  Drop out before we
@@ -3276,7 +3262,7 @@ remote_start_remote (struct ui_out *uiout, void *opaque)
         how to do it some other way, try again.  This is not
         supported for non-stop; it could be, but it is tricky if
         there are no stopped threads when we connect.  */
-      if (remote_read_description_p (args->target)
+      if (remote_read_description_p (target)
          && gdbarch_target_desc (target_gdbarch) == NULL)
        {
          target_clear_description ();
@@ -3289,7 +3275,7 @@ remote_start_remote (struct ui_out *uiout, void *opaque)
       rs->cached_wait_status = 1;
 
       immediate_quit--;
-      start_remote (args->from_tty); /* Initialize gdb process mechanisms.  */
+      start_remote (from_tty); /* Initialize gdb process mechanisms.  */
     }
   else
     {
@@ -3331,7 +3317,7 @@ remote_start_remote (struct ui_out *uiout, void *opaque)
 
       if (thread_count () == 0)
        {
-         if (!args->extended_p)
+         if (!extended_p)
            error (_("The target is not running (try extended-remote?)"));
 
          /* We're connected, but not running.  Drop out before we
@@ -4060,14 +4046,12 @@ remote_open_1 (char *name, int from_tty,
      all the ``target ....'' commands to share a common callback
      function.  See cli-dump.c.  */
   {
-    struct gdb_exception ex;
-    struct start_remote_args args;
-
-    args.from_tty = from_tty;
-    args.target = target;
-    args.extended_p = extended_p;
+    volatile struct gdb_exception ex;
 
-    ex = catch_exception (uiout, remote_start_remote, &args, RETURN_MASK_ALL);
+    TRY_CATCH (ex, RETURN_MASK_ALL)
+      {
+       remote_start_remote (from_tty, target, extended_p);
+      }
     if (ex.reason < 0)
       {
        /* Pop the partially set up target - unless something else did