From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11276 invoked by alias); 17 Dec 2006 23:46:08 -0000 Received: (qmail 11265 invoked by uid 22791); 17 Dec 2006 23:46:07 -0000 X-Spam-Check-By: sourceware.org Received: from 195.22.55.53.adsl.nextra.cz (HELO host0.dyn.jankratochvil.net) (195.22.55.53) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 17 Dec 2006 23:46:03 +0000 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.13.8/8.13.8) with ESMTP id kBHNjWUt022520; Mon, 18 Dec 2006 00:45:33 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.13.8/8.13.8/Submit) id kBHNjVE0022519; Mon, 18 Dec 2006 00:45:31 +0100 Date: Sun, 17 Dec 2006 23:46:00 -0000 From: Jan Kratochvil To: Chet Ramey Cc: "H. J. Lu" , GDB , bug-readline@gnu.org Subject: Re: PATCH: PR tui/2173: Arrow keys no longer works in breakpoint command list Message-ID: <20061217234530.GA20773@host0.dyn.jankratochvil.net> References: <20061121213205.GA13310@lucon.org> <20061128164658.GB20882@nevyn.them.org> <20061128165844.GA13667@lucon.org> <20061202184344.GA2197@lucon.org> <4571CF2A.3040608@case.edu> <20061202221541.GA9776@lucon.org> <45725FC9.9070304@case.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45725FC9.9070304@case.edu> User-Agent: Mutt/1.4.2.2i 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: 2006-12/txt/msg00224.txt.bz2 On Sun, 03 Dec 2006 06:25:29 +0100, Chet Ramey wrote: ... > More appropriate in the sense that the application controls the state > and switches between the callback and synchronous readline modes. > Since it's the app that's supposed to be calling into readline when in > callback mode anyway, I think this patch will work better. Chet, is it right it is more a design than implementation problem of readline? readline cannot determine how many nested readline calls have been abandoned by signal handler's longjmp (). Therefore it cannot determine if the current mode (the last unabandoned call) is a callback or synchronous one. The sample code should be readline documentation compliant, still the called function `_rl_next_macro_key' has undeterministic value of `RL_ISSTATE (RL_STATE_CALLBACK)'. Also any longjmp () from inside a signal handler is too dangerous as the data structures are not locked against signals. The signal handler should only set some flag. And the synchronous readline () function should be never used if one needs to quit the input mode by SIGINT (as one cannot abort readline () if not using the dangerous longjmp ()). IMO the right way is to stop using longjmp from GDB's signal handlers. Therefore to always use callbacked readline and stop the loop if detected a flag set by the installed signal handler. Thanks for info, Jan ------------------------------------------------------------------------------ main () { if (setjmp (buf_A)) { rl_read_key (); /* -> _rl_next_macro_key () */ } signal (SIGINT, handle_SIGINT_at_A); readline("mode-A"); ... } handle_SIGINT_at_A () { if (setjmp (buf_B)) { rl_read_key (); /* -> _rl_next_macro_key () */ } signal (SIGINT, handle_SIGINT_at_B); rl_callback_handler_install ("mode-B", mode_B_command); for (;;) rl_callback_read_char (); } handle_SIGINT_at_B () { if (rand () & 1) longjmp (buf_A); else longjmp (buf_B); }