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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [gdbtcl/] [process.itb] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Process window for GDBtk.
2
# Copyright 1998, 1999 Cygnus Solutions
3
#
4
# This program is free software; you can redistribute it and/or modify it
5
# under the terms of the GNU General Public License (GPL) as published by
6
# the Free Software Foundation; either version 2 of the License, or (at
7
# your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
 
14
 
15
# ----------------------------------------------------------------------
16
# Implements a process window with a list of threads, tasks, and/or
17
# processes to debug.
18
#
19
# ----------------------------------------------------------------------
20
 
21
body ProcessWin::constructor {args} {
22
  set top [winfo toplevel $itk_interior]
23
 
24
  window_name "Processes"
25
  gdbtk_busy
26
  build_win
27
  gdbtk_idle
28
 
29
  # Add hooks for this object
30
  add_hook gdb_no_inferior_hook [code $this idle]
31
}
32
 
33
 
34
# ------------------------------------------------------------------
35
#  METHOD:  build_win - build the main process window
36
# ------------------------------------------------------------------
37
body ProcessWin::build_win {} {
38
  global tixOption tcl_platform
39
  if {$tcl_platform(platform) == "windows"} {
40
    tixScrolledListBox $itk_interior.s -scrollbar both -sizebox 1
41
  } else {
42
    tixScrolledListBox $itk_interior.s -scrollbar auto
43
  }
44
  set lb [$itk_interior.s subwidget listbox]
45
  $lb configure -selectmode single -bg $tixOption(input1_bg) \
46
    -selectbackground green \
47
    -selectforeground black \
48
    -font src-font          \
49
    -exportselection false
50
  update dummy
51
  balloon register $lb "Click on a line to change context"
52
 
53
  # bind mouse button 1 to change the current context
54
  bind $lb  [code $this change_context %y]
55
  bind $lb  break
56
 
57
  pack $itk_interior.s -side left -expand yes -fill both
58
}
59
 
60
 
61
# ------------------------------------------------------------------
62
#  METHOD:  update - update widget when something changes
63
# ------------------------------------------------------------------
64
body ProcessWin::update {event} {
65
  if {!$protect_me} {
66
 
67
    $lb delete 0 end
68
    if {[catch {gdb_cmd "info thread"} threads]} {
69
      # failed.  leave window blank
70
      return
71
    }
72
 
73
    #debug "processWin update: \n$threads"
74
    if {[llength $threads] == 0} {
75
      # no processes/threads listed.
76
      return
77
    }
78
 
79
    # insert each line one at a time
80
    set active -1
81
    set num_threads 0
82
    foreach line [split $threads \n] {
83
      # Active line starts with "*"
84
      if {[string index $line 0] == "*"} {
85
        # strip off leading "*"
86
        set line " [string trimleft $line "*"]"
87
        set active $num_threads
88
      }
89
      # scan for GDB ID number at start of line
90
      if {[scan $line "%d" id($num_threads)] == 1} {
91
        $lb insert end $line
92
        incr num_threads
93
      }
94
    }
95
 
96
    # highlight the active thread
97
    if {$active >= 0} {
98
      set active_thread $id($active)
99
      $lb selection set $active
100
      $lb see $active
101
    }
102
  }
103
}
104
 
105
# ------------------------------------------------------------------
106
#  METHOD:  change_context - change the current context (active thread)
107
#        This method is currently ONLY called from the mouse binding
108
# ------------------------------------------------------------------
109
body ProcessWin::change_context {y} {
110
  if {!$Running && [$lb size] != 0} {
111
    gdbtk_busy
112
    set linenum [$lb nearest $y]
113
    set idnum $id($linenum)
114
    #debug "change_context to line $linenum  id=$idnum"
115
    catch {gdb_cmd "thread $idnum"}
116
    # Run idle hooks and cause all widgets to update
117
    set protect_me 1
118
    gdbtk_update
119
    set protect_me 0
120
    gdbtk_idle
121
  }
122
}
123
 
124
# ------------------------------------------------------------------
125
#  DESTRUCTOR - destroy window containing widget
126
# ------------------------------------------------------------------
127
body ProcessWin::destructor {} {
128
  remove_hook gdb_no_inferior_hook [code $this no_inferior]
129
}
130
 
131
# ------------------------------------------------------------------
132
#  METHOD:  reconfig - used when preferences change
133
# ------------------------------------------------------------------
134
body ProcessWin::reconfig {} {
135
  destroy $itk_interior.s
136
  build_win
137
}
138
 
139
# ------------------------------------------------------------------
140
#  METHOD:  busy - BusyEvent handler
141
#
142
#        This method should accomplish blocking
143
#        - clicks in the window
144
#        - change mouse pointer
145
# ------------------------------------------------------------------
146
body ProcessWin::busy {event} {
147
  set Running 1
148
  cursor watch
149
}
150
 
151
# ------------------------------------------------------------------
152
#  METHOD:  idle - handle IdleEvent
153
# ------------------------------------------------------------------
154
body ProcessWin::idle {event} {
155
  set Running 0
156
  cursor {}
157
}
158
 
159
# ------------------------------------------------------------------
160
#  METHOD:  cursor - set the window cursor
161
#        This is a convenience method which simply sets the mouse
162
#        pointer to the given glyph.
163
# ------------------------------------------------------------------
164
body ProcessWin::cursor {glyph} {
165
  $top configure -cursor $glyph
166
}

powered by: WebSVN 2.1.0

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