/* Top level stuff for GDB, the GNU debugger.
- Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994
+ Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995
Free Software Foundation, Inc.
This file is part of GDB.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "defs.h"
#include <setjmp.h>
#include "getopt.h"
#include <sys/types.h>
-#include <sys/stat.h>
+#include "gdb_stat.h"
#include <ctype.h>
-#include <string.h>
-/* R_OK lives in either unistd.h or sys/file.h. */
-#ifdef USG
+#include "gdb_string.h"
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifndef NO_SYS_FILE
long time_at_startup = get_run_time ();
-/* start-sanitize-mpw */
+ START_PROGRESS (argv[0], 0);
+
#ifdef MPW
- /* Drop into MacsBug, but only if the executable is specially named. */
- if (strcmp(argv[0], "DEBUGGDB") == 0)
- DebugStr("\pat start of GDB main");
/* Do all Mac-specific setup. */
mac_init ();
#endif /* MPW */
-/* end-sanitize-mpw */
+
/* This needs to happen before the first use of malloc. */
init_malloc ((PTR) NULL);
current_directory = gdb_dirbuf;
/* Parse arguments and options. */
+#ifndef WINGDB
{
int c;
/* When var field is 0, use flag field to record the equivalent
break;
case 'f':
annotation_level = 1;
+/* We have probably been invoked from emacs. Disable window interface. */
+ use_windows = 0;
break;
case 's':
symarg = optarg;
else
baud_rate = i;
}
+ case 'l':
+ {
+ int i;
+ char *p;
+
+ i = strtol (optarg, &p, 0);
+ if (i == 0 && p == optarg)
+
+ /* Don't use *_filtered or warning() (which relies on
+ current_target) until after initialize_all_files(). */
+
+ fprintf_unfiltered
+ (gdb_stderr,
+ "warning: could not set timeout limit to `%s'.\n", optarg);
+ else
+ remote_timeout = i;
+ }
break;
#ifdef ADDITIONAL_OPTION_CASES
}
}
+ /* If --help or --version, disable window interface. */
+ if (print_help || print_version)
+ use_windows = 0;
+
/* OK, that's all the options. The other arguments are filenames. */
count = 0;
for (; optind < argc; optind++)
quiet = 1;
}
+#endif
gdb_init ();
/* Do these (and anything which might call wrap_here or *_filtered)
/* But don't use *_filtered here. We don't want to prompt for continue
no matter how small the screen or how much we're going to print. */
-/* start-sanitize-mpw */
-/* For reasons too ugly to describe... */
-#ifdef MPW_C
- fputs_unfiltered ("This is the GNU debugger.\n", gdb_stdout);
-#else
-/* end-sanitize-mpw */
fputs_unfiltered ("\
This is the GNU debugger. Usage:\n\
gdb [options] [executable-file [core-file or process-id]]\n\
--quiet Do not print version number on startup.\n\
--fullname Output information used by emacs-GDB interface.\n\
--epoch Output information used by epoch emacs-GDB interface.\n\
+", gdb_stdout);
+ fputs_unfiltered ("\
--batch Exit after processing options.\n\
--nx Do not read .gdbinit file.\n\
--tty=TTY Use TTY for input/output by the program being debugged.\n\
--cd=DIR Change current directory to DIR.\n\
--directory=DIR Search for source files in DIR.\n\
+", gdb_stdout);
+ fputs_unfiltered ("\
--command=FILE Execute GDB commands from FILE.\n\
--symbols=SYMFILE Read symbols from SYMFILE.\n\
--exec=EXECFILE Use EXECFILE as the executable.\n\
--se=FILE Use FILE as symbol file and executable file.\n\
+", gdb_stdout);
+ fputs_unfiltered ("\
--core=COREFILE Analyze the core dump COREFILE.\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 */
-/* end-sanitize-mpw */
#ifdef ADDITIONAL_OPTION_HELP
fputs_unfiltered (ADDITIONAL_OPTION_HELP, gdb_stdout);
#endif
GDB manual (available as on-line info or a printed manual).\n", gdb_stdout);
exit (0);
}
-
+
if (!quiet)
{
/* Print all the junk at the top, with trailing "..." if we are about
}
error_pre_print = "\n\n";
+ quit_pre_print = error_pre_print;
+
/* We may get more than one warning, don't double space all of them... */
warning_pre_print = "\nwarning: ";
strcpy (homeinit, getenv ("HOME"));
strcat (homeinit, "/");
strcat (homeinit, gdbinit);
+
if (!inhibit_gdbinit && access (homeinit, R_OK) == 0)
{
if (!SET_TOP_LEVEL ())
if (!quiet)
printf_filtered ("\n");
error_pre_print = "\n";
+ quit_pre_print = error_pre_print;
warning_pre_print = "\nwarning: ";
if (corearg != NULL)
#endif
/* Error messages should no longer be distinguished with extra output. */
- error_pre_print = 0;
+ error_pre_print = NULL;
+ quit_pre_print = NULL;
warning_pre_print = "warning: ";
/* Read the .gdbinit file in the current directory, *if* it isn't
BEFORE_MAIN_LOOP_HOOK;
#endif
+ END_PROGRESS (argv[0]);
+
/* Show time and/or space usage. */
if (display_time)
if (display_space)
{
+#ifdef HAVE_SBRK
extern char **environ;
char *lim = (char *) sbrk (0);
printf_unfiltered ("Startup size: data size %ld\n",
(long) (lim - (char *) &environ));
+#endif
}
- /* The command loop. */
-
+ /* The default command loop.
+ The WIN32 Gui calls this main to set up gdb's state, and
+ has its own command loop. */
+#if !defined (WINGDB)
while (1)
{
if (!SET_TOP_LEVEL ())
quit_command ((char *)0, instream == stdin);
}
}
+
/* No exit -- exit is through quit_command. */
+#endif
+
}
\f
void
{
}
-int
-proc_wait (pid, status)
- int pid;
- int *status;
-{
-#ifndef __GO32__
- return wait (status);
-#endif
-}
-
void
proc_remove_foreign (pid)
int pid;