nn/dbg.hclass Instrument
Instrumentation class for tracing function calls.
If a program is compiled using the --gnu_instrument and --no_instrument_inline options of ARMCC, GCC (GNU Compiler Collection) format instrumentation code is inserted to the beginning and end of each function. The respective functions are _cyg_profile_func_enter and _cyg_profile_func_exit. With the Instrument instrumentation class, these functions are used to record when a function is called and also record system tick values.
There 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.
For details, see nn::dbg::CTR::Instrument::Initialize.
Start instrumentation by calling nn::dbg::CTR::Instrument::Enable after initialization. Stop instrumentation by calling nn::dbg::CTR::Instrument::Disable.
Only thread calls on which nn::dbg::CTR::Instrument::Initialize was executed are measured. If nn::dbg::CTR::Instrument::Initialize is executed on more than one thread for different instrumentation buffers, measurements will be made for each.
The instrumentation class only records calls to each function. The nn::dbg::CTR::Statistics class has been prepared for statistical analysis of this information.
// Instrumentation buffer and instrumentation class instances
#define INST_BUF_SIZE 0x1000
u8 instBuffer[ INST_BUF_SIZE ];
nn::dbg::CTR::Instrument inst;
// Statistics buffer and statistics class instances
#define STAT_BUF_SIZE 0x1000
u8 statBuffer[ STAT_BUF_SIZE ];
nn::dbg::CTR::Statistics stat;
nnMain()
{
// Initialization.
inst.Initialize( instBuffer,
INST_BUF_SIZE,
nn::dbg::CTR::TRACE_LOG );
stat.Initialize( statBuffer,
STAT_BUF_SIZE );
// Start instrumentation
inst.Enable();
...
...
...
// Stop instrumentation
inst.Disable();
// Statistical buffer content display
inst.Dump();
// Statistics
stat.Collect( &inst );
// Statistical results display
stat.Dump();
// End instrumentation
inst.Finalize();
}
Initialize
|
Declares the buffer region passed to the instrumentation class and performs initialization. | |
|---|---|---|
Finalize
|
Indicates the end of the instrumentation class. | |
Dump
|
Dumps buffer contents. | |
Clear
|
Destroys buffer contents. | |
Enable
|
Starts statistics. | |
Disable
|
Stops statistics. | |
GetRecordSize
|
Gets the per record size. | |
| S |
SetLogFunction
|
Specifies the output function used to display buffer contents. |
CONFIDENTIAL