From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111387 invoked by alias); 21 Aug 2015 19:07:28 -0000 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 Received: (qmail 111354 invoked by uid 89); 21 Aug 2015 19:07:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail-qg0-f51.google.com Received: from mail-qg0-f51.google.com (HELO mail-qg0-f51.google.com) (209.85.192.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 21 Aug 2015 19:07:26 +0000 Received: by qgj62 with SMTP id 62so52556294qgj.2 for ; Fri, 21 Aug 2015 12:07:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version:content-type; bh=cX6rillKAxR1cvv2V7rxg7sg6ifL+LL/6OqFxytNI3Q=; b=H5xmNLW75iAANEA0NlhopHXCm3lphCEh7NrpHn0zAwGspzPPVAGiuWfBPsgebp+XDE 44UQ2uqDdbOslU4EWubyclIfR+gd0gRbjFhds//JebaQQBXrNXLgN2WfJuf6VYkTlBcJ H8IHEBdNeMPk+7uLDRqfPDV8CPrVg3NlxFqh1Q5/2X/tyC0Fly73b7eXPiSn7b8jiuHc hvHy+0NL+Qfq8Iqsvc4acjxk7lj8bOZGdk1WrIDwVH4DJckp0COOTnkrj638Uy0Tp+tZ Nuk5ysZUclQmXfYfWfyR7eN33dtCCQqoTYwZgpP71cVauU0yJfXO1m6kWHuDGw/CPAHi OD5Q== X-Gm-Message-State: ALoCoQkJgGYdMzOHsmPJzvOv0/9dFC7ogjou3WyX7f53p/CtbNsHcREZNryQGA+h/QoW9FTucs2i X-Received: by 10.140.130.196 with SMTP id 187mr22052676qhc.58.1440184044728; Fri, 21 Aug 2015 12:07:24 -0700 (PDT) Received: from [192.168.1.130] (ool-4353acd8.dyn.optonline.net. [67.83.172.216]) by smtp.gmail.com with ESMTPSA id 132sm4929917qhx.28.2015.08.21.12.07.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Aug 2015 12:07:24 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Fri, 21 Aug 2015 19:07:00 -0000 To: Pedro Alves cc: Patrick Palka , gdb-patches@sourceware.org Subject: Re: [PATCH] tui: don't overwrite a subprompt line that was given no input In-Reply-To: <55D7682B.5050805@redhat.com> Message-ID: References: <1440175538-8021-1-git-send-email-patrick@parcs.ath.cx> <55D7682B.5050805@redhat.com> User-Agent: Alpine 2.20.8 (DEB 77 2015-05-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-SW-Source: 2015-08/txt/msg00588.txt.bz2 On Fri, 21 Aug 2015, Pedro Alves wrote: > On 08/21/2015 05:45 PM, Patrick Palka wrote: >> This patch fixes the following bug in TUI: >> >> (gdb) break foo >> No symbol table is loaded. Use the "file" command. >> Make breakpoint pending on future shared library load? (y or [n]) >> >> By submitting an empty command line to a subprompt, the subprompt line >> is undesirably cleared and overwritten. Outside of a subprompt, >> clearing the prompt line after submitting an empty command line is >> intended behavior which complements GDB's repeat-command shorthand. But >> inside a subprompt, this behavior is undesired since the shorthand is >> not applicable in that case. We should retain the subprompt line even >> when it's given to input. >> >> This patch makes sure that a prompt given an empty command line is >> cleared and overwritten only if it's not a subprompt. To acheive this, >> a new predicate is defined which informs us whether the current input >> handler is a subprompt. >> >> gdb/ChangeLog: >> >> * top.h (gdb_in_subprompt_p): Declare. >> * top.c (gdb_subprompt_depth): Define. >> (gdb_in_subprompt_p): Define. >> (gdb_readline_wrapper_cleanup): Decrement gdb_subprompt_depth. >> (gdb_readline_wrapper): Increment gdb_subprompt_depth. >> * tui/tui-io.c (tui_getc): Don't clear the prompt line if we >> are in a subprompt. > > OK, but should really be s/subprompt/secondary prompt/ everywhere. Done. Here is what I'll commit. -- >8 -- Subject: [PATCH] tui: don't overwrite a secondary prompt that was given no input This patch fixes the following bug in TUI: (gdb) break foo No symbol table is loaded. Use the "file" command. Make breakpoint pending on future shared library load? (y or [n]) By submitting an empty command line to a secondary prompt, the line corresponding to the secondary prompt is undesirably cleared and overwritten. Outside of a secondary prompt, clearing the prompt line after submitting an empty command line is intended behavior which complements GDB's repeat-command shorthand. But inside a secondary prompt, this behavior is undesired since the shorthand is not applicable in that case. We should retain the secondary-prompt line even when it's given no input. This patch makes sure that a prompt that was given an empty command line is cleared and overwritten only if it's not a secondary prompt. To acheive this, a new predicate is defined which informs us whether the current input handler is a secondary prompt. gdb/ChangeLog: * top.h (gdb_in_secondary_prompt_p): Declare. * top.c (gdb_secondary_prompt_depth): Define. (gdb_in_secondary_prompt_p): Define. (gdb_readline_wrapper_cleanup): Decrement gdb_secondary_prompt_depth. (gdb_readline_wrapper): Increment gdb_secondary_prompt_depth. * tui/tui-io.c (tui_getc): Don't clear the prompt line if we are in a secondary prompt. --- gdb/top.c | 18 ++++++++++++++++++ gdb/top.h | 4 ++++ gdb/tui/tui-io.c | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gdb/top.c b/gdb/top.c index 061b52f..cb3c761 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -754,6 +754,21 @@ static char *gdb_readline_wrapper_result; return. */ static void (*saved_after_char_processing_hook) (void); + +/* The number of nested readline secondary prompts that are currently + active. */ + +static int gdb_secondary_prompt_depth = 0; + +/* See top.h. */ + +int +gdb_in_secondary_prompt_p (void) +{ + return gdb_secondary_prompt_depth > 0; +} + + /* This function is called when readline has seen a complete line of text. */ @@ -808,6 +823,8 @@ gdb_readline_wrapper_cleanup (void *arg) gdb_readline_wrapper_result = NULL; gdb_readline_wrapper_done = 0; + gdb_secondary_prompt_depth--; + gdb_assert (gdb_secondary_prompt_depth >= 0); after_char_processing_hook = saved_after_char_processing_hook; saved_after_char_processing_hook = NULL; @@ -833,6 +850,7 @@ gdb_readline_wrapper (const char *prompt) cleanup->target_is_async_orig = target_is_async_p (); + gdb_secondary_prompt_depth++; back_to = make_cleanup (gdb_readline_wrapper_cleanup, cleanup); if (cleanup->target_is_async_orig) diff --git a/gdb/top.h b/gdb/top.h index 987279b..914a272 100644 --- a/gdb/top.h +++ b/gdb/top.h @@ -65,6 +65,10 @@ extern char *get_prompt (void); by gdb for its command prompt. */ extern void set_prompt (const char *s); +/* Return 1 if the current input handler is a secondary prompt, 0 otherwise. */ + +extern int gdb_in_secondary_prompt_p (void); + /* From random places. */ extern int readnow_symbol_files; diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index bca1f58..c7a092f 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -585,7 +585,7 @@ tui_getc (FILE *fp) with empty lines with gdb prompt at beginning. Instead of that, stay on the same line but provide a visual effect to show the user we recognized the command. */ - if (rl_end == 0) + if (rl_end == 0 && !gdb_in_secondary_prompt_p ()) { wmove (w, getcury (w), 0); -- 2.5.0.417.g69c5dbd.dirty