HP.com home PA-RISC Procedure Calling Conventions Reference Manual > Appendix D The Stack Unwind Process

D.5 Unwinding Across an Interrupt Marker

MPE documents

Complete PDF
Table of Contents

When a trap occurs in the hardware, the operating system is notified. The operating system will place an interrupt marker on the stack. This marker will contain the machine state at the time of the trap. Control comes to the user trap handler via the trap library after this.

Let us look at the situation where one needs to unwind from a trap handler. This situation will arise if a trap occurs within the handler, or if the handler performs a Pascal ESCAPE to a recover block or explicitly asks for a stack trace.

The operating system places the address of a special dummy routine as the return address from the trap handler and passes control over to the user trap handler. While unwinding from the trap handler, the RP value will have one of the following values:
  1. The address of the special dummy routine.

  2. The address of an export stub.

In the first case, the unwind descriptor for this special dummy routine (_sigreturn() in case of HP-UX, and hpe_interrupt_marker_stub(} in MPE) will tell us that the item on the stack is an interrupt stack marker (by means of the interrupt marker bit). In the second case, we have to unwind across the stub. In most situations, this stub will be the stub for the special routine. In such a case, unwinding across the stub will immediately lead us to the address of _sigreturn() itself.

In HP-UX alone there is one situation, however, when unwinding across an export-stub leads to another export stub. Consider the situation where the trap happens and is handled in two different user defined shared libraries. In this case, the OS calls the export stub for the handler and places the address of the export stub of _sigreturn() at SP-20. In this case, while unwinding from the handler, the RP value will take us to the export-stub for the handler. Now, we can take a new RP value from SP-20. However, this points to the export-stub of _sigreturn(). Although this is not a problem, one needs to be aware of this while writing routines that automatically unwind across a series of stubs.

The only way to recognize the interrupt stack marker is by reading the unwind descriptor of the _sigreturn() routine. The format of the interrupt stack marker is defined by the operating system. The format can be found in /usr/include/sys/signal.h in HP-UX. After recovering the machine state from the interrupt stack marker, unwinding should proceed as normal.




D.4 Unwinding From Millicode


D.6 Advanced Example