Unwind depends crucially on the ability to determine, for any given instruction,
the state of the stack and whether that instruction is part of a procedure
entry or exit sequence. In particular, instructions that modify SP or RP must
be made known to the unwind routines. Furthermore, it is necessary that all the
callee-saves registers be saved at the dedicated locations on the stack (which
are documented later in this chapter).
To guarantee that a routine is unwindable, the assembly programmer should
strictly adhere to the stack and register usage conventions described in this
manual. It is mandatory that the procedure entry and exit sequences conform to
the standard specifications. All procedures generated by HP's compilers will
automatically meet all these requirements and hence will be unwindable.
The assembler provides several directives that help in making routines
completely unwindable. The .ENTER and .LEAVE directives will
automatically generate the standard entry and exit sequences. The code
sequences generated by these directives are determined by the options specified
in the .CALLINFO directive. In rare cases, it may be necessary to
generate non-standard stack frames or to create multiple unwind regions for the
same routine. These cases can be handled with proper use of the
.CALLINFO, .ENTRY, .EXIT, .PROC and .PROCEND directives as
documented in the PA-RISC Assembly Language Reference Manual. (An example is
given in section 7.6.)
To successfully perform a stack trace from any given instruction in a program,
the following requirements must be met:
The specified instruction must lie within a standard code sequence,
as specified above.
Caller-save registers must be saved and restored across a call
(if their contents are live across a call).
Unwind table entries must be generated for each routine, and for
any discontinuous regions of code.
The frame size for each routine must be the same as is stated in
the unwind descriptor for that routine.
The use of RP (or MRP) in each routine must conform to the
specifications stated in the unwind descriptor for that
routine.
The minimum requirements for a successful context restoration are:
All requirements for a stack trace (as above) must be met.
The use of the callee-saves registers in each routine must conform to the specifications given
in the unwind descriptor for that routine.
The assembler generates fixup requests for the linker based on the information
made available to it by the programmer in the various procedure entry, exit,
and call directives. The linker builds the unwind descriptors based on these
fixup requests. The unwind descriptors describe the stack and register usage
information for a particular address range and the length of the entry and exit
sequences. The unwind descriptors are four word entities with the following
format:
The linker sorts all the unwind descriptors according to the address range they
refer to and places them in a separate subspace. Most stack unwind functions
depend on the unwind entries being sorted properly.