Note that the virtual frame pointer of an invocation is not the value used by the procedure itself for addressing. The contents of the SP register are modified in the procedure prologue and the resulting real frame pointer value is then sometimes copied into FP (as in the case of a variable size stack frame). The real frame pointer is always used for addressing local storage throughout the remainder of the procedure.
The real frame pointer is not, by itself, sufficient to unambiguously identify all possible procedure invocations. For example, a null frame procedure has the same real frame pointer as its caller because the null frame procedure allocates no stack storage. This ambiguity is of no consequence for the purposes of this calling standard because the real frame pointer value is always used in combination with a program counter value that identifies an instruction within a particular procedure.
The static link used in calling nested procedures in languages such as Pascal and Ada is usually the virtual frame pointer or the real frame pointer value. The choice is implementation-dependent and can vary from language to language and release to release.
The full context of a specific procedure invocation is provided through the use of the sigcontext data structure. The sigcontext structure is defined in the file /usr/include/signal.h.
exc_capture_context (ContextRecord)
ContextRecord | Address of a sigcontext structure into which the procedure context of the caller is written |
exc_virtual_unwind (FunctionEntry, ContextRecord)
FunctionEntry | Address of the function table entry for the function. If zero, the function table entry is looked up using the PC from ContextRecord. |
ContextRecord | Address of a sigcontext structure. The given structure is updated to represent the context of the previous (calling) frame. |
InPrologueOrEpilogue | If 1, indicates that the resulting program counter value in the given ContextRecord is within the prologue or the epilogue code of the function. If zero, indicates that the program counter is in the body of the function. |
There are two steps for performing call chain navigation: