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:

The responses to the exception can be one of the following:

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:

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

  1. Integer Divided by Zero. (Default)
  2. Break Point
  3. Access Violation
  4. Illegal Instruction
  5. Float Divided by Zero
  6. Float Overflow
  7. Float Underflow
  8. Float Denormalized Operand
  9. Float Inexact Result
  10. Float Invalid Operation
  11. 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.