aboutsummaryrefslogtreecommitdiff
path: root/gdb/top.c
diff options
context:
space:
mode:
authorPatrick Palka <patrick@parcs.ath.cx>2015-08-21 12:28:19 -0400
committerPatrick Palka <patrick@parcs.ath.cx>2015-08-21 16:18:39 -0400
commit948578a989f8c666c9b0e92c9a50906724921f14 (patch)
treebd15b70b95418bef3e72d09f42d9855cb2763a42 /gdb/top.c
parent7a8bcb88e77380fe9672b4f10777cc9e48011dd4 (diff)
downloadgdb-948578a989f8c666c9b0e92c9a50906724921f14.zip
gdb-948578a989f8c666c9b0e92c9a50906724921f14.tar.gz
gdb-948578a989f8c666c9b0e92c9a50906724921f14.tar.bz2
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]) <ENTER> 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.
Diffstat (limited to 'gdb/top.c')
-rw-r--r--gdb/top.c18
1 files changed, 18 insertions, 0 deletions
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)