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 <style type="text/css"><!-- 8 span.static_style 9 { 10 font-size : 8pt; 11 color : white; 12 font-weight : bold; 13 background : #44f; 14 border-left : solid 1px #aaf; 15 border-top : solid 1px #aaf; 16 border-right : solid 1px #00c; 17 border-bottom : solid 1px #00c; 18 padding-left : 2px; 19 padding-right : 2px; 20 } 21 span.virtual_style 22 { 23 font-size : 8pt; 24 color : white; 25 font-weight : bold; 26 background : #0a0; 27 border-left : solid 1px #0f0; 28 border-top : solid 1px #0f0; 29 border-right : solid 1px #060; 30 border-bottom : solid 1px #060; 31 padding-left : 2px; 32 padding-right : 2px; 33 } 34 span.protected_style 35 { 36 font-size : 8pt; 37 color : white; 38 font-weight : bold; 39 background : #444; 40 border-left : solid 1px #ccc; 41 border-top : solid 1px #ccc; 42 border-right : solid 1px #222; 43 border-bottom : solid 1px #222; 44 padding-left : 2px; 45 padding-right : 2px; 46 } 47 --></style> 48<title>nn::dbg::CTR::Instrument</title> 49 </head> 50 <body> 51<h1><a href="../../../../nn/Overview.html">nn</a>::<a href="../../../../nn/dbg/Overview.html">dbg</a>::<a href="../../../../nn/dbg/CTR/Overview.html">CTR</a>::Instrument Class</h1> 52 <div class="section"> 53<b>Header file: </b><CODE>nn/dbg.h</CODE></div> 54<h2>Syntax</h2> 55 <div class="section"> 56 <pre class="definition">class Instrument</pre> 57 </div> 58<h2>Description</h2> 59 <div class="section"> 60<p>Instrumentation class for tracing function calls.</p><H3>Instrumentation Mechanism</H3><P> 61If a program is compiled using the <CODE>--gnu_instrument</CODE> and <CODE>--no_instrument_inline</CODE> options of ARMCC, GCC (GNU Compiler Collection) format instrumentation code is inserted to the beginning and end of each function. The respective functions are <CODE>_cyg_profile_func_enter</CODE> and <CODE>_cyg_profile_func_exit</CODE>. With the <CODE>Instrument</CODE> instrumentation class, these functions are used to record when a function is called and also record system tick values. 62</P><H3>Instrumentation Types</H3><P> 63There are two recording modes: log mode and stack mode. You can also do things like record system ticks and use the instrumentation buffer as a ring buffer. 64</P><P> 65For details, see <a href="../../../../nn/dbg/CTR/Instrument/Initialize.html"><CODE>nn::dbg::CTR::Instrument::Initialize</CODE></a>. 66</P><H3>Starting and Stopping Instrumentation</H3><P> 67Start instrumentation by calling <a href="../../../../nn/dbg/CTR/Instrument/Enable.html"><CODE>nn::dbg::CTR::Instrument::Enable</CODE></a> after initialization. Stop instrumentation by calling <a href="../../../../nn/dbg/CTR/Instrument/Disable.html"><CODE>nn::dbg::CTR::Instrument::Disable</CODE></a>. 68</P><P> 69Only thread calls on which <a href="../../../../nn/dbg/CTR/Instrument/Initialize.html"><CODE>nn::dbg::CTR::Instrument::Initialize</CODE></a> was executed are measured. If <a href="../../../../nn/dbg/CTR/Instrument/Initialize.html"><CODE>nn::dbg::CTR::Instrument::Initialize</CODE></a> is executed on more than one thread for different instrumentation buffers, measurements will be made for each. 70</P><H3>Instrumentation Result Statistics</H3><P> 71The instrumentation class only records calls to each function. The <CODE>nn::dbg::CTR::Statistics</CODE> class has been prepared for statistical analysis of this information. 72</P><H3>Example</H3><PRE> 73// Instrumentation buffer and instrumentation class instances 74#define INST_BUF_SIZE 0x1000 75u8 instBuffer[ INST_BUF_SIZE ]; 76nn::dbg::CTR::Instrument inst; 77 78// Statistics buffer and statistics class instances 79#define STAT_BUF_SIZE 0x1000 80u8 statBuffer[ STAT_BUF_SIZE ]; 81nn::dbg::CTR::Statistics stat; 82 83nnMain() 84{ 85 // Initialization. 86 inst.Initialize( instBuffer, 87 INST_BUF_SIZE, 88 nn::dbg::CTR::TRACE_LOG ); 89 stat.Initialize( statBuffer, 90 STAT_BUF_SIZE ); 91 92 // Start instrumentation 93 inst.Enable(); 94 ... 95 ... 96 ... 97 98 // Stop instrumentation 99 inst.Disable(); 100 101 // Statistical buffer content display 102 inst.Dump(); 103 104 // Statistics 105 stat.Collect( &inst ); 106 107 // Statistical results display 108 stat.Dump(); 109 110 // End instrumentation 111 inst.Finalize(); 112} 113 114</PRE></div> 115 <a name="function" id="function"> 116<h2>Member Functions</h2> 117 <div class="section"> 118 <table class="members"> 119 <tr> 120 <td width="100"> </td> 121 <th> 122<a href="../../../../nn/dbg/CTR/Instrument/Initialize.html"><CODE>Initialize</CODE></a> 123 </th> 124<td>Declares the buffer region passed to the instrumentation class and performs initialization.</td> 125 </tr> 126 <tr> 127 <td width="100"> </td> 128 <th> 129<a href="../../../../nn/dbg/CTR/Instrument/Finalize.html"><CODE>Finalize</CODE></a> 130 </th> 131<td>Indicates the end of the instrumentation class.</td> 132 </tr> 133 <tr> 134 <td width="100"> </td> 135 <th> 136<a href="../../../../nn/dbg/CTR/Instrument/Dump.html"><CODE>Dump</CODE></a> 137 </th> 138<td>Dumps buffer contents.</td> 139 </tr> 140 <tr> 141 <td width="100"> </td> 142 <th> 143<a href="../../../../nn/dbg/CTR/Instrument/Clear.html"><CODE>Clear</CODE></a> 144 </th> 145<td>Destroys buffer contents.</td> 146 </tr> 147 <tr> 148 <td width="100"> </td> 149 <th> 150<a href="../../../../nn/dbg/CTR/Instrument/Enable.html"><CODE>Enable</CODE></a> 151 </th> 152<td>Starts statistics.</td> 153 </tr> 154 <tr> 155 <td width="100"> </td> 156 <th> 157<a href="../../../../nn/dbg/CTR/Instrument/Disable.html"><CODE>Disable</CODE></a> 158 </th> 159<td>Stops statistics.</td> 160 </tr> 161 <tr> 162 <td width="100"> </td> 163 <th> 164<a href="../../../../nn/dbg/CTR/Instrument/GetRecordSize.html"><CODE>GetRecordSize</CODE></a> 165 </th> 166<td>Gets the per record size.</td> 167 </tr> 168 <tr> 169 <td width="100"> 170<span class="static_style" title="static">S</span> </td> 171 <th> 172<a href="../../../../nn/dbg/CTR/Instrument/SetLogFunction.html"><CODE>SetLogFunction</CODE></a> 173 </th> 174<td>Specifies the output function used to display buffer contents.</td> 175 </tr> </table> 176 </div> 177 </a> 178<h2>Revision History</h2> 179 <div class="section"> 180 <dl class="history"> 181 <dt>2011/07/15</dt> 182<dd>Added an example.<br /> 183 </dd> 184 <dt>2011/07/12</dt> 185<dd>Initial version.<br /> 186 </dd> 187 </dl> 188 </div> 189 <hr><p>CONFIDENTIAL</p></body> 190</html> 191