Home |
RTTarget-32 Programming Manual Function RTRaiseCPUException Function RTSetDLLNameTranslation System Management BIOS (SMBIOS) Advanced Programmable Interrupt Controller (APIC) |
Function RTRaiseCPUExceptionThis function can install exception handlers which will raise a Win32 structured exception when the CPU signals an exception: void RTRaiseCPUException(BYTE Vector); Parameter Vector can be any value in the range 0 to 16. Win32 Function RaiseException will be called when the specified exception occurs. RTRaiseException may be called for any number of vectors in the range 0 .. 16. CPU exceptions handled in this manner will not be seen by the Debug Monitor, which will usually trap them and halt the program. To conditionally install exception handlers only when the program is not running under the control of the Debug Monitor, use the following code: if (RTCallDebugger(RT_DBG_MONITOR, 0, 0) >= 0) { // the debug monitor is not running; install handlers RTRaiseCPUException(0); // divide error RTRaiseCPUException(4); // INTO Overflow RTRaiseCPUException(5); // range check RTRaiseCPUException(6); // invalid opcode RTRaiseCPUException(13); // GPF RTRaiseCPUException(14); // page fault RTRaiseCPUException(16); // floating point error } Unit RTTarget used in Pascal programs automatically executes the above code at program startup. The Pascal run-time system will map all structured exceptions generated through this mechanism to run-time error exceptions which can be handled by Pascal's exception handling. Note that RTRaiseCPUException will happily install handlers for any exception in the range 0 .. 16, but normal applications cannot successfully handle all of them. For example, a stack fault (exception 12) can only be handled if the handler is executed on a different stack, which in turn requires handling it at a higher privilege level. However, the handlers of the application must run at the same privilege level as the application. The same is true for a double fault, which could, for example, be triggered by a page fault caused by the stack pointer. Again, the error can only be handled at a higher privilege level. For such exceptions, it is recommended to leave the default handlers of RTTarget-32's boot code in place. These handlers run at CPL 0 and will display a register dump on the screen, allowing further analysis. For additional information about handling structured exceptions, please refer to your compiler's or the Win32 API documentation.
|