Afficher tous les trace actifs
Vous aurez besoin des procédures
list_namespaces et list_namespaces_callback.
Procédure
###############################################################################
### Affichage de tous les "trace" actifs
###############################################################################
proc find_running_traces {} {
lappend found_traces
foreach currently_scanned_namespace [list_namespaces 0 ::] {
foreach command [::tcl::info::commands "[set currently_scanned_namespace]::*"] {
if { [set trace_data [trace info execution $command]] ne "" } {
foreach single_trace $trace_data {
lassign $single_trace tracetype call
if { ([::tcl::info::procs $command] eq "") && ([::tcl::info::commands $command] ne "") } {
set type "cmd"
set command [::tcl::string::trimleft $command ":"]
} else {
set type "prc"
}
lappend found_traces [list type $type target $command tracetype $tracetype call $call]
}
}
}
foreach var [::tcl::info::vars "[set currently_scanned_namespace]::*"] {
if { [set trace_data [trace info variable $var]] ne "" } {
foreach single_trace $trace_data {
lassign $single_trace tracetype call
lappend found_traces [list type var target $var tracetype $tracetype call $call]
}
}
}
}
return $found_traces
}
Exemple
find_running_traces
Tcl: {type cmd target channel tracetype leave call ::DuckHunt::chanset_call} {type cmd target *dcc:chanset tracetype leave call ::DuckHunt::chanset_call}