1 # Copyright
(C
) 1992-2019, 2020 Free Software Foundation
, Inc.
3 # This file is part of DejaGnu.
5 # DejaGnu is free software
: you can redistribute it and
/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation
, either version
3 of the License
, or
8 #
(at your option
) any later version.
10 # DejaGnu is distributed in the hope that it will be useful
, but
11 # WITHOUT
ANY WARRANTY
; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License
for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with DejaGnu.
If not
, see
<http
://www.gnu.org
/licenses
/>.
18 # This file was written by Rob Savoye
<rob@welcomehome.org
>.
20 # Dump the
values of a
shell expression representing
variable names.
22 proc dumpvars
{ args } {
23 uplevel
1 [list foreach i
[uplevel
1 "info vars $args"] {
24 if { [catch
"array names $i" names ] } {
25 eval
"puts \"$i = \$$i\""
28 eval
"puts \"$i\($k\) = \$$i\($k\)\""
35 # Dump the
values of a
shell expression representing
variable names.
37 proc dumplocals
{ args } {
38 uplevel
1 [list foreach i
[uplevel
1 "info locals $args"] {
39 if { [catch
"array names $i" names ] } {
40 eval
"puts \"${i} = \$${i}\""
43 eval
"puts \"$i\($k\) = \$$i\($k\)\""
50 # Dump the body of procedures specified by a pattern.
52 proc dumprocs
{ args } {
53 foreach i
[info procs $
args] {
54 puts
"\nproc $i \{ [info args $i] \} \{ [info body $i]\}"
58 # Dump all the current watchpoints.
60 proc dumpwatch
{ args } {
61 foreach i
[uplevel
1 "info vars $args"] {
63 if { [catch
"uplevel 1 array name $i" names] } {
64 set tmp
[uplevel
1 trace vinfo $i
]
70 set tmp
[uplevel
1 trace vinfo
[set i
]($k
)]
72 puts
"[set i]($k) = $tmp"
79 #
Trap a watchpoint
for an array.
81 proc watcharray
{ array element op
} {
82 upvar
[set array
]($element
) avar
84 "w" { puts "New value of [set array]($element) is $avar" }
85 "r" { puts "[set array]($element) (= $avar) was just read" }
86 "u" { puts "[set array]($element) (= $avar) was just unset" }
90 proc watchvar
{ v ignored op
} {
93 "w" { puts "New value of $v is $var" }
94 "r" { puts "$v (=$var) was just read" }
95 "u" { puts "$v (=$var) was just unset" }
99 #
Watch when a
variable is written.
101 proc watchunset
{ arg } {
102 if { [catch
"uplevel 1 array name $arg" names ] } {
103 if {![uplevel
1 info exists $
arg]} {
104 puts stderr
"$arg does not exist"
107 uplevel
1 trace variable $
arg u watchvar
110 if {![uplevel
1 info exists $
arg]} {
111 puts stderr
"$arg does not exist"
114 uplevel
1 trace variable [set arg]($k
) u watcharray
119 #
Watch when a
variable is written.
121 proc watchwrite
{ arg } {
122 if { [catch
"uplevel 1 array name $arg" names ] } {
123 if {![uplevel
1 info exists $
arg]} {
124 puts stderr
"$arg does not exist"
127 uplevel
1 trace variable $
arg w watchvar
130 if {![uplevel
1 info exists $
arg]} {
131 puts stderr
"$arg does not exist"
134 uplevel
1 trace variable [set arg]($k
) w watcharray
139 #
Watch when a
variable is read.
141 proc watchread
{ arg } {
142 if { [catch
"uplevel 1 array name $arg" names ] } {
143 if {![uplevel
1 info exists $
arg]} {
144 puts stderr
"$arg does not exist"
147 uplevel
1 trace variable $
arg r watchvar
150 if {![uplevel
1 info exists $
arg]} {
151 puts stderr
"$arg does not exist"
154 uplevel
1 trace variable [set arg]($k
) r watcharray
159 #
Delete a watchpoint.
161 proc watchdel
{ args } {
162 foreach i
[uplevel
1 "info vars $args"] {
164 if { [catch
"uplevel 1 array name $i" names] } {
165 catch
"uplevel 1 trace vdelete $i w watchvar"
166 catch
"uplevel 1 trace vdelete $i r watchvar"
167 catch
"uplevel 1 trace vdelete $i u watchvar"
170 catch
"uplevel 1 trace vdelete [set i]($k) w watcharray"
171 catch
"uplevel 1 trace vdelete [set i]($k) r watcharray"
172 catch
"uplevel 1 trace vdelete [set i]($k) u watcharray"
178 # This file creates GDB style commands
for the Tcl debugger
189 # The w command is provided by the Tcl debugger.
193 # Create some stub procedures since we can
't alias the command names.
196 uplevel 1 dumprocs $args
200 uplevel 1 dumpvars $args
204 uplevel 1 dumplocals $args
208 uplevel 1 dumpwatch $args
216 uplevel 1 print $args
220 uplevel 1 watchunset $args
224 uplevel 1 watchwrite $args
228 uplevel 1 watchread $args
232 uplevel 1 watchdel $args