Structure Exception Handling Sample
Description
This program demonstrates the functionality of Structured Exception Handling (SEH) in eRTOS. The sample generates different types of hardware exception in the _try guarded block based on input exception type as follows:
- Integer Divided by Zero. (Default)
- Break Point.
- Access Violation.
- Illegal Instruction.
- Float Divided by Zero.
- Float Overflow.
- Float Underflow.
- Float Denormalized Operand.
- Float Inexact Result.
- Float Invalid Operation.
- SIMD Divided by Zero.
The responses to the exception can be one of the following:
- Continue Execution disregard the exception
- Handle the Exception
- Continue Searching exception handler
Source Files
| File | Description |
|---|---|
| TryExceptType.c |
|
|
TryExceptTypeA.asm |
|
Building the Sample
To use Structured Exception Handling (SEH), you must link in C-Runtime libraries. Set Linker | Additional Dependences:
- startupCRT.lib
- libcmt.lib
- libucrt.lib
- libvcruntime.lib
- libcpmt.lib
- rtkrnl.lib
Usage
Run Seh.ertos [Filter Option] [Exception Type]
Filter Options
/dismiss
Disregard the exception, i.e., continue execution. Result: infinite looping by 10 times, process is frozen!
Note: Use Kill to terminate the frozen process.
/handle
Handle the exception, i.e., call exception handling body. Result: exit normally! (default)
/continue
Continue searching exception handler. Result: process is frozen!
Note: Use Kill to terminate the frozen process.
Exception Type
- Integer Divided by Zero. (Default)
- Break Point
- Access Violation
- Illegal Instruction
- Float Divided by Zero
- Float Overflow
- Float Underflow
- Float Denormalized Operand
- Float Inexact Result
- Float Invalid Operation
- SIMD Divided by Zero
Examples
Use this command to run the sample so that it generates a SIMD divide by zero exception that is handled:
run Seh.ertos /handle 11
Output
C:\>run d:\seh.ertos /handle 11
Exception Type: EXCEPTION_SIMD_DIVIDE_BY_ZERO
hello
in try
in filter. code: 0xc000008e
caught 'SIMD Divided by Zero'.
in except
world
Seh: PASS.
Use this command to run the sample so that it generates a SIMD divide by zero exception that will continue search of exception handlers:
run Seh.ertos /continue 11
Output
C:\>run d:\seh.ertos /continue 11
Exception Type: EXCEPTION_SIMD_DIVIDE_BY_ZERO
hello
in try
in filter. code: 0xc000008e
caught 'SIMD Divided by Zero'.
[RTSS_3_008E] eRTOS Exception - Float Divided by Zero at loc 0000000438355df8
(Proc=0000000438450750, Thread=00000004384621c0, Pid=03ef, Tid=0016)
Process image has been * frozen *
Debug and/or use "Kill" command to unload all processes
Note: Since the sample will be frozen, you will need to run Kill to terminate it once it is complete.
Use this command to run the sample so that it generates a SIMD divide by zero exception that disregards the exception handler:
run Seh.ertos /dismiss 11
Output
C:\>run d:\seh.ertos /dismiss 11
Exception Type: EXCEPTION_SIMD_DIVIDE_BY_ZERO
hello
in try
in filter. code: 0xc000008e
caught 'SIMD Divided by Zero'.
in filter. code: 0xc000008e
caught 'SIMD Divided by Zero'.
in filter. code: 0xc000008e
caught 'SIMD Divided by Zero'.
in filter. code: 0xc000008e
caught 'SIMD Divided by Zero'.
in filter. code: 0xc000008e
caught 'SIMD Divided by Zero'.
in filter. code: 0xc000008e
caught 'SIMD Divided by Zero'.
in filter. code: 0xc000008e
caught 'SIMD Divided by Zero'.
in filter. code: 0xc000008e
caught 'SIMD Divided by Zero'.
in filter. code: 0xc000008e
caught 'SIMD Divided by Zero'.
in filter. code: 0xc000008e
caught 'SIMD Divided by Zero'.
caught exception 0xc000008e by 10 times. The process is frozen!
[RTSS_3_008E] eRTOS Exception - Float Divided by Zero at loc 0000000438355df8
(Proc=0000000438450750, Thread=00000004384621c0, Pid=03f1, Tid=0017)
Process image has been * frozen *
Debug and/or use "Kill" command to unload all processes
Note: Since the sample will be frozen, you will need to run Kill to terminate it once it is complete.