Move catch_command_errors and catch_command_errors_const to main.c
authorPedro Alves <palves@redhat.com>
Mon, 14 Jul 2014 18:55:31 +0000 (19:55 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 14 Jul 2014 19:30:12 +0000 (20:30 +0100)
We'll need to add error handling code to commands run before the event
loop starts (commands in .gdbinit, -ex commands, etc.).  Turns out
those are run through catch_command_errors, and, catch_command_errors
is used nowhere else.  Move it (and the _const variant) to main.c, so
that we can further specialize it freely.

gdb/
2014-07-14  Pedro Alves  <palves@redhat.com>

* exceptions.c (catch_command_errors, catch_command_errors_const):
Moved to main.c.
* exceptions.h (catch_command_errors_ftype)
(catch_command_errors_const_ftype): Moved to main.c.
(catch_command_errors, catch_command_errors_const): Delete
declarations.
* main.c (catch_command_errors_ftype)
(catch_command_errors_const_ftype): Moved here from exceptions.h.
(catch_command_errors, catch_command_errors_const)): Moved here
from exceptions.c and make static.

gdb/ChangeLog
gdb/exceptions.c
gdb/exceptions.h
gdb/main.c

index 7d686b8a9b4808ef43e3aaf4d31e913425263986..7a5abe008f0dc610a39f15bf9c54a41140e83e39 100644 (file)
@@ -1,3 +1,16 @@
+2014-07-14  Pedro Alves  <palves@redhat.com>
+
+       * exceptions.c (catch_command_errors, catch_command_errors_const):
+       Moved to main.c.
+       * exceptions.h (catch_command_errors_ftype)
+       (catch_command_errors_const_ftype): Moved to main.c.
+       (catch_command_errors, catch_command_errors_const): Delete
+       declarations.
+       * main.c (catch_command_errors_ftype)
+       (catch_command_errors_const_ftype): Moved here from exceptions.h.
+       (catch_command_errors, catch_command_errors_const)): Moved here
+       from exceptions.c and make static.
+
 2014-07-14  Pedro Alves  <palves@redhat.com>
 
        * exceptions.c (print_any_exception): Delete.
index 8ee428d95c3ee95fd72f59d6c2236de4d650badc..def1f41b910d41d604015e04674f5266697659c0 100644 (file)
@@ -521,35 +521,3 @@ catch_errors (catch_errors_ftype *func, void *func_args, char *errstring,
     return 0;
   return val;
 }
-
-int
-catch_command_errors (catch_command_errors_ftype *command,
-                     char *arg, int from_tty, return_mask mask)
-{
-  volatile struct gdb_exception e;
-
-  TRY_CATCH (e, mask)
-    {
-      command (arg, from_tty);
-    }
-  exception_print (gdb_stderr, e);
-  if (e.reason < 0)
-    return 0;
-  return 1;
-}
-
-int
-catch_command_errors_const (catch_command_errors_const_ftype *command,
-                           const char *arg, int from_tty, return_mask mask)
-{
-  volatile struct gdb_exception e;
-
-  TRY_CATCH (e, mask)
-    {
-      command (arg, from_tty);
-    }
-  exception_print (gdb_stderr, e);
-  if (e.reason < 0)
-    return 0;
-  return 1;
-}
index b8dadc7b01f8d201ab8e4e82acbd017fd8390fd8..e5e1a493d81b2900768a3e69a675234f964eba86 100644 (file)
@@ -255,17 +255,4 @@ extern int catch_exceptions_with_msg (struct ui_out *uiout,
 typedef int (catch_errors_ftype) (void *);
 extern int catch_errors (catch_errors_ftype *, void *, char *, return_mask);
 
-/* Template to catch_errors() that wraps calls to command
-   functions.  */
-
-typedef void (catch_command_errors_ftype) (char *, int);
-extern int catch_command_errors (catch_command_errors_ftype *func,
-                                char *arg, int from_tty, return_mask);
-
-/* Like catch_command_errors, but works with const command and args.  */
-
-typedef void (catch_command_errors_const_ftype) (const char *, int);
-extern int catch_command_errors_const (catch_command_errors_const_ftype *func,
-                                      const char *arg, int from_tty, return_mask);
-
 #endif
index 0d4d5122f2e4ced9fe399ed4b70fe51b58536914..1d77bd38648cbee18d4635a0603b5ec2f41d4074 100644 (file)
@@ -337,6 +337,50 @@ captured_command_loop (void *data)
   return 1;
 }
 
+/* Type of the command callback passed to catch_command_errors.  */
+
+typedef void (catch_command_errors_ftype) (char *, int);
+
+/* Wrap calls to commands run before the event loop is started.  */
+
+static int
+catch_command_errors (catch_command_errors_ftype *command,
+                     char *arg, int from_tty, return_mask mask)
+{
+  volatile struct gdb_exception e;
+
+  TRY_CATCH (e, mask)
+    {
+      command (arg, from_tty);
+    }
+  exception_print (gdb_stderr, e);
+  if (e.reason < 0)
+    return 0;
+  return 1;
+}
+
+/* Type of the command callback passed to catch_command_errors_const.  */
+
+typedef void (catch_command_errors_const_ftype) (const char *, int);
+
+/* Like catch_command_errors, but works with const command and args.  */
+
+static int
+catch_command_errors_const (catch_command_errors_const_ftype *command,
+                           const char *arg, int from_tty, return_mask mask)
+{
+  volatile struct gdb_exception e;
+
+  TRY_CATCH (e, mask)
+    {
+      command (arg, from_tty);
+    }
+  exception_print (gdb_stderr, e);
+  if (e.reason < 0)
+    return 0;
+  return 1;
+}
+
 /* Arguments of --command option and its counterpart.  */
 typedef struct cmdarg {
   /* Type of this option.  */
This page took 0.031715 seconds and 4 git commands to generate.