1# Trace 2 3## Basic Concepts 4 5Trace helps you learn about the kernel running process and the execution sequence of modules and tasks. With the information, you can better understand the code running process of the kernel and locate time sequence problems. 6 7## Working Principles 8 9The kernel provides a hook framework to embed hooks in the main process of each module. In the initial startup phase of the kernel, the trace function is initialized and the trace handlers are registered with the hooks. 10 11When a hook is triggered, the trace module encapsulates the input information and adds the trace frame header information, including the event type, ID of the running CPU, ID of the running task, and relative timestamp. 12 13The trace module provides two working modes: offline mode and online mode. 14 15In offline mode, trace frames are stored in a circular buffer. If too many frames are stored in the circular buffer, earlier frames will be overwritten to ensure that the information in the buffer is always the latest. Data in the circular buffer can be exported by running the shell command for further analysis. The exported information is sorted by timestamp. 16 17 18 19The online mode must be used with the integrated development environment \(IDE\). Trace frames are sent to the IDE in real time. The IDE parses the records and displays them in a visualized manner. 20 21## Available APIs 22 23The trace module of the OpenHarmony LiteOS-M kernel provides the following functions. For more details about the APIs, see the API reference. 24 25**Table 1** Trace module APIs 26 27<a name="table208266479117"></a> 28<table><thead align="left"><tr id="row19826947121114"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p16415637105612"><a name="p16415637105612"></a><a name="p16415637105612"></a>Function</p> 29</th> 30<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p11415163718562"><a name="p11415163718562"></a><a name="p11415163718562"></a>API</p> 31</th> 32<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p1641533755612"><a name="p1641533755612"></a><a name="p1641533755612"></a>Description</p> 33</th> 34</tr> 35</thead> 36<tbody><tr id="row7235182719585"><td class="cellrowborder" rowspan="2" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p92241727105816"><a name="p92241727105816"></a><a name="p92241727105816"></a>Starting and stopping trace</p> 37</td> 38<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p222418279581"><a name="p222418279581"></a><a name="p222418279581"></a>LOS_TraceStart</p> 39</td> 40<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p18224112711581"><a name="p18224112711581"></a><a name="p18224112711581"></a>Starts trace.</p> 41</td> 42</tr> 43<tr id="row142340271586"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2224152795812"><a name="p2224152795812"></a><a name="p2224152795812"></a>LOS_TraceStop</p> 44</td> 45<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p722492710584"><a name="p722492710584"></a><a name="p722492710584"></a>Stops trace.</p> 46</td> 47</tr> 48<tr id="row12341278583"><td class="cellrowborder" rowspan="3" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p14224627175816"><a name="p14224627175816"></a><a name="p14224627175816"></a>Managing trace records</p> 49</td> 50<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p0224827145816"><a name="p0224827145816"></a><a name="p0224827145816"></a>LOS_TraceRecordDump</p> 51</td> 52<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p16224427125810"><a name="p16224427125810"></a><a name="p16224427125810"></a>Exports data in the trace buffer.</p> 53</td> 54</tr> 55<tr id="row14234527185811"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p152241327165810"><a name="p152241327165810"></a><a name="p152241327165810"></a>LOS_TraceRecordGet</p> 56</td> 57<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1422412274584"><a name="p1422412274584"></a><a name="p1422412274584"></a>Obtains the start address of the trace buffer.</p> 58</td> 59</tr> 60<tr id="row16234112725816"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p122244272582"><a name="p122244272582"></a><a name="p122244272582"></a>LOS_TraceReset</p> 61</td> 62<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1222413276581"><a name="p1222413276581"></a><a name="p1222413276581"></a>Clears events in the trace buffer.</p> 63</td> 64</tr> 65<tr id="row14234727155817"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p19224227205814"><a name="p19224227205814"></a><a name="p19224227205814"></a>Filtering trace records</p> 66</td> 67<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1922410277585"><a name="p1922410277585"></a><a name="p1922410277585"></a>LOS_TraceEventMaskSet</p> 68</td> 69<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p122242272585"><a name="p122242272585"></a><a name="p122242272585"></a>Sets the event mask to trace only events of the specified modules.</p> 70</td> 71</tr> 72<tr id="row5234627145818"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p152244272589"><a name="p152244272589"></a><a name="p152244272589"></a>Masking events of specified interrupt IDs</p> 73</td> 74<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p182244276586"><a name="p182244276586"></a><a name="p182244276586"></a>LOS_TraceHwiFilterHookReg</p> 75</td> 76<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p12224627135819"><a name="p12224627135819"></a><a name="p12224627135819"></a>Registers a hook to filter out events of specified interrupt IDs.</p> 77</td> 78</tr> 79<tr id="row22341027115815"><td class="cellrowborder" rowspan="2" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p1222462716588"><a name="p1222462716588"></a><a name="p1222462716588"></a>Performing function instrumentation</p> 80</td> 81<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p42242271585"><a name="p42242271585"></a><a name="p42242271585"></a>LOS_TRACE_EASY</p> 82</td> 83<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p1622416274584"><a name="p1622416274584"></a><a name="p1622416274584"></a>Performs simple instrumentation.</p> 84</td> 85</tr> 86<tr id="row16234627175820"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p622515274583"><a name="p622515274583"></a><a name="p622515274583"></a>LOS_TRACE</p> 87</td> 88<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p2225527185810"><a name="p2225527185810"></a><a name="p2225527185810"></a>Performs standard instrumentation.</p> 89</td> 90</tr> 91</tbody> 92</table> 93 94- You can perform function instrumentation in the source code to trace specific events. The system provides the following APIs for instrumentation: 95 - **LOS\_TRACE\_EASY\(TYPE, IDENTITY, params...\)** for simple instrumentation 96 - You only need to insert this API into the source code. 97 - **TYPE** specifies the event type. The value range is 0 to 0xF. The meaning of each value is user-defined. 98 - **IDENTITY** specifies the object of the event operation. The value is of the **UIntPtr** type. 99 - **Params** specifies the event parameters. The value is of the **UIntPtr** type. 100 - Example: 101 102 ``` 103 Perform simple instrumentation for reading and writing files fd1 and fd2. 104 Set TYPE to 1 for read operations and 2 for write operations. 105 Insert the following to the position where the fd1 file is read: 106 LOS_TRACE_EASY(1, fd1, flag, size); 107 Insert the following to the position where the fd2 file is read: 108 LOS_TRACE_EASY(1, fd2, flag, size); 109 Insert the following to the position where the fd1 file is written: 110 LOS_TRACE_EASY(2, fd1, flag, size); 111 Insert the following in the position where the fd2 file is written: 112 LOS_TRACE_EASY(2, fd2, flag, size); 113 ``` 114 115 - **LOS\_TRACE\(TYPE, IDENTITY, params...\)** for standard instrumentation. 116 - Compared with simple instrumentation, standard instrumentation supports dynamic event filtering and parameter tailoring. However, you need to extend the functions based on rules. 117 - **TYPE** specifies the event type. You can define the event type in **enum LOS\_TRACE\_TYPE** in the header file **los\_trace.h**. For details about methods and rules for defining events, see other event types. 118 - The **IDENTITY** and **Params** are the same as those of simple instrumentation. 119 - Example: 120 121 ``` 122 1. Set the event mask (module-level event type) in enum LOS_TRACE_MASK. 123 Format: TRACE_#MOD#_FLAG (MOD indicates the module name) 124 Example: 125 TRACE_FS_FLAG = 0x4000 126 2. Define the event type in enum LOS_TRACE_TYPE. 127 Format: #TYPE# = TRACE_#MOD#_FLAG | NUMBER 128 Example: 129 FS_READ = TRACE_FS_FLAG | 0; // Read files 130 FS_WRITE = TRACE_FS_FLAG | 1; // Write files 131 3. Set event parameters in the #TYPE#_PARAMS(IDENTITY, parma1...) IDENTITY, ... format. 132 #TYPE# is the #TYPE# defined in step 2. 133 Example: 134 #define FS_READ_PARAMS(fp, fd, flag, size) fp, fd, flag, size 135 The parameters defined by the macro correspond to the event parameters recorded in the trace buffer. You can modify the parameters as required. 136 If no parameter is specified, events of this type are not traced. 137 #define FS_READ_PARAMS(fp, fd, flag, size) // File reading events are not traced. 138 4. Insert a code stub in a proper position. 139 Format: LOS_TRACE(#TYPE#, #TYPE#_PARAMS(IDENTITY, parma1...)) 140 LOS_TRACE(FS_READ, fp, fd, flag, size); // Code stub for reading files 141 The parameters following #TYPE# are the input parameter of the FS_READ_PARAMS function in step 3. 142 ``` 143 144 > **NOTE:** 145 >The trace event types and parameters can be modified as required. For details about the parameters, see **kernel\\include\\los\_trace.h**. 146 147 148 149- For **LOS\_TraceEventMaskSet\(UINT32 mask\)**, only the most significant 28 bits \(corresponding to the enable bit of the module in **LOS\_TRACE\_MASK**\) of the mask take effect and are used only for module-based tracing. Currently, fine-grained event-based tracing is not supported. For example, in **LOS\_TraceEventMaskSet\(0x202\)**, the effective mask is **0x200 \(TRACE\_QUE\_FLAG\)** and all events of the QUE module are collected. The recommended method is **LOS\_TraceEventMaskSet\(TRACE\_EVENT\_FLAG | TRACE\_MUX\_FLAG | TRACE\_SEM\_FLAG | TRACE\_QUE\_FLAG\);**. 150- To enable trace of only simple instrumentation events, set **Trace Mask** to **TRACE\_MAX\_FLAG**. 151- The trace buffer has limited capacity. When the trace buffer is full, events will be overwritten. You can use **LOS\_TraceRecordDump** to export data from the trace buffer and locate the latest records by **CurEvtIndex**. 152- The typical trace operation process includes **LOS\_TraceStart**, **LOS\_TraceStop**, and **LOS\_TraceRecordDump**. 153- You can filter out interrupt events by interrupt ID to prevent other events from being overwritten due to frequent triggering of a specific interrupt in some scenarios. You can customize interrupt filtering rules. 154 155 The sample code is as follows: 156 157 ``` 158 BOOL Example_HwiNumFilter(UINT32 hwiNum) 159 { 160 if ((hwiNum == TIMER_INT) || (hwiNum == DMA_INT)) { 161 return TRUE; 162 } 163 return FALSE; 164 } 165 LOS_TraceHwiFilterHookReg(Example_HwiNumFilter); 166 ``` 167 168 The interrupt events with interrupt ID of **TIMER\_INT** or **DMA\_INT** are not traced. 169 170 171## Development Guidelines 172 173### How to Develop 174 175The typical trace process is as follows: 176 1771. Configure the macro related to the trace module. 178 179 Modify the configuration in the **target\_config.h** file. 180 181 <a name="table86631147151516"></a> 182 <table><thead align="left"><tr id="row5664134715156"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.1.4.1.1"><p id="p1466404761518"><a name="p1466404761518"></a><a name="p1466404761518"></a>Configuration</p> 183 </th> 184 <th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.1.4.1.2"><p id="p18664347131518"><a name="p18664347131518"></a><a name="p18664347131518"></a>Description</p> 185 </th> 186 <th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.1.4.1.3"><p id="p166413478159"><a name="p166413478159"></a><a name="p166413478159"></a>Value</p> 187 </th> 188 </tr> 189 </thead> 190 <tbody><tr id="row22591620121620"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.1 "><p id="p225117203162"><a name="p225117203162"></a><a name="p225117203162"></a>LOSCFG_KERNEL_TRACE</p> 191 </td> 192 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.2 "><p id="p72519205167"><a name="p72519205167"></a><a name="p72519205167"></a>Specifies whether to enable the trace feature.</p> 193 </td> 194 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p925182081614"><a name="p925182081614"></a><a name="p925182081614"></a>YES/NO</p> 195 </td> 196 </tr> 197 <tr id="row4259182012168"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.1 "><p id="p72515204168"><a name="p72515204168"></a><a name="p72515204168"></a>LOSCFG_RECORDER_MODE_OFFLINE</p> 198 </td> 199 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.2 "><p id="p4251620111614"><a name="p4251620111614"></a><a name="p4251620111614"></a>Specifies whether to enable the online trace mode.</p> 200 </td> 201 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p425162020167"><a name="p425162020167"></a><a name="p425162020167"></a>YES/NO</p> 202 </td> 203 </tr> 204 <tr id="row1825902061611"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.1 "><p id="p122511220191613"><a name="p122511220191613"></a><a name="p122511220191613"></a>LOSCFG_RECORDER_MODE_ONLINE</p> 205 </td> 206 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.2 "><p id="p7251192018169"><a name="p7251192018169"></a><a name="p7251192018169"></a>Specifies whether to enable the offline trace mode.</p> 207 </td> 208 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p1225115205163"><a name="p1225115205163"></a><a name="p1225115205163"></a>YES/NO</p> 209 </td> 210 </tr> 211 <tr id="row3259152015163"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.1 "><p id="p225118205169"><a name="p225118205169"></a><a name="p225118205169"></a>LOSCFG_TRACE_CLIENT_INTERACT</p> 212 </td> 213 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.2 "><p id="p225182016163"><a name="p225182016163"></a><a name="p225182016163"></a>Specifies whether to enable interaction with Trace IDE (dev tools), including data visualization and process control.</p> 214 </td> 215 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p182512208167"><a name="p182512208167"></a><a name="p182512208167"></a>YES/NO</p> 216 </td> 217 </tr> 218 <tr id="row02591120201618"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.1 "><p id="p82511920101615"><a name="p82511920101615"></a><a name="p82511920101615"></a>LOSCFG_TRACE_FRAME_CORE_MSG</p> 219 </td> 220 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.2 "><p id="p425192015165"><a name="p425192015165"></a><a name="p425192015165"></a>Specifies whether to enable recording of the CPU ID, interruption state, and lock task state.</p> 221 </td> 222 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p1925119204166"><a name="p1925119204166"></a><a name="p1925119204166"></a>YES/NO</p> 223 </td> 224 </tr> 225 <tr id="row1525916202166"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.1 "><p id="p3251162017161"><a name="p3251162017161"></a><a name="p3251162017161"></a>LOSCFG_TRACE_FRAME_EVENT_COUNT</p> 226 </td> 227 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.2 "><p id="p18251142021619"><a name="p18251142021619"></a><a name="p18251142021619"></a>Specifies whether to enables recording of the event sequence number.</p> 228 </td> 229 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p1251020171616"><a name="p1251020171616"></a><a name="p1251020171616"></a>YES/NO</p> 230 </td> 231 </tr> 232 <tr id="row1025920204167"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.1 "><p id="p2025172010166"><a name="p2025172010166"></a><a name="p2025172010166"></a>LOSCFG_TRACE_FRAME_MAX_PARAMS</p> 233 </td> 234 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.2 "><p id="p172511020141611"><a name="p172511020141611"></a><a name="p172511020141611"></a>Specifies the maximum number of parameters for event recording.</p> 235 </td> 236 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p12251182041610"><a name="p12251182041610"></a><a name="p12251182041610"></a>INT</p> 237 </td> 238 </tr> 239 <tr id="row225982091614"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.1 "><p id="p1725114206168"><a name="p1725114206168"></a><a name="p1725114206168"></a>LOSCFG_TRACE_BUFFER_SIZE</p> 240 </td> 241 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.2 "><p id="p4251142014161"><a name="p4251142014161"></a><a name="p4251142014161"></a>Specifies the trace buffer size.</p> 242 </td> 243 <td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.1.4.1.3 "><p id="p2251152014162"><a name="p2251152014162"></a><a name="p2251152014162"></a>INT</p> 244 </td> 245 </tr> 246 </tbody> 247 </table> 248 2492. \(Optional\) Preset event parameters and stubs \(or use the default event parameter settings and event stubs\). 2503. \(Optional\) Call **LOS\_TraceStop** to stop trace and call **LOS\_TraceReset** to clear the trace buffer. \(Trace is started by default.\) 2514. \(Optional\) Call **LOS\_TraceEventMaskSet** to set the event mask for trace \(only the interrupts and task events are enabled by default\). For details about the event mask, see **LOS\_TRACE\_MASK** in **los\_trace.h**. 2525. Call **LOS\_TraceStart** at the start of the code where the event needs to be traced. 2536. Call **LOS\_TraceStop** at the end of the code where the event needs to be traced. 2547. Call **LOS\_TraceRecordDump** to output the data in the buffer. \(The input parameter of the function is of the Boolean type. The value **FALSE** means to output data in the specified format, and the value **TRUE** means to output data to a Windows client.\) 255 256The methods in steps 3 to 7 are encapsulated with shell commands. After the shell is enabled, the corresponding commands can be executed. The mapping is as follows: 257 258- LOS\_TraceReset —— trace\_reset 259- LOS\_TraceEventMaskSet —— trace\_mask 260- LOS\_TraceStart —— trace\_start 261- LOS\_TraceStop —— trace\_stop 262- LOS\_TraceRecordDump —— trace\_dump 263 264### Development Example 265 266This example implements the following: 267 2681. Create a trace task. 2692. Set the event mask. 2703. Start trace. 2714. Stop trace. 2725. Output trace data in the specified format. 273 274### Sample Code 275 276The sample code is as follows: 277 278``` 279#include "los_trace.h" 280UINT32 g_traceTestTaskId; 281VOID Example_Trace(VOID) 282{ 283 UINT32 ret; 284 LOS_TaskDelay(10); 285 /* Start trace. */ 286 ret = LOS_TraceStart(); 287 if (ret != LOS_OK) { 288 dprintf("trace start error\n"); 289 return; 290 } 291 /* Trigger a task switching event.*/ 292 LOS_TaskDelay(1); 293 LOS_TaskDelay(1); 294 LOS_TaskDelay(1); 295 /* Stop trace.*/ 296 LOS_TraceStop(); 297 LOS_TraceRecordDump(FALSE); 298} 299UINT32 Example_Trace_test(VOID){ 300 UINT32 ret; 301 TSK_INIT_PARAM_S traceTestTask; 302 /* Create a trace task. */ 303 memset(&traceTestTask, 0, sizeof(TSK_INIT_PARAM_S)); 304 traceTestTask.pfnTaskEntry = (TSK_ENTRY_FUNC)Example_Trace; 305 traceTestTask.pcName = "TestTraceTsk"; /* Trace task name*/ 306 traceTestTask.uwStackSize = 0x800; 307 traceTestTask.usTaskPrio = 5; 308 traceTestTask.uwResved = LOS_TASK_STATUS_DETACHED; 309 ret = LOS_TaskCreate(&g_traceTestTaskId, &traceTestTask); 310 if(ret != LOS_OK){ 311 dprintf("TraceTestTask create failed .\n"); 312 return LOS_NOK; 313 } 314 /* Trace is started by default. Therefore, you can stop trace, clear the buffer, and then restart trace. */ 315 LOS_TraceStop(); 316 LOS_TraceReset(); 317 /* Enable trace of the Task module events. */ 318 LOS_TraceEventMaskSet(TRACE_TASK_FLAG); 319 return LOS_OK; 320} 321``` 322 323### Verification 324 325The output is as follows: 326 327``` 328*******TraceInfo begin******* 329clockFreq = 50000000 330CurEvtIndex = 7 331Index Time(cycles) EventType CurTask Identity params 3320 0x366d5e88 0x45 0x1 0x0 0x1f 0x4 0x0 3331 0x366d74ae 0x45 0x0 0x1 0x0 0x8 0x1f 3342 0x36940da6 0x45 0x1 0xc 0x1f 0x4 0x9 3353 0x3694337c 0x45 0xc 0x1 0x9 0x8 0x1f 3364 0x36eea56e 0x45 0x1 0xc 0x1f 0x4 0x9 3375 0x36eec810 0x45 0xc 0x1 0x9 0x8 0x1f 3386 0x3706f804 0x45 0x1 0x0 0x1f 0x4 0x0 3397 0x37070e59 0x45 0x0 0x1 0x0 0x8 0x1f 340*******TraceInfo end******* 341``` 342 343The output event information includes the occurrence time, event type, task in which the event occurs, object of the event operation, and other parameters of the event. 344 345- **EventType**: event type. For details, see **enum LOS\_TRACE\_TYPE** in the header file **los\_trace.h**. 346- **CurrentTask**: ID of the running task. 347- **Identity**: object of the event operation. For details, see **\#TYPE\#\_PARAMS** in the header file **los\_trace.h**. 348- **params**: event parameters. For details, see **\#TYPE\#\_PARAMS** in the header file **los\_trace.h**. 349 350The following uses output No. 0 as an example. 351 352``` 353Index Time(cycles) EventType CurTask Identity params 3540 0x366d5e88 0x45 0x1 0x0 0x1f 0x4 355``` 356 357- **Time \(cycles\)** can be converted into time \(in seconds\) by dividing the cycles by clockFreq. 358- **0x45** indicates the task switching event. **0x1** is the ID of the task in running. 359- For details about the meanings of **Identity** and **params**, see the **TASK\_SWITCH\_PARAMS** macro. 360 361``` 362#define TASK_SWITCH_PARAMS(taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus) \ 363taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus 364``` 365 366Because of **\#TYPE\#\_PARAMS\(IDENTITY, parma1...\) IDENTITY, ...**, **Identity** is **taskId \(0x0\)** and the first parameter is **oldPriority \(0x1f\)**. 367 368> **NOTE:** 369>The number of parameters in **params** is specified by the **LOSCFG\_TRACE\_FRAME\_MAX\_PARAMS** parameter. The default value is **3**. Excess parameters are not recorded. You need to set **LOSCFG\_TRACE\_FRAME\_MAX\_PARAMS** based on service requirements. 370 371Task 0x1 is switched to Task 0x0. The priority of task 0x1 is **0x1f**, and the state is **0x4**. The priority of the task 0x0 is **0x0**. 372 373