Joel Sherrill (joel@OARcorp.com)
[deliverable/binutils-gdb.git] / gdb / main.c
index 18c24459e8deadf68889e845a18075ad7763b2f3..6e94c29ba94a3acdc14130c956b4ee0dc68111de 100644 (file)
@@ -19,11 +19,13 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
-#include <setjmp.h>
 #include "top.h"
 #include "target.h"
 #include "inferior.h"
 #include "call-cmds.h"
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 #include "getopt.h"
 
@@ -33,19 +35,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "gdb_string.h"
 
-/* Temporary variable for SET_TOP_LEVEL.  */
-
-static int top_level_val;
-
-/* Do a setjmp on error_return and quit_return.  catch_errors is
-   generally a cleaner way to do this, but main() would look pretty
-   ugly if it had to use catch_errors each time.  */
-
-#define SET_TOP_LEVEL() \
-  (((top_level_val = SIGSETJMP (error_return)) \
-    ? (PTR) 0 : (PTR) memcpy (quit_return, error_return, sizeof (SIGJMP_BUF))) \
-   , top_level_val)
-
 /* If nonzero, display time usage both at startup and for each command.  */
 
 int display_time;
@@ -54,6 +43,12 @@ int display_time;
 
 int display_space;
 
+/* Whether this is the async version or not.  The async version is
+invoked on the command line with the -nw --async options.  In this
+version, the usual command_loop is substituted by and event loop which
+processes UI events asynchronously. */
+int async = 0;
+
 /* Whether this is the command line version or not */
 int tui_version = 0;
 
@@ -183,7 +178,8 @@ main (argc, argv)
        short option (or arbitrary numbers starting at 10 for those
        with no equivalent).  */
     static struct option long_options[] =
-      {
+       {
+        {"async", no_argument, &async, 1},  
 #if defined(TUI)
        {"tui", no_argument, &tui_version, 1},
 #endif
@@ -395,6 +391,10 @@ main (argc, argv)
       quiet = 1;
   }
 
+  /* Get ready to invoke the event loop instead of the
+     command_loop. See event-loop.h for more details.*/
+  if (async)
+    async_hook = setup_event_loop;
 #if defined(TUI)
   if (tui_version)
     init_ui_hook = tuiInit;
@@ -569,9 +569,14 @@ main (argc, argv)
     {
       if (!SET_TOP_LEVEL ())
        {
+         /* NOTE: I am commenting this out, because it is not clear
+            where this feature is used. It is very old and
+            undocumented. ezannoni: 5/4/99*/
+#if 0
          if (cmdarg[i][0] == '-' && cmdarg[i][1] == '\0')
            read_command_file (stdin);
          else
+#endif
            source_command (cmdarg[i], !batch);
          do_cleanups (ALL_CLEANUPS);
        }
@@ -617,6 +622,12 @@ main (argc, argv)
 #endif
     }
 
+  /* Call the event loop, if gdb was invoked with the --async
+     option. Control will never get back to this file, if the event
+     loop is invoked. See the files event-*.[ch] for details. */
+  if (async_hook)
+    async_hook();
+                
   /* The default command loop. 
      The WIN32 Gui calls this main to set up gdb's state, and 
      has its own command loop. */
This page took 0.023666 seconds and 4 git commands to generate.