From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2749 invoked by alias); 1 Aug 2011 14:08:43 -0000 Received: (qmail 2728 invoked by uid 22791); 1 Aug 2011 14:08:41 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_CP,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-gw0-f41.google.com (HELO mail-gw0-f41.google.com) (74.125.83.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 01 Aug 2011 14:08:27 +0000 Received: by gwaa20 with SMTP id a20so1670338gwa.0 for ; Mon, 01 Aug 2011 07:08:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.193.97 with SMTP id j61mr3235846yhn.207.1312207706305; Mon, 01 Aug 2011 07:08:26 -0700 (PDT) Received: by 10.236.105.161 with HTTP; Mon, 1 Aug 2011 07:08:26 -0700 (PDT) In-Reply-To: References: Date: Mon, 01 Aug 2011 14:08:00 -0000 Message-ID: Subject: Re: [patch] python prompt additions at first prompt. From: Matt Rice To: pmuldoon@redhat.com 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/msg00006.txt.bz2 On Mon, Aug 1, 2011 at 2:50 AM, Phil Muldoon wrote: > Matt Rice writes: > >> little bug with the new python prompt stuff, the prompt_hook doesn't >> take effect until the second prompt. > > Thanks for doing this. =A0This looks fine to me, apart from one question. > > For tests, there are prompt tests in the python.exp file for prompt > substitutions. =A0For passing arguments to GDB at start-up, see usage of > $GDBFLAGS in the testsuite. I'd tried that, but didn't have much luck, i'll give it another shot. >> - =A0 =A0 prompt, otherwise just print the prompt. =A0*/ >> - =A0if (async_command_editing_p) >> - =A0 =A0{ >> - =A0 =A0 =A0int length; >> - =A0 =A0 =A0char *a_prompt; >> - =A0 =A0 =A0char *gdb_prompt =3D get_prompt (0); >> - >> - =A0 =A0 =A0/* Tell readline what the prompt to display is and what fun= ction >> - =A0 =A0 =A0 =A0 it will need to call after a whole line is read. =A0Th= is also >> - =A0 =A0 =A0 =A0 displays the first prompt. =A0*/ >> - =A0 =A0 =A0length =3D strlen (get_prefix (0)) >> - =A0 =A0 + strlen (gdb_prompt) + strlen (get_suffix(0)) + 1; >> - =A0 =A0 =A0a_prompt =3D (char *) alloca (length); >> - =A0 =A0 =A0strcpy (a_prompt, get_prefix (0)); >> - =A0 =A0 =A0strcat (a_prompt, gdb_prompt); >> - =A0 =A0 =A0strcat (a_prompt, get_suffix (0)); >> - =A0 =A0 =A0rl_callback_handler_install (a_prompt, input_handler); >> - =A0 =A0} >> - =A0else >> - =A0 =A0display_gdb_prompt (0); >> + =A0display_gdb_prompt (0); > > > display_gdb_prompt removes any handler that is present, and then > installs a handler. =A0As this is the first prompt, the above code does > not (because there could not have been a handler installed). =A0I think > attempting to remove a handler that does not exist just results in a > NOOP, but it is worth checking. =A0I know very little about readline, > however. =A0So my question is: with GDB's copy of readline, is this okay? Yes, the effect of it seems to turn zero's into zero's. by my reading and valgrind, it seems fine, the documentation doesn't specify one way or the other though. If it is deemed not OK, it needs to be handled in display_gdb_prompt regard= less, because gdb -ex 'set editing off' ' followed by a 'set editing on', at the gdb prompt, results in 2 calls to _remove before the callback is installed from display_gdb_prompt, and change_line_handler.