start xterm.
* interface.tcl (run_executable): Call tty::create if requested.
* tty.tcl: New file.
+2000-12-06 Tom Tromey <tromey@redhat.com>
+
+ * targetselection.itb (TargetSelection::build_win): Add option to
+ start xterm.
+ * interface.tcl (run_executable): Call tty::create if requested.
+ * tty.tcl: New file.
+
2000-12-02 Tom Tromey <tromey@redhat.com>
* console.ith (_set_wrap): Declare.
# PROCEDURE: gdbtk_quit_check - Ask if the user really wants to quit.
# ------------------------------------------------------------------
proc gdbtk_quit_check {} {
- global gdb_downloading gdb_running
+ global gdb_downloading gdb_running gdb_exe_name
if {$gdb_downloading} {
set msg "Downloading to target,\n really close the debugger?"
return 0
}
} elseif {$gdb_running} {
- # While we are running the inferior, gdb_cmd is fenceposted and returns
- # immediately. Therefore, we need to ask here. Do we need to stop the target,
- # too?
+ # While we are running the inferior, gdb_cmd is fenceposted and
+ # returns immediately. Therefore, we need to ask here. Do we need
+ # to stop the target, too?
set msg "A debugging session is active.\n"
append msg "Do you still want to close the debugger?"
if {![gdbtk_tcl_query $msg no]} {
return 0
}
+ } elseif {$gdb_exe_name != ""} {
+ session_save
}
return 1
}
proc set_exe_name {exe} {
global gdb_exe_name gdb_exe_changed
#debug "set_exe_name: exe=$exe gdb_exe_name=$gdb_exe_name"
+
+ if {$gdb_exe_name != ""} then {
+ session_save
+ }
+
set gdb_exe_name $exe
set gdb_exe_changed 1
}
proc run_executable { {auto_start 1} } {
global gdb_loaded gdb_downloading gdb_target_name
global gdb_exe_changed gdb_target_changed gdb_program_has_run
- global gdb_running gdb_exe_name
+ global gdb_running gdb_exe_name tcl_platform
# debug "auto_start=$auto_start gdb_target_name=$gdb_target_name"
}
}
+ # If the user requested it, start an xterm for use as the
+ # inferior's tty.
+ if {$tcl_platform(platform) != "windows"
+ && [pref getd gdb/process/xtermtty] == "yes"} {
+ tty::create
+ }
+
#
# Run
entry $f.fr.bp.func -textvariable [pref varname gdb/load/bp_func] -width 20
checkbutton $f.fr.verb -text [gettext "Display Download Dialog"] \
-variable [pref varname gdb/load/$target-verbose]
+ checkbutton $f.fr.xterm -text [gettext "Use xterm as inferior's tty"] \
+ -variable [pref varname gdb/process/xtermtty] \
+ -onvalue yes -offvalue no
if {![pref get gdb/control_target]} {
$f.fr.main configure -state disabled
pack $f.fr.bp.at_func $f.fr.bp.func -side left
grid $f.fr.bp -sticky w -padx 5 -pady 5
grid $f.fr.verb -sticky w -padx 5 -pady 5
+ grid $f.fr.xterm -sticky w -padx 5 -pady 5
if {![pref get gdb/control_target]} {
grid $f.fr.check -sticky w -padx 5 -pady 5
}
--- /dev/null
+# tty.tcl - xterm as tty for the inferior
+# Copyright (C) 1996, 2000 Red Hat, Inc
+# Written by Tom Tromey <tromey@cygnus.com>
+#
+# Interface to the inferior's terminal. This is very rough, and is
+# guaranteed to only work on Unix machines (if even there).
+#
+
+namespace eval tty {
+ namespace export create
+
+ variable _xterm_fd {}
+
+ proc create {} {
+ variable _xterm_fd
+
+ destroy
+
+ # Tricky: we exec /bin/cat so that the xterm will exit whenever we
+ # close the write end of the pipe. Note that the stdin
+ # redirection must come after tty is run; tty looks at its stdin.
+ set shcmd {/bin/sh -c 'exec 1>&7; tty; exec /bin/cat 0<&6'}
+
+ set fg [option get . foreground Foreground]
+ if {$fg == ""} then {
+ set fg black
+ }
+
+ set bg [. cget -background]
+ if {$bg == ""} then {
+ set bg [lindex [. configure -background] 3]
+ }
+
+ set xterm [list /bin/sh -c "exec xterm -T 'Gdb Child' -n Gdb -bg '$bg' -fg '$fg' -e $shcmd 6<&0 7>&1"]
+
+ # Need both read and write access to xterm process.
+ set _xterm_fd [open "| $xterm" w+]
+ set tty [gets $_xterm_fd]
+
+ # On failure we don't try the tty command.
+ if {$tty != ""} {
+ gdb_cmd "tty $tty"
+ }
+ }
+
+ proc destroy {} {
+ variable _xterm_fd
+
+ if {$_xterm_fd != ""} then {
+ # We don't care if this fails.
+ catch {close $_xterm_fd}
+ }
+ set _xterm_fd {}
+ }
+}