更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_trace_pri.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#ifndef _LOS_TRACE_PRI_H
33#define _LOS_TRACE_PRI_H
34
35#include "los_trace.h"
36#include "los_task_pri.h"
37
38#ifdef __cplusplus
39#if __cplusplus
40extern "C" {
41#endif /* __cplusplus */
42#endif /* __cplusplus */
43
44#ifdef LOSCFG_TRACE_CONTROL_AGENT
45#define TRACE_CMD_END_CHAR 0xD
46#endif
47
48#define TRACE_ERROR PRINT_ERR
49#define TRACE_MODE_OFFLINE 0
50#define TRACE_MODE_ONLINE 1
51
52/* just task and hwi were traced */
53#define TRACE_DEFAULT_MASK (TRACE_HWI_FLAG | TRACE_TASK_FLAG)
54#define TRACE_CTL_MAGIC_NUM 0xDEADBEEF
55#define TRACE_BIGLITTLE_WORD 0x12345678
56#define TRACE_VERSION(MODE) (0xFFFFFFFF & (MODE))
57#define TRACE_MASK_COMBINE(c1, c2, c3, c4) (((c1) << 24) | ((c2) << 16) | ((c3) << 8) | (c4))
58
59#define TRACE_GET_MODE_FLAG(type) ((type) & 0xFFFFFFF0)
60
61#ifdef LOSCFG_KERNEL_SMP
63#define TRACE_LOCK(state) LOS_SpinLockSave(&g_traceSpin, &(state))
64#define TRACE_UNLOCK(state) LOS_SpinUnlockRestore(&g_traceSpin, (state))
65#else
66#define TRACE_LOCK(state) (state) = LOS_IntLock()
67#define TRACE_UNLOCK(state) LOS_IntRestore(state)
68#endif
69
70typedef VOID (*TRACE_DUMP_HOOK)(BOOL toClient);
72
79};
80
81/**
82 * @ingroup los_trace
83 * struct to store the trace cmd from traceClient.
84 */
85typedef struct {
94
95/**
96 * @ingroup los_trace
97 * struct to store the event infomation
98 */
99typedef struct {
100 UINT32 cmd; /* trace start or stop cmd | 开始和结束跟踪命令*/
101 UINT32 param; /* magic numb stand for notify msg | 命令参数*/
103
104/**
105 * @ingroup los_trace
106 * struct to store the trace config information. | 离线模式是将数据保存在缓存中,需要信息来记录整体数据.
107 */
108typedef struct {
109 struct WriteCtrl {//内容控制器
110 UINT16 curIndex; /* The current record index | 当前帧数据索引位*/
111 UINT16 maxRecordCount; /* The max num of trace items | 记录帧数据上限数*/
112 UINT16 curObjIndex; /* The current obj index | 当前对象索引位*/
113 UINT16 maxObjCount; /* The max num of obj index | 对象上限数*/
114 ObjData *objBuf; /* Pointer to obj info data | 循环buf,数组保存任务数据 ObjData*/
115 TraceEventFrame *frameBuf; /* Pointer to the trace items | 循环buf,数组保存帧数据 TraceEventFrame*/
116 } ctrl;
117 OfflineHead *head;///< 离线模式头部信息
119
120extern UINT32 OsTraceGetMaskTid(UINT32 taskId);
121extern VOID OsTraceSetObj(ObjData *obj, const LosTaskCB *tcb);
122extern VOID OsTraceWriteOrSendEvent(const TraceEventFrame *frame);
123extern VOID OsTraceObjAdd(UINT32 eventType, UINT32 taskId);
124extern BOOL OsTraceIsEnable(VOID);
125extern OfflineHead *OsTraceRecordGet(VOID);
126
127#ifdef LOSCFG_RECORDER_MODE_ONLINE
128extern VOID OsTraceSendHead(VOID);
129extern VOID OsTraceSendObjTable(VOID);
130extern VOID OsTraceSendNotify(UINT32 type, UINT32 value);
131/// 在线模式下,通知系统trace开始
132#define OsTraceNotifyStart() do { \
133 OsTraceSendNotify(SYS_START, TRACE_CTL_MAGIC_NUM); \
134 OsTraceSendHead(); \
135 OsTraceSendObjTable(); \
136 } while (0)
137/// 在线模式下,通知系统trace结束
138#define OsTraceNotifyStop() do { \
139 OsTraceSendNotify(SYS_STOP, TRACE_CTL_MAGIC_NUM); \
140 } while (0)
141
142#define OsTraceReset()
143#define OsTraceRecordDump(toClient)
144#else
145extern UINT32 OsTraceBufInit(UINT32 size);
146extern VOID OsTraceReset(VOID);
147extern VOID OsTraceRecordDump(BOOL toClient);
148#define OsTraceNotifyStart()
149#define OsTraceNotifyStop()
150#endif
151
152#ifdef __cplusplus
153#if __cplusplus
154}
155#endif /* __cplusplus */
156#endif /* __cplusplus */
157
158#endif /* _LOS_TRACE_PRI_H */
UINT32 OsTraceBufInit(UINT32 size)
trace离线模式初始化
Definition: trace_offline.c:63
VOID(* TRACE_DUMP_HOOK)(BOOL toClient)
Definition: los_trace_pri.h:70
VOID OsTraceSendObjTable(VOID)
发送所有任务对象至串口
Definition: trace_online.c:87
VOID OsTraceReset(VOID)
重置循环buf
TraceCmd
Definition: los_trace_pri.h:73
@ TRACE_CMD_STOP
Definition: los_trace_pri.h:75
@ TRACE_CMD_SET_EVENT_MASK
Definition: los_trace_pri.h:76
@ TRACE_CMD_START
Definition: los_trace_pri.h:74
@ TRACE_CMD_MAX_CODE
Definition: los_trace_pri.h:78
@ TRACE_CMD_RECODE_DUMP
Definition: los_trace_pri.h:77
TRACE_DUMP_HOOK g_traceDumpHook
输出缓冲区数据
Definition: los_trace.c:92
OfflineHead * OsTraceRecordGet(VOID)
VOID OsTraceSendHead(VOID)
发送头信息
Definition: trace_online.c:58
VOID OsTraceRecordDump(BOOL toClient)
VOID OsTraceSendNotify(UINT32 type, UINT32 value)
发送通知类信息(启动,停止 trace 等通知)
Definition: trace_online.c:69
UINT32 OsTraceGetMaskTid(UINT32 taskId)
Definition: trace_offline.c:58
VOID OsTraceObjAdd(UINT32 eventType, UINT32 taskId)
添加一个任务
VOID OsTraceWriteOrSendEvent(const TraceEventFrame *frame)
离线模式下保存帧数据 @note_thinking 此处未封装好,会懵逼,文件名中体现了对离线模式的保存或对在线模式的发送这样真的好吗? .
SPIN_LOCK_S g_traceSpin
BOOL OsTraceIsEnable(VOID)
Definition: los_trace.c:215
VOID OsTraceSetObj(ObjData *obj, const LosTaskCB *tcb)
Definition: los_trace.c:161
unsigned short UINT16
Definition: los_typedef.h:56
unsigned char UINT8
Definition: los_typedef.h:55
unsigned int UINT32
Definition: los_typedef.h:57
size_t BOOL
Definition: los_typedef.h:88
OfflineHead * head
离线模式头部信息