GDB (API)
|
00001 # tty.tcl - xterm as tty for the inferior 00002 # Copyright (C) 1996, 2000 Red Hat, Inc 00003 # Written by Tom Tromey <tromey@cygnus.com> 00004 # 00005 # Interface to the inferior's terminal. This is very rough, and is 00006 # guaranteed to only work on Unix machines (if even there). 00007 # 00008 00009 namespace eval tty { 00010 namespace export create 00011 00012 variable _xterm_fd {} 00013 00014 proc create {} { 00015 variable _xterm_fd 00016 00017 destroy 00018 00019 # Tricky: we exec /bin/cat so that the xterm will exit whenever we 00020 # close the write end of the pipe. Note that the stdin 00021 # redirection must come after tty is run; tty looks at its stdin. 00022 set shcmd {/bin/sh -c 'exec 1>&7; tty; exec /bin/cat 0<&6'} 00023 00024 set fg [option get . foreground Foreground] 00025 if {$fg == ""} then { 00026 set fg black 00027 } 00028 00029 set bg [. cget -background] 00030 if {$bg == ""} then { 00031 set bg [lindex [. configure -background] 3] 00032 } 00033 00034 set xterm [list /bin/sh -c "exec xterm -T 'Gdb Child' -n Gdb -bg '$bg' -fg '$fg' -e $shcmd 6<&0 7>&1"] 00035 00036 # Need both read and write access to xterm process. 00037 set _xterm_fd [open "| $xterm" w+] 00038 set tty [gets $_xterm_fd] 00039 00040 # On failure we don't try the tty command. 00041 if {$tty != ""} { 00042 gdb_cmd "tty $tty" 00043 } 00044 } 00045 00046 proc destroy {} { 00047 variable _xterm_fd 00048 00049 if {$_xterm_fd != ""} then { 00050 # We don't care if this fails. 00051 catch {close $_xterm_fd} 00052 } 00053 set _xterm_fd {} 00054 } 00055 }