eRTOS Exception Handling

For most exceptions, the eRTOS handler performs the following tasks:

Freeze or Terminate Processing

eRTOS supports these method for treating faulting processes:

Alert User

The eRTOS handler alerts the user of an exception with a print. For example, if the handler terminates the process, eRTOS might display the following in the console:

[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

Log Extra Exception Analysis Information

eRTOS provides the option of stopping at first exception to avoid extra exceptions during exception handling. To enable this option, modify the StopAtFirstException register value to FFFFFFFF in RtKrnlConfig.ini file.

After stop at first exception, in addition to freeze process and display error message, eRTOS provides the option of writing extra exception analysis information, including thread context and stack frames, into log file (RtLogFile.txt). To enable this option, modify the BehaviourStopAtFirstException register value to 00000001 in RtKrnlConfig.ini file.

The extra exception analysis information contains three sections of data: Technical Information, Current Thread Context, and Current Thread Stack.

Technical Information

The Technical Information section provides:

Current Thread Context

The Current Thread Context section includes information about the context (control, integer, and segment registers) of the current thread.

Current Thread Stack

The Current Thread Stack section includes information about calling stack frames (from thread starting frame up to the frame with exception), the exception address, the process and thread address and ID.

As an example, when double fault occurs in the SampleRtdll.edll, the extra exception analysis information logged at RtLogFile.txt is as follows.

A problem has been detected with an eRTOS application. System will be
shutdown to prevent damage to your computer. RTSS shutdown handlers
will not be invoked.
Technical Information:
Bugcheck Code         : Double Fault (0x00000008)
Current RTSS Process  : "ExplicitLoadRTDLL.rtss" (0x000003eb)
Current RTSS thread   : 21 (0x0000000437791f70)
Exception Address(RIP): 0x0000000011033dbe
Thread Context:
rax: 0x0000000000000010  rbx: 0x000000000000003e  rcx: 0x0000000437791f70
rdx: 0x0000000000000246  rsi: 0x0000000000000940  rdi: 0x0000000000000000
rip: 0x0000000011033dbe  rsp: 0x000000043775fe98  rbp: 0x000000043775ffe8
r8 : 0x00000000002c4020  r9 : 0x0000000000000001  r10: 0x00000004384daf00
r11: 0x000000000018ec00  r12: 0x00000004384e8000  r13: 0x0000000000000000
r14: 0x0000000000000000  r15: 0x0000000000000000  efl: 0x00000206
cs : 0x0010  ss: 0x0018  ds : 0x002b  es: 0x002b  fs : 0x0053  gs: 0x002b
Current Thread Stack:
Child - SP          RetAddr             Frame IP
0x000000043775fe98  0x00000004383181ab  0x0000000011033dbe  (rthal.bin + 0x33dbe)
0x000000043775fea0  0x0000000438318200  0x00000004383181ab  (SampleRtdll.edll + 0x11ab)
0x000000043775ff10  0x000000043846700e  0x0000000438318200  (SampleRtdll.edll + 0x1200)
0x000000043775ff40  0x00000004385118d3  0x000000043846700e  (ExplicitLoadRTDLL.rtss + 0x100e)
0x000000043775ff70  0x000000043850f205  0x00000004385118d3  (RtKrnl.bin + 0x298d3)
[RTSS_2_0008] RTX64 Exception - Double Fault at loc 0000000011033dbe
(Proc=00000004384355b0, Thread=0000000437791f70, Pid=03eb, Tid=0015)
Process image has been * frozen *
Debug and/or use "RTSSkill" command to unload all processes

Related topics: