Task Trace uses the external tool `"Trace Compass" <https://www.eclipse.org/tracecompass/>`_ to display the trace result.
Download it from https://www.eclipse.org/tracecompass/ and install into the host environment.
After the installation, execute it and choose ``Tools`` -> ``add-ons`` menu, then select ``Install Extensions`` to install the extension named "Trace Compass ftrace (Incubation)".
NuttX kernel configuration
--------------------------
To enable the task trace function, the NuttX kernel configuration needs to be modified.
The following configurations must be enabled.
-``CONFIG_SCHED_INSTRUMENTATION`` : Enables the feature of scheduler notes.
-``CONFIG_SCHED_INSTRUMENTATION_FILTER`` : Enables the filter logic of the notes.
-``CONFIG_SCHED_INSTRUMENTATION_SYSCALL`` : Enable system call instrumentation.
By using the logging function of your terminal software, the trace result can be saved into the host environment and it can be used as the input for `"Trace Compass" <https://www.eclipse.org/tracecompass/>`_.
If the target has a storage, the trace result can be stored into the file by using the following command.
It also can be used as the input for "Trace Compass" by transferring the file in the target device to the host.
..code-block::
nsh> trace dump <file name>
To display the trace result by `"Trace Compass" <https://www.eclipse.org/tracecompass/>`_, choose ``File`` -> ``Open Trace`` menu to specify the trace data file name.
..image:: image/trace-compass-screenshot.png
Trace command description
=========================
.._trace_start:
trace start
-----------
Start task tracing
**Command Syntax:**
..code-block::
trace start [-c][<duration>]
-``-c`` : Continue the previous trace.
The trace data is not cleared before starting new trace.
-``<duration>`` : Specify the duration of the trace by seconds.
Task tracing is stopped after the specified period.
If not specified, the tracing continues until stopped by the command.
.._trace_stop:
trace stop
----------
Stop task tracing
**Command Syntax:**
..code-block::
trace stop
.._trace_cmd:
trace cmd
---------
Get the trace while running the specified command.
After the termination of the command, task tracing is stopped.
To use this command, ``CONFIG_SYSTEM_SYSTEM`` needs to be enabled.
**Command Syntax:**
..code-block::
trace cmd [-c] <command> [<args>...]
-``-c`` : Continue the previous trace.
The trace data is not cleared before starting new trace.
-``<command>`` : Specify the command to get the task trace.
-``<args>`` : Arguments for the command.
**Example:**
..code-block::
nsh> trace cmd sleep 1
.._trace_dump:
trace dump
----------
Output the trace result.
If the task trace is running, it is stopped before the output.
**Command Syntax:**
..code-block::
trace dump [-c][<filename>]
-``-c`` : Not stop tracing before the output.
Because dumping trace itself is a task activity and new trace data is added while output, the dump will never stop.
-``<filename>`` : Specify the filename to save the trace result.
If not specified, the trace result is displayed to console.
.._trace_mode:
trace mode
----------
Set the task trace mode options.
The default value is given by the kernel configuration ``CONFIG_SCHED_INSTRUMENTATION_FILTER_DEFAULT_MODE``.