2005-01-14 Andrew Cagney <cagney@gnu.org>
authorAndrew Cagney <cagney@redhat.com>
Fri, 14 Jan 2005 22:59:36 +0000 (22:59 +0000)
committerAndrew Cagney <cagney@redhat.com>
Fri, 14 Jan 2005 22:59:36 +0000 (22:59 +0000)
* exceptions.h (exception_fprintf): Declare.
(exception_print): Drop pre_print parameter.
* mi/mi-main.c (mi_execute_command): Update exception_print call.
* cli/cli-interp.c (safe_execute_command): Update exception_print
call.
* remote.c (remote_open_1): Instead of passing an error prefix to
catch_exceptions, use catch_exceptions and exception_fprintf.
(remote_start_remote): Change return type to void.
* breakpoint.c (insert_bp_location): Instead of passing an error
prefix to catch_exceptions, use catch_exceptions and
exception_fprintf.
(insert_catchpoint): Change return type to void.
(break_command_1): Update exception_print call.
* exceptions.c (exception_fprintf): New function.
(print_exception): New function.
(exception_print): Use print_exception.

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

index 835d8288dbb02db90e397cbfe9068e764de0ba8b..48ee486e20f2d0fd781c384756a49a34a4f472dc 100644 (file)
@@ -1,5 +1,22 @@
 2005-01-14  Andrew Cagney  <cagney@gnu.org>
 
+       * exceptions.h (exception_fprintf): Declare.
+       (exception_print): Drop pre_print parameter.
+       * mi/mi-main.c (mi_execute_command): Update exception_print call.
+       * cli/cli-interp.c (safe_execute_command): Update exception_print
+       call.
+       * remote.c (remote_open_1): Instead of passing an error prefix to
+       catch_exceptions, use catch_exceptions and exception_fprintf.
+       (remote_start_remote): Change return type to void.
+       * breakpoint.c (insert_bp_location): Instead of passing an error
+       prefix to catch_exceptions, use catch_exceptions and
+       exception_fprintf.
+       (insert_catchpoint): Change return type to void.
+       (break_command_1): Update exception_print call.
+       * exceptions.c (exception_fprintf): New function.
+       (print_exception): New function.
+       (exception_print): Use print_exception.
+       
        * utils.c (error_output_message): Delete function.
        * defs.h (error_output_message): Delete declaration.
 
index 75249f5b7cfd8070f824aabfa9206a3dfecd916b..9b77543c85bea6d9e0b5fca1d58cee1d49694479 100644 (file)
@@ -709,7 +709,7 @@ deprecated_read_memory_nobpt (CORE_ADDR memaddr, char *myaddr, unsigned len)
 \f
 
 /* A wrapper function for inserting catchpoints.  */
-static int
+static void
 insert_catchpoint (struct ui_out *uo, void *args)
 {
   struct breakpoint *b = (struct breakpoint *) args;
@@ -733,8 +733,6 @@ insert_catchpoint (struct ui_out *uo, void *args)
 
   if (val < 0)
     throw_reason (RETURN_ERROR);
-
-  return 0;
 }
 
 /* Helper routine: free the value chain for a breakpoint (watchpoint).  */
