[PATCH 5/7] [gdb/testsuite] Fix Term::_csi_m with no args

Tom de Vries
2025-07-18T13:04:18Z

When calling Term::_csi_m with no args, default behaviour needs to be applied,
which is equivalent to "Term::_csi_m 0" [1].

However, while "Term::_csi_m 0" works, as well as 'Term::_csi_m ""', calling
Term::_csi_m with no args has no effect.

Fix this by implementing the default behaviour in Term::_csi_m.

Tested on aarch64-linux.

[1] https://vt100.net/docs/vt510-rm/SGR.html
---
gdb/testsuite/gdb.tui/tuiterm.exp | 9 +++++++++
gdb/testsuite/lib/tuiterm.exp | 5 +++++
2 files changed, 14 insertions(+)

diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index e58de688ef2..6cd65f3ede7 100644
--- a/gdb/testsuite/gdb.tui/tuiterm.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm.exp
@@ -783,6 +783,15 @@ proc test_attrs {} {
set line [Term::get_line_with_attrs 0]
gdb_assert { [regexp $re $line] } "attribute: $attr"
}
+
+ # Regression test: Check that _csi_m works without arguments.
+ setup_terminal 4 1
+ Term::_csi_m 7
+ Term::_insert "a"
+ Term::_csi_m
+ Term::_insert "a"
+ set line [Term::get_line_with_attrs 0]
+ gdb_assert { [string equal $line "<reverse:1>a<reverse:0>a "] }
}

# Run proc TEST_PROC_NAME with a "small" terminal.
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 451fccc6693..10c5a3d0dce 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -638,6 +638,11 @@ namespace eval Term {
#
# https://vt100.net/docs/vt510-rm/SGR.html
proc _csi_m {args} {
+ if { [llength $args] == 0 } {
+ # Apply default.
+ set args { 0 }
+ }
+
_log_cur "Select Graphic Rendition ([join $args {, }])" {
variable _attrs

--
2.43.0