get rid of unused m4 files
[deliverable/binutils-gdb.git] / gdb / main.c
index 2e0c00de86965912f78b4ba97a06094101b37a85..228d62ce0c1b4494a6e4be69e22651293ea7f236 100644 (file)
@@ -22,11 +22,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <setjmp.h>
 #include "top.h"
 #include "target.h"
+#include "inferior.h"
+#include "call-cmds.h"
 
 #include "getopt.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <ctype.h>
 
 #include <string.h>
 /* R_OK lives in either unistd.h or sys/file.h.  */
@@ -38,6 +41,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #endif
 
 /* Temporary variable for SET_TOP_LEVEL.  */
+
 static int top_level_val;
 
 /* Do a setjmp on error_return and quit_return.  catch_errors is
@@ -49,6 +53,16 @@ static int top_level_val;
     ? (PTR) 0 : (PTR) memcpy (quit_return, error_return, sizeof (jmp_buf))) \
    , top_level_val)
 
+/* If nonzero, display time usage both at startup and for each command.  */
+
+int display_time;
+
+/* If nonzero, display space usage both at startup and for each command.  */
+
+int display_space;
+
+extern void gdb_init PARAMS ((void));
+
 int
 main (argc, argv)
      int argc;
@@ -88,6 +102,8 @@ main (argc, argv)
 
   register int i;
 
+  long time_at_startup = get_run_time ();
+
 /* start-sanitize-mpw */
 #ifdef MPW
   /* Drop into MacsBug, but only if the executable is specially named. */
@@ -169,11 +185,16 @@ main (argc, argv)
        {"tty", required_argument, 0, 't'},
        {"baud", required_argument, 0, 'b'},
        {"b", required_argument, 0, 'b'},
+       {"nw", no_argument, &use_windows, 0},
+       {"nowindows", no_argument, &use_windows, 0},
+       {"w", no_argument, &use_windows, 1},
+       {"windows", no_argument, &use_windows, 1},
+       {"statistics", no_argument, 0, 13},
 /* Allow machine descriptions to add more options... */
 #ifdef ADDITIONAL_OPTIONS
        ADDITIONAL_OPTIONS
 #endif
-       {0, no_argument, 0, 0},
+       {0, no_argument, 0, 0}
       };
 
     while (1)
@@ -205,6 +226,11 @@ main (argc, argv)
            /* FIXME: what if the syntax is wrong (e.g. not digits)?  */
            annotation_level = atoi (optarg);
            break;
+         case 13:
+           /* Enable the display of both time and space usage.  */
+           display_time = 1;
+           display_space = 1;
+           break;
          case 'f':
            annotation_level = 1;
            break;
@@ -345,6 +371,7 @@ Options:\n\
   -b BAUDRATE        Set serial port baud rate used for remote debugging.\n\
   --mapped           Use mapped symbol files if supported on this system.\n\
   --readnow          Fully read symbol files on first access.\n\
+  --nw              Do not use a window interface.\n\
 ", gdb_stdout);
 /* start-sanitize-mpw */
 #endif /* MPW_C */
@@ -405,7 +432,7 @@ GDB manual (available as on-line info or a printed manual).\n", gdb_stdout);
       stat (gdbinit, &cwdbuf); /* We'll only need this if
                                       homedir was set.  */
     }
-  
+
   /* Now perform all the actions indicated by the arguments.  */
   if (cdarg != NULL)
     {
@@ -514,6 +541,25 @@ GDB manual (available as on-line info or a printed manual).\n", gdb_stdout);
   BEFORE_MAIN_LOOP_HOOK;
 #endif
 
+  /* Show time and/or space usage.  */
+
+  if (display_time)
+    {
+      long init_time = get_run_time () - time_at_startup;
+
+      printf_unfiltered ("Startup time: %ld.%06ld\n",
+                        init_time / 1000000, init_time % 1000000);
+    }
+
+  if (display_space)
+    {
+      extern char **environ;
+      char *lim = (char *) sbrk (0);
+
+      printf_unfiltered ("Startup size: data size %ld\n",
+                        (long) (lim - (char *) &environ));
+    }
+
   /* The command loop.  */
 
   while (1)
@@ -521,18 +567,13 @@ GDB manual (available as on-line info or a printed manual).\n", gdb_stdout);
       if (!SET_TOP_LEVEL ())
        {
          do_cleanups (ALL_CLEANUPS);           /* Do complete cleanup */
-/* start-sanitize-mpw */
-#ifdef MPW
-         /* If we're being a Mac application, go into a Mac-specific
-            event-handling loop instead.  We still want to be inside
-            the outer loop, because that will catch longjmps resulting
-            from some command executions. */
-         if (mac_app)
-           mac_command_loop ();
+         /* GUIs generally have their own command loop, mainloop, or whatever.
+            This is a good place to gain control because many error
+            conditions will end up here via longjmp(). */
+         if (command_loop_hook)
+           command_loop_hook ();
          else
-#endif /* MPW */
-/* end-sanitize-mpw */
-         command_loop ();
+           command_loop ();
           quit_command ((char *)0, instream == stdin);
        }
     }
@@ -549,7 +590,9 @@ proc_wait (pid, status)
      int pid;
      int *status;
 {
+#ifndef __GO32__
   return wait (status);
+#endif
 }
 
 void
@@ -563,5 +606,16 @@ fputs_unfiltered (linebuffer, stream)
      const char *linebuffer;
      FILE *stream;
 {
+  if (fputs_unfiltered_hook)
+    {
+      /* FIXME: I think we should only be doing this for stdout or stderr.
+        Either that or we should be passing stream to the hook so it can
+        deal with it.  If that is cleaned up, this function can go back
+        into utils.c and the fputs_unfiltered_hook can replace the current
+        ability to avoid this function by not linking with main.c.  */
+      fputs_unfiltered_hook (linebuffer, stream);
+      return;
+    }
+
   fputs (linebuffer, stream);
 }
This page took 0.025207 seconds and 4 git commands to generate.