X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Ftop.c;h=86c9971fa6dfb48e8301a58bfe09e785b109a2ce;hb=0d02e70b197c786f26175b9a73f94e01d14abdab;hp=e6786118a188e092e25b2e209f36d679246801e9;hpb=fa8a0804b8fd7599367147754b4c82d555860374;p=binutils-gdb.git diff --git a/gdb/top.c b/gdb/top.c index e6786118a18..86c9971fa6d 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -257,6 +257,41 @@ void (*deprecated_context_hook) (int id); /* The highest UI number ever assigned. */ static int highest_ui_num; +/* Unbuffer STREAM. This is a wrapper around setbuf(STREAM, nullptr) + which applies some special rules for MS-Windows hosts. */ + +static void +unbuffer_stream (FILE *stream) +{ + /* Unbuffer the input stream so that in gdb_readline_no_editing_callback, + the calls to fgetc fetch only one char at the time from STREAM. + + This is important because gdb_readline_no_editing_callback will read + from STREAM up to the first '\n' character, after this GDB returns to + the event loop and relies on a select on STREAM indicating that more + input is pending. + + If STREAM is buffered then the fgetc calls may have moved all the + pending input from the kernel into a local buffer, after which the + select will not indicate that more input is pending, and input after + the first '\n' will not be processed immediately. + + Please ensure that any changes in this area run the MI tests with the + FORCE_SEPARATE_MI_TTY=1 flag being passed. */ + +#ifdef __MINGW32__ + /* With MS-Windows runtime, making stdin unbuffered when it's + connected to the terminal causes it to misbehave. */ + if (!ISATTY (stream)) + setbuf (stream, nullptr); +#else + /* On GNU/Linux the issues described above can impact GDB even when + dealing with input from a terminal. For now we unbuffer the input + stream for everyone except MS-Windows. */ + setbuf (stream, nullptr); +#endif +} + /* See top.h. */ ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_) @@ -283,6 +318,8 @@ ui::ui (FILE *instream_, FILE *outstream_, FILE *errstream_) { buffer_init (&line_buffer); + unbuffer_stream (instream_); + if (ui_list == NULL) ui_list = this; else @@ -412,6 +449,8 @@ read_command_file (FILE *stream) { struct ui *ui = current_ui; + unbuffer_stream (stream); + scoped_restore save_instream = make_scoped_restore (&ui->instream, stream); @@ -1428,9 +1467,11 @@ print_gdb_version (struct ui_file *stream, bool interactive) there is no warranty. */ gdb_printf (stream, "\ -License GPLv3+: GNU GPL version 3 or later \ +License GPLv3+: GNU GPL version 3 or later <%ps>\ \nThis is free software: you are free to change and redistribute it.\n\ -There is NO WARRANTY, to the extent permitted by law."); +There is NO WARRANTY, to the extent permitted by law.", + styled_string (file_name_style.style (), + "http://gnu.org/licenses/gpl.html")); if (!interactive) return; @@ -1459,11 +1500,15 @@ There is NO WARRANTY, to the extent permitted by law."); { gdb_printf (stream, _("For bug reporting instructions, please see:\n")); - gdb_printf (stream, "%s.\n", REPORT_BUGS_TO); + gdb_printf (stream, "%ps.\n", + styled_string (file_name_style.style (), + REPORT_BUGS_TO)); } gdb_printf (stream, _("Find the GDB manual and other documentation \ -resources online at:\n .")); +resources online at:\n <%ps>."), + styled_string (file_name_style.style (), + "http://www.gnu.org/software/gdb/documentation/")); gdb_printf (stream, "\n\n"); gdb_printf (stream, _("For help, type \"help\".\n")); gdb_printf (stream, @@ -1619,11 +1664,11 @@ This GDB was configured as follows:\n\ #endif #if CXX_STD_THREAD - fprintf_filtered (stream, _("\ + gdb_printf (stream, _("\ --enable-threading\n\ ")); #else - fprintf_filtered (stream, _("\ + gdb_printf (stream, _("\ --disable-threading\n\ ")); #endif @@ -2161,12 +2206,7 @@ set_history_filename (const char *args, that was read. */ if (!history_filename.empty () && !IS_ABSOLUTE_PATH (history_filename.c_str ())) - { - gdb::unique_xmalloc_ptr temp - (gdb_abspath (history_filename.c_str ())); - - history_filename = temp.get (); - } + history_filename = gdb_abspath (history_filename.c_str ()); } /* Whether we're in quiet startup mode. */ @@ -2224,6 +2264,7 @@ init_main (void) rl_completion_display_matches_hook = cli_display_match_list; rl_readline_name = "gdb"; rl_terminal_name = getenv ("TERM"); + rl_deprep_term_function = gdb_rl_deprep_term_function; /* The name for this defun comes from Bash, where it originated. 15 is Control-o, the same binding this function has in Bash. */ @@ -2438,7 +2479,6 @@ _initialize_top () const char *fname = ".gdb_history"; #endif - gdb::unique_xmalloc_ptr temp (gdb_abspath (fname)); - history_filename = temp.get (); + history_filename = gdb_abspath (fname); } }