[PATCH 20/24] Allow TUI windows in Python
Simon Marchi
simark@simark.ca
Wed Mar 11 04:47:51 GMT 2020
On 2020-03-10 8:23 p.m., Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
>
> Simon> In file included from /home/smarchi/src/binutils-gdb/gdb/python/py-tui.c:24:
> Simon> /home/smarchi/src/binutils-gdb/gdb/gdb_curses.h:47:10: fatal error: ncurses.h: No such file or directory
> Simon> 47 | #include <ncurses.h>
> Simon> | ^~~~~~~~~~~
>
> Simon> So I suspect weare missing an #if/#ifdef somwhere. config.log contains:
>
> Simon> /* Define to 1 if you have the <ncursesw/ncurses.h> header file. */
> Simon> /* #undef HAVE_NCURSESW_NCURSES_H */
>
> Simon> /* Define to 1 if you have the <ncurses.h> header file. */
> Simon> /* #undef HAVE_NCURSES_H */
>
> Simon> /* Define to 1 if you have the <ncurses/ncurses.h> header file. */
> Simon> /* #undef HAVE_NCURSES_NCURSES_H */
>
> That is weird because gdb_curses.h says (I marked line 47):
>
> #if defined (HAVE_NCURSESW_NCURSES_H)
> #include <ncursesw/ncurses.h>
> #elif defined (HAVE_NCURSES_NCURSES_H)
> #include <ncurses/ncurses.h>
> #elif defined (HAVE_NCURSES_H)
> ---> #include <ncurses.h>
> #elif defined (HAVE_CURSESX_H)
> #include <cursesX.h>
> #elif defined (HAVE_CURSES_H)
> #include <curses.h>
> #endif
>
> ... which sure looks like it is guarded by HAVE_NCURSES_H.
>
> I couldn't find any other code that might define HAVE_NCURSES_H.
>
> I don't know what's going on here :(
>
> Tom
>
Sorry for being terse earlier, I didn't have much time. I took another look,
I built the file with -save-temps and inspected the .ii file. The
HAVE_NCURSES_H comes from pyconfig.h, which comes from the Python installation.
For example, on my Ubuntu here, it's at:
/usr/include/x86_64-linux-gnu/python3.8/pyconfig.h
This file tells us Python was built with ncurses, which doesn't mean the
ncurses development headers are installed and available to GDB. I find it
very odd that Python exposes these very generically-named macros in the global
namespace. Almost any of these HAVE_FOO macros from Python could clash with
our own macros.
Anyway, I was able to reproduce it starting from a scratch Ubuntu 20.04 docker
container, installing everything required to build GDB except the ncurses
development headers.
One way to fix it is to make sure "python-internal.h" is included after
"gdb_curses.h", in py-tui.c.
Simon
More information about the Gdb-patches
mailing list