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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Kernel Object Display Window for Insight.
2
# Copyright (C) 1998, 1999, 2001 Red Hat, Inc.
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
#   AUTHOR:  Fernando Nasser 
15
#
16
 
17
 
18
# ------------------------------------------------------------------
19
#  CONSTRUCTOR - create new process window
20
# ------------------------------------------------------------------
21
body KodWin::constructor {args} {
22
  #
23
  #  Create a window with the same name as this object
24
  #
25
  global gdb_kod_cmd
26
 
27
  # initialize local variables
28
  set LevelCmd(0) "info $gdb_kod_cmd "
29
  debug "Level 0 kod command is $LevelCmd(0)"
30
 
31
  gdbtk_busy
32
  build_win
33
  gdbtk_idle
34
}
35
 
36
# ------------------------------------------------------------------
37
#  METHOD:  build_win - build the main KOD window
38
# ------------------------------------------------------------------
39
body KodWin::build_win {} {
40
  # FIXME: rename this variable.
41
  global kodActivePane
42
 
43
  debug "Will build KOD window"
44
 
45
  cyg::PanedWindow $itk_interior.pw -orient horizontal
46
  $itk_interior.pw add titlepane
47
  # We would like to use a fixed pane for the buttons.  However,
48
  # this feature of PanedWindow doesn't work.
49
  # $itk_interior.pw add buttonpane -resizable 0
50
  $itk_interior.pw add pane1
51
  $itk_interior.pw add pane2
52
 
53
  # Now a frame for what is being listed, headers and list
54
  set tp [$itk_interior.pw childsite titlepane]
55
  Labelledframe $tp.tf -text "No Kernel Objects Known" \
56
    -anchor nw
57
  set titl $tp.tf
58
  set lf [$tp.tf get_frame]
59
 
60
  set p1 [$itk_interior.pw childsite pane1]
61
  set p2 [$itk_interior.pw childsite pane2]
62
  $p1 configure -height 120 -bd 2
63
  $p2 configure -height 120 -bd 2
64
  Labelledframe $p1.d1 -text "Details" -anchor nw
65
  Labelledframe $p2.d2 -text "Details" -anchor nw
66
  set d1 [$p1.d1 get_frame]
67
  set d2 [$p2.d2 get_frame]
68
  pack $p1.d1 $p2.d2 -side top -expand yes -fill both -padx 5 -pady 5
69
  set pl1 $p1.d1
70
  set pl2 $p2.d2
71
 
72
  # Setup the button box
73
  set bf [frame $tp.bf]
74
  set BTop [button $bf.top -height 1 -text Top -command [code $this top]]
75
  set BUp  [button $bf.up   -height 1   -text Up -command [code $this up]]
76
  set BClear [button $bf.clear  -height 1 -text Clear \
77
                -command [code $this clear]]
78
  set BDisplay [button $bf.display -height 1 -text Display \
79
                  -command [code $this display]]
80
  set kodActivePane pane1
81
  set BPane1 [radiobutton $bf.pane1 -variable kodActivePane \
82
                -height 1 -text "Pane 1" -value pane1]
83
  set BPane2 [radiobutton $bf.pane2 -variable kodActivePane \
84
                -height 1 -text "Pane 2" -value pane2]
85
  balloon register $bf.top "Return to List of Kernel Objects"
86
  balloon register $bf.up "Return to previous List of Objects"
87
  balloon register $bf.clear "Clear Object Detail Panes\nand Active setting"
88
  balloon register $bf.display \
89
    "Display Object or\nList of Objects of this type"
90
  balloon register $bf.pane1 "Make Pane 1 Active"
91
  balloon register $bf.pane2 "Make Pane 2 Active"
92
  pack $bf.top $bf.up -side left -padx 5
93
  pack $bf.display $bf.clear -side right -padx 5
94
  pack $bf.pane2 $bf.pane1 -side bottom -padx 5 -fill both
95
 
96
  # The list of objects
97
  table $lf.s -titlerows 1 \
98
    -colstretch last -rowstretch last -selectmode single \
99
    -selecttype row -variable $this \
100
    -yscrollcommand "$lf.sb set" -resizeborders none \
101
    -state disabled
102
  scrollbar $lf.sb -orient vertical -command "$lf.s yview"
103
  bind $lf.s  [code $this display]
104
  $lf.s tag configure coltag -anchor nw
105
 
106
  grid $lf.s -row 0 -column 0 -sticky nsew
107
  grid $lf.sb -row 0 -column 1 -sticky nsw
108
  grid columnconfigure $lf 0 -weight 1
109
  grid rowconfigure $lf 0 -weight 1
110
 
111
  # Areas to display object details
112
  set t1 [table $d1.t1 -titlerows 1 -colstretch last -rowstretch last \
113
            -selectmode single -selecttype row -variable $this-pane1 \
114
            -yscrollcommand "$d1.s1 set" -resizeborders none \
115
            -rows 1 -cols 1 -state disabled]
116
  scrollbar $d1.s1 -orient vertical -command "$d1.t1 yview"
117
  set t2 [table $d2.t2 -titlerows 1 -colstretch last -rowstretch last \
118
            -selectmode single -selecttype row -variable $this-pane2 \
119
            -yscrollcommand "$d2.s2 set" -resizeborders none \
120
            -rows 1 -cols 1 -state disabled]
121
  scrollbar $d2.s2 -orient vertical -command "$d2.t2 yview"
122
 
123
  grid $d1.t1 -row 0 -column 0 -sticky nsew
124
  grid $d1.s1 -row 0 -column 1 -sticky nsw
125
  grid columnconfigure $d1 0 -weight 1
126
  grid rowconfigure $d1 0 -weight 1
127
  grid $d2.t2 -row 0 -column 0 -sticky nsew
128
  grid $d2.s2 -row 0 -column 1 -sticky nsw
129
  grid columnconfigure $d2 0 -weight 1
130
  grid rowconfigure $d2 0 -weight 1
131
 
132
  debug "Will pack KOD window"
133
  pack $tp.tf -side top -expand yes -fill both -padx 5 -pady 5
134
  pack $tp.bf -side top -expand no -fill x -padx 5 -pady 5
135
  pack $itk_interior.pw -side bottom -expand yes -fill both
136
  wm minsize $_top 450 500
137
 
138
  # Initialize button state variables for idle (called before update)
139
  set BState(BDisplay) disabled
140
  set BState(BClear) disabled
141
  set BState(BTop) disabled
142
  set BState(BUp) disabled
143
 
144
  #    window_name "Kernel Objects"
145
 
146
  update dummy
147
}
148
 
