Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Patrick Palka <patrick@parcs.ath.cx>
To: gdb-patches@sourceware.org
Cc: Patrick Palka <patrick@parcs.ath.cx>
Subject: [PATCH] tui: don't overwrite a subprompt line that was given no input
Date: Fri, 21 Aug 2015 16:45:00 -0000	[thread overview]
Message-ID: <1440175538-8021-1-git-send-email-patrick@parcs.ath.cx> (raw)

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]) <ENTER>

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);
 
-- 
2.5.0.417.g69c5dbd.dirty


             reply	other threads:[~2015-08-21 16:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-21 16:45 Patrick Palka [this message]
2015-08-21 18:04 ` Pedro Alves
2015-08-21 19:07   ` Patrick Palka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440175538-8021-1-git-send-email-patrick@parcs.ath.cx \
    --to=patrick@parcs.ath.cx \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox