]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Log on return in Term::_log_cur
authorTom de Vries <tdevries@suse.de>
Thu, 24 Jul 2025 07:18:57 +0000 (09:18 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 24 Jul 2025 07:18:57 +0000 (09:18 +0200)
Proc Term::_log_cur logs the cursor update of code in its body argument:
...
    proc _ctl_0x08 {} {
        _log_cur "Backspace" {
            variable _cur_col

            if {$_cur_col > 0} {
                incr _cur_col -1
            }
        }
    }
...
giving us for instance:
...
+++ Backspace, cursor: (2, 0) -> (2, 0)
...

But if we rewrite the code to use a return:
...
    if { $_cur_col == 0 } {
return
    }
    incr _cur_col -1
...
and the return is triggered, the log message disappears.

Fix this by wrapping the "uplevel $body" in a catch:
...
- uplevel $body
+ set code [catch {uplevel $body} result]
...

Tested on aarch64-linux.

gdb/testsuite/lib/tuiterm.exp

index 9ca8334d4376ad2dc3e6e36ffa7af14554eeb5bc..ce5df306ba44a4e62510d22a560e901a637e1e46 100644 (file)
@@ -45,9 +45,16 @@ namespace eval Term {
        set orig_cur_row $_cur_row
        set orig_cur_col $_cur_col
 
-       uplevel $body
+       set code [catch {uplevel $body} result]
 
        _log "$what, cursor: ($orig_cur_row, $orig_cur_col) -> ($_cur_row, $_cur_col)"
+
+       if { $code == 1 } {
+           global errorInfo errorCode
+           return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
+       } else {
+           return -code $code $result
+       }
     }
 
     # If ARG is empty, return DEF: otherwise ARG.  This is useful for