nn::os::ARM::SetUserExceptionHandler Function

Syntax

void SetUserExceptionHandler(
     UserExceptionHandler pHandler,
     uptr stackBottom,
     ExceptionBuffer * pExceptionBuffer
);

Parameters

Name Description
in pHandler Specifies the exception handler called when an exception occurs.
in stackBottom Specifies the stack to use for the exception handler. You must specify the bottom of the stack.
in pExceptionBuffer Specifies a buffer for storing exception information.

Return Values

None.

Description

Specifies the global exception handler.

Arguments

If HANDLER_STACK_USE_THREAD_STACK is specified for stackBottom, the stack for the thread in which the exception occurred is used as-is as the exception handler stack.

The instances of ExceptionInfo and ExceptionContext, passed to the handler given by pHandler, are allocated from the buffer specified by pExceptionBuffer. If EXCEPTION_BUFFER_USE_HANDLER_STACK is specified in pExceptionBuffer, they are allocated from the exception handler stack. If EXCEPTION_BUFFER_USE_THREAD_STACK is specified in pExceptionBuffer, they are allocated from the stack for the thread in which the exception occurred.

Exception Handler Settings

Exception handler settings exist for each thread. If an exception occurs, an exception handler is called based on the settings for the thread in question. If an exception handler has not been set for the particular thread in question, an exception handler based on settings for the main thread is called.

The global exception handler refers to the exception handler for the main thread. This function sets the exception handler for the main thread.

When an exception handler is specified and an exception occurs, the function specified by the pHandler parameter is called in the context of the thread where the exception occurred. However, the stack gets replaced by the stack specified by stackBottom.

Note that special processing, such as disabling interrupts, is not used when calling the exception handler. If the same memory is set for more than one thread as a buffer for storing the exception handler stack and exception information, and if an exception occurs in one thread that shares this memory while the exception handler is executing for another of these threads, the exception handler stack and buffer for exception information will be destroyed.

Exception Handler Implementation

Exception handlers have the following restrictions.

Note that the exception handler cannot be called in the debug environment.

Thread Safety

This function is not thread-safe at the function level. It also requires mutual exclusion with the SetUserExceptionHandlerLocal function called in the main thread.

Revision History

2012/04/23
Added a description about thread safety.
2011/10/12
Added restrictions about exception handlers.
2011/05/02
Modified wording to read "to the stack specified by stackBottom" rather than just "to stackBottom."
2010/09/16
Added mention that the exception handler is not called in the debug environment.
2010/08/16
Initial version.

CONFIDENTIAL