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
, write to the Free Software Foundation
,
17 # Inc.
, 51 Franklin Street
- Fifth Floor
, Boston
, MA
02110-1301, USA.
19 # This file was written by Rob Savoye
<rob@welcomehome.org
>.
21 # Dump the
values of a
shell expression representing
variable names.
23 proc dumpvars
{ args } {
24 uplevel
1 [list foreach i
[uplevel
1 "info vars $args"] {
25 if { [catch
"array names $i" names ] } {
26 eval
"puts \"$i = \$$i\""
29 eval
"puts \"$i\($k\) = \$$i\($k\)\""
36 # Dump the
values of a
shell expression representing
variable names.
38 proc dumplocals
{ args } {
39 uplevel
1 [list foreach i
[uplevel
1 "info locals $args"] {
40 if { [catch
"array names $i" names ] } {
41 eval
"puts \"${i} = \$${i}\""
44 eval
"puts \"$i\($k\) = \$$i\($k\)\""
51 # Dump the body of procedures specified by a pattern.
53 proc dumprocs
{ args } {
54 foreach i
[info procs $
args] {
55 puts
"\nproc $i \{ [info args $i] \} \{ [info body $i]\}"
59 # Dump all the current watchpoints.
61 proc dumpwatch
{ args } {
62 foreach i
[uplevel
1 "info vars $args"] {
64 if { [catch
"uplevel 1 array name $i" names] } {
65 set tmp
[uplevel
1 trace vinfo $i
]
71 set tmp
[uplevel
1 trace vinfo
[set i
]($k
)]
73 puts
"[set i]($k) = $tmp"
80 #
Trap a watchpoint
for an array.
82 proc watcharray
{ array element op
} {
83 upvar
[set array
]($element
) avar
85 "w" { puts "New value of [set array]($element) is $avar" }
86 "r" { puts "[set array]($element) (= $avar) was just read" }
87 "u" { puts "[set array]($element) (= $avar) was just unset" }
91 proc watchvar
{ v ignored op
} {
94 "w" { puts "New value of $v is $var" }
95 "r" { puts "$v (=$var) was just read" }
96 "u" { puts "$v (=$var) was just unset" }
100 #
Watch when a
variable is written.
102 proc watchunset
{ arg } {
103 if { [catch
"uplevel 1 array name $arg" names ] } {
104 if {![uplevel
1 info exists $
arg]} {
105 puts stderr
"$arg does not exist"
108 uplevel
1 trace variable $
arg u watchvar
111 if {![uplevel
1 info exists $
arg]} {
112 puts stderr
"$arg does not exist"
115 uplevel
1 trace variable [set arg]($k
) u watcharray
120 #
Watch when a
variable is written.
122 proc watchwrite
{ arg } {
123 if { [catch
"uplevel 1 array name $arg" names ] } {
124 if {![uplevel
1 info exists $
arg]} {
125 puts stderr
"$arg does not exist"
128 uplevel
1 trace variable $
arg w watchvar
131 if {![uplevel
1 info exists $
arg]} {
132 puts stderr
"$arg does not exist"
135 uplevel
1 trace variable [set arg]($k
) w watcharray
140 #
Watch when a
variable is read.
142 proc watchread
{ arg } {
143 if { [catch
"uplevel 1 array name $arg" names ] } {
144 if {![uplevel
1 info exists $
arg]} {
145 puts stderr
"$arg does not exist"
148 uplevel
1 trace variable $
arg r watchvar
151 if {![uplevel
1 info exists $
arg]} {
152 puts stderr
"$arg does not exist"
155 uplevel
1 trace variable [set arg]($k
) r watcharray
160 #
Delete a watchpoint.
162 proc watchdel
{ args } {
163 foreach i
[uplevel
1 "info vars $args"] {
165 if { [catch
"uplevel 1 array name $i" names] } {
166 catch
"uplevel 1 trace vdelete $i w watchvar"
167 catch
"uplevel 1 trace vdelete $i r watchvar"
168 catch
"uplevel 1 trace vdelete $i u watchvar"
171 catch
"uplevel 1 trace vdelete [set i]($k) w watcharray"
172 catch
"uplevel 1 trace vdelete [set i]($k) r watcharray"
173 catch
"uplevel 1 trace vdelete [set i]($k) u watcharray"
179 # This file creates GDB style commands
for the Tcl debugger
190 # The w command is provided by the Tcl debugger.
194 # Create some stub procedures since we can
't alias the command names.
197 uplevel 1 dumprocs $args
201 uplevel 1 dumpvars $args
205 uplevel 1 dumplocals $args
209 uplevel 1 dumpwatch $args
217 uplevel 1 print $args
221 uplevel 1 watchunset $args
225 uplevel 1 watchwrite $args
229 uplevel 1 watchread $args
233 uplevel 1 watchdel $args