/usr/share/tkgate/scripts/breakpoint.tcl is in tkgate-data 2.0~b10-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | #############################################################################
#
# breakpoint handling
#
namespace eval Breakpoint {
variable bp_w
variable bplb_w
variable stateImage
array set stateImage {
-1 bp_bad.gif
0 bp_go.gif
1 bp_stop.gif
2 bp_disabled.gif
3 bp_standby.gif
}
#
# Images for various states
#
# bp_stop.gif
# bp_go.gif
# bp_bad.gif
# bp_disabled.gif
# bp_standby.gif
#
#############################################################################
#
# Create the breakpoint editor.
#
proc create {w args} {
variable bp_w
variable bplb_w
set bp_w $w
frame $w
frame $w.actions
button $w.actions.add -text [m mm.add] -command Breakpoint::add -width [m @mm.width]
button $w.actions.delete -text [m mm.delete] -command Breakpoint::deleteSelection -width [m @mm.width]
button $w.actions.edit -text [m mm.edit] -command Breakpoint::edit -width [m @mm.width]
button $w.actions.enable -text [m mm.enable] -command Breakpoint::enableSelection -width [m @mm.width]
button $w.actions.disable -text [m mm.disable] -command Breakpoint::disableSelection -width [m @mm.width]
set i 0
foreach {b1 b2} {add enable delete disable edit .} {
if { $b1 != "." } {
grid $w.actions.$b1 -row $i -column 0 -padx 1 -pady 1 -sticky ew
}
if { $b2 != "." } {
grid $w.actions.$b2 -row $i -column 1 -padx 1 -pady 1 -sticky ew
}
incr i
}
# frame $w.actions
# button $w.actions.enable -text [m mm.enable] -command Breakpoint::enableSelection -width [m @mm.width]
# button $w.actions.disable -text [m mm.disable] -command Breakpoint::disableSelection -width [m @mm.width]
# button $w.actions.delete -text [m mm.delete] -command Breakpoint::deleteSelection -width [m @mm.width]
# pack $w.actions.enable $w.actions.disable $w.actions.delete -fill x -padx 1 -pady 1
pack $w.actions -side right -fill x -anchor nw
frame $w.t
pack $w.t -fill both
frame $w.t.bplist
set bplb_w $w.t.bplist.lb
SpreadSheet::create $w.t.bplist.lb -height 12 -bd 2 -relief sunken -yscrollcommand "$w.t.bplist.vb set" \
-entrycommand Breakpoint::manager -expandcol 2 -resize 1
SpreadSheet::addcolumn $w.t.bplist.lb -width 4 -header [m break.id]
SpreadSheet::addcolumn $w.t.bplist.lb -width 3 -header [m break.state] -type image
SpreadSheet::addcolumn $w.t.bplist.lb -width 50 -header [m break.condition]
SpreadSheet::addcolumn $w.t.bplist.lb -width 12 -header [m break.value]
pack $w.t.bplist.lb -side left -fill both -expand 1
scrollbar $w.t.bplist.vb -orient vertical -command "SpreadSheet::yview $w.t.bplist.lb"
pack $w.t.bplist.vb -side left -fill y
pack $w.t.bplist -fill both -expand 1
gat_breakpoint -load
}
proc post {} {
# DVM::post
# DVM::setactive Breakpoint
}
#############################################################################
#
# Called in response to pressing the 'Add' button on the breakpoint editor.
#
proc add {} {
variable bplb_w
set r [SpreadSheet::size $bplb_w]
SpreadSheet::see $bplb_w $r
set r [SpreadSheet::getPhysicalRow $bplb_w $r]
SpreadSheet::entrySelect $bplb_w $r 2
}
#############################################################################
#
# Called in response to pressing the 'Edit' button on the breakpoint editor.
#
proc edit {} {
variable bplb_w
set items [SpreadSheet::getselection $bplb_w]
if { [llength $items] < 1 } { return }
set r [lindex $items 0]
set r [SpreadSheet::getPhysicalRow $bplb_w $r]
SpreadSheet::entrySelect $bplb_w $r 2
}
#############################################################################
#
# Add a new breakpoint entry on the tcl side only
#
proc addEntry {id state cond} {
variable bplb_w
variable stateImage
SpreadSheet::insert $bplb_w end [list $id [gifI $stateImage($state)] $cond]
}
#############################################################################
#
# Delete the specified items from both tcl and C.
#
proc delete {items} {
variable bplb_w
action DelBP {
foreach i $items {
gat_breakpoint -delete [SpreadSheet::getcell $bplb_w $i 0]
}
}
SpreadSheet::delete $bplb_w $items
}
#############################################################################
#
# Delete the selected breakpoints.
#
proc deleteSelection {} {
variable bplb_w
SpreadSheet::clearEntrySelect $bplb_w
delete [SpreadSheet::getselection $bplb_w]
}
#############################################################################
#
# Enable the selected breakpoints.
#
proc enableSelection {} {
variable bplb_w
SpreadSheet::clearEntrySelect $bplb_w
action EnableBP {
set select [SpreadSheet::getselection $bplb_w]
foreach i $select {
gat_breakpoint -enable [SpreadSheet::getcell $bplb_w $i 0]
}
}
}
#############################################################################
#
# Disable the selected breakpoints.
#
proc disableSelection {} {
variable bplb_w
SpreadSheet::clearEntrySelect $bplb_w
action DisableBP {
set select [SpreadSheet::getselection $bplb_w]
foreach i $select {
gat_breakpoint -disable [SpreadSheet::getcell $bplb_w $i 0]
}
}
}
#############################################################################
#
# Synchronize tcl brekpoint list with C list.
#
proc undoSync {} {
catch {
flush
gat_breakpoint -load
}
}
#############################################################################
#
# Pick an ID for a new breakpoint
#
proc pickID {} {
variable bplb_w
global simOn
set max_id 0
set n [SpreadSheet::size $bplb_w]
#
# Don't look at the row we just created
#
incr n -1
for {set i 0} {$i < $n} {incr i} {
catch {
set id [lindex [SpreadSheet::get $bplb_w $i] 0]
if {$id > $max_id} {set max_id $id}
}
}
return [expr $max_id + 1]
}
proc find {id} {
variable bplb_w
set n [SpreadSheet::size $bplb_w]
for {set i 0} {$i < $n} {incr i} {
set e [SpreadSheet::get $bplb_w $i]
if { [lindex $e 0] == $id} {
return $i
}
}
return -1
}
#############################################################################
#
# Flush all breakpoints from tcl spreadsheet
#
proc flush {} {
variable bplb_w
SpreadSheet::flush $bplb_w
}
#############################################################################
#
# Set states for breakpoint events
#
proc seeError {id} { setState $id -1 }
proc seeGo {id} { setState $id 0 }
proc seeStandby {id} { setState $id 3 }
#############################################################################
#
# See a trigger of a breakpoint. Make breakpoint list visible if necessary.
#
proc seeBreak {id value} {
variable bplb_w
setState $id 1
set er [find $id]
if {$er >= 0 } {
SpreadSheet::putcell $bplb_w $er 3 $value
}
InfoPanel::notify Breakpoints
}
#############################################################################
#
# Set the state of breakpoint in the tcl spreadsheet.
#
proc setState {id state} {
variable stateImage
variable bplb_w
catch {
set er [find $id]
if {$er >= 0 } {
set gif $stateImage($state)
SpreadSheet::putcell $bplb_w $er 1 [gifI $gif]
}
InfoPanel::notify Breakpoints
}
}
#############################################################################
#
# Spreadsheet entry manager for breakpoint editor.
#
proc manager {cmd args} {
global simOn
if { [lindex $args 0] == "-args" } {
set args [lindex $args 1]
}
switch $cmd {
canenter { # check to see if we can enter data
set c [lindex $args 2]
if {$c == 2} {
return 1
} else {
return 0
}
}
entrywidget { # use a special widget for some cells (return 0 for normal entry)
return 0
}
rightclick { # respond to right mouse click
}
deletenotify { # notification of a deletion
}
delete { # respond to the delete key
deleteSelection
}
close { # called when a cell editing is finish to do any post processing
set w [lindex $args 0]
set r [lindex $args 1]
set c [lindex $args 2]
set data [lindex $args 3]
set er [SpreadSheet::getEffectiveRow $w $r]
set entry [SpreadSheet::get $w $er]
if {$c == 2} {
action AddBP { gat_breakpoint -replace [lindex $entry 0] $data }
if { $simOn } {
set gif bp_go.gif
} else {
set gif bp_standby.gif
}
SpreadSheet::put $w $er [list [lindex $entry 0] [gifI $gif] $data]
}
return $data
}
reorder { # Some list entries may have been moved
}
canappend { # return 1 if we can append to the table
return 1
}
initentry { # create data for a new entry in a table
set id [pickID]
switch [expr $id % 5] {
0 { set gif bp_standby.gif}
1 { set gif bp_go.gif}
2 { set gif bp_stop.gif}
3 { set gif bp_bad.gif}
4 { set gif bp_disabled.gif}
}
if { $simOn } {
set gif bp_go.gif
} else {
set gif bp_standby.gif
}
return [list $id [gifI $gif] "" ""]
}
}
}
}
|