From patchwork Fri Aug 21 16:45:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 8343 Received: (qmail 99909 invoked by alias); 21 Aug 2015 16:45:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 99889 invoked by uid 89); 21 Aug 2015 16:45:46 -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-f54.google.com Received: from mail-qg0-f54.google.com (HELO mail-qg0-f54.google.com) (209.85.192.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 21 Aug 2015 16:45:45 +0000 Received: by qgeg42 with SMTP id g42so50370258qge.1 for ; Fri, 21 Aug 2015 09:45:43 -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:to:cc:subject:date:message-id; bh=7Uz099ejNEBaj3Q0/hxjG8JjOfhHX/pVhIXLrTqKrVk=; b=W3FsF38ao+w7bqDShX0ZDjcG8U6xJ8FhR6MvFJ8BVN+9YlTgQmqJrBpXAPZ/+FGBvw OiSDklM5PqAhmTNF5LaNCGXqX0aY4LrG81gphd9IJMEDtWg79MskfEqMny0IRS8IdCrc VLjdT9zqIqg+nk8kmw0Fe2Mm+b77OkWpmPw9R1iPHogtDEvfxKE8KqWgQ9oAKvdNwheL AZeHlE00rQ1qHZ72SGNkDzTUYZ+SwcxN+MBiNMZdrZy9qgUcdj0s1PVZBxqRPNoT/z99 aQ/sOKiT8Jn6fhIkGkaDWS9JsxeAry+1wtuTiIZbuNJKeqJfkK0Z8qzRezSq3vJA9U1u uG1A== X-Gm-Message-State: ALoCoQl0gbu9+SbIvfqVUUbn3u2dK1ACPQPBudbsy9ZvEVVWtZPlaWMj9vUMw9+W7o7urH0QsA2X X-Received: by 10.140.132.71 with SMTP id 68mr20538114qhe.64.1440175543106; Fri, 21 Aug 2015 09:45:43 -0700 (PDT) Received: from localhost.localdomain (ool-4353acd8.dyn.optonline.net. [67.83.172.216]) by smtp.gmail.com with ESMTPSA id o2sm4686149qkl.38.2015.08.21.09.45.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Aug 2015 09:45:42 -0700 (PDT) From: Patrick Palka To: gdb-patches@sourceware.org Cc: Patrick Palka Subject: [PATCH] tui: don't overwrite a subprompt line that was given no input Date: Fri, 21 Aug 2015 12:45:38 -0400 Message-Id: <1440175538-8021-1-git-send-email-patrick@parcs.ath.cx> 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. --- gdb/top.c | 17 +++++++++++++++++ gdb/top.h | 4 ++++ gdb/tui/tui-io.c | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gdb/top.c b/gdb/top.c index 061b52f..6d0701c 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -754,6 +754,20 @@ static char *gdb_readline_wrapper_result; return. */ static void (*saved_after_char_processing_hook) (void); + +/* The number of nested readline subprompts that are currently active. */ + +static int gdb_subprompt_depth = 0; + +/* See top.h. */ + +int +gdb_in_subprompt_p (void) +{ + return gdb_subprompt_depth > 0; +} + + /* This function is called when readline has seen a complete line of text. */ @@ -808,6 +822,8 @@ gdb_readline_wrapper_cleanup (void *arg) gdb_readline_wrapper_result = NULL; gdb_readline_wrapper_done = 0; + gdb_subprompt_depth--; + gdb_assert (gdb_subprompt_depth >= 0); after_char_processing_hook = saved_after_char_processing_hook; saved_after_char_processing_hook = NULL; @@ -841,6 +857,7 @@ gdb_readline_wrapper (const char *prompt) /* Display our prompt and prevent double prompt display. */ display_gdb_prompt (prompt); rl_already_prompted = 1; + gdb_subprompt_depth++; if (after_char_processing_hook) (*after_char_processing_hook) (); diff --git a/gdb/top.h b/gdb/top.h index 987279b..dcab1d2 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 subprompt, 0 otherwise. */ + +extern int gdb_in_subprompt_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..b660a7f 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_subprompt_p ()) { wmove (w, getcury (w), 0);