VxWorks Reference Manual : Libraries

excLib

NAME

excLib - generic exception handling facilities

ROUTINES

excInit( ) - initialize the exception handling package
excHookAdd( ) - specify a routine to be called with exceptions
excTask( ) - handle task-level exceptions

DESCRIPTION

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

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.

NORMAL EXCEPTION HANDLING

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.

ADDITIONAL EXCEPTION HANDLING ROUTINE

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.

TASK-LEVEL SUPPORT

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.

DBGLIB

The facilities of excLib, including excTask( ), are used by dbgLib to support breakpoints, single-stepping, and additional exception handling functions.

SIGLIB

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.

INCLUDE FILES

excLib.h

SEE ALSO

excLib, dbgLib, sigLib, intLib


Libraries : Routines

excInit( )

NAME

excInit( ) - initialize the exception handling package

SYNOPSIS


STATUS excInit ()

DESCRIPTION

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( ).

NOTE

The exception handling facilities should be installed as early as possible during system initialization in the root task, usrRoot( ), in usrConfig.c.

RETURNS

OK, or ERROR if a message queue cannot be created or excTask( ) cannot be spawned.

SEE ALSO

excLib, excTask( )


Libraries : Routines

excHookAdd( )

NAME

excHookAdd( ) - specify a routine to be called with exceptions

SYNOPSIS

void excHookAdd
    (
    FUNCPTR excepHook /* routine to call when exceptions occur */
    )

DESCRIPTION

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.

RETURNS

N/A

SEE ALSO

excLib, excTask( )


Libraries : Routines

excTask( )

NAME

excTask( ) - handle task-level exceptions

SYNOPSIS


void excTask ()

DESCRIPTION

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.

RETURNS

N/A

SEE ALSO

excLib, excInit( )