Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

possible to retrieve call stack info?

93 views
Skip to first unread message

py

unread,
Apr 5, 2012, 3:40:46 PM4/5/12
to
Hi,

I'm supporting a large program written in tcl/tk for my team. There are
times when a user would run into a tcl error, which generates a Wish pop
up message with call stack stack information. The pop up allows the user
to manually save this information. But I'm looking for a way to retrieve
the same information from a procedure (immediately after the user close
the pop up box). I am writing a debug procedure to collect system state,
config files, and SVN info from the program. The only thing missing
right now is the call stack.

I did some testing with errorInfo and errorCode, but couldn't quite get
what I want. The problem is that they require the entire program to be
wrap inside a catch statement, and I can't really do that.

Any ideas?


Win2k8, tcl8.4.19


Thanks

tombert

unread,
Apr 6, 2012, 2:46:02 AM4/6/12
to
Would this do the trick?

proc backtrace {args} {
set msg "$args"
set lvl [info level]
for {set i 1} {$i<$lvl} {incr i} {
append msg "\n"
append msg [string repeat " " $i]
append msg "called from: [list [info level [expr {-$i }]]]"
}
return $msg
}

py

unread,
Apr 6, 2012, 2:33:18 AM4/6/12
to
Hi,

Doesn't seem to work. I place the function in a utility file, so when I
execute [info level] the return value is always 1. ::errorInfo is set to
"invalid command name "::tkerror" while executing "::tkerror $err".

I think the problem is that the (global) debug procedure and failing
procedures are in two different locations, which would mess up [info level]


Thanks

Alexandre Ferrieux

unread,
Apr 7, 2012, 6:45:01 PM4/7/12
to
If the program has an event loop (which is likely if it has a GUI),
then [bgerror] is the way to intercept uncaught errors in event
handlers. If the pop-up is the default one provided by Tk, then
defining bgerror will take over, and your code is then in charge
(using ::errorInfo, ::errorCode, and [info errorstack] in 8.6).
If this pop-up is already made by some other programmer's [bgerror],
then you may want to [rename] it out instead of overwriting it, so
that you can delegate to it after adding your part.

-Alex

Don Porter

unread,
Apr 9, 2012, 2:17:07 PM4/9/12
to
On 04/07/2012 06:45 PM, Alexandre Ferrieux wrote:
> If the program has an event loop (which is likely if it has a GUI),
> then [bgerror] is the way to intercept uncaught errors...

You misspelled [interp bgerror]. :)

--
| Don Porter Applied and Computational Mathematics Division |
| donald...@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|

py

unread,
Apr 9, 2012, 9:57:17 AM4/9/12
to
On 4/9/2012 9:17 PM, Don Porter wrote:
> On 04/07/2012 06:45 PM, Alexandre Ferrieux wrote:
>> If the program has an event loop (which is likely if it has a GUI),
>> then [bgerror] is the way to intercept uncaught errors...
>
> You misspelled [interp bgerror]. :)
>

Hi all,

the bgerror usage that you guys mentioned are only available in tcl 8.5
and up right? I think that would be ok, just need to wait for my group
to make the upgrade


Thanks.

Harald Oehlmann

unread,
Apr 10, 2012, 4:34:26 AM4/10/12
to
On 9 Apr., 15:57, py <pyj...@shaw.ca> wrote:
> the bgerror usage that you guys mentioned are only available in tcl 8.5
> and up right?
No, should be available on 8.4
0 new messages