From db47da255d841a0881b8e33c6630df0279149c12 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Thu, 24 Jul 2025 09:18:57 +0200 Subject: [PATCH] [gdb/testsuite] Log on return in Term::_log_cur 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 9ca8334d437..ce5df306ba4 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -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 -- 2.47.2