SourceForge.net Logo
Home

Software Trace (SWTRACE)


SWTRACE is a software tracing mechanism that runs on Windows and Linux. swtrace is the PI command which provides command-line control of the SWTRACE facility.

Essentially SWTRACE manages trace buffers, one per processor, to which hooks (records) are written. SWTRACE allows for allocating and initializing the trace buffers, selecting which types of hooks are written, enabling and disabling writing of trace hooks to the buffer, writing trace hooks, and retrieving the contents of the trace buffers once tracing is completed.

The basic SWTRACE unit is the hook. Hooks are just records. Only hooks whose major code is enabled are written to the trace buffer. When written to disk, the contents of the trace buffers is written, in binary form, to an NRM2 file. The NRM2 file access API allows for querying trace file information and for reading trace hooks.

Properties of trace hooks:

Reserved Major Codes:

Steps required to use the SWTRACE facility are:




TraceInit




TraceSetMetrics    [Windows]




TraceSetMode    [Linux]




TraceSetName    [Linux]




TraceGetName    [Linux]




TraceSetMteSize    [Linux]




TraceSetSectionSize    [Linux]




TraceEnable




TraceDisable




TraceAllowMultiMetric    [Windows]




TraceDisallowMultiMetric    [Windows]




TraceOn




TraceOff




TraceSuspend




TraceResume




TraceTerminate




TraceDiscard




TraceQueryMajor




TraceWriteBufferToFile




TraceGetMaxNumberOfMetrics




TraceGetIntervalId




IsTraceOn




IsTraceActive




IsContMode    [Linux]




IsWrapMode    [Linux]




SetProfilerRate




TraceSetTprofEvent




TraceHook




WriteAddressHookEx    [Windows]




SWTRACE usage example