1 This patch against debian fpc-2.2.2-8 does the following:
2 When a pascal program is compiled with -gl, then any runtime
3 error (either internal, caused by caught signal, or runerror())
4 dumps the stack and then kills itself by SIGABRT.
6 This is to allow catching runtime errors in gdb.
8 Details: We want the stack to be as small as possible when sending
9 SIGABRT. That is why DumpStackAndAbort is a macro and not a function
10 and why we call syscall using assembly. Another trick we do is
11 to place abort calls not only in HandleErrorAddrFrame, but in
12 fpc_rangecheck, fpc_iocheck, fpc_... too. If a rangecheck fails,
13 the resulting stack trace is:
15 #0 0x08058409 in fpc_rangeerror ()
16 #1 0x08048115 in F (I=0) at testp.pas:13
18 Beware, gdb is not able to decode stack if the abort is called
19 in HandleErrorAddrFrame. That was another reason why fpc_*chech
20 methods calls abort themselves, not relying on HandleErrorAddrFrame.