From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28138 invoked by alias); 21 Mar 2008 21:04:04 -0000 Received: (qmail 28104 invoked by uid 22791); 21 Mar 2008 21:03:47 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 21 Mar 2008 21:03:27 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id D21A598298; Fri, 21 Mar 2008 21:03:24 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id A4CFF98278; Fri, 21 Mar 2008 21:03:24 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1JcoOa-0001HS-16; Fri, 21 Mar 2008 17:03:24 -0400 Date: Fri, 21 Mar 2008 21:04:00 -0000 From: Daniel Jacobowitz To: Jan Kratochvil Cc: gdb-patches@sourceware.org, Chet Ramey Subject: Re: [patch] Fix testsuite annotate-quit race (PR 544) Message-ID: <20080321210323.GA30247@caradoc.them.org> Mail-Followup-To: Jan Kratochvil , gdb-patches@sourceware.org, Chet Ramey References: <20080318225436.GA27374@host0.dyn.jankratochvil.net> <20080318231738.GA22432@caradoc.them.org> <20080319081056.GA32510@host0.dyn.jankratochvil.net> <20080321204506.GA5033@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080321204506.GA5033@host0.dyn.jankratochvil.net> User-Agent: Mutt/1.5.17 (2007-12-11) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-03/txt/msg00318.txt.bz2 On Fri, Mar 21, 2008 at 09:45:06PM +0100, Jan Kratochvil wrote: > The patch was approved by the readline maintainer: Great! Thank you for pursuing this. > On Fri, 21 Mar 2008 19:37:31 +0100, Chet Ramey wrote: > > I will add something like your block_sigint/release_sigint changes around > > the guts of rl_redisplay. That's the right thing to do anyway. It will > > probably not come out as a patch for readline-5.2; you can use your > > current patch (though the names will change to _rl_block_sigint and > > _rl_release_sigint -- fair warning). > > It could be probably also coded only in GDB by modifying the function pointer > RL_REDISPLAY_FUNCTION instead to a custom wrapper calling RL_REDISPLAY but it > would need the SIGINT blocking/handling done in GDB. > > OK to commit as a readline fork before readline-6 is here? We have a --with-system-readline option, which many distributors use instead of the internal readline. So I would rather fix it in GDB. I did it just the way you suggested. I'm running some stress tests with this patch. So far it hasn't failed once. -- Daniel Jacobowitz CodeSourcery 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. Index: top.c =================================================================== RCS file: /cvs/src/src/gdb/top.c,v retrieving revision 1.135 diff -u -p -r1.135 top.c --- top.c 21 Mar 2008 14:39:22 -0000 1.135 +++ top.c 21 Mar 2008 21:01:37 -0000 @@ -921,7 +921,7 @@ gdb_rl_operate_and_get_next_completion ( 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, 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. */