gdb always quit after press any key

234 Views Asked by At

I checked out the gdb source and compiled successfully with MinGW. When I run the output file gdb.exe, I cannot input anything, any key press would cause it quit:

aj@TERRAN E:\
$ gdb --data-directory=E:\gdb_build\gdb\gdb-7.11\gdb\data-directory
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-mingw32 --target=arm-linux-androideabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) quit

aj@TERRAN E:\
$

I didn't input the last quit, I just hit the space and it quits. I downloaded another prebuilt gdb which works fine, but it doesn't support python, so I need to build it myself.

But I tried the tui mode with gdb -tui, it works fine, I can type commands. Why does non-tui-mode quit?

2

There are 2 best solutions below

0
On BEST ANSWER

This is a bug of gdb 7.12, 7.11.1 works just fine.

0
On

The older versions of GDB have this bug when building them from sources on Windows. I have this problem with a custom GDB 7.6.1 built with MSYS2. The problem appears when the GDB is linked with ncurses library. In this case, the function getch() is taken from ncurses and returns EOF because there's no curses window. It is called from readline/input.c:rl_getc().
The latest sources have this fixed and call _getch() from the standard library. This simple fix ends with backspace key not deleting characters. So, there are more fixes in readline to fix that too. More info: https://www.mail-archive.com/[email protected]/msg01203.html
https://gdb-patches.sourceware.narkive.com/A7CT0KH0/enabled-tui-mode-on-msys2

A simple workaround to build an old version is to disable TUI mode with --disable-tui configure option. This will build GDB without ncurses dependency and not expose this bug.