[PATCH]: Fix readline/TUI deadlock

Stephane Carrez stcarrez@nerim.fr
Tue Sep 3 13:54:00 GMT 2002


Hi!

The TUI creates a pipe and redirects all readline output to that pipe.
It was designed like that because it was the only way to make readline
clean enough to work with TUI.  So, readline sometimes (not always!) writes
in the pipe and later on the TUI flushes the pipe in the command window.

The problem is that since gdb is mono-thread, if the pipe if full we are blocked.
This happens when a big completion list is printed by readline.

This patch fixes that by installing a readline hook to print the completion
list.  The display functions come from readline/complete.c and have been
modified to print in TUI command window directly.  It is installed only
when we are in TUI mode.

With this patch, the pipe is no longer necessary.  This is a good news for
Windows & Mingw32 as the TUI has more chances to work on that platform
(if we are willing to integrate mingw32-readline!).  Despite that, it is
still there in case readline still writes on the output file (kind of backup wheel).
I've #if'ed the code so that it's possible to compile with and without the pipe
(only for testing).

I committed this patch on mainline.

	Stephane

2002-09-04  Stephane Carrez  <stcarrez@nerim.fr>

	* tuiIO.c (tui_putc): New function to print one character.
	(printable_part): New function from readline/complete.c.
	(PUTX): New macro, likewise.
	(print_filename): New function, likewise.
	(get_y_or_n): New function, likewise and adapted for TUI.
	(tui_rl_display_match_list): New function from readline/complete.c
	and writes on TUI command window.
	(tui_setup_io): Install or remove the readline hook
	rl_completion_display_matches_hook so that completion is written
	directly in TUI command window instead of in the TUI pipe.
	(tui_initialize_io): Use #ifdef TUI_USE_PIPE_FOR_READLINE for the
	TUI redirection pipe.
	(tui_getc): Likewise for call to tui_readline_output.
	(tui_readline_output): Likewise for function.
	* tui.c (tui_rl_startup_hook): Always take care of gdb prompt.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: tui-readline-fixes.diffs
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20020903/6c6d6e67/attachment.ksh>


More information about the Gdb-patches mailing list