diff options
author | Andrew Cagney <cagney@redhat.com> | 2003-02-06 01:19:12 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2003-02-06 01:19:12 +0000 |
commit | 4389a95abbef3cf59d29e0fe15458335a0b3f0ab (patch) | |
tree | 8551c07e6de03f1cf9cdc9df764a873d696dda07 /gdb/main.c | |
parent | 0667fdb0c6b70b1e9712c6bf837e77a60ba40904 (diff) | |
download | gdb-4389a95abbef3cf59d29e0fe15458335a0b3f0ab.zip gdb-4389a95abbef3cf59d29e0fe15458335a0b3f0ab.tar.gz gdb-4389a95abbef3cf59d29e0fe15458335a0b3f0ab.tar.bz2 |
2003-02-05 Jim Ingham <jingham@apple.com>
Keith Seitz <keiths@redhat.com>
Elena Zannoni <ezannoni@redhat.com>
Andrew Cagney <ac131313@redhat.com>
* Makefile.in (SUBDIR_CLI_OBS): Add "cli-interp.o".
(SUBDIR_CLI_SRCS): Add "cli/cli-interp.c".
(SUBDIR_MI_OBS): Add "mi-interp.o".
(SUBDIR_MI_SRCS): Add "mi/mi-interp.c".
(SFILES): Add "interps.c".
(COMMON_OBS): Add "interps.o".
(interps_h, mi_main_h): Define.
(interps.o, cli-interp.o, mi-interp.o): Add dependencies.
(mi-main.o, main.o, event-top.o): Update dependencies.
* cli/cli-interp.c: New file.
* interps.h, interps.c: New files.
* top.c: (gdb_init): Don't install the default interpreter, handed
by captured_main.
* main.c: Include "interps.h".
(interpreter_p): Note that it should malloc'ed.
(captured_command_loop): Call current_interp_command_loop.
(captured_main): Initialize interpreter_p to INTERP_CONSOLE. Use
xfree and xstrdup when updating interpreter_p. Install the
default interpreter. Add hack to stop mi1's copyright notice
being encoded.
* event-top.h (gdb_setup_readline): Declare.
(gdb_disable_readline): Declare.
* event-top.c: Include "interps.h".
(display_gdb_prompt): Call current_interp_display_prompt_p.
(gdb_setup_readline): Initialize gdb_stdout, gdb_stderr,
gdb_stdlog, and gdb_stdtarg.
(_initialize_event_loop): Don't call gdb_setup_readline.
* cli-out.c (cli_out_set_stream): New function.
* cli-out.h (cli_out_set_stream): Declare.
Diffstat (limited to 'gdb/main.c')
-rw-r--r-- | gdb/main.c | 75 |
1 files changed, 64 insertions, 11 deletions
@@ -1,7 +1,8 @@ /* Top level stuff for GDB, the GNU debugger. - Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, - 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 - Free Software Foundation, Inc. + + Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software + Foundation, Inc. This file is part of GDB. @@ -37,6 +38,7 @@ #include "event-loop.h" #include "ui-out.h" +#include "interps.h" #include "main.h" /* If nonzero, display time usage both at startup and for each command. */ @@ -53,7 +55,9 @@ int display_space; processes UI events asynchronously. */ int event_loop_p = 1; -/* Has an interpreter been specified and if so, which. */ +/* The selected interpreter. This will be used as a set command + variable, so it should always be malloc'ed - since + do_setshow_command will free it. */ char *interpreter_p; /* Whether this is the command line version or not */ @@ -93,10 +97,7 @@ extern char *external_editor_command; static int captured_command_loop (void *data) { - if (command_loop_hook == NULL) - command_loop (); - else - command_loop_hook (); + current_interp_command_loop (); /* FIXME: cagney/1999-11-05: A correct command_loop() implementaton would clean things up (restoring the cleanup chain) to the state they were just prior to the call. Technically, this means that @@ -227,6 +228,12 @@ captured_main (void *data) #endif #endif + /* There will always be an interpreter. Either the one passed into + this captured main (not yet implemented), or one specified by the + user at start up, or the console. Make life easier by always + initializing the interpreter to something. */ + interpreter_p = xstrdup (INTERP_CONSOLE); + /* Parse arguments and options. */ { int c; @@ -381,7 +388,8 @@ extern int gdbtk_test (char *); } #endif /* GDBTK */ case 'i': - interpreter_p = optarg; + xfree (interpreter_p); + interpreter_p = xstrdup (optarg); break; case 'd': dirarg[ndir++] = optarg; @@ -509,7 +517,10 @@ extern int gdbtk_test (char *); gdb_init (argv[0]); /* Do these (and anything which might call wrap_here or *_filtered) - after initialize_all_files. */ + after initialize_all_files() but before the interpreter has been + installed. Otherwize the help/version messages will be eaten by + the interpreter's output handler. */ + if (print_version) { print_gdb_version (gdb_stdout); @@ -525,7 +536,49 @@ extern int gdbtk_test (char *); exit (0); } - if (!quiet) + /* FIXME: cagney/2003-02-03: The big hack (part 1 of 2) that lets + GDB retain the old MI1 interpreter startup behavior. Output the + copyright message before the interpreter is installed. That way + it isn't encapsulated in MI output. */ + if (!quiet && strcmp (interpreter_p, INTERP_MI1) == 0) + { + /* Print all the junk at the top, with trailing "..." if we are about + to read a symbol file (possibly slowly). */ + print_gdb_version (gdb_stdout); + if (symarg) + printf_filtered (".."); + wrap_here (""); + gdb_flush (gdb_stdout); /* Force to screen during slow operations */ + } + + + /* Install the default UI. All the interpreters should have had a + look at things by now. Initialize the default interpreter. */ + + { + /* Find it. */ + struct interp *interp = interp_lookup (interpreter_p); + if (interp == NULL) + { + fprintf_unfiltered (gdb_stderr, "Interpreter `%s' unrecognized.\n", + interpreter_p); + exit (1); + } + /* Install it. */ + if (!interp_set (interp)) + { + fprintf_unfiltered (gdb_stderr, + "Interpreter `%s' failed to initialize.\n", + interpreter_p); + exit (1); + } + } + + /* FIXME: cagney/2003-02-03: The big hack (part 2 of 2) that lets + GDB retain the old MI1 interpreter startup behavior. Output the + copyright message after the interpreter is installed when it is + any sane interpreter. */ + if (!quiet && !current_interp_named_p (INTERP_MI1)) { /* Print all the junk at the top, with trailing "..." if we are about to read a symbol file (possibly slowly). */ |