[fpc-pascal] ansistrings, exceptions, pascal call stack and access violations
Peter Vreman
peter at freepascal.org
Thu Nov 4 20:48:20 CET 2004
At 19:12 4-11-2004, you wrote:
>Peter wrote:
>
> >The quick fix for it will be to disable the dump_stack call after an
> unhandled exception is found.
>
>That gets rid of the junk, but I still lose the call stack.
>
> >Alternative solution is to retrieve the caller stack at the time an
> exception is raised. But that will take more cpu time and more memory.
>
>Regarding the system resources -- it would only take that extra cpu time /
>memory at the time the exception is raised, correct?
>
>(( Our own project does not raise exceptions extensively, but we do want
>to be able to handle them when they come up, rather than crash out. Maybe
>we will have one exception in five minutes of execution. ))
>
>Also, I assume this would only work if I raise the exception. If I
>encounter, e.g., a stack overflow, I guess there wouldn't be a way to get
>the backtrace until the bug is taken care of? Or can I get it within my
>exception handling code before reraising?
>
>I'm working on the "alternative solution" ... how do I get my hands on the
>Relevent Address and frame?
>
> Writeln (backtrace_text, BackTraceStrFunc(Addr -- ???) );
> Dump_Stack (backtrace_text, frame - ???);
The exception handling routines are located in except.inc
In fpc_PushExceptObj the exception is raised. There is a structure
PExceptObject that needs to be extended to contain a few (8?) caller addresses.
How to get the addresses of the frames can be found in dump_stack() located
in system.inc
The unhandled exception code is in excepts.inc (rtl/objpas/sysutils/)
Peter
More information about the fpc-pascal
mailing list