1 |
578 |
markom |
# Register display window for Insight.
|
2 |
|
|
# Copyright 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 |
|
|
# ------------------------------------------------------------------
|
15 |
|
|
# CONSTRUCTOR - create new register window
|
16 |
|
|
# ------------------------------------------------------------------
|
17 |
|
|
body RegWin::constructor {args} {
|
18 |
|
|
global tixOption
|
19 |
|
|
debug
|
20 |
|
|
wm withdraw [winfo toplevel $itk_interior]
|
21 |
|
|
gdbtk_busy
|
22 |
|
|
|
23 |
|
|
set NormalForeground $tixOption(fg)
|
24 |
|
|
set HighlightForeground [pref get gdb/reg/highlight_fg]
|
25 |
|
|
|
26 |
|
|
if {[pref getd gdb/reg/menu] != ""} {
|
27 |
|
|
set mbar 0
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
init_reg_display_vars 1
|
31 |
|
|
build_win
|
32 |
|
|
eval itk_initialize $args
|
33 |
|
|
|
34 |
|
|
gdbtk_idle
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
# ------------------------------------------------------------------
|
38 |
|
|
# DESTRUCTOR - destroy window containing widget
|
39 |
|
|
# ------------------------------------------------------------------
|
40 |
|
|
body RegWin::destructor {} {
|
41 |
|
|
debug
|
42 |
|
|
save_reg_display_vars
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
# ------------------------------------------------------------------
|
47 |
|
|
# METHOD: build_win - build the main register window
|
48 |
|
|
# ------------------------------------------------------------------
|
49 |
|
|
body RegWin::build_win {} {
|
50 |
|
|
global reg_display tixOption tcl_platform
|
51 |
|
|
|
52 |
|
|
set dim [dimensions]
|
53 |
|
|
set nRows [lindex $dim 0]
|
54 |
|
|
set nCols [lindex $dim 1]
|
55 |
|
|
if {$tcl_platform(platform) == "windows"} {
|
56 |
|
|
tixScrolledWindow $itk_interior.scrolled -scrollbar both -sizebox 1
|
57 |
|
|
} else {
|
58 |
|
|
tixScrolledWindow $itk_interior.scrolled -scrollbar auto
|
59 |
|
|
}
|
60 |
|
|
set ScrolledWin [$itk_interior.scrolled subwidget window]
|
61 |
|
|
|
62 |
|
|
# Calculate the maximum length of a register name
|
63 |
|
|
set regMaxLen 0
|
64 |
|
|
foreach r [gdb_regnames] {
|
65 |
|
|
set l [string length $r]
|
66 |
|
|
if {$l > $regMaxLen} {
|
67 |
|
|
set regMaxLen $l
|
68 |
|
|
}
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
# Calculate the minimum size for each column so that the register values fit.
|
72 |
|
|
set row 0
|
73 |
|
|
set col 0
|
74 |
|
|
foreach r $reg_display_list {
|
75 |
|
|
if {$row == 0} {
|
76 |
|
|
# A minimum of 10 so the appearence is nice
|
77 |
|
|
set vmax($col) 10
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
# Typed registers natural values start with a brace (escaped by a slash)
|
81 |
|
|
if {[catch {gdb_fetch_registers {} $r} valtest]} {
|
82 |
|
|
set values($r) ""
|
83 |
|
|
} else {
|
84 |
|
|
if {[string index $valtest 1] == "\{"} {
|
85 |
|
|
# If it is a typed register, we print it raw
|
86 |
|
|
set format r
|
87 |
|
|
set reg_display($r,format) r
|
88 |
|
|
set reg_display($r,typed) 1
|
89 |
|
|
set reg_display($r,editable) 0
|
90 |
|
|
} else {
|
91 |
|
|
set format $reg_display($r,format)
|
92 |
|
|
set reg_display($r,editable) 1
|
93 |
|
|
}
|
94 |
|
|
if {[catch {gdb_fetch_registers $format $r} values($r)]} {
|
95 |
|
|
set values($r) ""
|
96 |
|
|
} else {
|
97 |
|
|
set values($r) [string trim $values($r) \ ]
|
98 |
|
|
}
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
set l [string length $values($r)]
|
102 |
|
|
if {$l > $vmax($col)} {
|
103 |
|
|
set vmax($col) $l
|
104 |
|
|
}
|
105 |
|
|
incr row
|
106 |
|
|
if {$row == $nRows} {
|
107 |
|
|
set row 0
|
108 |
|
|
incr col
|
109 |
|
|
}
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
# Create labels
|
113 |
|
|
set row 0
|
114 |
|
|
set col 0
|
115 |
|
|
foreach r $reg_display_list {
|
116 |
|
|
if {$row == $nRows} {
|
117 |
|
|
grid columnconfigure $ScrolledWin $col -weight 1
|
118 |
|
|
set row 0
|
119 |
|
|
incr col
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
frame $ScrolledWin.$r -takefocus 1
|
123 |
|
|
bind $ScrolledWin.$r "$this reg_select_up"
|
124 |
|
|
bind $ScrolledWin.$r "$this reg_select_down"
|
125 |
|
|
bind $ScrolledWin.$r "$this reg_select_down"
|
126 |
|
|
bind $ScrolledWin.$r "$this reg_select_left"
|
127 |
|
|
bind $ScrolledWin.$r "$this reg_select_right"
|
128 |
|
|
if {![pref get gdb/mode]} {
|
129 |
|
|
bind $ScrolledWin.$r "$this edit $r"
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
label $ScrolledWin.$r.lbl -text [fixLength $reg_display($r,name) $regMaxLen left] \
|
133 |
|
|
-relief solid -bd 1 -font src-font
|
134 |
|
|
label $ScrolledWin.$r.val -anchor e -text [fixLength $values($r) $vmax($col) right] \
|
135 |
|
|
-relief ridge -bd 1 -font src-font -bg $tixOption(input1_bg)
|
136 |
|
|
|
137 |
|
|
grid $ScrolledWin.$r.lbl $ScrolledWin.$r.val -sticky nsew
|
138 |
|
|
grid columnconfigure $ScrolledWin.$r 1 -weight 1
|
139 |
|
|
grid $ScrolledWin.$r -colum $col -row $row -sticky nsew
|
140 |
|
|
# grid rowconfigure $ScrolledWin $row -weight 1
|
141 |
|
|
bind $ScrolledWin.$r.val <1> "$this reg_select $r"
|
142 |
|
|
bind $ScrolledWin.$r.lbl <1> "$this reg_select $r"
|
143 |
|
|
bind $ScrolledWin.$r.val <3> "$this but3 $r %X %Y"
|
144 |
|
|
bind $ScrolledWin.$r.lbl <3> "$this but3 $r %X %Y"
|
145 |
|
|
if {![pref get gdb/mode]} {
|
146 |
|
|
bind $ScrolledWin.$r.lbl "$this edit $r"
|
147 |
|
|
bind $ScrolledWin.$r.val "$this edit $r"
|
148 |
|
|
}
|
149 |
|
|
incr row
|
150 |
|
|
}
|
151 |
|
|
grid columnconfigure $ScrolledWin $col -weight 1
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
if { $mbar } {
|
155 |
|
|
menu $itk_interior.m -tearoff 0
|
156 |
|
|
[winfo toplevel $itk_interior] configure -menu $itk_interior.m
|
157 |
|
|
$itk_interior.m add cascade -menu $itk_interior.m.reg -label "Register" -underline 0
|
158 |
|
|
set m [menu $itk_interior.m.reg]
|
159 |
|
|
if {![pref get gdb/mode]} {
|
160 |
|
|
$m add command -label "Edit" -underline 0 -state disabled
|
161 |
|
|
}
|
162 |
|
|
$m add cascade -menu $itk_interior.m.reg.format -label "Format" -underline 0
|
163 |
|
|
set f [menu $itk_interior.m.reg.format]
|
164 |
|
|
$f add radio -label "Hex" -value x -underline 0 -state disabled \
|
165 |
|
|
-command "$this update dummy"
|
166 |
|
|
$f add radio -label "Decimal" -value d -underline 0 -state disabled \
|
167 |
|
|
-command "$this update dummy"
|
168 |
|
|
$f add radio -label "Natural" -value {} -underline 0 -state disabled \
|
169 |
|
|
-command "$this update dummy"
|
170 |
|
|
$f add radio -label "Binary" -value t -underline 0 -state disabled \
|
171 |
|
|
-command "$this update dummy"
|
172 |
|
|
$f add radio -label "Octal" -value o -underline 0 -state disabled \
|
173 |
|
|
-command "$this update dummy"
|
174 |
|
|
$f add radio -label "Raw" -value r -underline 0 -state disabled \
|
175 |
|
|
-command "$this update dummy"
|
176 |
|
|
$f add radio -label "Floating Point" -value f -underline 0 -state disabled \
|
177 |
|
|
-command "$this update dummy"
|
178 |
|
|
$m add command -label "Remove from Display" -underline 0 -state disabled
|
179 |
|
|
$m add separator
|
180 |
|
|
$m add command -label "Add to Watch" -underline 7 -state disabled
|
181 |
|
|
$m add separator
|
182 |
|
|
$m add command -label "Display All Registers" -underline 0 -state disabled \
|
183 |
|
|
-command "$this display_all"
|
184 |
|
|
set disp_all_menu_item [$m index last]
|
185 |
|
|
|
186 |
|
|
if {!$all_regs_shown} {
|
187 |
|
|
$m entryconfigure $disp_all_menu_item -state normal
|
188 |
|
|
}
|
189 |
|
|
}
|
190 |
|
|
|
191 |
|
|
set Menu [menu $ScrolledWin.pop -tearoff 0]
|
192 |
|
|
set disabled_fg [$Menu cget -fg]
|
193 |
|
|
$Menu configure -disabledforeground $disabled_fg
|
194 |
|
|
|
195 |
|
|
# Clear gdb's changed list
|
196 |
|
|
catch {gdb_changed_register_list}
|
197 |
|
|
|
198 |
|
|
pack $itk_interior.scrolled -anchor nw -fill both -expand yes
|
199 |
|
|
|
200 |
|
|
window_name "Registers" "Regs"
|
201 |
|
|
}
|
202 |
|
|
|
203 |
|
|
# ------------------------------------------------------------------------------
|
204 |
|
|
# NAME: init_reg_display_vars
|
205 |
|
|
# DESC: Initialize the list of registers displayed.
|
206 |
|
|
# args - not used
|
207 |
|
|
# RETURNS:
|
208 |
|
|
# NOTES:
|
209 |
|
|
# ------------------------------------------------------------------------------
|
210 |
|
|
body RegWin::init_reg_display_vars {args} {
|
211 |
|
|
global reg_display max_regs
|
212 |
|
|
set reg_display_list {}
|
213 |
|
|
set regnames [gdb_regnames -numbers]
|
214 |
|
|
|
215 |
|
|
set i 1
|
216 |
|
|
set x 0
|
217 |
|
|
foreach r $regnames {
|
218 |
|
|
incr x
|
219 |
|
|
set name [lindex $r 0]
|
220 |
|
|
set rn [lindex $r 1]
|
221 |
|
|
set reg_display($rn,name) $name
|
222 |
|
|
|
223 |
|
|
# All registers shall be considered editable
|
224 |
|
|
# and non-typed until proved otherwise
|
225 |
|
|
set reg_display($rn,typed) 0
|
226 |
|
|
set reg_display($rn,editable) 0
|
227 |
|
|
|
228 |
|
|
# If user has no preference, show register in hex (if we can)
|
229 |
|
|
set format [pref getd gdb/reg/$name-format]
|
230 |
|
|
if {$format == ""} { set format x }
|
231 |
|
|
set reg_display($rn,format) $format
|
232 |
|
|
|
233 |
|
|
# Check if the user prefers not to show this register
|
234 |
|
|
if {$args != "" && [pref getd gdb/reg/$name] == "no"} {
|
235 |
|
|
set all_regs_shown 0
|
236 |
|
|
set reg_display($rn,line) 0
|
237 |
|
|
} else {
|
238 |
|
|
set reg_display($rn,line) $i
|
239 |
|
|
lappend reg_display_list $rn
|
240 |
|
|
incr i
|
241 |
|
|
}
|
242 |
|
|
}
|
243 |
|
|
|
244 |
|
|
set num_regs [expr {$i - 1}]
|
245 |
|
|
set max_regs $x
|
246 |
|
|
set reg_names_dirty 0
|
247 |
|
|
}
|
248 |
|
|
|
249 |
|
|
body RegWin::set_variable {event} {
|
250 |
|
|
switch [$event get variable] {
|
251 |
|
|
disassembly-flavor {
|
252 |
|
|
disassembly_changed
|
253 |
|
|
}
|
254 |
|
|
}
|
255 |
|
|
}
|
256 |
|
|
|
257 |
|
|
body RegWin::disassembly_changed {} {
|
258 |
|
|
set reg_names_dirty 1
|
259 |
|
|
}
|
260 |
|
|
# ------------------------------------------------------------------------------
|
261 |
|
|
# NAME: save_reg_display_vars
|
262 |
|
|
# DESC: save the list of displayed registers to the preferences file.
|
263 |
|
|
# ------------------------------------------------------------------------------
|
264 |
|
|
body RegWin::save_reg_display_vars {} {
|
265 |
|
|
global reg_display max_regs
|
266 |
|
|
set regnames [gdb_regnames -numbers]
|
267 |
|
|
foreach r $regnames {
|
268 |
|
|
set rn [lindex $r 1]
|
269 |
|
|
set name $reg_display($rn,name)
|
270 |
|
|
if {$reg_display($rn,line) == 0} {
|
271 |
|
|
pref setd gdb/reg/$name no
|
272 |
|
|
} else {
|
273 |
|
|
pref setd gdb/reg/$name {}
|
274 |
|
|
}
|
275 |
|
|
if {$reg_display($rn,format) != "x"} {
|
276 |
|
|
pref setd gdb/reg/$name-format $reg_display($rn,format)
|
277 |
|
|
} else {
|
278 |
|
|
pref setd gdb/reg/$name-format {}
|
279 |
|
|
}
|
280 |
|
|
}
|
281 |
|
|
pref_save ""
|
282 |
|
|
}
|
283 |
|
|
|
284 |
|
|
# ------------------------------------------------------------------
|
285 |
|
|
# PUBLIC METHOD: reg_select_up
|
286 |
|
|
# ------------------------------------------------------------------
|
287 |
|
|
body RegWin::reg_select_up { } {
|
288 |
|
|
if { $selected == -1 || $Running} {
|
289 |
|
|
return
|
290 |
|
|
}
|
291 |
|
|
set current_index [lsearch -exact $reg_display_list $selected]
|
292 |
|
|
set new_reg [lindex $reg_display_list [expr {$current_index - 1}]]
|
293 |
|
|
if { $new_reg != {} } {
|
294 |
|
|
$this reg_select $new_reg
|
295 |
|
|
}
|
296 |
|
|
}
|
297 |
|
|
|
298 |
|
|
# ------------------------------------------------------------------
|
299 |
|
|
# PUBLIC METHOD: reg_select_down
|
300 |
|
|
# ------------------------------------------------------------------
|
301 |
|
|
body RegWin::reg_select_down { } {
|
302 |
|
|
if { $selected == -1 || $Running} {
|
303 |
|
|
return
|
304 |
|
|
}
|
305 |
|
|
set current_index [lsearch -exact $reg_display_list $selected]
|
306 |
|
|
set new_reg [lindex $reg_display_list [expr {$current_index + 1}]]
|
307 |
|
|
if { $new_reg != {} } {
|
308 |
|
|
$this reg_select $new_reg
|
309 |
|
|
}
|
310 |
|
|
}
|
311 |
|
|
|
312 |
|
|
# ------------------------------------------------------------------
|
313 |
|
|
# PUBLIC METHOD: reg_select_right
|
314 |
|
|
# ------------------------------------------------------------------
|
315 |
|
|
body RegWin::reg_select_right { } {
|
316 |
|
|
if { $selected == -1 || $Running} {
|
317 |
|
|
return
|
318 |
|
|
}
|
319 |
|
|
set current_index [lsearch -exact $reg_display_list $selected]
|
320 |
|
|
set new_reg [lindex $reg_display_list [expr {$current_index + $nRows}]]
|
321 |
|
|
if { $new_reg != {} } {
|
322 |
|
|
$this reg_select $new_reg
|
323 |
|
|
}
|
324 |
|
|
}
|
325 |
|
|
|
326 |
|
|
# ------------------------------------------------------------------
|
327 |
|
|
# PUBLIC METHOD: reg_select_left
|
328 |
|
|
# ------------------------------------------------------------------
|
329 |
|
|
body RegWin::reg_select_left { } {
|
330 |
|
|
if { $selected == -1 || $Running} {
|
331 |
|
|
return
|
332 |
|
|
}
|
333 |
|
|
set current_index [lsearch -exact $reg_display_list $selected]
|
334 |
|
|
set new_reg [lindex $reg_display_list [expr {$current_index - $nRows}]]
|
335 |
|
|
if { $new_reg != {} } {
|
336 |
|
|
$this reg_select $new_reg
|
337 |
|
|
}
|
338 |
|
|
}
|
339 |
|
|
|
340 |
|
|
# ------------------------------------------------------------------
|
341 |
|
|
# PUBLIC METHOD: reg_select - select a register
|
342 |
|
|
# ------------------------------------------------------------------
|
343 |
|
|
body RegWin::reg_select { r } {
|
344 |
|
|
global reg_display tixOption
|
345 |
|
|
|
346 |
|
|
if {$Running} { return }
|
347 |
|
|
if {$selected != -1} {
|
348 |
|
|
catch {$ScrolledWin.$selected.lbl configure -fg $tixOption(fg) -bg $tixOption(bg)}
|
349 |
|
|
catch {$ScrolledWin.$selected.val configure -fg $tixOption(fg) \
|
350 |
|
|
-bg $tixOption(input1_bg)}
|
351 |
|
|
}
|
352 |
|
|
|
353 |
|
|
# if we click on the same line, unselect it and return
|
354 |
|
|
if {$selected == $r} {
|
355 |
|
|
set selected -1
|
356 |
|
|
$itk_interior.m.reg entryconfigure 0 -state disabled
|
357 |
|
|
$itk_interior.m.reg entryconfigure 2 -state disabled
|
358 |
|
|
for {set i 0} {$i < 7} {incr i} {
|
359 |
|
|
$itk_interior.m.reg.format entryconfigure $i -state disabled
|
360 |
|
|
}
|
361 |
|
|
return
|
362 |
|
|
}
|
363 |
|
|
|
364 |
|
|
if {$Editing != -1} {
|
365 |
|
|
unedit
|
366 |
|
|
}
|
367 |
|
|
|
368 |
|
|
$ScrolledWin.$r.lbl configure -fg $tixOption(select_fg) -bg $tixOption(select_bg)
|
369 |
|
|
$ScrolledWin.$r.val configure -fg $tixOption(fg) -bg $tixOption(bg)
|
370 |
|
|
|
371 |
|
|
if {![pref get gdb/mode] && $reg_display($r,editable)} {
|
372 |
|
|
$itk_interior.m.reg entryconfigure 0 -state normal -command "$this edit $r"
|
373 |
|
|
}
|
374 |
|
|
$itk_interior.m.reg entryconfigure 2 -state normal \
|
375 |
|
|
-command "$this delete_from_display_list $r"
|
376 |
|
|
if {$reg_display($r,typed)} {
|
377 |
|
|
set state disabled
|
378 |
|
|
} else {
|
379 |
|
|
set state normal
|
380 |
|
|
}
|
381 |
|
|
for {set i 0} {$i < 7} {incr i} {
|
382 |
|
|
debug "format $i $state"
|
383 |
|
|
$itk_interior.m.reg.format entryconfigure $i -state $state \
|
384 |
|
|
-variable reg_display($r,format)
|
385 |
|
|
}
|
386 |
|
|
$itk_interior.m.reg entryconfigure 4 -state normal \
|
387 |
|
|
-command "$this addToWatch $r"
|
388 |
|
|
focus -force $ScrolledWin.$r
|
389 |
|
|
set selected $r
|
390 |
|
|
}
|
391 |
|
|
|
392 |
|
|
# ------------------------------------------------------------------
|
393 |
|
|
# PRIVATE METHOD: dimensions - determine square-like dimensions for
|
394 |
|
|
# register window
|
395 |
|
|
# ------------------------------------------------------------------
|
396 |
|
|
body RegWin::dimensions {} {
|
397 |
|
|
set rows [pref get gdb/reg/rows]
|
398 |
|
|
# set rows [expr int(floor(sqrt($num_regs)))]
|
399 |
|
|
set cols [expr {int(ceil(sqrt($num_regs)))}]
|
400 |
|
|
|
401 |
|
|
return [list $rows $cols]
|
402 |
|
|
}
|
403 |
|
|
|
404 |
|
|
# ------------------------------------------------------------------------------
|
405 |
|
|
# NAME:
|
406 |
|
|
# private method RegWin::fixLength
|
407 |
|
|
#
|
408 |
|
|
# SYNOPSIS:
|
409 |
|
|
# fixLength {s size where}
|
410 |
|
|
#
|
411 |
|
|
# DESC:
|
412 |
|
|
# Makes a string into a fixed-length string, inserting spaces as
|
413 |
|
|
# necessary. If 'where' is "left" spaces will be added to the left,
|
414 |
|
|
# if 'where' is "right" spaces will be added to the right.
|
415 |
|
|
# ARGS:
|
416 |
|
|
# s - input string
|
417 |
|
|
# size - size of string to output
|
418 |
|
|
# where - "left" or "right"
|
419 |
|
|
#
|
420 |
|
|
# RETURNS:
|
421 |
|
|
# Padded string of length 'size'
|
422 |
|
|
#
|
423 |
|
|
# NOTES:
|
424 |
|
|
# This should really be a proc, not a method.
|
425 |
|
|
# ------------------------------------------------------------------------------
|
426 |
|
|
body RegWin::fixLength {s size where} {
|
427 |
|
|
set blank " "
|
428 |
|
|
set len [string length $s]
|
429 |
|
|
set bl [expr {$size - $len}]
|
430 |
|
|
set b [string range $blank 0 $bl]
|
431 |
|
|
|
432 |
|
|
switch $where {
|
433 |
|
|
left { set fl "$s$b"}
|
434 |
|
|
right { set fl "$b$s"}
|
435 |
|
|
}
|
436 |
|
|
return $fl
|
437 |
|
|
}
|
438 |
|
|
|
439 |
|
|
# ------------------------------------------------------------------
|
440 |
|
|
# PUBLIC METHOD: but3 - generate and display a popup window on button 3
|
441 |
|
|
# over the register value
|
442 |
|
|
# ------------------------------------------------------------------
|
443 |
|
|
body RegWin::but3 {rn X Y} {
|
444 |
|
|
global reg_display max_regs
|
445 |
|
|
|
446 |
|
|
if {!$Running} {
|
447 |
|
|
$Menu delete 0 end
|
448 |
|
|
$Menu add command -label $reg_display($rn,name) -state disabled
|
449 |
|
|
$Menu add separator
|
450 |
|
|
if {!$reg_display($rn,typed)} {
|
451 |
|
|
$Menu add radio -label "Hex" -command "$this update dummy" \
|
452 |
|
|
-value x -variable reg_display($rn,format)
|
453 |
|
|
$Menu add radio -label "Decimal" -command "$this update dummy" \
|
454 |
|
|
-value d -variable reg_display($rn,format)
|
455 |
|
|
$Menu add radio -label "Natural" -command "$this update dummy" \
|
456 |
|
|
-value {} -variable reg_display($rn,format)
|
457 |
|
|
$Menu add radio -label "Binary" -command "$this update dummy" \
|
458 |
|
|
-value t -variable reg_display($rn,format) -underline 0
|
459 |
|
|
$Menu add radio -label "Octal" -command "$this update dummy" \
|
460 |
|
|
-value o -variable reg_display($rn,format)
|
461 |
|
|
$Menu add radio -label "Raw" -command "$this update dummy" \
|
462 |
|
|
-value r -variable reg_display($rn,format)
|
463 |
|
|
$Menu add radio -label "Floating Point" -command "$this update dummy" \
|
464 |
|
|
-value f -variable reg_display($rn,format)
|
465 |
|
|
$Menu add separator
|
466 |
|
|
}
|
467 |
|
|
$Menu add command -command "$this addToWatch $rn" \
|
468 |
|
|
-label "Add $reg_display($rn,name) to Watch"
|
469 |
|
|
$Menu add separator
|
470 |
|
|
$Menu add command -command "$this delete_from_display_list $rn" \
|
471 |
|
|
-label "Remove $reg_display($rn,name) from Display"
|
472 |
|
|
if {$max_regs != $num_regs} {
|
473 |
|
|
$Menu add separator
|
474 |
|
|
$Menu add command -command "$this display_all" \
|
475 |
|
|
-label "Display all registers"
|
476 |
|
|
}
|
477 |
|
|
tk_popup $Menu $X $Y
|
478 |
|
|
}
|
479 |
|
|
}
|
480 |
|
|
|
481 |
|
|
# ------------------------------------------------------------------
|
482 |
|
|
# PUBLIC METHOD: display_all - add all registers to the display list
|
483 |
|
|
# ------------------------------------------------------------------
|
484 |
|
|
body RegWin::display_all {} {
|
485 |
|
|
init_reg_display_vars
|
486 |
|
|
$itk_interior.m.reg entryconfigure $disp_all_menu_item -state disabled
|
487 |
|
|
set all_regs_shown 1
|
488 |
|
|
reconfig
|
489 |
|
|
}
|
490 |
|
|
|
491 |
|
|
# ------------------------------------------------------------------
|
492 |
|
|
# PUBLIC METHOD: delete_from_display_list - remove a register from the
|
493 |
|
|
# display list
|
494 |
|
|
# ------------------------------------------------------------------
|
495 |
|
|
body RegWin::delete_from_display_list {rn} {
|
496 |
|
|
global reg_display max_regs
|
497 |
|
|
set reg_display($rn,line) 0
|
498 |
|
|
set reg_display_list {}
|
499 |
|
|
set regnames [gdb_regnames -numbers]
|
500 |
|
|
set i 0
|
501 |
|
|
foreach r $regnames {
|
502 |
|
|
set rnx [lindex $r 1]
|
503 |
|
|
if {$reg_display($rnx,line) > 0} {
|
504 |
|
|
lappend reg_display_list $rnx
|
505 |
|
|
incr i
|
506 |
|
|
set reg_display($rnx,line) $i
|
507 |
|
|
}
|
508 |
|
|
}
|
509 |
|
|
set num_regs $i
|
510 |
|
|
reconfig
|
511 |
|
|
$itk_interior.m.reg entryconfigure 6 -state normal
|
512 |
|
|
}
|
513 |
|
|
|
514 |
|
|
|
515 |
|
|
|
516 |
|
|
# ------------------------------------------------------------------
|
517 |
|
|
# PUBLIC METHOD: edit - edit a cell
|
518 |
|
|
# ------------------------------------------------------------------
|
519 |
|
|
body RegWin::edit {r} {
|
520 |
|
|
global reg_display
|
521 |
|
|
if {$Running} { return }
|
522 |
|
|
if {!$reg_display($r,editable)} {return}
|
523 |
|
|
unedit
|
524 |
|
|
|
525 |
|
|
set Editing $r
|
526 |
|
|
set txt [$ScrolledWin.$r.val cget -text]
|
527 |
|
|
set len [string length $txt]
|
528 |
|
|
set entry [entry $ScrolledWin.$r.ent -width $len -bd 0 -font src-font]
|
529 |
|
|
$entry insert 0 $txt
|
530 |
|
|
|
531 |
|
|
grid remove $ScrolledWin.$r.val
|
532 |
|
|
grid $entry -row 0 -col 1
|
533 |
|
|
bind $entry "$this acceptEdit $r"
|
534 |
|
|
bind $entry "$this unedit"
|
535 |
|
|
$entry selection to end
|
536 |
|
|
focus $entry
|
537 |
|
|
}
|
538 |
|
|
|
539 |
|
|
# ------------------------------------------------------------------
|
540 |
|
|
# PUBLIC METHOD: acceptEdit - callback invoked when enter key pressed
|
541 |
|
|
# in an editing entry
|
542 |
|
|
# ------------------------------------------------------------------
|
543 |
|
|
body RegWin::acceptEdit {r} {
|
544 |
|
|
global reg_display
|
545 |
|
|
|
546 |
|
|
set value [string trimleft [$ScrolledWin.$r.ent get]]
|
547 |
|
|
debug "value=${value}="
|
548 |
|
|
if {$value == ""} {
|
549 |
|
|
set value 0
|
550 |
|
|
}
|
551 |
|
|
if {[catch {gdb_cmd "set \$$reg_display($r,name)=$value"} result]} {
|
552 |
|
|
tk_messageBox -icon error -type ok -message $result \
|
553 |
|
|
-title "Error in Expression" -parent [winfo toplevel $itk_interior]
|
554 |
|
|
focus $ScrolledWin.$r.ent
|
555 |
|
|
$ScrolledWin.$r.ent selection to end
|
556 |
|
|
} else {
|
557 |
|
|
unedit
|
558 |
|
|
gdbtk_update
|
559 |
|
|
}
|
560 |
|
|
}
|
561 |
|
|
|
562 |
|
|
# ------------------------------------------------------------------
|
563 |
|
|
# PUBLIC METHOD: addToWatch - add a register to the watch window
|
564 |
|
|
# ------------------------------------------------------------------
|
565 |
|
|
body RegWin::addToWatch {reg} {
|
566 |
|
|
global reg_display
|
567 |
|
|
[ManagedWin::open WatchWin] add "\$$reg_display($reg,name)"
|
568 |
|
|
}
|
569 |
|
|
|
570 |
|
|
# ------------------------------------------------------------------
|
571 |
|
|
# PUBLIC METHOD: unedit - clear any editing entry on the screen
|
572 |
|
|
# ------------------------------------------------------------------
|
573 |
|
|
body RegWin::unedit {} {
|
574 |
|
|
if {$Editing != -1} {
|
575 |
|
|
destroy $ScrolledWin.$Editing.ent
|
576 |
|
|
|
577 |
|
|
# Fill the entry with the old label, updating value
|
578 |
|
|
grid $ScrolledWin.$Editing.val -column 1 -row 0
|
579 |
|
|
focus -force $ScrolledWin.$Editing
|
580 |
|
|
set Editing -1
|
581 |
|
|
update dummy
|
582 |
|
|
}
|
583 |
|
|
}
|
584 |
|
|
|
585 |
|
|
# ------------------------------------------------------------------
|
586 |
|
|
# PRIVATE METHOD: update - update widget when PC changes
|
587 |
|
|
# ------------------------------------------------------------------
|
588 |
|
|
body RegWin::update {event} {
|
589 |
|
|
global reg_display
|
590 |
|
|
debug "START REGISTER UPDATE CALLBACK"
|
591 |
|
|
if {$reg_display_list == ""
|
592 |
|
|
|| [catch {eval gdb_changed_register_list $reg_display_list} changed_reg_list]} {
|
593 |
|
|
set changed_reg_list {}
|
594 |
|
|
}
|
595 |
|
|
|
596 |
|
|
set row 0
|
597 |
|
|
set col 0
|
598 |
|
|
foreach r $reg_display_list {
|
599 |
|
|
if {$row == 0} {
|
600 |
|
|
# A minimum of 10 so the appearence is nice
|
601 |
|
|
set vmax($col) 10
|
602 |
|
|
}
|
603 |
|
|
|
604 |
|
|
# Typed registers natural values start with a brace (escaped by a slash)
|
605 |
|
|
if {[catch {gdb_fetch_registers {} $r} valtest]} {
|
606 |
|
|
set values($r) ""
|
607 |
|
|
} else {
|
608 |
|
|
if {[string index $valtest 1] == "\{"} {
|
609 |
|
|
# If it is a typed register, we print it raw
|
610 |
|
|
set format r
|
611 |
|
|
set reg_display($r,format) r
|
612 |
|
|
set reg_display($r,typed) 1
|
613 |
|
|
set reg_display($r,editable) 0
|
614 |
|
|
} else {
|
615 |
|
|
set format $reg_display($r,format)
|
616 |
|
|
set reg_display($r,editable) 1
|
617 |
|
|
}
|
618 |
|
|
if {[catch {gdb_fetch_registers $format $r} values($r)]} {
|
619 |
|
|
set values($r) ""
|
620 |
|
|
} else {
|
621 |
|
|
set values($r) [string trim $values($r) \ ]
|
622 |
|
|
}
|
623 |
|
|
}
|
624 |
|
|
|
625 |
|
|
set l [string length $values($r)]
|
626 |
|
|
if {$l > $vmax($col)} {
|
627 |
|
|
set vmax($col) $l
|
628 |
|
|
}
|
629 |
|
|
incr row
|
630 |
|
|
if {$row == $nRows} {
|
631 |
|
|
set row 0
|
632 |
|
|
incr col
|
633 |
|
|
}
|
634 |
|
|
}
|
635 |
|
|
|
636 |
|
|
set row 0
|
637 |
|
|
set col 0
|
638 |
|
|
foreach r $reg_display_list {
|
639 |
|
|
if {[lsearch -exact $changed_reg_list $r] != -1} {
|
640 |
|
|
set fg $HighlightForeground
|
641 |
|
|
} else {
|
642 |
|
|
set fg $NormalForeground
|
643 |
|
|
}
|
644 |
|
|
$ScrolledWin.$r.val configure -text [fixLength $values($r) $vmax($col) right] \
|
645 |
|
|
-fg $fg
|
646 |
|
|
incr row
|
647 |
|
|
if {$row == $nRows} {
|
648 |
|
|
set row 0
|
649 |
|
|
incr col
|
650 |
|
|
}
|
651 |
|
|
}
|
652 |
|
|
debug "END REGISTER UPDATE CALLBACK"
|
653 |
|
|
}
|
654 |
|
|
|
655 |
|
|
body RegWin::idle {event} {
|
656 |
|
|
[winfo toplevel $itk_interior] configure -cursor {}
|
657 |
|
|
set Running 0
|
658 |
|
|
}
|
659 |
|
|
|
660 |
|
|
# ------------------------------------------------------------------
|
661 |
|
|
# PRIVATE METHOD: reconfig - used when preferences change
|
662 |
|
|
# ------------------------------------------------------------------
|
663 |
|
|
body RegWin::reconfig {} {
|
664 |
|
|
if {$reg_names_dirty} {
|
665 |
|
|
init_reg_display_vars
|
666 |
|
|
}
|
667 |
|
|
destroy $Menu $itk_interior.g $itk_interior.scrolled $itk_interior.m
|
668 |
|
|
gdbtk_busy
|
669 |
|
|
build_win
|
670 |
|
|
gdbtk_idle
|
671 |
|
|
}
|
672 |
|
|
|
673 |
|
|
# ------------------------------------------------------------------
|
674 |
|
|
# PUBLIC METHOD: busy - BusyEvent handler
|
675 |
|
|
# ------------------------------------------------------------------
|
676 |
|
|
body RegWin::busy {event} {
|
677 |
|
|
# Cancel edits
|
678 |
|
|
unedit
|
679 |
|
|
|
680 |
|
|
# Fencepost
|
681 |
|
|
set Running 1
|
682 |
|
|
|
683 |
|
|
# cursor
|
684 |
|
|
[winfo toplevel $itk_interior] configure -cursor watch
|
685 |
|
|
}
|