Skip to content

Adding user exception state managing functions

Frederic Kehrein requested to merge (removed):store_exception_state into main

FPC tracks exception information (such as except handler) through data on stack frames. When performing jumps accross stack frames (e.g. via setjmp/longjmp when implemented manually using assembly instructions), the exception state still references the old, now invalid, stack frame.

This MR tries to solve this by adding two new functions SaveExceptionState and RestoreExceptionState, to give the user manual control over the exception state. By using SaveExceptionState the current state can be stored in an TExceptionState record, which can be used to restore that state later with RestoreExceptionState.

This enables the user to setup jumps between stack frames by loading the correct exception state before performing the jump and thereby not having the exception state reference invalid memory.

Merge request reports