Replace <sys/dir.h> (and <dirent.h>) with "gdb_dirent.h".
[deliverable/binutils-gdb.git] / gdb / main.c
index 42485c0e6d35b6ebbad5c7a897b7069dfd2c5eee..9f845a89c5ea02d53af4993e96d0ce1edf1ea749 100644 (file)
@@ -1,6 +1,5 @@
 /* Top level stuff for GDB, the GNU debugger.
-   Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 1999
-   Free Software Foundation, Inc.
+   Copyright 1986-1995, 1999-2000 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 
 #include "gdb_string.h"
 #include "event-loop.h"
+#include "ui-out.h"
+#if defined (TUI) || defined (GDBTK)
+/* FIXME: cagney/2000-01-31: This #include is to allow older code such
+   as that found in the TUI to continue to build. */
+#include "tui/tui-file.h"
+#endif
 
 /* If nonzero, display time usage both at startup and for each command.  */
 
@@ -48,6 +53,11 @@ int display_space;
    processes UI events asynchronously. */
 int event_loop_p = 1;
 
+#ifdef UI_OUT
+/* Has an interpreter been specified and if so, which. */
+char *interpreter_p;
+#endif
+
 /* Whether this is the command line version or not */
 int tui_version = 0;
 
@@ -57,10 +67,10 @@ int xdb_commands = 0;
 /* Whether dbx commands will be handled */
 int dbx_commands = 0;
 
-GDB_FILE *gdb_stdout;
-GDB_FILE *gdb_stderr;
-GDB_FILE *gdb_stdlog;
-GDB_FILE *gdb_stdtarg;
+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 */
 
@@ -69,7 +79,7 @@ extern void error_init (void);
 /* Whether to enable writing into executable and core files */
 extern int write_files;
 
-static void print_gdb_help PARAMS ((GDB_FILE *));
+static void print_gdb_help (struct ui_file *);
 
 /* These two are used to set the external editor commands when gdb is farming
    out files to be edited by another program. */
@@ -187,17 +197,19 @@ captured_main (void *data)
   getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
   current_directory = gdb_dirbuf;
 
-#if 0
-  /* not yet */
-  gdb_stdout = stdio_fileopen (stdout);
-  gdb_stderr = stdio_fileopen (stderr);
-  gdb_stdlog = gdb_stderr;     /* for moment */
-  gdb_stdtarg = gdb_stderr;    /* for moment */
-#else
+#if defined (TUI) || defined (GDBTK)
+  /* Older code uses the tui_file and fputs_unfiltered_hook().  It
+     should be using a customized UI_FILE object and re-initializing
+     within its own _initialize function.  */
   gdb_stdout = tui_fileopen (stdout);
   gdb_stderr = tui_fileopen (stderr);
   gdb_stdlog = gdb_stdout;     /* for moment */
   gdb_stdtarg = gdb_stderr;    /* for moment */
+#else
+  gdb_stdout = stdio_fileopen (stdout);
+  gdb_stderr = stdio_fileopen (stderr);
+  gdb_stdlog = gdb_stderr;     /* for moment */
+  gdb_stdtarg = gdb_stderr;    /* for moment */
 #endif
 
   /* initialize error() */
@@ -248,7 +260,18 @@ captured_main (void *data)
       {"command", required_argument, 0, 'x'},
       {"version", no_argument, &print_version, 1},
       {"x", required_argument, 0, 'x'},
+#ifdef GDBTK
+      {"tclcommand", required_argument, 0, 'z'},
+      {"enable-external-editor", no_argument, 0, 'y'},
+      {"editor-command", required_argument, 0, 'w'},
+#endif
+#ifdef UI_OUT
+      {"ui", required_argument, 0, 'i'},
+      {"interpreter", required_argument, 0, 'i'},
+      {"i", required_argument, 0, 'i'},
+#endif
       {"directory", required_argument, 0, 'd'},
+      {"d", required_argument, 0, 'd'},
       {"cd", required_argument, 0, 11},
       {"tty", required_argument, 0, 't'},
       {"baud", required_argument, 0, 'b'},
@@ -323,6 +346,45 @@ captured_main (void *data)
                                             cmdsize * sizeof (*cmdarg));
              }
            break;
+#ifdef GDBTK
+         case 'z':
+           {
+             extern int gdbtk_test PARAMS ((char *));
+             if (!gdbtk_test (optarg))
+               {
+                 fprintf_unfiltered (gdb_stderr, "%s: unable to load tclcommand file \"%s\"",
+                                     argv[0], optarg);
+                 exit (1);
+               }
+             break;
+           }
+         case 'y':
+           {
+             /*
+              * This enables the edit/button in the main window, even
+              * when IDE_ENABLED is set to false. In this case you must
+              * use --tclcommand to specify a tcl/script to be called,
+              * Tcl/Variable to store the edit/command is:
+              * external_editor
+              */
+             enable_external_editor = 1;
+             break;
+           }
+         case 'w':
+           {
+             /*
+              * if editor command is enabled, both flags are set
+              */
+             enable_external_editor = 1;
+             external_editor_command = xstrdup (optarg);
+             break;
+           }
+#endif /* GDBTK */
+#ifdef UI_OUT
+         case 'i':
+           interpreter_p = optarg;
+           break;
+#endif
          case 'd':
            dirarg[ndir++] = optarg;
            if (ndir >= dirsize)
@@ -693,7 +755,6 @@ captured_main (void *data)
 int
 main (int argc, char **argv)
 {
-  int top_level_val;
   struct captured_main_args args;
   args.argc = argc;
   args.argv = argv;
@@ -707,8 +768,7 @@ main (int argc, char **argv)
    to print.  */
 
 static void
-print_gdb_help (stream)
-     GDB_FILE *stream;
+print_gdb_help (struct ui_file *stream)
 {
   fputs_unfiltered ("\
 This is the GNU debugger.  Usage:\n\n\
@@ -732,6 +792,10 @@ Options:\n\n\
   --exec=EXECFILE    Use EXECFILE as the executable.\n\
   --fullname         Output information used by emacs-GDB interface.\n\
   --help             Print this message.\n\
+", stream);
+  fputs_unfiltered ("\
+  --interpreter=INTERP\n\
+                     Select a specific interpreter / user interface\n\
 ", stream);
   fputs_unfiltered ("\
   --mapped           Use mapped symbol files if supported on this system.\n\
This page took 0.025377 seconds and 4 git commands to generate.