149
# ------------------------------------------------------------------
150
#  METHOD:  update - update widget when something changes
151
# ------------------------------------------------------------------
152
body KodWin::update {event} {
153
 
154
  debug "updating kod window"
155
 
156
  _disable_buttons
157
 
158
  display_list
159
  display_object
160
 
161
  _restore_buttons
162
 
163
}
164
 
165
# ------------------------------------------------------------------
166
#  METHOD:  display - update the display based on the selection
167
#           it can be a list or an actual object
168
#           We get here from a press on the Display button or
169
#           from a  on a line of the list of objects
170
# ------------------------------------------------------------------
171
body KodWin::display {} {
172
  upvar \#0 $this table_vals
173
  if {!$Running && [$lf.s cget -rows] > 1} {
174
    gdbtk_busy
175
    set linenum [$lf.s index active row]
176
    set object $table_vals($linenum,0)
177
    debug "display selection on line $linenum $object"
178
    incr level
179
    set LevelCmd($level) $LevelCmd([expr $level-1])
180
    append LevelCmd($level) $object
181
    debug "kod command for level $level is now: $LevelCmd($level)"
182
    update dummy
183
    # Run idle hooks and cause all other widgets to update
184
    gdbtk_idle
185
  }
186
}
187
 
188
# ------------------------------------------------------------------
189
#  METHOD:  display_list - display list of objects
190
# ------------------------------------------------------------------
191
body KodWin::display_list {} {
192
  upvar \#0 $this table_vals
193
 
194
  debug "displaying list of objects"
195
 
196
  $lf.s configure -state normal
197
  set cmd $LevelCmd($level)
198
  debug "new kod command is $cmd"
199
  if {[catch "gdb_cmd \"$cmd\"" objects]} {
200
    # failed.  leave window blank
201
    $titl configure -text "Kernel Object Display Failed"
202
    $lf.s delete rows 0 [$lf.s index end row]
203
    $lf.s configure -state disabled
204
    set BState(BDisplay) disabled
205
    return
206
  }
207
 
208
  debug "KodWin update: \n$objects"
209
  if {[llength $objects] == 0} {
210
    $titl configure -text "No Kernel Objects Known"
211
    # no objects listed.
212
    $lf.s delete rows 0 [$lf.s index end row]
213
    $lf.s configure -state disabled
214
    set BState(BDisplay) disabled
215
    return
216
  }
217
 
218
  # insert each line one at a time
219
  set num_lines -1
220
  foreach line [split $objects \n] {
221
    if {$num_lines == -1} {
222
      if {![string match List* $line]} {
223
        if {($level > 0)} {
224
          display_object $cmd objects
225
          incr level -1
226
          $lf.s configure -state disabled
227
          return
228
        } else {
229
          # if level 0 first line does not start with List ignore it
230
          $titl configure -text "List of Kernel Objects"
231
        }
232
      } else {
233
        $titl configure -text $line
234
      }
235
      # Clear listbox and headers to get new stuff.
236
      $lf.s delete rows 0 [$lf.s index end row]
237
    } elseif {$line == ""} {
238
      break
239
    } else {
240
      set col 0
241
      set list [split [string trim $line] \t]
242
      if {$num_lines == 0} {
243
        $lf.s configure -cols [llength $list] -titlerows 1
244
      }
245
      foreach item $list {
246
        debug "inserting $item at $num_lines,$col"
247
        set table_vals($num_lines,$col) $item
248
        incr col
249
      }
250
    }
251
    incr num_lines
252
  }
253
  $lf.s configure -rows [expr {$num_lines + 1}]
254
 
255
  if {$num_lines > 0} {
256
    set BState(BDisplay) active
257
  }
258
 
259
  if {$level == 0} {
260
    set BState(BTop) disabled
261
    set BState(BUp) disabled
262
  } else {
263
    set BState(BTop) active
264
    set BState(BUp) active
265
  }
266
 
267
  $lf.s configure -state disabled
268
  $lf.s see 0,0
269
  $lf.s activate 1,0
270
 
271
  _restore_buttons
272
}
273
 