@@ -1073,13 +1071,11 @@ insert_bp_location (struct bp_location *bpt,
           || bpt->owner->type == bp_catch_vfork
           || bpt->owner->type == bp_catch_exec)
     {
-      char *prefix = xstrprintf ("warning: inserting catchpoint %d: ",
-                                bpt->owner->number);
-      struct cleanup *cleanups = make_cleanup (xfree, prefix);
-      val = catch_exceptions (uiout, insert_catchpoint, bpt->owner, prefix,
-                             RETURN_MASK_ERROR);
-      do_cleanups (cleanups);
-      if (val < 0)
+      struct exception e = catch_exception (uiout, insert_catchpoint,
+                                           bpt->owner, RETURN_MASK_ERROR);
+      exception_fprintf (gdb_stderr, e, "warning: inserting catchpoint %d: ",
+                        bpt->owner->number);
+      if (e.reason < 0)
        bpt->owner->enable_state = bp_disabled;
       else
        bpt->inserted = 1;
@@ -5134,7 +5130,7 @@ break_command_1 (char *arg, int flag, int from_tty, struct breakpoint *pending_b
   switch (e.reason)
     {
     case RETURN_QUIT:
-      exception_print (gdb_stderr, NULL, e);
+      exception_print (gdb_stderr, e);
       return e.reason;
     case RETURN_ERROR:
       switch (e.error)
@@ -5145,7 +5141,7 @@ break_command_1 (char *arg, int flag, int from_tty, struct breakpoint *pending_b
          if (pending_bp)
            return e.reason;
 
-         exception_print (gdb_stderr, NULL, e);
+         exception_print (gdb_stderr, e);
 
          /* If pending breakpoint support is turned off, throw
             error.  */
@@ -5171,7 +5167,7 @@ break_command_1 (char *arg, int flag, int from_tty, struct breakpoint *pending_b
          pending = 1;
          break;
        default:
-         exception_print (gdb_stderr, NULL, e);
+         exception_print (gdb_stderr, e);
          return e.reason;
        }
     default:
index ac905b2bb35052b529bd36ff15ef11b0f0cd1061..8893cb189e0c41336df5f25d162aa9fa6d869afe 100644 (file)
@@ -133,7 +133,7 @@ safe_execute_command (struct ui_out *uiout, char *command, int from_tty)
                       RETURN_MASK_ALL);
   /* FIXME: cagney/2005-01-13: This shouldn't be needed.  Instead the
      caller should print the exception.  */
-  exception_print (gdb_stderr, NULL, e);
+  exception_print (gdb_stderr, e);
   return e;
 }
 
index aed10a8e5fec845b8fd71eec381ac02ca94e6f3e..1301623edc46dbf90a37a541d1b5bcc272490410 100644 (file)
@@ -302,9 +302,28 @@ do_write (void *data, const char *buffer, long length_buffer)
 }
 
 
+static void
+print_exception (struct ui_file *file, struct exception e)
+{
+  /* KLUGE: cagney/2005-01-13: Write the string out one line at a time
+     as that way the MI's behavior is preserved.  */
+  const char *start;
+  const char *end;
+  for (start = e.message; start != NULL; start = end)
+    {
+      end = strchr (start, '\n');
+      if (end == NULL)
+       fputs_filtered (start, file);
+      else
+       {
+         end++;
+         ui_file_write (file, start, end - start);
+       }
+    }                                      
+}
+
 void
-exception_print (struct ui_file *file, const char *pre_print,
-                struct exception e)
+exception_print (struct ui_file *file, struct exception e)
 {
   if (e.reason < 0 && e.message != NULL)
     {
@@ -312,26 +331,29 @@ exception_print (struct ui_file *file, const char *pre_print,
       wrap_here ("");          /* Force out any buffered output */
       gdb_flush (file);
       annotate_error_begin ();
-      if (pre_print)
-       fputs_filtered (pre_print, file);
+      print_exception (file, e);
+      fprintf_filtered (file, "\n");
+    }
+}
 
-      /* KLUGE: cagney/2005-01-13: Write the string out one line at a
-        time as that way the MI's behavior is preserved.  */
-      {
-       const char *start;
-       const char *end;
-       for (start = e.message; start != NULL; start = end)
-         {
-           end = strchr (start, '\n');
-           if (end == NULL)
-             fputs_filtered (start, file);
-           else
-             {
-               end++;
-               ui_file_write (file, start, end - start);
-             }
-         }                                         
-      }
+void
+exception_fprintf (struct ui_file *file, struct exception e,
+                  const char *prefix, ...)
+{
+  if (e.reason < 0 && e.message != NULL)
+    {
+      va_list args;
+      target_terminal_ours ();
+      wrap_here ("");          /* Force out any buffered output */
+      gdb_flush (file);
+      annotate_error_begin ();
+
+      /* Print the prefix.  */
+      va_start (args, prefix);
+      vfprintf_filtered (file, prefix, args);
+      va_end (args);
+
+      print_exception (file, e);
       fprintf_filtered (file, "\n");
     }
 }
index 03318aef7752b4d743944dcdb6c7d14cadff36db..80c120d57ca8a8395c49c9ceba830deaed692744 100644 (file)
@@ -67,9 +67,11 @@ struct exception
 extern const struct exception exception_none;
 
 /* If E is an exception, print it's error message on the specified
-   stream.  */
-extern void exception_print (struct ui_file *file, const char *pre_print,
-                            struct exception e);
+   stream. for _fprintf, prefix the message with PREFIX...  */
+extern void exception_print (struct ui_file *file, struct exception e);
+extern void exception_fprintf (struct ui_file *file, struct exception e,
+                              const char *prefix,
+                              ...) ATTR_FORMAT (printf, 3, 4);
 
 /* Throw an exception (as described by "struct exception").  Will
    execute a LONG JUMP to the inner most containing exception handler
index bd45cd51ae37db542f329d5d95d6b6d232b574a5..7351d1edc4165b29993f1a9e5eda18b71b814708 100644 (file)
@@ -1156,7 +1156,7 @@ mi_execute_command (char *cmd, int from_tty)
       args.command = command;
       result = catch_exception (uiout, captured_mi_execute_command, &args,
                                RETURN_MASK_ALL);
-      exception_print (gdb_stderr, NULL, result);
+      exception_print (gdb_stderr, result);
 
       if (args.action == EXECUTE_COMMAND_SUPRESS_PROMPT)
        {
index 108b5e882041698ed7fd1ca14165d98f7e018731..a2e22a5bfa754de8368fa49fa780bc9bb1971f06 100644 (file)
@@ -83,8 +83,6 @@ static void remote_resume (ptid_t ptid, int step,
                            enum target_signal siggnal);
 static void remote_async_resume (ptid_t ptid, int step,
                                 enum target_signal siggnal);
-static int remote_start_remote (struct ui_out *uiout, void *dummy);
-
 static void remote_open (char *name, int from_tty);
 static void remote_async_open (char *name, int from_tty);
 
@@ -2019,7 +2017,7 @@ remote_start_remote_dummy (struct ui_out *uiout, void *dummy)
   return 1;
 }
 
-static int
+static void
 remote_start_remote (struct ui_out *uiout, void *dummy)
 {
   immediate_quit++;            /* Allow user to interrupt it.  */
@@ -2037,9 +2035,7 @@ remote_start_remote (struct ui_out *uiout, void *dummy)
   putpkt ("?");                        /* Initiate a query from remote machine.  */
   immediate_quit--;
 
-  /* NOTE: See comment above in remote_start_remote_dummy().  This
-     function returns something >=0.  */
-  return remote_start_remote_dummy (uiout, dummy);
+  remote_start_remote_dummy (uiout, dummy);
 }
 
 /* Open a connection to a remote debugger.
@@ -2157,7 +2153,7 @@ static void
 remote_open_1 (char *name, int from_tty, struct target_ops *target,
               int extended_p, int async_p)
 {
-  int ex;
+  struct exception ex;
   struct remote_state *rs = get_remote_state ();
   if (name == 0)
     error ("To open a remote debug connection, you need to specify what\n"
@@ -2260,17 +2256,15 @@ remote_open_1 (char *name, int from_tty, struct target_ops *target,
      been fixed - the function set_cmd_context() makes it possible for
      all the ``target ....'' commands to share a common callback
      function.  See cli-dump.c.  */
-  ex = catch_exceptions (uiout,
-                        remote_start_remote, NULL,
-                        "Couldn't establish connection to remote"
-                        " target\n",
-                        RETURN_MASK_ALL);
-  if (ex < 0)
+  ex = catch_exception (uiout, remote_start_remote, NULL, RETURN_MASK_ALL);
+  exception_fprintf (gdb_stderr, ex, "Couldn't establish connection to remote"
+                    " target\n");
+  if (ex.reason < 0)
     {
       pop_target ();
       if (async_p)
        wait_forever_enabled_p = 1;
-      throw_reason (ex);
+      throw_reason (ex.reason);
     }
 
   if (async_p)
This page took 0.042257 seconds and 4 git commands to generate.