]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/tui] Don't try deferred curses initialization twice
authorTom de Vries <tdevries@suse.de>
Mon, 7 Apr 2025 20:27:39 +0000 (22:27 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 7 Apr 2025 20:27:39 +0000 (22:27 +0200)
commit907c06d0e4eb0bb9b7eb712d7d1018836bb52cc4
tree79003a7015968df746ea835fb1f5b944b4eeac78
parent2707d55e539ef323dd14a1293e762bf3d9739ee7
[gdb/tui] Don't try deferred curses initialization twice

I noticed that if deferred curses initialization fails, for instance when
using TERM=dumb, and we try the same again, we run into the same error:
...
$ TERM=dumb gdb -batch -ex "tui enable" -ex "tui enable"
Cannot enable the TUI: terminal doesn't support cursor addressing [TERM=dumb]
Cannot enable the TUI: terminal doesn't support cursor addressing [TERM=dumb]
...

I think it's better to try deferred curses initialization only once.

Fix this by changing bool tui_finish_init into a tribool, and using
TRIBOOL_UNKNOWN to represent the "initialization failed" state, such that we
get instead:
...
$ TERM=dumb gdb -batch -ex "tui enable" -ex "tui enable"
Cannot enable the TUI: terminal doesn't support cursor addressing [TERM=dumb]
Cannot enable the TUI
...

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/tui/tui.c