This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
Patch: xterm for tty
- To: Insight List <insight at sourceware dot cygnus dot com>
- Subject: Patch: xterm for tty
- From: Tom Tromey <tromey at redhat dot com>
- Date: 05 Dec 2000 17:55:44 -0700
- Reply-To: tromey at redhat dot com
This patch makes it possible to use an xterm as the tty for the
inferior process. This only works on Unix, and it is only used if you
select this option from the target selection dialog.
Ok to commit?
2000-12-05 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.
Tom
Index: targetselection.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/targetselection.itb,v
retrieving revision 1.6
diff -u -r1.6 targetselection.itb
--- targetselection.itb 2000/10/31 20:21:48 1.6
+++ targetselection.itb 2000/12/06 00:42:29
@@ -432,6 +432,9 @@
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
@@ -457,6 +460,7 @@
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
}
Index: interface.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/interface.tcl,v
retrieving revision 1.8
diff -u -r1.8 interface.tcl
--- interface.tcl 2000/11/30 22:49:46 1.8
+++ interface.tcl 2000/12/06 00:42:30
@@ -995,7 +1002,7 @@
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"
@@ -1086,6 +1093,13 @@
debug "set args $gdb_args"
catch {gdb_cmd "set args $gdb_args"}
}
+ }
+
+ # 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
}
#
Index: tty.tcl
===================================================================
RCS file: tty.tcl
diff -N tty.tcl
--- /dev/null Tue May 5 13:32:27 1998
+++ tty.tcl Tue Dec 5 16:42:30 2000
@@ -0,0 +1,55 @@
+# 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 {}
+ }
+}