PinkeyNBrain
IS-IT--Management
Since I drop in here now and again to ask questions - thought I'd attempt to return some effort. The following procedure is something I put together a long time ago but has come in fairly handy while debugging larger scripts. If anyone has upgrade suggestions - great. If anyone can use this - you are welcome to it:
I know some of the variable names are a little long. I'd just recently changed them to try and make the code a little more self documenting.
Code:
# If you just want to look at yourself, call w/ value
# nesting_levels_to_trace_back = 0
# You'll at least see what was passed to you.
proc call_trace {{nesting_levels_to_trace_back 999}} {
puts "Call Trace: {call lvl} -> proc args_passed_to_proc"
set call_trace_nesting_level [info level]
set calling_nest_level [expr $call_trace_nesting_level - 1]
if {! [regexp -- {^\s*\d+\s*$} $nesting_levels_to_trace_back]} {
set nesting_levels_to_trace_back 0
}
set level_to_trace_to [expr $calling_nest_level - $nesting_levels_to_trace_back]
if {$level_to_trace_to < 1} {set level_to_trace_to 1}
for {set i $calling_nest_level} {$i >= $level_to_trace_to} {incr i -1} {
set outline [format "%3s --> %s" $i [info level $i]]
puts $outline
}
return {}
};# END call_trace