<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.14"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>Crypto++: DebugTrapHandler Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">Crypto++  <span id="projectnumber">7.0</span> </div> <div id="projectbrief">Free C++ class library of cryptographic schemes</div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.14 --> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(function() { initMenu('',false,false,'search.php','Search'); }); /* @license-end */</script> <div id="main-nav"></div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="class_debug_trap_handler-members.html">List of all members</a> </div> <div class="headertitle"> <div class="title">DebugTrapHandler Class Reference</div> </div> </div><!--header--> <div class="contents"> <p>Default SIGTRAP handler. <a href="class_debug_trap_handler.html#details">More...</a></p> <div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;"> <img id="dynsection-0-trigger" src="closed.png" alt="+"/> Inheritance diagram for DebugTrapHandler:</div> <div id="dynsection-0-summary" class="dynsummary" style="display:block;"> </div> <div id="dynsection-0-content" class="dyncontent" style="display:none;"> <div class="center"> <img src="class_debug_trap_handler.png" usemap="#DebugTrapHandler_map" alt=""/> <map id="DebugTrapHandler_map" name="DebugTrapHandler_map"> <area href="struct_signal_handler.html" alt="SignalHandler< SIGILL, false >" shape="rect" coords="0,0,189,24"/> </map> </div></div> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="inherited"></a> Additional Inherited Members</h2></td></tr> <tr class="inherit_header pub_methods_struct_signal_handler"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_struct_signal_handler')"><img src="closed.png" alt="-"/> Public Member Functions inherited from <a class="el" href="struct_signal_handler.html">SignalHandler< SIGILL, false ></a></td></tr> <tr class="memitem:acd307684154846febeedf1b605f69486 inherit pub_methods_struct_signal_handler"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="struct_signal_handler.html#acd307684154846febeedf1b605f69486">SignalHandler</a> (<a class="el" href="ossig_8h.html#a487b4e7d6c7251a7b9a5fa0fbeebbf86">SignalHandlerFn</a> pfn=NULL, int flags=0)</td></tr> <tr class="memdesc:acd307684154846febeedf1b605f69486 inherit pub_methods_struct_signal_handler"><td class="mdescLeft"> </td><td class="mdescRight">Construct a signal handler. <a href="struct_signal_handler.html#acd307684154846febeedf1b605f69486">More...</a><br /></td></tr> <tr class="separator:acd307684154846febeedf1b605f69486 inherit pub_methods_struct_signal_handler"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><p>Default SIGTRAP handler. </p> <p><a class="el" href="class_debug_trap_handler.html" title="Default SIGTRAP handler. ">DebugTrapHandler()</a> can be used by a program to install an empty SIGTRAP handler. If present, the handler ensures there is a signal handler in place for <code>SIGTRAP</code> raised by <code>CRYPTOPP_ASSERT</code>. If <code>CRYPTOPP_ASSERT</code> raises <code>SIGTRAP</code> <em>without</em> a handler, then one of two things can occur. First, the OS might allow the program to continue. Second, the OS might terminate the program. OS X allows the program to continue, while some Linuxes terminate the program.</p> <p>If <a class="el" href="class_debug_trap_handler.html" title="Default SIGTRAP handler. ">DebugTrapHandler</a> detects another handler in place, then it will not install a handler. This ensures a debugger can gain control of the <code>SIGTRAP</code> signal without contention. It also allows multiple <a class="el" href="class_debug_trap_handler.html" title="Default SIGTRAP handler. ">DebugTrapHandler</a> to be created without contentious or unusual behavior. Though multiple <a class="el" href="class_debug_trap_handler.html" title="Default SIGTRAP handler. ">DebugTrapHandler</a> can be created, a program should only create one, if needed.</p> <p>A <a class="el" href="class_debug_trap_handler.html" title="Default SIGTRAP handler. ">DebugTrapHandler</a> is subject to C++ static initialization [dis]order. If you need to install a handler and it must be installed early, then reference the code associated with <code>CRYPTOPP_INIT_PRIORITY</code> in <a class="el" href="cryptlib_8cpp_source.html">cryptlib.cpp</a> and <a class="el" href="cpu_8cpp_source.html">cpu.cpp</a>.</p> <p>If you want to ensure <code>CRYPTOPP_ASSERT</code> is inert, then <em>do not</em> define <code>CRYPTOPP_DEBUG</code>, <code>DEBUG</code> or <code>_DEBUG</code>. Avoiding the defines means <code>CRYPTOPP_ASSERT</code> is processed into <code>((void)(exp))</code>.</p> <p>The traditional Posix define <code>NDEBUG</code> has no effect on <code>CRYPTOPP_DEBUG</code>, <code>CRYPTOPP_ASSERT</code> or <a class="el" href="class_debug_trap_handler.html" title="Default SIGTRAP handler. ">DebugTrapHandler</a>.</p> <p>An example of using <a class="el" href="trap_8h.html#adf3b392588bc94cbeae9f415a78c7b95">CRYPTOPP_ASSERT</a> and <a class="el" href="class_debug_trap_handler.html" title="Default SIGTRAP handler. ">DebugTrapHandler</a> is shown below. The library's test program, <code>cryptest.exe</code> (from test.cpp), exercises the structure: </p><pre> #if defined(CRYPTOPP_DEBUG) && defined(UNIX_SIGNALS_AVAILABLE) static const <a class="el" href="class_debug_trap_handler.html" title="Default SIGTRAP handler. ">DebugTrapHandler</a> g_dummyHandler; #endif</pre><pre> int main(int argc, char* argv[]) { CRYPTOPP_ASSERT(argv != nullptr); ... } </pre> <dl class="section since"><dt>Since</dt><dd>Crypto++ 5.6.5 </dd></dl> <dl class="section see"><dt>See also</dt><dd><a class="el" href="trap_8h.html#adf3b392588bc94cbeae9f415a78c7b95">CRYPTOPP_ASSERT</a>, <a class="el" href="struct_signal_handler.html" title="Signal handler for Linux and Unix compatibles. ">SignalHandler</a>, <a href="http://github.com/weidai11/cryptopp/issues/277">Issue 277</a>, <a href="http://seclists.org/oss-sec/2016/q3/520">CVE-2016-7420</a> </dd></dl> <p class="definition">Definition at line <a class="el" href="trap_8h_source.html#l00135">135</a> of file <a class="el" href="trap_8h_source.html">trap.h</a>.</p> </div><hr/>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="trap_8h_source.html">trap.h</a></li> </ul> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Sun Sep 16 2018 07:58:23 for Crypto++ by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.14 </small></address> </body> </html>