This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Enabled TUI mode on MSYS2

> From: Giah de Barag <>
> Date: Wed, 14 Sep 2016 02:32:09 -0400
> Cc:
> I do not understand the apparent conflict between this statement, that “GDB simply should not use that function in the MinGW build,” and the statement above, “I don't think there's a need for any patches.” How should one not use that function without affecting the source? Has this patch (changing getch to _getch) already been applied somewhere other than 7.11 (where I happen to be focused)?

Sorry for not explaining this clearly enough.  Let me try again.

The function getch from ncurses can only work when GDB is invoked with
the -tui command line option, i.e. when you activate the TUI user
interface.  Otherwise, it will always return EOF because no text-mode
window was created by GDB, and ncurses requires a window before it can
take any input.

When GDB is linked with ncurses, the getch function call by Readline
is resolved to the ncurses version of that function, and not to getch
in the MS-Windows runtime library.  (The call to getch in Readline is
MinGW-specific, so this problem doesn't show on other platforms.)
Readline only calls getch when TUI is _not_ in use, so the solution is
to replace the call to getch with a call to _getch.

The Readline library is maintained separately from GDB; GDB imports
Readline into its repository, and has its own copy there.  I submitted
the patch to use _getch (and several other MinGW-related patches) to
the Readline maintainer about 2 years ago, and those patches are
already in the latest versions of Readline.  Unfortunately, GDB did
not yet import those latest versions of Readline, so you don't see the
patches in the GDB sources.  (When I produce the binaries I use and
make available from the ezwinports site, I patch Readline to fix all
thos problems.)

I hope this explains the issue.  The bottom line is that GDB should
import a newer version of Readline, and then these problems will be
fixed without any need for further patches.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]