The fine detail of exception management by OS/2 is complex. However the principles are easy to grasp. This section gives an overview of OS/2 Exception Management sufficient to provide the reader with a technique for intercepting exceptions in user code under the Kernel Debugger.
Exception Definition
Exceptions may be summarised as follows:
Hardware Traps and Faults - INTEL defined.
Software generated exceptions - OS/2 and User defined.
Page fault exceptions.
Trap 1 and 3 for system trace
387 Co-processor emulation
VDM privileged instruction emulation
Exception Logic
The essential logic for exception handling is as follows:
If recovery is not directly possible or further special processing is required then control passes to one of the following second level exception handlers:
V8086 Emulation for instruction emulation.
VDM Exception Handler to reflect non-fatal exceptions back to the VDM using its IDT.
Process Fatal Fault Handler (_TRAPProcessFatalFault) for non-kernel mode code (InDos=0).
Kernel Fault Handler for kernel code (InDos=1)
Special handlers for Co-processor handling, NMIs etc..
The parameters to XCPTBuildR3DispatcherStack are:
Trap number or 0x0000ffff for S/W generated exceptions Exception
number
Count of exception info parameters
Pointer to the array of exception info parameters
Boolean, if true then exception is non-contnueable.
Pointer to any additional nested report record
Trap number
Pointer to the exception report
record
Pointer to the exception context
record
The values for the various return codes are as follows:
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³Name ³Bit Mask ³Description ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³XCPT_CONTINUE_SEARCH ³0x00000000³Exception not handled³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³XCPT_CONTINUE_EXECUTION³0xFFFFFFFF³Exception handled ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³XCPT_CONTINUE_STOP ³0x00716668³Exception handled by ³ ³ ³ ³debugger (via ³ ³ ³ ³DosDebug) ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
The following additional return codes are used by internal excfeption handlers to manage nested exceptions.
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³Name ³Bit Mask ³Description ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³NESTED ³0xf0f0f0f0³An exception occurred while an exception³ ³ ³ ³was active ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³COLLIDED_UNWIND³0x0f0f0f0f³Indicates collided unwinds ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³EXIT_UNWIND ³0x65796C4B³Indicates the end of an exit unwind ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
Trap number
Pointer to the exception report
record
Pointer to the exception context
record
Exception disposition
For fatal exceptions _xctDefaultAction. calls DelayHardError to format the trap screen information from the context record and wake the Hard Error process. It also writes the POPUPLOG.OS2 entry and calls the Kernel Debugger if the VSU command has been specified.
These details are summarised in the following diagrams: