1e41f4b71Sopenharmony_ci# Trace
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## Basic Concepts
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ciTrace helps you learn about the kernel running process and the execution sequence of modules and tasks. With the traced information, you can better understand the code running process of the kernel and locate time sequence problems.
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## Working Principles
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciThe 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.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ciWhen 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.
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ciThe trace module provides two working modes: offline mode and online mode.
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciIn 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.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci![](figures/kernel-small-mode-process.png)
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ciThe 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.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci## Available APIs
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ciThe trace module of the OpenHarmony LiteOS-M kernel provides the following APIs. For more details about the APIs, see the API reference.
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci  **Table 1** APIs of the trace module
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci| Category| API|
31e41f4b71Sopenharmony_ci| -------- | -------- |
32e41f4b71Sopenharmony_ci| Starting/Stopping trace| - **LOS_TraceStart**: starts a trace.<br>- **LOS_TraceStop**: stops the trace.|
33e41f4b71Sopenharmony_ci| Managing trace records| - **LOS_TraceRecordDump**: dumps data from the trace buffer.<br>- **LOS_TraceRecordGet**: obtains the start address of the trace buffer.<br>- **LOS_TraceReset**: clears events in the trace buffer.|
34e41f4b71Sopenharmony_ci| Filtering trace records| **LOS_TraceEventMaskSet**: sets the event mask to trace only events of the specified modules.|
35e41f4b71Sopenharmony_ci| Masking events of specified interrupt IDs| **LOS_TraceHwiFilterHookReg**: registers a hook to filter out events of specified interrupt IDs.|
36e41f4b71Sopenharmony_ci| Performing function instrumentation| - **LOS_TRACE_EASY**: performs simple instrumentation.<br>- **LOS_TRACE**: performs standard instrumentation.|
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci- You can perform function instrumentation in the source code to trace specific events. The system provides the following APIs for instrumentation:
39e41f4b71Sopenharmony_ci  - **LOS_TRACE_EASY(TYPE, IDENTITY, params...)** for simple instrumentation
40e41f4b71Sopenharmony_ci     - You only need to insert this API into the source code.
41e41f4b71Sopenharmony_ci     - **TYPE** specifies the event type. The value range is 0 to 0xF. The meaning of each value is user-defined.
42e41f4b71Sopenharmony_ci     - **IDENTITY** specifies the object of the event operation. The value is of the **UIntPtr** type.
43e41f4b71Sopenharmony_ci     - **Params** specifies the event parameters. The value is of the **UIntPtr** type.
44e41f4b71Sopenharmony_ci     - Example of simple instrumentation for reading and writing data based on the file FDs:
45e41f4b71Sopenharmony_ci       
46e41f4b71Sopenharmony_ci        ```
47e41f4b71Sopenharmony_ci        /* Set TYPE to 1 for read operation and 2 for write operations. */
48e41f4b71Sopenharmony_ci        LOS_TRACE_EASY(1, fd, flag, size); /* Add it to a proper position. */
49e41f4b71Sopenharmony_ci        LOS_TRACE_EASY(2, fd, flag, size);  /* Add it to a proper position. */
50e41f4b71Sopenharmony_ci        ```
51e41f4b71Sopenharmony_ci  - **LOS_TRACE(TYPE, IDENTITY, params...)** for standard instrumentation.
52e41f4b71Sopenharmony_ci     - Compared with simple instrumentation, standard instrumentation supports dynamic event filtering and parameter tailoring. However, you need to extend the functions based on rules.
53e41f4b71Sopenharmony_ci     - **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.
54e41f4b71Sopenharmony_ci     - The **IDENTITY** and **Params** are the same as those of simple instrumentation.
55e41f4b71Sopenharmony_ci     - Example:
56e41f4b71Sopenharmony_ci          1. Define the type of the FS module (event mask of the FS module) in **enum LOS_TRACE_MASK**.
57e41f4b71Sopenharmony_ci          
58e41f4b71Sopenharmony_ci        ```
59e41f4b71Sopenharmony_ci        /* Define the event mask in the format of TRACE_#MOD#_FLAG, where #MOD# indicates the module name. */
60e41f4b71Sopenharmony_ci        TRACE_FS_FLAG = 0x4000
61e41f4b71Sopenharmony_ci        ```
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci        2. Define the event types of the FS module.
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci        
66e41f4b71Sopenharmony_ci        ```
67e41f4b71Sopenharmony_ci        /* Define the event type in the format: #TYPE# = TRACE_#MOD#_FLAG | NUMBER */
68e41f4b71Sopenharmony_ci        FS_READ  = TRACE_FS_FLAG | 0; /* Read data. */
69e41f4b71Sopenharmony_ci        FS_WRITE = TRACE_FS_FLAG | 1; /* Write data. */
70e41f4b71Sopenharmony_ci        ```
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci        3. Define event parameters.
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci        
75e41f4b71Sopenharmony_ci        ```
76e41f4b71Sopenharmony_ci        /* Define the parameters in the format: #TYPE#_PARAMS(IDENTITY, parma1...) IDENTITY, ... */
77e41f4b71Sopenharmony_ci        #define FS_READ_PARAMS(fp, fd, flag, size)  fp, fd, flag, size /* The parameters defined by the macro correspond to the event parameters recorded in the trace buffer. You can tailor the parameters as required. */
78e41f4b71Sopenharmony_ci        #define FS_READ_PARAMS(fp, fd, flag, size)                     /* If no parameters are defined, events of this type are not traced. */
79e41f4b71Sopenharmony_ci        ```
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci        4. Add the code stubs in the code.
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci        
84e41f4b71Sopenharmony_ci        ```
85e41f4b71Sopenharmony_ci        /* Format: LOS_TRACE(#TYPE#, #TYPE#_PARAMS(IDENTITY, parma1...)) */
86e41f4b71Sopenharmony_ci        LOS_TRACE(FS_READ, fp, fd, flag, size); /* Code stub for reading data. */
87e41f4b71Sopenharmony_ci        ```
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci        > **NOTE**<br>
90e41f4b71Sopenharmony_ci        > You can modify the traced event types and parameters as required. For details about the parameters, see **kernel\include\los_trace.h**.
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci- 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);**.
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci- To enable trace of only simple instrumentation events, set **Trace Mask** to **TRACE_MAX_FLAG**.
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci- 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**.
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci- The typical trace operation process includes **LOS_TraceStart**, **LOS_TraceStop**, and **LOS_TraceRecordDump**.
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci- 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.<br>
101e41f4b71Sopenharmony_ci    The sample code is as follows:
102e41f4b71Sopenharmony_ci    
103e41f4b71Sopenharmony_ci  ```
104e41f4b71Sopenharmony_ci  BOOL Example_HwiNumFilter(UINT32 hwiNum)
105e41f4b71Sopenharmony_ci  {
106e41f4b71Sopenharmony_ci         if ((hwiNum == TIMER_INT) || (hwiNum == DMA_INT)) {
107e41f4b71Sopenharmony_ci          return TRUE;
108e41f4b71Sopenharmony_ci      }
109e41f4b71Sopenharmony_ci      return FALSE;
110e41f4b71Sopenharmony_ci  }
111e41f4b71Sopenharmony_ci  LOS_TraceHwiFilterHookReg(Example_HwiNumFilter);
112e41f4b71Sopenharmony_ci  ```
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci  The interrupt events with interrupt ID of **TIMER_INT** or **DMA_INT** are not traced.
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci## Development Guidelines
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci### How to Develop
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ciThe typical development process is as follows:
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci1. Configure the macros related to the trace module in the **target_config.h** file.
125e41f4b71Sopenharmony_ci     | Configuration Item| Description| Value|
126e41f4b71Sopenharmony_ci   | -------- | -------- | -------- |
127e41f4b71Sopenharmony_ci   | LOSCFG_KERNEL_TRACE | Whether to enable the trace feature. | YES/NO |
128e41f4b71Sopenharmony_ci   | LOSCFG_RECORDER_MODE_OFFLINE | Whether to enable the online trace mode. | YES/NO |
129e41f4b71Sopenharmony_ci   | LOSCFG_RECORDER_MODE_ONLINE | Whether to enable the offline trace mode. | YES/NO |
130e41f4b71Sopenharmony_ci   | LOSCFG_TRACE_CLIENT_INTERACT | Whether to enable interaction with Trace IDE (dev tools), including data visualization and process control. | YES/NO |
131e41f4b71Sopenharmony_ci   | LOSCFG_TRACE_FRAME_CORE_MSG | Whether to enable trace of the CPU ID, interruption state, and lock task state. | YES/NO |
132e41f4b71Sopenharmony_ci   | LOSCFG_TRACE_FRAME_EVENT_COUNT | Whether to enable trace of the event sequence number. | YES/NO |
133e41f4b71Sopenharmony_ci   | LOSCFG_TRACE_FRAME_MAX_PARAMS | Specifies the maximum number of parameters for event tracing. | INT |
134e41f4b71Sopenharmony_ci   | LOSCFG_TRACE_BUFFER_SIZE | Specifies the trace buffer size.| INT |
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_ci2. (Optional) Preset event parameters and stubs (or use the default event parameter settings and event stubs).
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci3. (Optional) Call **LOS_TraceStop** to stop trace and **LOS_TraceReset** to clear the trace buffer. (Trace is started by default.)
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ci4. (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**.
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_ci5. Call **LOS_TraceStart** at the start of the code where the event needs to be traced.
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci6. Call **LOS_TraceStop** at the end of the code where the event needs to be traced.
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci7. 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.)
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ciThe 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:
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci- LOS_TraceReset —— trace_reset
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ci- LOS_TraceEventMaskSet —— trace_mask
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci- LOS_TraceStart —— trace_start
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci- LOS_TraceStop —— trace_stop
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci- LOS_TraceRecordDump —— trace_dump
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci### Development Example
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ciThis example implements the following:
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci1. Create a trace task.
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci2. Set the event mask.
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci3. Start trace.
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci4. Stop trace.
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci5. Output trace data in the specified format.
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci### Sample Code
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ciThe sample code is as follows:
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ciThe sample code can be compiled and verified in **./kernel/liteos_m/testsuites/src/osTest.c**. The **ExampleTraceTest** function is called in **TestTaskEntry**.
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci```
184e41f4b71Sopenharmony_ci#include "los_trace.h"
185e41f4b71Sopenharmony_ciUINT32 g_traceTestTaskId;
186e41f4b71Sopenharmony_ciVOID Example_Trace(VOID)
187e41f4b71Sopenharmony_ci{ 
188e41f4b71Sopenharmony_ci    UINT32 ret;    
189e41f4b71Sopenharmony_ci    LOS_TaskDelay(10);
190e41f4b71Sopenharmony_ci    /* Start trace. */
191e41f4b71Sopenharmony_ci    ret = LOS_TraceStart();    
192e41f4b71Sopenharmony_ci    if (ret != LOS_OK) {        
193e41f4b71Sopenharmony_ci        dprintf("trace start error\n");        
194e41f4b71Sopenharmony_ci        return;    
195e41f4b71Sopenharmony_ci    }    
196e41f4b71Sopenharmony_ci    /* Trigger a task switching event. */   
197e41f4b71Sopenharmony_ci    LOS_TaskDelay(1);    
198e41f4b71Sopenharmony_ci    LOS_TaskDelay(1);    
199e41f4b71Sopenharmony_ci    LOS_TaskDelay(1);    
200e41f4b71Sopenharmony_ci    /* Stop trace. */   
201e41f4b71Sopenharmony_ci    LOS_TraceStop();    
202e41f4b71Sopenharmony_ci    LOS_TraceRecordDump(FALSE);
203e41f4b71Sopenharmony_ci}
204e41f4b71Sopenharmony_ciUINT32 ExampleTraceTest(VOID){
205e41f4b71Sopenharmony_ci    UINT32 ret;    
206e41f4b71Sopenharmony_ci    TSK_INIT_PARAM_S traceTestTask = { 0 };
207e41f4b71Sopenharmony_ci    /* Create a trace task. */   
208e41f4b71Sopenharmony_ci    memset(&traceTestTask, 0, sizeof(TSK_INIT_PARAM_S));    
209e41f4b71Sopenharmony_ci    traceTestTask.pfnTaskEntry = (TSK_ENTRY_FUNC)Example_Trace;    
210e41f4b71Sopenharmony_ci    traceTestTask.pcName       = "TestTraceTsk";    /* Trace task name. */   				     
211e41f4b71Sopenharmony_ci    traceTestTask.uwStackSize  = 0x800;    
212e41f4b71Sopenharmony_ci    traceTestTask.usTaskPrio   = 5;    
213e41f4b71Sopenharmony_ci    traceTestTask.uwResved   = LOS_TASK_STATUS_DETACHED;    
214e41f4b71Sopenharmony_ci    ret = LOS_TaskCreate(&g_traceTestTaskId, &traceTestTask);    
215e41f4b71Sopenharmony_ci    if(ret != LOS_OK){        
216e41f4b71Sopenharmony_ci        dprintf("TraceTestTask create failed .\n");        
217e41f4b71Sopenharmony_ci        return LOS_NOK;    
218e41f4b71Sopenharmony_ci    }    
219e41f4b71Sopenharmony_ci    /* Trace is started by default. You can stop trace, clear the buffer, and restart trace. */                   	  
220e41f4b71Sopenharmony_ci    LOS_TraceStop();    
221e41f4b71Sopenharmony_ci    LOS_TraceReset();    
222e41f4b71Sopenharmony_ci    /* Enable trace of the Task module events. */   
223e41f4b71Sopenharmony_ci    LOS_TraceEventMaskSet(TRACE_TASK_FLAG);    
224e41f4b71Sopenharmony_ci    return LOS_OK;
225e41f4b71Sopenharmony_ci}
226e41f4b71Sopenharmony_ci```
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci### Verification
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ciThe output is as follows:
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci```
235e41f4b71Sopenharmony_ci***TraceInfo begin***
236e41f4b71Sopenharmony_ciclockFreq = 50000000
237e41f4b71Sopenharmony_ciCurEvtIndex = 7
238e41f4b71Sopenharmony_ciIndex   Time(cycles)      EventType      CurTask   Identity      params    
239e41f4b71Sopenharmony_ci0       0x366d5e88        0x45           0x1       0x0           0x1f         0x4       0x0
240e41f4b71Sopenharmony_ci1       0x366d74ae        0x45           0x0       0x1           0x0          0x8       0x1f
241e41f4b71Sopenharmony_ci2       0x36940da6        0x45           0x1       0xc           0x1f         0x4       0x9
242e41f4b71Sopenharmony_ci3       0x3694337c        0x45           0xc       0x1           0x9          0x8       0x1f
243e41f4b71Sopenharmony_ci4       0x36eea56e        0x45           0x1       0xc           0x1f         0x4       0x9
244e41f4b71Sopenharmony_ci5       0x36eec810        0x45           0xc       0x1           0x9          0x8       0x1f
245e41f4b71Sopenharmony_ci6       0x3706f804        0x45           0x1       0x0           0x1f         0x4       0x0
246e41f4b71Sopenharmony_ci7       0x37070e59        0x45           0x0       0x1           0x0          0x8       0x1f
247e41f4b71Sopenharmony_ci***TraceInfo end***
248e41f4b71Sopenharmony_ci
249e41f4b71Sopenharmony_ciThe preceding data may vary depending on the running environment.
250e41f4b71Sopenharmony_ci```
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ciThe 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.
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci- **EventType**: event type. For details, see **enum LOS_TRACE_TYPE** in the header file **los_trace.h**.
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci- **CurrentTask**: ID of the running task.
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ci- **Identity**: object of the event operation. For details, see **#TYPE#_PARAMS** in the header file **los_trace.h**.
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ci- **params**: event parameters. For details, see **#TYPE#_PARAMS** in the header file **los_trace.h**.
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ciThe following uses output No. 0 as an example.
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ci```
266e41f4b71Sopenharmony_ciIndex   Time(cycles)      EventType      CurTask   Identity      params
267e41f4b71Sopenharmony_ci0       0x366d5e88        0x45           0x1       0x0           0x1f         0x4
268e41f4b71Sopenharmony_ci```
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ci- **Time (cycles)** can be converted into time (in seconds) by dividing the cycles by clockFreq.
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_ci- **0x45** indicates the task switching event. **0x1** is the ID of the task in running. 
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ci- For details about the meanings of **Identity** and **params**, see the **TASK_SWITCH_PARAMS** macro.
275e41f4b71Sopenharmony_ci
276e41f4b71Sopenharmony_ci  
277e41f4b71Sopenharmony_ci```
278e41f4b71Sopenharmony_ci#define TASK_SWITCH_PARAMS(taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus) \
279e41f4b71Sopenharmony_citaskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus
280e41f4b71Sopenharmony_ci```
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ci  **Identity** is **taskId (0x0)**, and the first parameter is **oldPriority (0x1f)**.
283e41f4b71Sopenharmony_ci> **NOTE**<br>
284e41f4b71Sopenharmony_ci> The number of parameters in **params** is specified by **LOSCFG_TRACE_FRAME_MAX_PARAMS**. The default value is **3**. Excess parameters are not recorded. Set **LOSCFG_TRACE_FRAME_MAX_PARAMS** based on service requirements.
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ciTask 0x1 is switched to Task 0x0. The priority of task 0x1 is **0x1f**, and the state is **0x4**. The priority of task 0x0 is **0x0**.
287