How to trace segmentation with tcldebugger?

Posted by lulunguy on 2011-12-08 01:50
Forums: TDK discussion | OS: Linux

hello,
my expectation by using tcldebugger is to help me out to trace any encountered segmentation.

i am running a script where i encounter a true segmentation.
And thru the tcldebugger, by now when it happens, it cannot show me where is the problematic line but just stop the script. i expect to see the cursor to point to the last valid tcl-line before the segmentation.
Any ideas to achieve that?
Thanks

andreas.kupries
ActiveState Staff
Thu, 2011-12-08 09:31

That is not possible.

The tcldebugger is debugging issues with your script, and not for debugging a crash at the C level, i.e. the Tcl runtime itself.

From a more technical point of view, the debugger injects a bit of Tcl code into the debugged application to manage the breakpoints and such in the application. When the Tcl runtime dumps core this piece of code and its data structures are gone also, leaving the debugger frontend without information about where the application was.

The nearest you can come to what you want is if you know roughly where the runtime crashes. In that case you can put breakpoints into suspected locations, and then single-step from the breakpoint until the segmentation fault happens.

However, knowing where in your Tcl script the crash happens only may or may not provide a clue to the whereabouts of the problem in the C code underneath.

Do you know from the core dump and stack trace therein if the crash happens in the Tcl C code, or in one of the C packages you are using (if any) ?

Have you considered to build Tcl and all involved C packages with debug symbols to get a good stack trace with file names and line numbers in the C code ?

Again, an actual segmentation fault is outside of the scope of things tcldebugger can help you with. This application is intended to track down an issue with your script itself, not with the underlying C code, be it the Tcl interpreter, or a C-based package.