From b562a0cb2a0d913bf06b25765608fed640be7748 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Fri, 21 Mar 2008 21:44:30 +0000 Subject: [PATCH] PR gdb/544 Suggested by Jan Kratochvil: * top.c (gdb_rl_operate_and_get_next_completion): Call rl_redisplay_function. (gdb_rl_redisplay): New. (init_main): Set rl_redisplay_function. * gdb.cp/annota2.exp, gdb.cp/annota3.exp: Remove KFAIL for fixed PR gdb/544. --- gdb/ChangeLog | 9 +++++++++ gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.cp/annota2.exp | 3 --- gdb/testsuite/gdb.cp/annota3.exp | 2 -- gdb/top.c | 26 +++++++++++++++++++++++++- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6a25570944..f96de065af 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2008-03-21 Daniel Jacobowitz + + PR gdb/544 + Suggested by Jan Kratochvil: + * top.c (gdb_rl_operate_and_get_next_completion): Call + rl_redisplay_function. + (gdb_rl_redisplay): New. + (init_main): Set rl_redisplay_function. + 2008-03-21 Thomas Mittelstaedt (tiny change) * aix-thread.c (pdc_read_regs): Fix compiler warning. diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 2f9ee94bd3..5df1fb39c5 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-03-21 Daniel Jacobowitz + + * gdb.cp/annota2.exp, gdb.cp/annota3.exp: Remove KFAIL for + fixed PR gdb/544. + 2008-03-21 Pedro Alves * gdb.threads/fork-child-threads.exp: Test next over fork. diff --git a/gdb/testsuite/gdb.cp/annota2.exp b/gdb/testsuite/gdb.cp/annota2.exp index 4cf6b711c1..2dd9f4bfae 100644 --- a/gdb/testsuite/gdb.cp/annota2.exp +++ b/gdb/testsuite/gdb.cp/annota2.exp @@ -205,13 +205,10 @@ gdb_expect { # test: # annotate-quit # -# This test sometimes fails, but not reproducibly. See gdb/544. -# send_gdb "\003" gdb_expect { -re "\r\n\032\032error-begin\r\nQuit\r\n\r\n\032\032quit\r\n$gdb_prompt$" \ { pass "annotate-quit" } - -re "$gdb_prompt$" { kfail "gdb/544" "annotate-quit" } -re ".*$gdb_prompt$" { fail "annotate-quit" } timeout { fail "annotate-quit (timeout)" } } diff --git a/gdb/testsuite/gdb.cp/annota3.exp b/gdb/testsuite/gdb.cp/annota3.exp index c2d61682a0..7b7e9f9acf 100644 --- a/gdb/testsuite/gdb.cp/annota3.exp +++ b/gdb/testsuite/gdb.cp/annota3.exp @@ -208,8 +208,6 @@ gdb_expect { # test: # annotate-quit # -# This test sometimes fails, but not reproducibly. See gdb/544. -# send_gdb "\003" gdb_expect_list "annotate-quit" "$gdb_prompt$" { "\r\n\032\032error-begin\r\n" diff --git a/gdb/top.c b/gdb/top.c index 418ff8e95f..505b583250 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -921,7 +921,7 @@ gdb_rl_operate_and_get_next_completion (void) operate_saved_history = -1; /* readline doesn't automatically update the display for us. */ - rl_redisplay (); + rl_redisplay_function (); after_char_processing_hook = NULL; rl_pre_input_hook = NULL; @@ -956,6 +956,29 @@ gdb_rl_operate_and_get_next (int count, int key) return rl_newline (1, key); } + +/* Readline 5.2 and earlier do not block SIGINT while redrawing the prompt. + This can lead to corrupted internal state. As long as we do not require + a newer readline version, compensate for it. */ +static void +gdb_rl_redisplay (void) +{ +#if HAVE_SIGPROCMASK + sigset_t sigint_set, sigint_oset; + + sigemptyset (&sigint_set); + sigemptyset (&sigint_oset); + sigaddset (&sigint_set, SIGINT); + sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset); +#endif + + rl_redisplay (); + +#if HAVE_SIGPROCMASK + sigprocmask (SIG_SETMASK, &sigint_oset, (sigset_t *)NULL); +#endif +} + /* Read one line from the command input stream `instream' into the local static buffer `linebuffer' (whose current length @@ -1581,6 +1604,7 @@ init_main (void) rl_completer_quote_characters = get_gdb_completer_quote_characters (); rl_readline_name = "gdb"; rl_terminal_name = getenv ("TERM"); + rl_redisplay_function = gdb_rl_redisplay; /* The name for this defun comes from Bash, where it originated. 15 is Control-o, the same binding this function has in Bash. */ -- 2.34.1