From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12948 invoked by alias); 9 Aug 2011 00:20:28 -0000 Received: (qmail 12940 invoked by uid 22791); 9 Aug 2011 00:20:27 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-yw0-f41.google.com (HELO mail-yw0-f41.google.com) (209.85.213.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 09 Aug 2011 00:20:13 +0000 Received: by ywa6 with SMTP id 6so3420246ywa.0 for ; Mon, 08 Aug 2011 17:20:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.133.200 with SMTP id q48mr221210yhi.198.1312849212847; Mon, 08 Aug 2011 17:20:12 -0700 (PDT) Received: by 10.236.34.193 with HTTP; Mon, 8 Aug 2011 17:20:12 -0700 (PDT) In-Reply-To: References: Date: Tue, 09 Aug 2011 00:20:00 -0000 Message-ID: Subject: Re: [patch] python prompt additions at first prompt. From: Matt Rice To: Tom Tromey Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 2011-08/txt/msg00163.txt.bz2 On Wed, Aug 3, 2011 at 11:07 AM, Tom Tromey wrote: >>>>>> "Matt" =3D=3D Matt Rice writes: > > Matt> I think it's ok anyways, the 'if (async_command_editing_p)' case in > Matt> display_gdb_prompt seems to cover it, > Matt> with the addition of rl_callback_handler_remove() which afaict seem= ed > Matt> ok to call before a handler is installed > > It is really unclear to me whether or not this patch is ok. > > display_gdb_prompt can early exit in a couple of cases: > > 1: > > =A0if (!current_interp_display_prompt_p ()) > =A0 =A0return; > > (I don't think this one can happen here.) > > 2: > > =A0if (sync_execution && is_running (inferior_ptid)) > =A0 =A0{ > [...] > =A0 =A0 =A0rl_callback_handler_remove (); > =A0 =A0 =A0return; > > This seems like it could be possible, maybe with attach + cont from the > command line? argh, thanks for noticing this should have seen it. yes it is possible, ./gdb/gdb -ex 'set target-async on' -ex 'attach 26359' -ex 'continue&' I have yet to fully unfurl the state machine, but in this case, display_gdb_prompt now gets called twice, first hitting this sync_execution && is_running and returning, secondly without returning early, and hitting async_editing. This leads to one prompt being displayed. further, trying this same case without my patch leads me to believe that the original code is not correct either. precisely because it does call rl_callback_handler_install, debugging gdb gives an infinite loop of these. not debugging gdb you seem to wind up back at the shell needing to 'fg' gdb. Program received signal SIGTTOU, Stopped (tty output). 0x000000394acd7f18 in tcsetattr () from /lib64/libc.so.6 (gdb) bt #0 0x000000394acd7f18 in tcsetattr () from /lib64/libc.so.6 #1 0x00000000006c16db in _set_tty_settings (tty=3D0, tiop=3D0x7fffffffdcf0) at rltty.c:476 #2 0x00000000006c1706 in set_tty_settings (tty=3D0, tiop=3D0x7fffffffdcf0) at rltty.c:490 #3 0x00000000006c1a71 in rl_prep_terminal (meta_flag=3D1) at rltty.c:653 #4 0x00000000006d436e in _rl_callback_newline () at callback.c:82 #5 0x00000000006d43d3 in rl_callback_handler_install (prompt=3D0x7fffffffdd70 "", linefunc=3D0x5b6236 ) at callback.c:102 #6 0x00000000004fa86c in tui_command_loop (data=3D0x0) at ./tui/tui-interp= .c:159 the patch at least suffers from one issue that the first 'current' argument to gdb.prompt_hook is both inconsistent and unsatisfactory. None, or "" empty string with patch: (normal vs target-async/attach .. etc) rather than the "(gdb) " it is without the patch/should be. (by putting the observer mechanism before the first rl_callback_handler_ins= tall) So, I guess neither the current patch or adding the observer calls to the existing code is correct and we at least need to split up prompt displaying from the setting of the prompt parameter? > If that one cannot be taken, then I agree the patch is correct. > Could you try this? > > Tom >