diff options
author | Pedro Alves <palves@redhat.com> | 2014-07-24 15:51:21 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2014-07-24 15:51:21 +0100 |
commit | 36d6eb95c1de72b1c5703c5204124abe589d34b1 (patch) | |
tree | e4f5bdcf62eda7e52785110ac55011e8c3b67349 /gdb/tui/tui-io.c | |
parent | 8009206ae2dec541b55edc488103c6c1ccb1416a (diff) | |
download | gdb-36d6eb95c1de72b1c5703c5204124abe589d34b1.zip gdb-36d6eb95c1de72b1c5703c5204124abe589d34b1.tar.gz gdb-36d6eb95c1de72b1c5703c5204124abe589d34b1.tar.bz2 |
Fix pagination crash when the TUI is active
The TUI currently crashes when the user types <return> in response to
a pagination prompt:
$ gdb --tui ...
*the TUI is now active*
(gdb) set height 2
(gdb) help
List of classes of commands:
Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/x86_64/strlen.S:106
106 movdqu (%rax), %xmm12
(top-gdb) bt
#0 strlen () at ../sysdeps/x86_64/strlen.S:106
#1 0x000000000086be5f in xstrdup (s=0x0) at ../src/libiberty/xstrdup.c:33
#2 0x00000000005163f9 in tui_prep_terminal (notused1=1) at ../src/gdb/tui/tui-io.c:296
#3 0x000000000077a7ee in _rl_callback_newline () at ../src/readline/callback.c:82
#4 0x000000000077a853 in rl_callback_handler_install (prompt=0x0, linefunc=0x618b60 <command_line_handler>) at ../src/readline/callback.c:102
#5 0x0000000000718a5c in gdb_readline_wrapper_cleanup (arg=0xfd14d0) at ../src/gdb/top.c:788
#6 0x0000000000596d08 in do_my_cleanups (pmy_chain=0xcf0b38 <cleanup_chain>, old_chain=0x1043d10) at ../src/gdb/cleanups.c:155
#7 0x0000000000596d75 in do_cleanups (old_chain=0x1043d10) at ../src/gdb/cleanups.c:177
#8 0x0000000000718bd9 in gdb_readline_wrapper (prompt=0x7fffffffcfa0 "---Type <return> to continue, or q <return> to quit---")
at ../src/gdb/top.c:835
#9 0x000000000071cf74 in prompt_for_continue () at ../src/gdb/utils.c:1894
#10 0x000000000071d434 in fputs_maybe_filtered (linebuffer=0x1043db0 "List of classes of commands:\n\n", stream=0xf72e20, filter=1)
at ../src/gdb/utils.c:2111
#11 0x000000000071da0f in vfprintf_maybe_filtered (stream=0xf72e20, format=0x89aef8 "List of classes of %scommands:\n\n", args=0x7fffffffd118, filter=1)
at ../src/gdb/utils.c:2339
#12 0x000000000071da4a in vfprintf_filtered (stream=0xf72e20, format=0x89aef8 "List of classes of %scommands:\n\n", args=0x7fffffffd118)
at ../src/gdb/utils.c:2347
#13 0x000000000071dc72 in fprintf_filtered (stream=0xf72e20, format=0x89aef8 "List of classes of %scommands:\n\n") at ../src/gdb/utils.c:2399
#14 0x00000000004f90ab in help_list (list=0xe6d100, cmdtype=0x89ad8c "", class=all_classes, stream=0xf72e20)
at ../src/gdb/cli/cli-decode.c:1038
#15 0x00000000004f8dba in help_cmd (arg=0x0, stream=0xf72e20) at ../src/gdb/cli/cli-decode.c:946
Git 0017922 added:
@@ -776,6 +777,12 @@ gdb_readline_wrapper_cleanup (void *arg)
gdb_assert (input_handler == gdb_readline_wrapper_line);
input_handler = cleanup->handler_orig;
+
+ /* Reinstall INPUT_HANDLER in readline, without displaying a
+ prompt. */
+ if (async_command_editing_p)
+ rl_callback_handler_install (NULL, input_handler);
and tui_prep_terminal simply misses handling the case of a NULL
rl_prompt.
I also checked that readline's sources do similar checks.
gdb/
2014-07-24 Pedro Alves <palves@redhat.com>
* tui/tui-io.c (tui_prep_terminal): Handle NULL rl_prompt.
Diffstat (limited to 'gdb/tui/tui-io.c')
-rw-r--r-- | gdb/tui/tui-io.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index dcccb08..75eb4b8 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -293,7 +293,7 @@ tui_prep_terminal (int notused1) (we can't use gdb_prompt() due to secondary prompts and can't use rl_prompt because it points to an alloca buffer). */ xfree (tui_rl_saved_prompt); - tui_rl_saved_prompt = xstrdup (rl_prompt); + tui_rl_saved_prompt = rl_prompt != NULL ? xstrdup (rl_prompt) : NULL; } /* Readline callback to restore the terminal. It is called once each |