HPlogo Communicator e3000 MPE/iX Release 7.5 (Software Release C75.00): HP e3000 MPE/iX Computer Systems

Chapter 7 Catalog of User Documentation

MPE documents

Complete PDF
Table of Contents

Table of Contents
7.1 Requirements for Successful Stack Unwinding
7.2 Unwinding From Millicode
7.3 Instances in Which Unwinding May Fail
7.4 Callee-Saves Register Spill
7.5 The HP Pascal ESCAPE Mechanism
7.6 A Simple Example
7.7 An Advanced Example: Multiple Unwind Regions
This chapter is primarily intended for assembly language programmers. Some additional detail is provided for application developers who may have a need to use the stack unwind library routines.

Stack unwinding refers to the processes of procedure trace-back and context restoration, both of which have several possible system and user-level applications. A software stack unwinding convention is necessary on PA-RISC because in the event of an interruption of execution, there is insufficient information directly available to perform a comprehensive stack trace. The stack trace is the basic operation performed in context restoration.

Some important tools are heavily dependent on the presence of the stack unwinding facility. For example, system dump analysis tools examine all system processes that were running at the time of a system crash, an operation which involves multiple stack traces. Symbolic debuggers require the ability to display the state of the call stack at any point during a program's execution. Many language-specific features such as the ESCAPE mechanism in HP Pascal also require stack unwinding capabilities.

The information necessary to perform a stack trace, such as the size of each frame, is not available on the stack. One approach to supporting stack unwind would have been to generate information at run time and store it in the frame marker. This would have required extra instructions to be executed for most procedure calls. The designers of the PA-RISC calling convention chose not to use this approach under the assumption that stack unwinding is infrequently necessary.

Alternatively, stack unwind information is generated once at compile time and stored in a static data structure called the unwind table. An unwind table is automatically built into each program file by the linker.

Each entry in the unwind table contains two addresses which describe a region of code, typically the starting and ending address of a procedure. Each entry also contains an unwind descriptor which holds information about the frame and register usage of that region. When an unwind operation is required, the unwind table is searched to find the region containing the instruction where the exception or interrupt occurred.

The implementation details of stack unwinding are unimportant for most high-level programs and programmers. Assembly programmers, however, need to follow the documented guidelines outlined in this chapter to ensure that programs can be successfully unwound.

Further details are available in Appendix C and D. Appendix C explains the functionality of the PA-RISC unwind library routines. These can be used by programmers who want or need to access stack unwind functionality from their applications. Appendix D provides a more detailed description of what is involved in implementing customized stack unwind routines.




6.6 Nested Millicode Calls


7.1 Requirements for Successful Stack Unwinding