更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_trace.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 * of conditions and the following disclaimer in the documentation and/or other materials
13 * provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16 * to endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32/**
33 * @defgroup los_trace Trace
34 * @ingroup kernel
35 */
36
37#ifndef _LOS_TRACE_H
38#define _LOS_TRACE_H
39
40#include "los_task.h"
41#include "los_base.h"
42
43#ifdef __cplusplus
44#if __cplusplus
45extern "C" {
46#endif /* __cplusplus */
47#endif /* __cplusplus */
48
49#ifdef LOSCFG_TRACE_CONTROL_AGENT
50
51/**
52 * @ingroup los_trace
53 * Trace Control agent task's priority.
54 */
55#define LOSCFG_TRACE_TASK_PRIORITY 2 ///< trace 任务的优先级为 2, 也挺高的,仅次于软件定时器 0
56#endif
57
58#define LOSCFG_TRACE_OBJ_MAX_NAME_SIZE LOS_TASK_NAMELEN ///< Trace 对象的名称(内核对象,如任务)
59
60#define LOS_TRACE_LR_RECORD 5
61#define LOS_TRACE_LR_IGNORE 0
62/**
63 * @ingroup los_trace
64 * Trace records the max number of objects(kernel object, like tasks), range is [0, LOSCFG_BASE_CORE_TSK_LIMIT].
65 * if set to 0, trace will not record any object.
66 */
67#define LOSCFG_TRACE_OBJ_MAX_NUM 0 ///< Trace 记录对象的最大数量(内核对象,如任务)
68
69/**
70 * @ingroup los_trace
71 * Trace tlv encode buffer size, the buffer is used to encode one piece raw frame to tlv message in online mode.
72 */
73#define LOSCFG_TRACE_TLV_BUF_SIZE 100
74
75/**
76 * @ingroup los_trace
77 * Trace error code: init trace failed.
78 *
79 * Value: 0x02001400
80 *
81 * Solution: Follow the trace State Machine.
82 */
83#define LOS_ERRNO_TRACE_ERROR_STATUS LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x00)
84
85/**
86 * @ingroup los_trace
87 * Trace error code: Insufficient memory for trace buf init.
88 *
89 * Value: 0x02001401
90 *
91 * Solution: Expand the configured system memory or decrease the value defined by LOS_TRACE_BUFFER_SIZE.
92 */
93#define LOS_ERRNO_TRACE_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x01)
94
95/**
96 * @ingroup los_trace
97 * Trace error code: Insufficient memory for trace struct.
98 *
99 * Value: 0x02001402
100 *
101 * Solution: Increase trace buffer's size.
102 */
103#define LOS_ERRNO_TRACE_BUF_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x02)
104
105/**
106 * @ingroup los_trace
107 * Trace state. | 跟踪状态
108 */
110 TRACE_UNINIT = 0, /**< trace isn't inited | 未初始化*/
111 TRACE_INITED, /**< trace is inited but not started yet | 已初始化但未开始*/
112 TRACE_STARTED, /**< trace is started and system is tracing | 跟踪进行中...*/
113 TRACE_STOPED, /**< trace is stopped | 跟踪结束*/
114};
115
116/**
117 * @ingroup los_trace
118 * Trace mask is used to filter events in runtime. Each mask keep only one unique bit to 1, and user can define own
119 * module's trace mask.
120 */
121typedef enum {
122 TRACE_SYS_FLAG = 0x10, ///< 跟踪系统
123 TRACE_HWI_FLAG = 0x20, ///< 跟踪硬中断
124 TRACE_TASK_FLAG = 0x40, ///< 跟踪任务/线程
125 TRACE_SWTMR_FLAG = 0x80, ///< 跟踪软件定时器
126 TRACE_MEM_FLAG = 0x100, ///< 跟踪内存
127 TRACE_QUE_FLAG = 0x200, ///< 跟踪队列
128 TRACE_EVENT_FLAG = 0x400, ///< 跟踪事件
129 TRACE_SEM_FLAG = 0x800, ///< 跟踪信号量
130 TRACE_MUX_FLAG = 0x1000, ///< 跟踪互斥量
131 TRACE_IPC_FLAG = 0x2000, ///< 跟踪IPC
132
133 TRACE_MAX_FLAG = 0x80000000,
136
137/**
138 * @ingroup los_trace
139 * Trace event type which indicate the exactly happend events, user can define own module's event type like
140 * TRACE_#MODULE#_FLAG | NUMBER.
141 * 28 4
142 * 0 0 0 0 0 0 0 0 X X X X X X X X 0 0 0 0 0 0
143 * | | |
144 * trace_module_flag number
145 *
146 */
147typedef enum { //跟进模块的具体事件
148 /* 0x10~0x1F */
150 SYS_START = TRACE_SYS_FLAG | 1, ///< trace模块开始
151 SYS_STOP = TRACE_SYS_FLAG | 2, ///< trace模块停止
152
153 /* 0x20~0x2F */
167
168 /* 0x40~0x4F */
176
177 /* 0x80~0x8F */
183
184 /* 0x100~0x10F */
191
192 /* 0x200~0x20F */
196
197 /* 0x400~0x40F */
203
204 /* 0x800~0x80F */
209
210 /* 0x1000~0x100F */
215
216 /* 0x2000~0x200F */
225/// http://weharmonyos.com/openharmony/zh-cn/device-dev/kernel/kernel-mini-memory-trace.html
226/*******TraceInfo begin******* trace 模块结构体多,可参考输出日志理解
227clockFreq = 50000000
228CurEvtIndex = 7
229Index Time(cycles) EventType CurTask Identity params
2300 0x366d5e88 0x45 0x1 0x0 0x1f 0x4 0x0
2311 0x366d74ae 0x45 0x0 0x1 0x0 0x8 0x1f
2322 0x36940da6 0x45 0x1 0xc 0x1f 0x4 0x9
2333 0x3694337c 0x45 0xc 0x1 0x9 0x8 0x1f
2344 0x36eea56e 0x45 0x1 0xc 0x1f 0x4 0x9
2355 0x36eec810 0x45 0xc 0x1 0x9 0x8 0x1f
2366 0x3706f804 0x45 0x1 0x0 0x1f 0x4 0x0
2377 0x37070e59 0x45 0x0 0x1 0x0 0x8 0x1f
238*******TraceInfo end*******/
239
240/**
241 * @ingroup los_trace
242 * struct to store the trace config information.
243 */
244typedef struct {
245 UINT32 bigLittleEndian; /**< big little endian flag | 大小端标记*/
246 UINT32 clockFreq; /**< system clock frequency | 系统时钟频率*/
247 UINT32 version; /**< trace version | 跟踪版本号*/
249
250/**
251 * @ingroup los_trace
252 * struct to store the event infomation | 保存跟踪事件的信息 ,Trace模块会对输入信息进行封装,
253 * 添加Trace帧头信息,包含事件类型、运行的cpuid、运行的任务id、运行的相对时间戳等信息
254 */
255typedef struct {
256 UINT32 eventType; /**< event type | 事件类型*/
257 UINT32 curTask; /**< current running task | 当前任务ID*/
258 UINT32 curPid; /**< current running processID | 当前进程ID*/
259 UINT64 curTime; /**< current timestamp | 时间戳*/
260 UINTPTR identity; /**< subject of the event description | 描述事件*/
261#ifdef LOSCFG_TRACE_FRAME_CORE_MSG //跟踪CPU信息
262 struct CoreStatus {
263 UINT32 cpuid : 8, /**< cpuid | CPU 核 ID*/
264 hwiActive : 4, /**< whether is in hwi response | 是否在等硬中断回应*/
265 taskLockCnt : 4, /**< task lock count | 等锁任务数量*/
266 paramCount : 4, /**< event frame params' number | */
267 reserves : 12; /**< reserves */
268 } core;
269#endif
270
271#ifdef LOSCFG_TRACE_FRAME_EVENT_COUNT
272 UINT32 eventCount; /**< the sequence of happend events | 事件发生的顺序 */
273#endif
274
275#ifdef LOS_TRACE_FRAME_LR
276 UINTPTR linkReg[LOS_TRACE_LR_RECORD];
277#endif
278
279#ifdef LOSCFG_TRACE_FRAME_MAX_PARAMS
280 UINTPTR params[LOSCFG_TRACE_FRAME_MAX_PARAMS]; /**< event frame's params */
281#endif
283
284#ifdef LOSCFG_DRIVERS_TRACE
285typedef struct {
286 UINT32 eventType; ///< 表示的具体事件
287 UINTPTR identity; ///< 表示事件操作的主体对象
288 UINTPTR params[3]; ///< 表示的事件参数
290#endif
291
292/**
293 * @ingroup los_trace
294 * struct to store the kernel obj information, we defined task as kernel obj in this system.
295 * 存储内核对象信息, 在本系统中就是指任务
296 */
297typedef struct {
298 UINT32 id; /**< kernel obj's id | 这里对象一般指任务ID*/
299 UINT32 prio; /**< kernel obj's priority | 任务优先级*/
300 CHAR name[LOSCFG_TRACE_OBJ_MAX_NAME_SIZE]; /**< kernel obj's name | 任务名称*/
301} ObjData;
302
303/**
304 * @ingroup los_trace
305 * struct to store the trace data. | 离线模式头信息
306 */
307typedef struct {
308 TraceBaseHeaderInfo baseInfo; /**< basic info, include bigLittleEndian flag, system clock freq | 基础信息*/
309 UINT16 totalLen; /**< trace data's total length | 总大小*/
310 UINT16 objSize; /**< sizeof #ObjData | 对象大小*/
311 UINT16 frameSize; /**< sizeof #TraceEventFrame | 事件帧大小*/
312 UINT16 objOffset; /**< the offset of the first obj data to record beginning | 开始对象数据位置*/
313 UINT16 frameOffset; /**< the offset of the first event frame data to record beginning | 开始事件帧数据位置 g_traceRecoder.ctrl.frameBuf*/
315
316
317
318/**
319 * @ingroup los_trace
320 * @brief Define the type of trace hardware interrupt filter hook function.
321 *
322 * @par Description:
323 * User can register fliter function by LOS_TraceHwiFilterHookReg to filter hardware interrupt events. Return true if
324 * user don't need trace the certain number.
325 *
326 * @attention
327 * None.
328 *
329 * @param hwiNum [IN] Type #UINT32. The hardware interrupt number.
330 * @retval #TRUE 0x00000001: Not record the certain number.
331 * @retval #FALSE 0x00000000: Need record the certain number.
332 *
333 * @par Dependency:
334 * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
335 */
337
338typedef VOID (*TRACE_EVENT_HOOK)(UINT32 eventType, UINTPTR identity, const UINTPTR *params, UINT16 paramCount);
340
341/**
342 * @ingroup los_trace
343 * Trace event params:
344 1. Configure the macro without parameters so as not to record events of this type;
345 2. Configure the macro at least with one parameter to record this type of event;
346 3. User can delete unnecessary parameters which defined in corresponding marco;
347 * @attention
348 * <ul>
349 * <li>The first param is treat as key, keep at least this param if you want trace this event.</li>
350 * <li>All parameters were treated as UINTPTR.</li>
351 * </ul>
352 * eg. Trace a event as:
353 * #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId, taskStatus, oldPrio, newPrio
354 * eg. Not Trace a event as:
355 * #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio)
356 * eg. Trace only you need parmas as:
357 * #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId
358 */
359#define TASK_SWITCH_PARAMS(taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus) \
360 taskId, oldPriority, oldTaskStatus, newPriority, newTaskStatus
361#define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId, taskStatus, oldPrio, newPrio
362#define TASK_CREATE_PARAMS(taskId, taskStatus, prio) taskId, taskStatus, prio
363#define TASK_DELETE_PARAMS(taskId, taskStatus, usrStack) taskId, taskStatus, usrStack
364#define TASK_SUSPEND_PARAMS(taskId, taskStatus, runTaskId) taskId, taskStatus, runTaskId
365#define TASK_RESUME_PARAMS(taskId, taskStatus, prio) taskId, taskStatus, prio
366#define TASK_SIGNAL_PARAMS(taskId, signal, schedFlag) // taskId, signal, schedFlag
367
368#define SWTMR_START_PARAMS(swtmrId, mode, interval) swtmrId, mode, interval
369#define SWTMR_DELETE_PARAMS(swtmrId) swtmrId
370#define SWTMR_EXPIRED_PARAMS(swtmrId) swtmrId
371#define SWTMR_STOP_PARAMS(swtmrId) swtmrId
372#define SWTMR_CREATE_PARAMS(swtmrId) swtmrId
373
374#define HWI_CREATE_PARAMS(hwiNum, hwiPrio, hwiMode, hwiHandler) hwiNum, hwiPrio, hwiMode, hwiHandler
375#define HWI_CREATE_SHARE_PARAMS(hwiNum, pDevId, ret) hwiNum, pDevId, ret
376#define HWI_DELETE_PARAMS(hwiNum) hwiNum
377#define HWI_DELETE_SHARE_PARAMS(hwiNum, pDevId, ret) hwiNum, pDevId, ret
378#define HWI_RESPONSE_IN_PARAMS(hwiNum) hwiNum
379#define HWI_RESPONSE_OUT_PARAMS(hwiNum) hwiNum
380#define HWI_ENABLE_PARAMS(hwiNum) hwiNum
381#define HWI_DISABLE_PARAMS(hwiNum) hwiNum
382#define HWI_TRIGGER_PARAMS(hwiNum) hwiNum
383#define HWI_SETPRI_PARAMS(hwiNum, priority) hwiNum, priority
384#define HWI_CLEAR_PARAMS(hwiNum) hwiNum
385#define HWI_SETAFFINITY_PARAMS(hwiNum, cpuMask) hwiNum, cpuMask
386#define HWI_SENDIPI_PARAMS(hwiNum, cpuMask) hwiNum, cpuMask
387
388#define EVENT_CREATE_PARAMS(eventCB) eventCB
389#define EVENT_DELETE_PARAMS(eventCB, delRetCode) eventCB, delRetCode
390#define EVENT_READ_PARAMS(eventCB, eventId, mask, mode, timeout) \
391 eventCB, eventId, mask, mode, timeout
392#define EVENT_WRITE_PARAMS(eventCB, eventId, events) eventCB, eventId, events
393#define EVENT_CLEAR_PARAMS(eventCB, eventId, events) eventCB, eventId, events
394
395#define QUEUE_CREATE_PARAMS(queueId, queueSz, itemSz, queueAddr, memType) \
396 queueId, queueSz, itemSz, queueAddr, memType
397#define QUEUE_DELETE_PARAMS(queueId, state, readable) queueId, state, readable
398#define QUEUE_RW_PARAMS(queueId, queueSize, bufSize, operateType, readable, writable, timeout) \
399 queueId, queueSize, bufSize, operateType, readable, writable, timeout
400
401#define SEM_CREATE_PARAMS(semId, type, count) semId, type, count
402#define SEM_DELETE_PARAMS(semId, delRetCode) semId, delRetCode
403#define SEM_PEND_PARAMS(semId, count, timeout) semId, count, timeout
404#define SEM_POST_PARAMS(semId, type, count) semId, type, count
405
406#define MUX_CREATE_PARAMS(muxId) muxId
407#define MUX_DELETE_PARAMS(muxId, state, count, owner) muxId, state, count, owner
408#define MUX_PEND_PARAMS(muxId, count, owner, timeout) muxId, count, owner, timeout
409#define MUX_POST_PARAMS(muxId, count, owner) muxId, count, owner
410
411#define MEM_ALLOC_PARAMS(pool, ptr, size) pool, ptr, size
412#define MEM_ALLOC_ALIGN_PARAMS(pool, ptr, size, boundary) pool, ptr, size, boundary
413#define MEM_REALLOC_PARAMS(pool, ptr, size) pool, ptr, size
414#define MEM_FREE_PARAMS(pool, ptr) pool, ptr
415#define MEM_INFO_REQ_PARAMS(pool) pool
416#define MEM_INFO_PARAMS(pool, usedSize, freeSize) pool, usedSize, freeSize
417
418#define IPC_WRITE_DROP_PARAMS(dstTid, dstPid, msgType, code, ipcStatus) \
419 dstTid, dstPid, msgType, code, ipcStatus
420#define IPC_WRITE_PARAMS(dstTid, dstPid, msgType, code, ipcStatus) \
421 dstTid, dstPid, msgType, code, ipcStatus
422#define IPC_READ_DROP_PARAMS(srcTid, srcPid, msgType, code, ipcStatus) \
423 srcTid, srcPid, msgType, code, ipcStatus
424#define IPC_READ_PARAMS(srcTid, srcPid, msgType, code, ipcStatus) \
425 srcTid, srcPid, msgType, code, ipcStatus
426#define IPC_TRY_READ_PARAMS(msgType, ipcStatus) msgType, ipcStatus
427#define IPC_READ_TIMEOUT_PARAMS(msgType, ipcStatus) msgType, ipcStatus
428#define IPC_KILL_PARAMS(msgType, ipcStatus) msgType, ipcStatus
429
430#define SYS_ERROR_PARAMS(errno) errno
431
432#ifdef LOSCFG_KERNEL_TRACE
433
434/**
435 * @ingroup los_trace
436 * @brief Trace static code stub. | 标准插桩
437 *
438 * @par Description:
439 * This API is used to instrument trace code stub in source code, to track events.
440
441 \n 1. 相比简易插桩,支持动态过滤事件和参数裁剪,但使用上需要用户按规则来扩展。
442 \n 2. TYPE用于设置具体的事件类型,可以在头文件los_trace.h中的enum LOS_TRACE_TYPE中自定义事件类型。定义方法和规则可以参考其他事件类型。
443 \n 3. IDENTITY和Params的类型及含义同简易插桩。
444
445 * @attention
446 * None.
447 *
448 * @param TYPE [IN] Type #LOS_TRACE_TYPE. The event type.
449 * @param IDENTITY [IN] Type #UINTPTR. The subject of this event description.
450 * @param ... [IN] Type #UINTPTR. This piece of event's params.
451 * @retval None.
452 *
453 * @par Dependency:
454 * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
455 */
456#define LOS_TRACE(TYPE, IDENTITY, ...) \
457 do { \
458 UINTPTR _inner[] = {0, TYPE##_PARAMS((UINTPTR)IDENTITY, ##__VA_ARGS__)}; \
459 UINTPTR _n = sizeof(_inner) / sizeof(UINTPTR); \
460 if ((_n > 1) && (g_traceEventHook != NULL)) { \
461 g_traceEventHook(TYPE, _inner[1], _n > 2 ? &_inner[2] : NULL, _n - 2); \
462 } \
463 } while (0)
464#else
465#define LOS_TRACE(TYPE, ...)
466#endif
467
468#ifdef LOSCFG_KERNEL_TRACE
469
470/**
471 * @ingroup los_trace
472 * @brief Trace static easier user-defined code stub. | 简易插桩
473 *
474 * @par Description:
475 * This API is used to instrument user-defined trace code stub in source code, to track events simply.
476 \n 1. 一句话插桩,用户在目标源代码中插入该接口即可。
477 \n 2. TYPE有效取值范围为[0, 0xF],表示不同的事件类型,不同取值表示的含义由用户自定义。
478 \n 3. IDENTITY类型UINTPTR,表示事件操作的主体对象。
479 \n 4. Params类型UINTPTR,表示事件的参数。
480 * @attention
481 * None.
482 *
483 * @param TYPE [IN] Type #UINT32. The event type, only low 4 bits take effect.
484 * @param IDENTITY [IN] Type #UINTPTR. The subject of this event description.
485 * @param ... [IN] Type #UINTPTR. This piece of event's params.
486 * @retval None.
487 *
488 * @par Dependency:
489 * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
490 */
491#define LOS_TRACE_EASY(TYPE, IDENTITY, ...) \
492 do { \
493 UINTPTR _inner[] = {0, ##__VA_ARGS__}; \
494 UINTPTR _n = sizeof(_inner) / sizeof(UINTPTR); \
495 if (g_traceEventHook != NULL) { \
496 g_traceEventHook(TRACE_USER_DEFAULT_FLAG | TYPE, (UINTPTR)IDENTITY, _n > 1 ? &_inner[1] : NULL, _n - 1); \
497 } \
498 } while (0)
499#else
500#define LOS_TRACE_EASY(...)
501#endif
502
503/**
504 * @ingroup los_trace
505 * @brief Start trace.
506 *
507 * @par Description:
508 * This API is used to start trace.
509 * @attention
510 * <ul>
511 * <li>Start trace</li>
512 * </ul>
513 *
514 * @param None.
515 * @retval #LOS_ERRNO_TRACE_ERROR_STATUS 0x02001400: Trace start failed.
516 * @retval #LOS_OK 0x00000000: Trace start success.
517 *
518 * @par Dependency:
519 * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
520 * @see LOS_TraceStart
521 */
522extern UINT32 LOS_TraceStart(VOID);
523
524/**
525 * @ingroup los_trace
526 * @brief Stop trace.
527 *
528 * @par Description:
529 * This API is used to stop trace.
530 * @attention
531 * <ul>
532 * <li>Stop trace</li>
533 * </ul>
534 *
535 * @param None.
536 * @retval #None.
537 *
538 * @par Dependency:
539 * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
540 * @see LOS_TraceStop
541 */
542extern VOID LOS_TraceStop(VOID);
543
544/**
545 * @ingroup los_trace
546 * @brief Clear the trace buf.
547 *
548 * @par Description:
549 * Clear the event frames in trace buf only at offline mode.
550 * @attention
551 * <ul>
552 * <li>This API can be called only after that trace buffer has been established.</li>
553 * Otherwise, the trace will be failed.</li>
554 * </ul>
555 *
556 * @param None.
557 * @retval #NA
558 * @par Dependency:
559 * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
560 * @see LOS_TraceReset
561 */
562extern VOID LOS_TraceReset(VOID);
563
564/**
565 * @ingroup los_trace
566 * @brief Set trace event mask.
567 *
568 * @par Description:
569 * Set trace event mask.
570 * @attention
571 * <ul>
572 * <li>Set trace event filter mask.</li>
573 * <li>The Default mask is (TRACE_HWI_FLAG | TRACE_TASK_FLAG), stands for switch on task and hwi events.</li>
574 * <li>Customize mask according to the type defined in enum LOS_TRACE_MASK to switch on corresponding module's
575 * trace.</li>
576 * <li>The system's trace mask will be overrode by the input parameter.</li>
577 * </ul>
578 *
579 * @param mask [IN] Type #UINT32. The mask used to filter events of LOS_TRACE_MASK.
580 * @retval #NA.
581 * @par Dependency:
582 * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
583 * @see LOS_TraceEventMaskSet
584 */
585extern VOID LOS_TraceEventMaskSet(UINT32 mask);
586
587/**
588 * @ingroup los_trace
589 * @brief Offline trace buffer display.
590 *
591 * @par Description:
592 * Display trace buf data only at offline mode.
593 * @attention
594 * <ul>
595 * <li>This API can be called only after that trace stopped. Otherwise the trace dump will be failed.</li>
596 * <li>Trace data will be send to pipeline when user set toClient = TRUE. Otherwise it will be formatted and printed
597 * out.</li>
598 * </ul>
599 *
600 * @param toClient [IN] Type #BOOL. Whether send trace data to Client through pipeline.
601 * @retval #NA
602 *
603 * @par Dependency:
604 * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
605 * @see LOS_TraceRecordDump
606 */
607extern VOID LOS_TraceRecordDump(BOOL toClient);
608
609/**
610 * @ingroup los_trace
611 * @brief Offline trace buffer export.
612 *
613 * @par Description:
614 * Return the trace buf only at offline mode.
615 * @attention
616 * <ul>
617 * <li>This API can be called only after that trace buffer has been established. </li>
618 * <li>The return buffer's address is a critical resource, user can only ready.</li>
619 * </ul>
620 *
621 * @param NA
622 * @retval #OfflineHead* The trace buffer's address, analyze this buffer according to the structure of
623 * OfflineHead.
624 *
625 * @par Dependency:
626 * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
627 * @see LOS_TraceRecordGet
628 */
629extern OfflineHead *LOS_TraceRecordGet(VOID);
630
631/**
632 * @ingroup los_trace
633 * @brief Hwi num fliter hook.
634 *
635 * @par Description:
636 * Hwi fliter function.
637 * @attention
638 * <ul>
639 * <li>Filter the hwi events by hwi num</li>
640 * </ul>
641 *
642 * @param hook [IN] Type #TRACE_HWI_FILTER_HOOK. The user defined hook for hwi num filter,
643 * the hook should return true if you don't want trace this hwi num.
644 * @retval #None
645 * @par Dependency:
646 * <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
647 * @see LOS_TraceHwiFilterHookReg
648 */
650#ifdef __cplusplus
651#if __cplusplus
652}
653#endif /* __cplusplus */
654#endif /* __cplusplus */
655
656#endif /* _LOS_TRACE_H */
BOOL(* TRACE_HWI_FILTER_HOOK)(UINT32 hwiNum)
Define the type of trace hardware interrupt filter hook function.
Definition: los_trace.h:336
OfflineHead * LOS_TraceRecordGet(VOID)
Offline trace buffer export.
Definition: los_trace.c:412
LOS_TRACE_MASK
Definition: los_trace.h:121
VOID LOS_TraceEventMaskSet(UINT32 mask)
Set trace event mask.
Definition: los_trace.c:398
VOID LOS_TraceReset(VOID)
Clear the trace buf.
Definition: los_trace.c:417
UINT32 LOS_TraceStart(VOID)
Start trace.
Definition: los_trace.c:353
VOID LOS_TraceHwiFilterHookReg(TRACE_HWI_FILTER_HOOK hook)
Hwi num fliter hook.
Definition: los_trace.c:427
LOS_TRACE_TYPE
Definition: los_trace.h:147
TraceState
Definition: los_trace.h:109
VOID LOS_TraceStop(VOID)
Stop trace.
Definition: los_trace.c:382
VOID LOS_TraceRecordDump(BOOL toClient)
Offline trace buffer display.
Definition: los_trace.c:403
@ TRACE_MEM_FLAG
跟踪内存
Definition: los_trace.h:126
@ TRACE_MUX_FLAG
跟踪互斥量
Definition: los_trace.h:130
@ TRACE_HWI_FLAG
跟踪硬中断
Definition: los_trace.h:123
@ TRACE_SWTMR_FLAG
跟踪软件定时器
Definition: los_trace.h:125
@ TRACE_IPC_FLAG
跟踪IPC
Definition: los_trace.h:131
@ TRACE_QUE_FLAG
跟踪队列
Definition: los_trace.h:127
@ TRACE_SYS_FLAG
跟踪系统
Definition: los_trace.h:122
@ TRACE_USER_DEFAULT_FLAG
Definition: los_trace.h:134
@ TRACE_SEM_FLAG
跟踪信号量
Definition: los_trace.h:129
@ TRACE_TASK_FLAG
跟踪任务/线程
Definition: los_trace.h:124
@ TRACE_EVENT_FLAG
跟踪事件
Definition: los_trace.h:128
@ TRACE_MAX_FLAG
Definition: los_trace.h:133
@ QUEUE_DELETE
Definition: los_trace.h:194
@ HWI_DELETE_SHARE
Definition: los_trace.h:157
@ HWI_SETAFFINITY
Definition: los_trace.h:165
@ HWI_SENDIPI
Definition: los_trace.h:166
@ SEM_CREATE
Definition: los_trace.h:205
@ MEM_INFO
Definition: los_trace.h:190
@ TASK_SUSPEND
Definition: los_trace.h:172
@ SEM_DELETE
Definition: los_trace.h:206
@ IPC_READ_TIMEOUT
Definition: los_trace.h:222
@ HWI_CREATE_SHARE
Definition: los_trace.h:155
@ MEM_ALLOC
Definition: los_trace.h:185
@ QUEUE_CREATE
Definition: los_trace.h:193
@ IPC_TRY_READ
Definition: los_trace.h:221
@ TASK_DELETE
Definition: los_trace.h:171
@ EVENT_DELETE
Definition: los_trace.h:199
@ TASK_PRIOSET
Definition: los_trace.h:170
@ MUX_DELETE
Definition: los_trace.h:212
@ IPC_READ_DROP
Definition: los_trace.h:219
@ EVENT_CREATE
Definition: los_trace.h:198
@ TASK_CREATE
Definition: los_trace.h:169
@ SYS_ERROR
Definition: los_trace.h:149
@ IPC_WRITE_DROP
Definition: los_trace.h:217
@ SWTMR_STOP
Definition: los_trace.h:181
@ MEM_REALLOC
Definition: los_trace.h:187
@ IPC_READ
Definition: los_trace.h:220
@ QUEUE_RW
Definition: los_trace.h:195
@ HWI_RESPONSE_OUT
Definition: los_trace.h:159
@ MEM_INFO_REQ
Definition: los_trace.h:189
@ TASK_RESUME
Definition: los_trace.h:173
@ IPC_WRITE
Definition: los_trace.h:218
@ MUX_CREATE
Definition: los_trace.h:211
@ SWTMR_DELETE
Definition: los_trace.h:179
@ MUX_PEND
Definition: los_trace.h:213
@ SYS_STOP
trace模块停止
Definition: los_trace.h:151
@ HWI_ENABLE
Definition: los_trace.h:160
@ SWTMR_EXPIRED
Definition: los_trace.h:182
@ SEM_PEND
Definition: los_trace.h:207
@ SWTMR_START
Definition: los_trace.h:180
@ TASK_SIGNAL
Definition: los_trace.h:175
@ SWTMR_CREATE
Definition: los_trace.h:178
@ HWI_SETPRI
Definition: los_trace.h:163
@ HWI_TRIGGER
Definition: los_trace.h:162
@ EVENT_CLEAR
Definition: los_trace.h:202
@ EVENT_READ
Definition: los_trace.h:200
@ SEM_POST
Definition: los_trace.h:208
@ SYS_START
trace模块开始
Definition: los_trace.h:150
@ IPC_KILL
Definition: los_trace.h:223
@ HWI_RESPONSE_IN
Definition: los_trace.h:158
@ MUX_POST
Definition: los_trace.h:214
@ MEM_ALLOC_ALIGN
Definition: los_trace.h:186
@ HWI_DELETE
Definition: los_trace.h:156
@ EVENT_WRITE
Definition: los_trace.h:201
@ TASK_SWITCH
Definition: los_trace.h:174
@ HWI_DISABLE
Definition: los_trace.h:161
@ MEM_FREE
Definition: los_trace.h:188
@ HWI_CREATE
Definition: los_trace.h:154
@ HWI_CLEAR
Definition: los_trace.h:164
@ TRACE_UNINIT
Definition: los_trace.h:110
@ TRACE_INITED
Definition: los_trace.h:111
@ TRACE_STOPED
Definition: los_trace.h:113
@ TRACE_STARTED
Definition: los_trace.h:112
VOID(* TRACE_EVENT_HOOK)(UINT32 eventType, UINTPTR identity, const UINTPTR *params, UINT16 paramCount)
Definition: los_trace.h:338
TRACE_EVENT_HOOK g_traceEventHook
事件钩子函数
Definition: los_trace.c:91
unsigned short UINT16
Definition: los_typedef.h:56
long unsigned int UINT64
Definition: los_typedef.h:66
unsigned long UINTPTR
Definition: los_typedef.h:68
unsigned int UINT32
Definition: los_typedef.h:57
char CHAR
Definition: los_typedef.h:63
size_t BOOL
Definition: los_typedef.h:88
UINT32 id
Definition: los_trace.h:298
UINT32 prio
Definition: los_trace.h:299
TraceBaseHeaderInfo baseInfo
Definition: los_trace.h:308
UINT16 totalLen
Definition: los_trace.h:309
UINT16 objOffset
Definition: los_trace.h:312
UINT16 frameOffset
Definition: los_trace.h:313
UINT16 frameSize
Definition: los_trace.h:311
UINT16 objSize
Definition: los_trace.h:310
http://weharmonyos.com/openharmony/zh-cn/device-dev/kernel/kernel-mini-memory-trace....
Definition: los_trace.h:244
UINT32 bigLittleEndian
Definition: los_trace.h:245
UINT64 curTime
Definition: los_trace.h:259
UINT32 eventCount
Definition: los_trace.h:272
UINTPTR identity
Definition: los_trace.h:260
UINT32 curTask
Definition: los_trace.h:257
UINT32 eventType
Definition: los_trace.h:256
UINTPTR identity
表示事件操作的主体对象
Definition: los_trace.h:287
UINT32 eventType
表示的具体事件
Definition: los_trace.h:286