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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [gdbtk/] [library/] [stackwin.itb] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# Stack window for GDBtk.
2
# Copyright 1997, 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
#  CONSTRUCTOR - create new stack window
17
# ------------------------------------------------------------------
18
body StackWin::constructor {args} {
19
  gdbtk_busy
20
  build_win
21
  gdbtk_idle
22
 
23
  add_hook gdb_no_inferior_hook [code $this no_inferior]
24
}
25
 
26
# ------------------------------------------------------------------
27
#  DESTRUCTOR - destroy window containing widget
28
# ------------------------------------------------------------------
29
body StackWin::destructor {} {
30
  remove_hook gdb_no_inferior_hook [code $this no_inferior]
31
}
32
 
33
# ------------------------------------------------------------------
34
#  METHOD:  build_win - build the main register window
35
# ------------------------------------------------------------------
36
body StackWin::build_win {} {
37
  global tixOption tcl_platform
38
  if {$tcl_platform(platform) == "windows"} {
39
    tixScrolledListBox $itk_interior.s -scrollbar both -sizebox 1
40
  } else {
41
    tixScrolledListBox $itk_interior.s -scrollbar auto
42
  }
43
  set lb [$itk_interior.s subwidget listbox]
44
  $lb configure -selectmode single -bg $tixOption(input1_bg) \
45
    -selectbackground [pref get gdb/src/STACK_TAG] \
46
    -selectforeground black \
47
    -font src-font          \
48
    -exportselection false
49
  update dummy
50
  $lb configure -width $maxwidth
51
 
52
  # bind mouse button 1 to change the stack frame
53
  bind $lb  [code $this change_frame %y]
54
  bind $lb  break
55
 
56
  pack $itk_interior.s -side left -expand yes -fill both
57
 
58
  window_name "Stack"
59
}
60
 
61
 
62
# ------------------------------------------------------------------
63
#  METHOD:  update - update widget when PC changes
64
# ------------------------------------------------------------------
65
body StackWin::update {event} {
66
  global gdb_selected_frame_level
67
 
68
  if {!$protect_me} {
69
    set lb [$itk_interior.s subwidget listbox]
70
 
71
    # The gdb_stack command might fail, for instance if you are browsing
72
    # a trace experiment, and the stack has not been collected.
73
 
74
    if {[catch {gdb_stack 0 -1} frames]} {
75
      dbug W "Error in stack collection $frames"
76
      set frames {}
77
    }
78
 
79
    if {[llength $frames] == 0} {
80
      $lb delete 0 end
81
      $lb insert end {NO STACK}
82
      return
83
    }
84
 
85
    $lb delete 0 end
86
    set levels 0
87
    foreach frame $frames {
88
      set len [string length $frame]
89
 
90
      if {$len > $maxwidth} {
91
        set maxwidth $len
92
      }
93
      $lb insert end $frame
94
      incr levels
95
    }
96
 
97
    # this next section checks to see if the source
98
    # window is looking at some location other than the
99
    # bottom of the stack.  If so, highlight the stack frame
100
    set level [expr {$levels - $gdb_selected_frame_level - 1}]
101
    $lb selection set $level
102
    $lb see $level
103
  }
104
}
105
 
106
body StackWin::idle {event} {
107
  set Running 0
108
  cursor {}
109
}
110
 
111
# ------------------------------------------------------------------
112
#  METHOD:  change_frame - change the current frame
113
#        This body StackWin::is currently ONLY called from the mouse binding
114
# ------------------------------------------------------------------
115
body StackWin::change_frame {y} {
116
  set lb [$itk_interior.s subwidget listbox]
117
 
118
  if {!$Running && [$lb size] != 0} {
119
    gdbtk_busy
120
    set lb [$itk_interior.s subwidget listbox]
121
    set linenum [$lb nearest $y]
122
    set size [$lb size]
123
    set linenum [expr {$size - $linenum - 1}]
124
    catch {gdb_cmd "frame $linenum"}
125
 
126
    # Run idle hooks and cause all widgets to update
127
    set protect_me 1
128
    gdbtk_update
129
    set protect_me 0
130
    gdbtk_idle
131
  }
132
}
133
 
134
# ------------------------------------------------------------------
135
#  METHOD:  reconfig - used when preferences change
136
# ------------------------------------------------------------------
137
body StackWin::reconfig {} {
138
  destroy $itk_interior.s
139
  build_win
140
}
141
 
142
# ------------------------------------------------------------------
143
#  PUBLIC METHOD:  busy - BusyEvent handler
144
#                  This method should cause blocking of clicks in
145
#                  the window and change mouse pointer.
146
# ------------------------------------------------------------------
147
body StackWin::busy {event} {
148
  set Running 1
149
  cursor watch
150
}
151
 
152
# ------------------------------------------------------------------
153
#  METHOD:  no_inferior - gdb_no_inferior_hook
154
# ------------------------------------------------------------------
155
body StackWin::no_inferior {} {
156
  set Running 0
157
  cursor {}
158
}
159
 
160
# ------------------------------------------------------------------
161
#  METHOD:  cursor - set the window cursor
162
#        This is a convenience body StackWin::which simply sets the mouse
163
#        pointer to the given glyph.
164
# ------------------------------------------------------------------
165
body StackWin::cursor {glyph} {
166
  set top [winfo toplevel $itk_interior]
167
  $top configure -cursor $glyph
168
}

powered by: WebSVN 2.1.0

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