274
# ------------------------------------------------------------------
275
#  METHOD:  display_object - display information about an object
276
#           When called from update we have to reissue the gdb
277
#           command to get fresh data
278
# ------------------------------------------------------------------
279
body KodWin::display_object {{cmd ""} {obj ""}} {
280
  debug  "Displaying object details..."
281
  upvar $obj objects
282
  global kodActivePane
283
  debug "Active Pane is $kodActivePane"
284
 
285
  # Determine which frame to use
286
  if {$kodActivePane == "pane2"} {
287
    set curpan $t2
288
    upvar \#0 $this-pane2 pane_values
289
    if {$cmd != ""} {
290
      # save command for update
291
      set pane2command $cmd
292
    } else {
293
      # reuse saved command
294
      set cmd $pane2command
295
    }
296
  } else {
297
    set curpan $t1
298
    upvar \#0 $this-pane1 pane_values
299
    if {$cmd != ""} {
300
      # save command for update
301
      set pane1command $cmd
302
    } else {
303
      # reuse saved command
304
      set cmd $pane1command
305
    }
306
  }
307
  debug "curpan $curpan"
308
 
309
  # here we must take care of the case where the user has activated a window
310
  # but it does not have been filled yet.  We just return.
311
  if {$cmd == ""} {
312
    return
313
  }
314
 
315
  $curpan configure -state normal
316
  $curpan delete rows 0 [$curpan index end row]
317
  if {$obj == ""} {
318
    debug "pane kod command is $cmd"
319
    if {[catch "gdb_cmd \"$cmd\"" objects]
320
        || $objects == ""} {
321
      # Failed.  Tell user object no longer there.
322
      $curpan configure -state disabled
323
      return
324
    }
325
  }
326
 
327
  set num_lin 0
328
  foreach line [split $objects \n] {
329
    set col 0
330
    set list [split [string trim $line] \t]
331
    if {$num_lin == 0} {
332
      $curpan configure -cols [llength $list]
333
    }
334
    foreach item $list {
335
      set pane_values($num_lin,$col) $item
336
      incr col
337
    }
338
    incr num_lin
339
  }
340
  $curpan configure -rows $num_lin -state disabled
341
}
342
 
