OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [gdbtcl/] [tty.tcl] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# tty.tcl - xterm as tty for the inferior
2
# Copyright (C) 1996, 2000 Red Hat, Inc
3
# Written by Tom Tromey <tromey@cygnus.com>
4
#
5
# Interface to the inferior's terminal.  This is very rough, and is
6
# guaranteed to only work on Unix machines (if even there).
7
#
8
 
9
namespace eval tty {
10
  namespace export create
11
 
12
  variable _xterm_fd {}
13
 
14
  proc create {} {
15
    variable _xterm_fd
16
 
17
    destroy
18
 
19
    # Tricky: we exec /bin/cat so that the xterm will exit whenever we
20
    # close the write end of the pipe.  Note that the stdin
21
    # redirection must come after tty is run; tty looks at its stdin.
22
    set shcmd {/bin/sh -c 'exec 1>&7; tty; exec /bin/cat 0<&6'}
23
 
24
    set fg [option get . foreground Foreground]
25
    if {$fg == ""} then {
26
      set fg black
27
    }
28
 
29
    set bg [. cget -background]
30
    if {$bg == ""} then {
31
      set bg [lindex [. configure -background] 3]
32
    }
33
 
34
    set xterm [list /bin/sh -c "exec xterm -T 'Gdb Child' -n Gdb -bg '$bg' -fg '$fg' -e $shcmd 6<&0 7>&1"]
35
 
36
    # Need both read and write access to xterm process.
37
    set _xterm_fd [open "| $xterm" w+]
38
    set tty [gets $_xterm_fd]
39
 
40
    # On failure we don't try the tty command.
41
    if {$tty != ""} {
42
      gdb_cmd "tty $tty"
43
    }
44
  }
45
 
46
  proc destroy {} {
47
    variable _xterm_fd
48
 
49
    if {$_xterm_fd != ""} then {
50
      # We don't care if this fails.
51
      catch {close $_xterm_fd}
52
    }
53
    set _xterm_fd {}
54
  }
55
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.