Mingw-packages: GDB has no TUI (curses) interface

Created on 21 Sep 2016  路  9Comments  路  Source: msys2/MINGW-packages

Apparently GNU debugger has a text UI made wth ncurses.

For the text UI to be present, GDB has to be compiled with configure --enable-tui.

From what i tested, the msys2-GDB variant has TUI, but the mingw64-GDB variant does not have it. We can confirm that by looking the PKGBUILD scripts.

https://github.com/Alexpux/MSYS2-packages/blob/master/gdb/PKGBUILD
https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-gdb/PKGBUILD

Why is that? Can it be changed so both have the text UI?
Or as a workaround, can I use the MSYS2-gdb for pure mingw builds?

Most helpful comment

According to the help text, it is full screen, but several screenshots I have seen show it in a windowed mode. I am going to build GDB with it (and possibly GdbTK) and see what happens (well, I will when I get to that package. I am currently on Gettext, and I have a number of other things I build in this set of programs before GDB, so it may be a while).

All 9 comments

According to the help text, it is full screen, but several screenshots I have seen show it in a windowed mode. I am going to build GDB with it (and possibly GdbTK) and see what happens (well, I will when I get to that package. I am currently on Gettext, and I have a number of other things I build in this set of programs before GDB, so it may be a while).

If you intend to build gdbtk you will need itcl-3.2/itk-3.2 which are a pain in the proverbial behind to build with 64 bit support because of age. Later versions do not work however so good luck.
Small hint when configuring itcl/itk use the i686-w64-mingw32 shell to configure the packages the x86_64-w64-mingw32 version will break the configuring stage.

It appears that GDBTK is now part of Insight, and there is a (very old) PKGBUILD for it here, so I will work with that instead.

Fingers crossed.

And it doesn't work. The UI pops up, and then hangs. I am going to have to figure that one out.

That is about the Insight gdbtk? What about the TUI, did you tried that?

I decided to download the repo and to build GDB myself. After some experimentation I got to the following.

Enabling the TUI requires two extra switches on ./configure and one extra dependency.

The additional dependency is Readline, and the extra switches are for the TUI and Readline. Readline is needed because without Readline, gdb breaks in normal (non TUI) mode when running under cmd.exe. With readline everything is fine.

@@ -17,7 +17,8 @@ groups=("${MINGW_PACKAGE_PREFIX}-toolchain")
 depends=("${MINGW_PACKAGE_PREFIX}-expat"
          "${MINGW_PACKAGE_PREFIX}-libiconv"
          "${MINGW_PACKAGE_PREFIX}-python2"
-         "${MINGW_PACKAGE_PREFIX}-zlib")
+         "${MINGW_PACKAGE_PREFIX}-zlib"
+         "${MINGW_PACKAGE_PREFIX}-readline")
 checkdepends=('dejagnu' 'bc')
 makedepends=("${MINGW_PACKAGE_PREFIX}-iconv"
              "${MINGW_PACKAGE_PREFIX}-ncurses"
@@ -75,10 +76,11 @@ build() {
     --with-system-gdbinit=${MINGW_PREFIX}/etc/gdbinit \
     --with-python=${MINGW_PREFIX}/bin/python-config-u.sh \
     --with-expat \
+    --with-system-readline \
     --with-libiconv-prefix=${MINGW_PREFIX} \
     --with-zlib \
     --with-lzma \
-    --disable-tui
+    --enable-tui

   make
 }

With this change, everything works the same + the TUI is added. The TUI can be started only under cmd.exe and not under Mintty which is OK since we are using MINGW ncurses. But then there are other problems under the TUI.

IN TUI mode, and _only in TUI mode_, after I load the file and i write start, I get error from Windows:

a.exe - Application Error
---------------------------
The application was unable to start correctly (0xc0000142). Click OK to close the application. 

C:\msys2\mingw64\bin is already in the PATH. Any help?

Few additional notes.

  • If I run gdb a.exe in normal mode (without the switch --tui), start and then enter tui with the command -, i can nicely step in the program. So this is kind of workaround.
  • If I run gdb --tui a.exe and then start, I get the error.

I was investigating into the GDB source code and so far I think I pinpointed the problem to the function windows_create_inferior() in windows-nat.c. One should investigate how the call to CreateProcess differs in TUI and in normal mode.

Last note for today. In Windows 10 there was a redesgn of the Windows Console (the terminal), e.g. easier copy and paste.

If I DISABLE the new features like on the picture, then start under TUI works.

cmd legacy

So I actually started debugging GDB with itself phew. I used Codeblocks as IDE for the debugger GDB and I attached to the debugee GDB process. I stepped around the code and found the following.

For further solving the issue one can just write the following commands:

file a.exe
set debugevents on
- #enters tui
start

This prints more stuff on how the exe is loaded and what leads to the error 0x142.

Also I found a workaround to use the TUI with the new Windows 10 console. That is:

set new-console on
-
start

After this, in TUI mode there won't be any problem when starting a process.

The 142 error is probably related to this use case: Windows 10 new console + ncurses TUI + starting a new process that uses the same console window. It should be investigated outside GDB, with a simple TUI and a call to system().

Since we have a workable TUI, i I will propose a pull request for the TUI. It does not changes the present behavior, only adds a new feature that is buggy in a very specific case and that will be sorted out in the future.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MenaceInc picture MenaceInc  路  6Comments

joankaradimov picture joankaradimov  路  5Comments

Alex-Gamper picture Alex-Gamper  路  8Comments

omichel picture omichel  路  4Comments

oscarbg picture oscarbg  路  7Comments