X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Ftop.c;h=83d858adcfc4b184dceef249c2887fc18e2dc675;hb=9c1877ead06db18e19614a598d1e280acb97e971;hp=b3e7d37536056b3c9fbcfb2c8d39c074244f3b8b;hpb=257e6d53e260db58681013eb25ea17ee061ba052;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/top.c b/gdb/top.c index b3e7d37536..83d858adcf 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1,6 +1,6 @@ /* Top level stuff for GDB, the GNU debugger. - Copyright (C) 1986-2013 Free Software Foundation, Inc. + Copyright (C) 1986-2014 Free Software Foundation, Inc. This file is part of GDB. @@ -25,9 +25,10 @@ #include "cli/cli-decode.h" #include "symtab.h" #include "inferior.h" -#include "exceptions.h" +#include "infrun.h" #include #include "target.h" +#include "target-dcache.h" #include "breakpoint.h" #include "gdbtypes.h" #include "expression.h" @@ -40,11 +41,10 @@ #include "version.h" #include "serial.h" #include "doublest.h" -#include "gdb_assert.h" #include "main.h" #include "event-loop.h" #include "gdbthread.h" -#include "python/python.h" +#include "extension.h" #include "interps.h" #include "observer.h" #include "maint.h" @@ -60,12 +60,12 @@ #include #include "event-top.h" -#include "gdb_string.h" -#include "gdb_stat.h" +#include #include #include "ui-out.h" #include "cli-out.h" #include "tracepoint.h" +#include "inf-loop.h" extern void initialize_all_files (void); @@ -85,11 +85,6 @@ const char gdbinit[] = GDBINIT; int inhibit_gdbinit = 0; -/* If nonzero, and GDB has been configured to be able to use windows, - attempt to open them upon startup. */ - -int use_windows = 0; - extern char lang_frame_mismatch_warn[]; /* language.c */ /* Flag for whether we want to confirm potentially dangerous @@ -144,13 +139,6 @@ int saved_command_line_size = 100; is issuing commands too. */ int server_command; -/* Baud rate specified for talking to serial target systems. Default - is left as -1, so targets can choose their own defaults. */ -/* FIXME: This means that "show remotebaud" and gr_files_info can - print -1 or (unsigned int)-1. This is a Bad User Interface. */ - -int baud_rate = -1; - /* Timeout limit for response from target. */ /* The default value has been changed many times over the years. It @@ -259,11 +247,6 @@ ptid_t (*deprecated_target_wait_hook) (ptid_t ptid, void (*deprecated_call_command_hook) (struct cmd_list_element * c, char *cmd, int from_tty); -/* Called after a `set' command has finished. Is only run if the - `set' command succeeded. */ - -void (*deprecated_set_hook) (struct cmd_list_element * c); - /* Called when the current thread changes. Argument is thread id. */ void (*deprecated_context_hook) (int id); @@ -389,6 +372,23 @@ check_frame_language_change (void) } } +/* See top.h. */ + +void +maybe_wait_sync_command_done (int was_sync) +{ + /* If the interpreter is in sync mode (we're running a user + command's list, running command hooks or similars), and we + just ran a synchronous command that started the target, wait + for that command to end. */ + if (!interpreter_async && !was_sync && sync_execution) + { + while (gdb_do_one_event () >= 0) + if (!sync_execution) + break; + } +} + /* Execute the line P as a command, in the current user context. Pass FROM_TTY as second argument to the defining function. */ @@ -422,6 +422,8 @@ execute_command (char *p, int from_tty) { const char *cmd = p; char *arg; + int was_sync = sync_execution; + line = p; /* If trace-commands is set then this will print this command. */ @@ -456,7 +458,7 @@ execute_command (char *p, int from_tty) /* If this command has been pre-hooked, run the hook first. */ execute_cmd_pre_hook (c); - if (c->flags & DEPRECATED_WARN_USER) + if (c->deprecated_warn_user) deprecated_cmd_warning (line); /* c->user_commands would be NULL in the case of a python command. */ @@ -473,16 +475,7 @@ execute_command (char *p, int from_tty) else cmd_func (c, arg, from_tty); - /* If the interpreter is in sync mode (we're running a user - command's list, running command hooks or similars), and we - just ran a synchronous command that started the target, wait - for that command to end. */ - if (!interpreter_async && sync_execution) - { - while (gdb_do_one_event () >= 0) - if (!sync_execution) - break; - } + maybe_wait_sync_command_done (was_sync); /* If this command has been post-hooked, run the hook last. */ execute_cmd_post_hook (c); @@ -574,11 +567,14 @@ command_loop (void) make_command_stats_cleanup (1); - execute_command (command, instream == stdin); - - /* Do any commands attached to breakpoint we are stopped at. */ - bpstat_do_actions (); + /* Do not execute commented lines. */ + if (command[0] != '#') + { + execute_command (command, instream == stdin); + /* Do any commands attached to breakpoint we are stopped at. */ + bpstat_do_actions (); + } do_cleanups (old_chain); } } @@ -766,15 +762,24 @@ gdb_readline_wrapper_line (char *line) after_char_processing_hook = NULL; /* Prevent parts of the prompt from being redisplayed if annotations - are enabled, and readline's state getting out of sync. */ + are enabled, and readline's state getting out of sync. We'll + reinstall the callback handler, which puts the terminal in raw + mode (or in readline lingo, in prepped state), when we're next + ready to process user input, either in display_gdb_prompt, or if + we're handling an asynchronous target event and running in the + background, just before returning to the event loop to process + further input (or more target events). */ if (async_command_editing_p) - rl_callback_handler_remove (); + gdb_rl_callback_handler_remove (); } struct gdb_readline_wrapper_cleanup { void (*handler_orig) (char *); int already_prompted_orig; + + /* Whether the target was async. */ + int target_is_async_orig; }; static void @@ -786,12 +791,23 @@ gdb_readline_wrapper_cleanup (void *arg) gdb_assert (input_handler == gdb_readline_wrapper_line); input_handler = cleanup->handler_orig; + + /* Don't restore our input handler in readline yet. That would make + readline prep the terminal (putting it in raw mode), while the + line we just read may trigger execution of a command that expects + the terminal in the default cooked/canonical mode, such as e.g., + running Python's interactive online help utility. See + gdb_readline_wrapper_line for when we'll reinstall it. */ + gdb_readline_wrapper_result = NULL; gdb_readline_wrapper_done = 0; after_char_processing_hook = saved_after_char_processing_hook; saved_after_char_processing_hook = NULL; + if (cleanup->target_is_async_orig) + target_async (inferior_event_handler, 0); + xfree (cleanup); } @@ -808,8 +824,13 @@ gdb_readline_wrapper (char *prompt) cleanup->already_prompted_orig = rl_already_prompted; + cleanup->target_is_async_orig = target_is_async_p (); + back_to = make_cleanup (gdb_readline_wrapper_cleanup, cleanup); + if (cleanup->target_is_async_orig) + target_async (NULL, NULL); + /* Display our prompt and prevent double prompt display. */ display_gdb_prompt (prompt); rl_already_prompted = 1; @@ -1068,19 +1089,9 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix) *p = 0; /* Add line to history if appropriate. */ - if (instream == stdin - && ISATTY (stdin) && *linebuffer) + if (*linebuffer && input_from_terminal_p ()) add_history (linebuffer); - /* Note: lines consisting solely of comments are added to the command - history. This is useful when you type a command, and then - realize you don't want to execute it quite yet. You can comment - out the command and then later fetch it from the value history - and remove the '#'. The kill ring is probably better, but some - people are in the habit of commenting things out. */ - if (*p1 == '#') - *p1 = '\0'; /* Found a comment. */ - /* Save into global buffer if appropriate. */ if (repeat) { @@ -1109,7 +1120,7 @@ print_gdb_version (struct ui_file *stream) /* Second line is a copyright notice. */ fprintf_filtered (stream, - "Copyright (C) 2013 Free Software Foundation, Inc.\n"); + "Copyright (C) 2014 Free Software Foundation, Inc.\n"); /* Following the copyright is a brief statement that the program is free software, that users are free to copy and change it on @@ -1208,6 +1219,15 @@ This GDB was configured as follows:\n\ --with-python=%s%s\n\ "), WITH_PYTHON_PATH, PYTHON_PATH_RELOCATABLE ? " (relocatable)" : ""); #endif +#if HAVE_GUILE + fprintf_filtered (stream, _("\ + --with-guile\n\ +")); +#else + fprintf_filtered (stream, _("\ + --without-guile\n\ +")); +#endif #ifdef RELOC_SRCDIR fprintf_filtered (stream, _("\ --with-relocated-sources=%s\n\ @@ -1355,18 +1375,9 @@ quit_confirm (void) stb = mem_fileopen (); old_chain = make_cleanup_ui_file_delete (stb); - /* This is something of a hack. But there's no reliable way to see - if a GUI is running. The `use_windows' variable doesn't cut - it. */ - if (deprecated_init_ui_hook) - fprintf_filtered (stb, _("A debugging session is active.\n" - "Do you still want to close the debugger?")); - else - { - fprintf_filtered (stb, _("A debugging session is active.\n\n")); - iterate_over_inferiors (print_inferior_quit_action, stb); - fprintf_filtered (stb, _("\nQuit anyway? ")); - } + fprintf_filtered (stb, _("A debugging session is active.\n\n")); + iterate_over_inferiors (print_inferior_quit_action, stb); + fprintf_filtered (stb, _("\nQuit anyway? ")); str = ui_file_xstrdup (stb, NULL); make_cleanup (xfree, str); @@ -1573,7 +1584,7 @@ set_history (char *args, int from_tty) { printf_unfiltered (_("\"set history\" must be followed " "by the name of a history subcommand.\n")); - help_list (sethistlist, "set history ", -1, gdb_stdout); + help_list (sethistlist, "set history ", all_commands, gdb_stdout); } void @@ -1692,14 +1703,28 @@ show_exec_done_display_p (struct ui_file *file, int from_tty, value); } +/* New values of the "data-directory" parameter are staged here. */ +static char *staged_gdb_datadir; + /* "set" command for the gdb_datadir configuration variable. */ static void set_gdb_datadir (char *args, int from_tty, struct cmd_list_element *c) { + set_gdb_data_directory (staged_gdb_datadir); observer_notify_gdb_datadir_changed (); } +/* "show" command for the gdb_datadir configuration variable. */ + +static void +show_gdb_datadir (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("GDB's data directory is \"%s\".\n"), + gdb_datadir); +} + static void set_history_filename (char *args, int from_tty, struct cmd_list_element *c) { @@ -1817,11 +1842,11 @@ Use \"on\" to enable the notification, and \"off\" to disable it."), &setlist, &showlist); add_setshow_filename_cmd ("data-directory", class_maintenance, - &gdb_datadir, _("Set GDB's data directory."), + &staged_gdb_datadir, _("Set GDB's data directory."), _("Show GDB's data directory."), _("\ When set, GDB uses the specified path to search for data files."), - set_gdb_datadir, NULL, + set_gdb_datadir, show_gdb_datadir, &setlist, &showlist); } @@ -1876,11 +1901,9 @@ gdb_init (char *argv0) if (deprecated_init_ui_hook) deprecated_init_ui_hook (argv0); -#ifdef HAVE_PYTHON - /* Python initialization can require various commands to be + /* Python initialization, for example, can require various commands to be installed. For example "info pretty-printer" needs the "info" prefix to be installed. Keep things simple and just do final - python initialization here. */ - finish_python_initialization (); -#endif + script initialization here. */ + finish_ext_lang_initialization (); }