* MAINTAINERS: Change my e-mail address.
[deliverable/binutils-gdb.git] / gdb / main.c
index fa976ea14a5805fc4678a9510207d4c2a68c5688..5a06017ac887aee325c305fc5ab749e10c91da2d 100644 (file)
@@ -73,10 +73,10 @@ struct ui_file *gdb_stdout;
 struct ui_file *gdb_stderr;
 struct ui_file *gdb_stdlog;
 struct ui_file *gdb_stdtarg;
-
-/* Used to initialize error() - defined in utils.c */
-
-extern void error_init (void);
+struct ui_file *gdb_stdin;
+/* target IO streams */
+struct ui_file *gdb_stdtargin;
+struct ui_file *gdb_stdtargerr;
 
 /* Whether to enable writing into executable and core files */
 extern int write_files;
@@ -168,6 +168,10 @@ captured_main (void *data)
   /* This needs to happen before the first use of malloc.  */
   init_malloc (NULL);
 
+#ifdef HAVE_SBRK
+  lim_at_start = (char *) sbrk (0);
+#endif
+
 #if defined (ALIGN_STACK_ON_STARTUP)
   i = (int) &count & 0x3;
   if (i != 0)
@@ -193,6 +197,9 @@ captured_main (void *data)
   gdb_stderr = stdio_fileopen (stderr);
   gdb_stdlog = gdb_stderr;     /* for moment */
   gdb_stdtarg = gdb_stderr;    /* for moment */
+  gdb_stdin = stdio_fileopen (stdin);
+  gdb_stdtargerr = gdb_stderr; /* for moment */
+  gdb_stdtargin = gdb_stdin;   /* for moment */
 
   /* initialize error() */
   error_init ();
@@ -242,7 +249,9 @@ captured_main (void *data)
       OPT_CD,
       OPT_ANNOTATE,
       OPT_STATISTICS,
-      OPT_TUI
+      OPT_TUI,
+      OPT_NOWINDOWS,
+      OPT_WINDOWS
     };
     static struct option long_options[] =
     {
@@ -299,10 +308,10 @@ captured_main (void *data)
       {"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},
+      {"nw", no_argument, NULL, OPT_NOWINDOWS},
+      {"nowindows", no_argument, NULL, OPT_NOWINDOWS},
+      {"w", no_argument, NULL, OPT_WINDOWS},
+      {"windows", no_argument, NULL, OPT_WINDOWS},
       {"statistics", no_argument, 0, OPT_STATISTICS},
       {"write", no_argument, &write_files, 1},
       {"args", no_argument, &set_args, 1},
@@ -348,6 +357,17 @@ captured_main (void *data)
            xfree (interpreter_p);
            interpreter_p = xstrdup ("tui");
            break;
+         case OPT_WINDOWS:
+           /* FIXME: cagney/2003-03-01: Not sure if this option is
+               actually useful, and if it is, what it should do.  */
+           use_windows = 1;
+           break;
+         case OPT_NOWINDOWS:
+           /* -nw is equivalent to -i=console.  */
+           xfree (interpreter_p);
+           interpreter_p = xstrdup (INTERP_CONSOLE);
+           use_windows = 0;
+           break;
          case 'f':
            annotation_level = 1;
 /* We have probably been invoked from emacs.  Disable window interface.  */
@@ -557,11 +577,7 @@ extern int gdbtk_test (char *);
     /* Find it.  */
     struct interp *interp = interp_lookup (interpreter_p);
     if (interp == NULL)
-      {
-        fprintf_unfiltered (gdb_stderr, "Interpreter `%s' unrecognized.\n",
-                            interpreter_p);
-        exit (1);
-      }
+      error ("Interpreter `%s' unrecognized", interpreter_p);
     /* Install it.  */
     if (!interp_set (interp))
       {
@@ -802,7 +818,9 @@ gdb_main (struct captured_main_args *args)
 {
   use_windows = args->use_windows;
   catch_errors (captured_main, args, "", RETURN_MASK_ALL);
-  return 0;
+  /* The only way to end up here is by an error (normal exit is
+     handled by quit_force()), hence always return an error status.  */
+  return 1;
 }
 
 
This page took 0.024524 seconds and 4 git commands to generate.