What about running the code in a debugger, setting the breakpoint at Tcl_Eval()
(or whatever method your C code uses to call out into Tcl) then make your program call that piece of Tcl code and then examine the stack?
You'd need the debug build of your C code (with symbols); debugging version of the Tcl runtime would also make the stack trace more comprehensible.
FWIW, I failed to find any published API for traversing the stack trace here, so presumably it does not exist. Moreover, to traverse the stack on the C side, the Tcl runtime would need something like libunwind
, and AFAIK Tcl does not have anything like this built-in.