VxWorks Reference Manual : Libraries
excLib - generic exception handling facilities
excInit( ) - initialize the exception handling package
excHookAdd( ) - specify a routine to be called with exceptions
excTask( ) - handle task-level exceptions
This library provides generic initialization facilities for handling exceptions. It safely traps and reports exceptions caused by program errors in VxWorks tasks, and it reports occurrences of interrupts that are explicitly connected to other handlers. For information about architecture-dependent exception handling facilities, see the manual entry for excArchLib.
Initialization of excLib facilities occurs in two steps. First, the routine excVecInit( ) is called to set all vectors to the default handlers for an architecture provided by the corresponding architecture exception handling library. Since this does not involve VxWorks' kernel facilities, it is usually done early in the system start-up routine usrInit( ) in the library usrConfig.c with interrupts disabled.
The rest of this package is initialized by calling excInit( ), which spawns the exception support task, excTask( ), and creates the message queues used to communicate with it.
Exceptions or uninitialized interrupts that occur after the vectors have been initialized by excVecInit( ), but before excInit( ) is called, cause a trap to the ROM monitor.
When a program error generates an exception (such as divide by zero, or a bus or address error), the task that was executing when the error occurred is suspended, and a description of the exception is displayed on standard output. The VxWorks kernel and other system tasks continue uninterrupted. The suspended task can be examined with the usual VxWorks routines, including ti( ) for task information and tt( ) for a stack trace. It may be possible to fix the task and resume execution with tr( ). However, tasks aborted in this way are often unsalvageable and can be deleted with td( ).
When an interrupt that is not connected to a handler occurs, the default handler provided by the architecture-specific module displays a description of the interrupt on standard output.
The excHookAdd( ) routine adds a routine that will be called when a hardware exception occurs. This routine is called at the end of normal exception handling.
The excInit( ) routine spawns excTask( ), which performs special exception handling functions that need to be done at task level. Do not suspend, delete, or change the priority of this task.
The facilities of excLib, including excTask( ), are used by dbgLib to support breakpoints, single-stepping, and additional exception handling functions.
A higher-level, UNIX-compatible interface for hardware and software exceptions is provided by sigLib. If sigvec( ) is used to initialize the appropriate hardware exception/interrupt (e.g., BUS ERROR == SIGSEGV), excLib will use the signal mechanism instead.
excLib.h
excLib, dbgLib, sigLib, intLib
excInit( ) - initialize the exception handling package
STATUS excInit ()
This routine installs the exception handling facilities and spawns excTask( ), which performs special exception handling functions that need to be done at task level. It also creates the message queue used to communicate with excTask( ).
The exception handling facilities should be installed as early as possible during system initialization in the root task, usrRoot( ), in usrConfig.c.
OK, or ERROR if a message queue cannot be created or excTask( ) cannot be spawned.
excHookAdd( ) - specify a routine to be called with exceptions
void excHookAdd ( FUNCPTR excepHook /* routine to call when exceptions occur */ )
This routine specifies a routine that will be called when hardware exceptions occur. The specified routine is called after normal exception handling, which includes displaying information about the error. Upon return from the specified routine, the task that incurred the error is suspended.
The exception handling routine should be declared as:
void myHandler ( int task, /* ID of offending task */ int vecNum, /* exception vector number */ ESFxx *pEsf /* pointer to exception stack frame */ )where task is the ID of the task that was running when the exception occurred. ESFxx is architecture-specific and can be found by examining /target/h/arch/arch/esfarch.h; for example, the PowerPC uses ESFPPC.This facility is normally used by dbgLib() to activate its exception handling mechanism. If an application provides its own exception handler, it will supersede the dbgLib mechanism.
N/A
excTask( ) - handle task-level exceptions
void excTask ()
This routine is spawned as a task by excInit( ) to perform functions that cannot be performed at interrupt or trap level. It has a priority of 0. Do not suspend, delete, or change the priority of this task.
N/A