+2021-06-10 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * lib/gdb.exp (default_gdb_exit): Unset gdb_tty_name.
+ (spawn_capture_tty_name): New, override builtin spawn.
+ (default_gdb_spawn): Capture GDB's TTY name.
+ * lib/tuiterm.exp (tuiterm_spawn): Remove.
+ (tuiterm_env_init, tuiterm_env_finish): Remove spawn override.
+ (Term) <resize>: Use new variable name.
+ (tuiterm_env_init, tuiterm_env_finish): Remove.
+ (tuiterm_env): Don't call tuiterm_env_init and register
+ tuiterm_env_finish in gdb_finish_hooks.
+ (gdb_finish_hooks): Remove.
+ (gdb_finish): Don't call finish hooks.
+
2021-06-08 Lancelot Six <lsix@lancelotsix.com>
* python/lib/gdb/FrameDecorator.py (FrameDecorator): Use 'is None'
remote_close host
}
unset gdb_spawn_id
+ unset ::gdb_tty_name
unset inferior_spawn_id
}
}
}
+# The expect "spawn" function puts the tty name into the spawn_out
+# array; but dejagnu doesn't export this globally. So, we have to
+# wrap spawn with our own function and poke in the built-in spawn
+# so that we can capture this value.
+#
+# If available, the TTY name is saved to the LAST_SPAWN_TTY_NAME global.
+# Otherwise, LAST_SPAWN_TTY_NAME is unset.
+
+proc spawn_capture_tty_name { args } {
+ set result [uplevel builtin_spawn $args]
+ upvar spawn_out spawn_out
+ if { [info exists spawn_out] } {
+ set ::last_spawn_tty_name $spawn_out(slave,name)
+ } else {
+ unset ::last_spawn_tty_name
+ }
+ return $result
+}
+
+rename spawn builtin_spawn
+rename spawn_capture_tty_name spawn
+
# Default gdb_spawn procedure.
proc default_gdb_spawn { } {
}
set gdb_spawn_id $res
+ set ::gdb_tty_name $::last_spawn_tty_name
return 0
}
# finalization function.
proc tuiterm_env { } {
load_lib tuiterm.exp
-
- # Do initialization.
- tuiterm_env_init
-
- # Schedule finalization.
- global gdb_finish_hooks
- lappend gdb_finish_hooks tuiterm_env_finish
}
# Dejagnu has a version of note, but usage is not allowed outside of dejagnu.
# An ANSI terminal emulator for expect.
-# The expect "spawn" function puts the tty name into the spawn_out
-# array; but dejagnu doesn't export this globally. So, we have to
-# wrap spawn with our own function, so that we can capture this value.
-# The value is later used in calls to stty.
-proc tuiterm_spawn { args } {
- set result [uplevel builtin_spawn $args]
- global gdb_spawn_name
- upvar spawn_out spawn_out
- if { [info exists spawn_out] } {
- set gdb_spawn_name $spawn_out(slave,name)
- } else {
- unset gdb_spawn_name
- }
- return $result
-}
-
-# Initialize tuiterm.exp environment.
-proc tuiterm_env_init { } {
- # Override spawn with tui_spawn.
- rename spawn builtin_spawn
- rename tuiterm_spawn spawn
-}
-
-# Finalize tuiterm.exp environment.
-proc tuiterm_env_finish { } {
- # Restore spawn.
- rename spawn tuiterm_spawn
- rename builtin_spawn spawn
-}
-
namespace eval Term {
# Size of the terminal.
variable _rows
variable _cols
variable _resize_count
- global gdb_spawn_name
# expect handles each argument to stty separately. This means
# that gdb will see SIGWINCH twice. Rather than rely on this
# behavior (which, after all, could be changed), we make it
# explicit here. This also simplifies waiting for the redraw.
_do_resize $rows $_cols
- stty rows $_rows < $gdb_spawn_name
+ stty rows $_rows < $::gdb_tty_name
# Due to the strange column resizing behavior, and because we
# don't care about this intermediate resize, we don't check
# the size here.
# than what we request from expect. We hide this weird
# details from the caller.
_do_resize $_rows $cols
- stty columns [expr {$_cols + 1}] < $gdb_spawn_name
+ stty columns [expr {$_cols + 1}] < $::gdb_tty_name
wait_for "@@ resize done $_resize_count, size = ${_cols}x${rows}"
incr _resize_count
}