1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <meta http-equiv="Content-Style-Type" content="text/css" /> 6 <link rel="stylesheet" href="../../../css/manpage.css" type="text/css" /> 7<title>SetUserExceptionHandler</title> 8 </head> 9 <body> 10<h1><CODE><a href="../../../nn/Overview.html">nn</a>::<a href="../../../nn/os/Overview.html">os</a>::<a href="../../../nn/os/ARM/Overview.html">ARM</a>::SetUserExceptionHandler</CODE> Function</h1> 11<h2>Syntax</h2> 12 <div class="section"> 13 <pre class="definition"> 14void SetUserExceptionHandler( 15 <a href="../../../nn/os/ARM/UserExceptionHandler.html">UserExceptionHandler</a> pHandler, 16 <a href="../../../nn_types/uptr.html">uptr</a> stackBottom, 17 <a href="../../../nn/os/ARM/ExceptionBuffer/Overview.html">ExceptionBuffer</a> * pExceptionBuffer 18); 19 20template <typename T> 21void SetUserExceptionHandler( 22 <a href="../../../nn/os/ARM/UserExceptionHandler.html">UserExceptionHandler</a> pHandler, 23 T * pStack, 24 <a href="../../../nn/os/ARM/ExceptionBuffer/Overview.html">ExceptionBuffer</a> * pExceptionBuffer 25); 26 27void SetUserExceptionHandler( 28 <a href="../../../nn/os/ARM/UserExceptionHandler.html">UserExceptionHandler</a> pHandler, 29 <a href="../../../nn_types/uptr.html">uptr</a> stackBottom 30); 31 32template <typename T> 33void SetUserExceptionHandler( 34 <a href="../../../nn/os/ARM/UserExceptionHandler.html">UserExceptionHandler</a> pHandler, 35 T * pStack 36); 37</pre> 38 </div> 39<h2>List of Overloaded Member Functions</h2> 40 <div class="section"> 41 <table class="members"> 42 <tr> 43 <td> 44<a href="./SetUserExceptionHandler(0).html">SetUserExceptionHandler ( UserExceptionHandler, uptr, ExceptionBuffer * ) </a> 45 </td> 46<td>Specifies the global exception handler.</td> 47 </tr> 48 <tr> 49 <td> 50<a href="./SetUserExceptionHandler(1).html">SetUserExceptionHandler ( UserExceptionHandler, T *, ExceptionBuffer * ) </a> 51 </td> 52<td>Specifies the global exception handler.</td> 53 </tr> 54 <tr> 55 <td> 56<a href="./SetUserExceptionHandler(2).html"><CODE>SetUserExceptionHandler(UserExceptionHandler, uptr)</CODE> </a> 57 </td> 58<td>Provided for compatibility with past SDKs.</td> 59 </tr> 60 <tr> 61 <td> 62<a href="./SetUserExceptionHandler(3).html"><CODE>SetUserExceptionHandler(UserExceptionHandler, T *)</CODE> </a> 63 </td> 64<td>Provided for compatibility with past SDKs.</td> 65 </tr> </table> 66 </div> 67<h2>Description of SetUserExceptionHandler ( UserExceptionHandler, uptr, ExceptionBuffer * )</h2> 68<div class="section"><h4>Arguments</h4><p> 69If <a href="../../../nn/os/ARM/HANDLER_STACK_USE_THREAD_STACK.html"><CODE>HANDLER_STACK_USE_THREAD_STACK</CODE></a> is specified for <CODE>stackBottom</CODE>, the stack for the thread in which the exception occurred is used as-is as the exception handler stack. 70 </p><p> 71The instances of <a href="../../../nn/os/ARM/ExceptionInfo/Overview.html"><CODE>ExceptionInfo</CODE></a> and <a href="../../../nn/os/ARM/ExceptionContext/Overview.html"><CODE>ExceptionContext</CODE></a>, passed to the handler given by <SPAN class="argument">pHandler</SPAN>, are allocated from the buffer specified by <SPAN class="argument">pExceptionBuffer</SPAN>. If <a href="../../../nn/os/ARM/Overview.html"><CODE>EXCEPTION_BUFFER_USE_HANDLER_STACK</CODE></a> is specified in <CODE>pExceptionBuffer</CODE>, they are allocated from the exception handler stack. If <a href="../../../nn/os/ARM/Overview.html">EXCEPTION_BUFFER_USE_THREAD_STACK</a> is specified in <CODE>pExceptionBuffer</CODE>, they are allocated from the stack for the thread in which the exception occurred. 72</p><h4>Exception Handler Settings</h4><p> 73Exception 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. 74 </p><p> 75The global exception handler refers to the exception handler for the main thread. This function sets the exception handler for the main thread. 76 </p><p> 77When an exception handler is specified and an exception occurs, the function specified by the <SPAN class="argument">pHandler</SPAN> parameter is called in the context of the thread where the exception occurred. However, the stack gets replaced by the stack specified by <SPAN class="argument">stackBottom</SPAN>. 78 </p><p> 79Note 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. 80</p><h4>Exception Handler Implementation</h4><p> 81Exception handlers have the following restrictions. 82</p><ul><li>Control cannot return from an exception handler. A return statement will lead to undefined behavior.</li><li>Exception handlers must be compiled with ARM instructions. You cannot use exception handlers that have THUMB instructions. Exception handlers are allowed to call functions that have THUMB instructions.</li></ul><p> 83Note that the exception handler cannot be called in the debug environment. 84</p><h4>Thread Safety</h4><p> 85This function is not thread-safe at the function level. It also requires mutual exclusion with the <CODE><a href="../../../nn/os/ARM/SetUserExceptionHandlerLocal.html">SetUserExceptionHandlerLocal</a></CODE> function called in the main thread. 86 </p></div> 87<h2>Description of SetUserExceptionHandler ( UserExceptionHandler, T *, ExceptionBuffer * )</h2> 88<div class="section"><p>This is a wrapper function for accepting the stack used by the exception handler via a stack-type member function.</p><p>For details, see <a href="../../../nn/os/ARM/SetUserExceptionHandler.html"><CODE>SetUserExceptionHandler(UserExceptionHandler, uptr, ExceptionBuffer*)</CODE></a>.</p><!-- write here --></div> 89<h2>Description of <CODE>SetUserExceptionHandler(UserExceptionHandler, uptr)</CODE></h2> 90<div class="section"><p>Calls <a href="../../../nn/os/ARM/SetUserExceptionHandler.html"><CODE>SetUserExceptionHandler</CODE></a>(<CODE>pHandler</CODE>, <CODE>stackBottom</CODE>, <a href="../../../nn/os/ARM/Overview.html"><CODE>EXCEPTION_BUFFER_USE_HANDLER_STACK</CODE></a>).</p><p>For details, see <a href="../../../nn/os/ARM/SetUserExceptionHandler.html"><CODE>SetUserExceptionHandler(UserExceptionHandler, uptr, ExceptionBuffer*)</CODE></a>.</p><!-- write here --></div> 91<h2>Description of <CODE>SetUserExceptionHandler(UserExceptionHandler, T *)</CODE></h2> 92<div class="section"><p>Calls <a href="../../../nn/os/ARM/SetUserExceptionHandler.html"><CODE>SetUserExceptionHandler</CODE></a>(<CODE>pHandler</CODE>, <CODE>pStack</CODE>, <a href="../../../nn/os/ARM/Overview.html"><CODE>EXCEPTION_BUFFER_USE_HANDLER_STACK</CODE></a>).</p><p>For details, see <a href="../../../nn/os/ARM/SetUserExceptionHandler.html"><CODE>SetUserExceptionHandler(UserExceptionHandler, uptr, ExceptionBuffer*)</CODE></a>.</p><!-- write here --></div> 93 <hr><p>CONFIDENTIAL</p></body> 94</html>