[EF] wrote the following while trying to discover the reason why his "big" application ends with a "segmentation fault" when being run within [undroidwish]. He stills doesn't know, but is a useful package richer.... Source the following and call `::proctrace::init` from a point wherefrom you wish a full trace of what happens in your application. `::proctrace::init` accepts the following options: `-file`: The location of a file that will contain the trace output, empty for stderr (the default). `-allowed`: A list of patterns matching the names of the procedures that will be traced. `-denied`: A list of patterns matching the names of the procedures that should not be traced. `-detailed`: A boolean that will drive tracing: either complete command tracing or trace on procedure entry (the default). The code below introspects your application to ensure that all procedures, even the ones that you have defined before calling `::proctrace::init` will be part of the tracing activity. ====== package require Tcl 8.6 namespace eval ::proctrace { namespace eval vars { variable fd stderr variable -file "" variable -allowed {*} variable -denied {} variable -detailed off } } proc ::proctrace::init { args } { set opts [list] foreach o [info vars vars::-*] { set i [string last "::-" $o] lappend opts [string trimleft [string range $o $i end] :] } foreach {k v} $args { if { $k in $opts } { set vars::$k $v } else { return -code error "$k unknown options, should be [join $opts ,\ ]" } } if { ${vars::-file} ne "" } { set vars::fd [open ${vars::-file} w] } rename ::proc ::proctrace::RealProc interp alias {} ::proc {} ::proctrace::Proc foreach p [AllProcs] { if { [Tracable $p]} { Follow $p 2 } } } proc ::proctrace::AllProcs { { base "::" } } { set procs [info procs [string trimright ${base} :]::*] foreach ns [namespace children $base] { set procs [concat $procs [AllProcs $ns]] } return $procs } proc ::proctrace::Follow { name {lvl 1}} { if { [string is true ${vars::-detailed}] } { uplevel $lvl [list trace add execution $name enterstep [list ::proctrace::Trace $name]] } else { uplevel $lvl [list trace add execution $name enter [list ::proctrace::Trace $name]] } } proc ::proctrace::Proc { name arglist body } { uplevel 1 [list ::proctrace::RealProc $name $arglist $body] if { [Tracable $name]} { Follow $name 2 } } proc ::proctrace::Trace { name command op } { puts $vars::fd "$name >> $command" flush $vars::fd } proc ::proctrace::Tracable { name } { set allow 0 foreach ptn ${vars::-allowed} { if { [string match $ptn $name] } { set allow 1 break } } foreach ptn ${vars::-denied} { if { [string match $ptn $name] } { set allow 0 break } } return $allow } ====== <>Debugging