aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-09-25 08:27:51 -0600
committerTom Tromey <tromey@adacore.com>2024-11-01 11:06:47 -0600
commit76367d23146136b457b1494285b807437a9fec60 (patch)
tree29cec25266e8d522ba7a135659699542885af03d /gdb/testsuite/gdb.python
parent893e4fd6231922495175b701a6c44b665e91cd7e (diff)
downloadbinutils-76367d23146136b457b1494285b807437a9fec60.zip
binutils-76367d23146136b457b1494285b807437a9fec60.tar.gz
binutils-76367d23146136b457b1494285b807437a9fec60.tar.bz2
Add gdb.events.tui_enabled
This adds a new event source so that Python scripts can track whether or not the TUI is presently enabled. v2 of the patch renames "status" -> "enabled". Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32162 Reviewed-By: Eli Zaretskii <eliz@gnu.org> Reviewed-by: Keith Seitz <keiths@redhat.com>
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r--gdb/testsuite/gdb.python/tui-window.exp8
-rw-r--r--gdb/testsuite/gdb.python/tui-window.py11
2 files changed, 19 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/tui-window.exp b/gdb/testsuite/gdb.python/tui-window.exp
index e7ff162..c521dcc 100644
--- a/gdb/testsuite/gdb.python/tui-window.exp
+++ b/gdb/testsuite/gdb.python/tui-window.exp
@@ -43,6 +43,9 @@ if {![Term::enter_tui]} {
return
}
+Term::command "python print('tui_enabled=' + str(tui_enabled))"
+Term::check_contents "tui start event" "tui_enabled=True"
+
Term::command "layout test"
Term::check_contents "test title" \
"This Is The Title"
@@ -63,3 +66,8 @@ Term::resize 51 51
Term::check_contents "Window was updated" "Test: 2"
Term::command "layout fail"
+
+Term::command "tui disable"
+gdb_test "python print('tui_enabled=' + str(tui_enabled))" \
+ "tui_enabled=False" \
+ "tui disable event"
diff --git a/gdb/testsuite/gdb.python/tui-window.py b/gdb/testsuite/gdb.python/tui-window.py
index d031f72..0661acc 100644
--- a/gdb/testsuite/gdb.python/tui-window.py
+++ b/gdb/testsuite/gdb.python/tui-window.py
@@ -20,6 +20,9 @@ import gdb
the_window = None
+tui_enabled = False
+
+
class TestWindow:
def __init__(self, win):
global the_window
@@ -62,3 +65,11 @@ def change_window_title():
gdb.register_window_type("fail", failwin)
+
+
+def set_tui_enabled(ev):
+ global tui_enabled
+ tui_enabled = ev.enabled
+
+
+gdb.events.tui_enabled.connect(set_tui_enabled)