343
# ------------------------------------------------------------------
344
#  METHOD:  clear - clear detail panes and reset pane selection
345
# ------------------------------------------------------------------
346
body KodWin::clear {} {
347
  debug "going to clear detail panes and pane selection"
348
  $t1 configure -state normal
349
  $t2 configure -state normal
350
  $t1 delete rows 0 [$t1 index end row]
351
  $t2 delete rows 0 [$t2 index end row]
352
  $t1 configure -state disabled
353
  $t2 configure -state disabled
354
  # Default to pane 1 again.
355
  global kodActivePane
356
  set kodActivePane pane1
357
  set pane1command ""
358
  set pane2command ""
359
}
360
 
361
# ------------------------------------------------------------------
362
#  METHOD:  top - go to the list of types of objects (top level)
363
# ------------------------------------------------------------------
364
body KodWin::top {} {
365
  debug "going to top from level $level"
366
  if {$level > 0} {
367
    set level 0
368
    update dummy
369
  }
370
}
371
 
372
# ------------------------------------------------------------------
373
#  METHOD:  up - go to the list of objects which led to the current one
374
# ------------------------------------------------------------------
375
body KodWin::up {} {
376
  debug "going up from level $level..."
377
  if {$level > 0} {
378
    incr level -1
379
    debug "...to level $level"
380
    update dummy
381
  }
382
}
383
 
384
# ------------------------------------------------------------------
385
#  DESTRUCTOR - destroy window containing widget
386
# ------------------------------------------------------------------
387
body KodWin::destructor {} {
388
  upvar \#0 $this table_vals $this-pane1 pane1_vals $this-pane2 pane2_vals
389
  global kodActivePane
390
 
391
  catch {unset table_vals}
392
  catch {unset pane1_vals}
393
  catch {unset pane2_vals}
394
  catch {unset kodActivePane}
395
}
396
 
397
# ------------------------------------------------------------------
398
#  PUBLIC METHOD:  set_variable - called when user runs `set os'
399
#                   command
400
# ------------------------------------------------------------------
401
body KodWin::set_variable {event} {
402
 
403
  set value [$event get value]
404
  if {[$event get variable] == "os" && $value != ""} {
405
    set LevelCmd(0) "info $value "
406
    set level 0
407
    update dummy
408
  }
409
}
410
 
411
# ------------------------------------------------------------------
412
#  METHOD:  reconfig - used when preferences change
413
# ------------------------------------------------------------------
414
body KodWin::reconfig {} {
415
  destroy $itk_interior.bf
416
  destroy $titl
417
  build_win
418
}
419
 
420
# ------------------------------------------------------------------
421
#  METHOD:  busy - BusyEvent handler
422
#
423
#        This method should accomplish blocking
424
#        - clicks in the window
425
#        - change mouse pointer
426
# ------------------------------------------------------------------
427
body KodWin::busy {event} {
428
  set Running 1
429
  _disable_buttons
430
  cursor watch
431
}
432
 
433
# ------------------------------------------------------------------
434
#  METHOD:  idle - idle event handler.  Run when the target is not
435
#           running
436
# ------------------------------------------------------------------
437
body KodWin::idle {event} {
438
  set Running 0
439
  _restore_buttons
440
  cursor {}
441
}
442
 
443
# ------------------------------------------------------------------
444
#  METHOD:  cursor - set the window cursor
445
#        This is a convenience method which simply sets the mouse
446
#        pointer to the given glyph.
447
# ------------------------------------------------------------------
448
body KodWin::cursor {glyph} {
449
  $_top configure -cursor $glyph
450
}
451
 
452
# ------------------------------------------------------------------
453
#  PRIVATE METHOD:  _disable_buttons - disable all buttons
454
#       Used when we are busy and can't take another event
455
# ------------------------------------------------------------------
456
body KodWin::_disable_buttons {} {
457
  $BTop configure -state disabled
458
  $BUp configure -state disabled
459
  $BDisplay configure -state disabled
460
  $BClear configure -state disabled
461
}
462
 
463
# ------------------------------------------------------------------
464
#  PRIVATE METHOD:  _restore_buttons - restore all buttons to their
465
#       previous states.
466
#       Used when we are busy and can't take another event
467
# ------------------------------------------------------------------
468
body KodWin::_restore_buttons {} {
469
  $BTop configure -state $BState(BTop)
470
  $BUp configure -state $BState(BUp)
471
  $BDisplay configure -state $BState(BDisplay)
472
  # CLEAR is always active, except when busy
473
  $BClear configure -state active
474
}

powered by: WebSVN 2.1.0

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