更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_queue_debug.c 文件参考

浏览源代码.

结构体

struct  QueueDebugCB
 

函数

STATIC BOOL QueueCompareValue (const IpcSortParam *sortParam, UINT32 left, UINT32 right)
 
UINT32 OsQueueDbgInit (VOID)
 
VOID OsQueueDbgTimeUpdate (UINT32 queueID)
 
VOID OsQueueDbgUpdate (UINT32 queueID, TSK_ENTRY_FUNC entry)
 
STATIC INLINE VOID OsQueueInfoOutPut (const LosQueueCB *node)
 
STATIC INLINE VOID OsQueueOpsOutput (const QueueDebugCB *node)
 
STATIC VOID SortQueueIndexArray (UINT32 *indexArray, UINT32 count)
 
VOID OsQueueCheck (VOID)
 
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdQueueInfoGet (UINT32 argc, const CHAR **argv)
 
 SHELLCMD_ENTRY (queue_shellcmd, CMD_TYPE_EX, "queue", 0,(CmdCallBackFunc) OsShellCmdQueueInfoGet)
 

变量

STATIC QueueDebugCBg_queueDebugArray = NULL
 

函数说明

◆ OsQueueCheck()

VOID OsQueueCheck ( VOID  )

在文件 los_queue_debug.c130 行定义.

131{
132 LosQueueCB queueNode = {0};
133 QueueDebugCB queueDebugNode = {0};
134 UINT32 index, intSave;
135 UINT32 count = 0;
136
137 /*
138 * This return value does not need to be judged immediately,
139 * and the following code logic has already distinguished the return value from null and non-empty,
140 * and there is no case of accessing the null pointer.
141 */
142 UINT32 *indexArray = (UINT32 *)LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, LOSCFG_BASE_IPC_QUEUE_LIMIT * sizeof(UINT32));
143
144 for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_LIMIT; index++) {
145 SCHEDULER_LOCK(intSave);
146 (VOID)memcpy_s(&queueNode, sizeof(LosQueueCB),
147 GET_QUEUE_HANDLE(index), sizeof(LosQueueCB));
148 (VOID)memcpy_s(&queueDebugNode, sizeof(QueueDebugCB),
149 &g_queueDebugArray[index], sizeof(QueueDebugCB));
150 SCHEDULER_UNLOCK(intSave);
151 if ((queueNode.queueState == OS_QUEUE_UNUSED) ||
152 ((queueNode.queueState == OS_QUEUE_INUSED) && (queueDebugNode.creater == NULL))) {
153 continue;
154 }
155 if ((queueNode.queueState == OS_QUEUE_INUSED) &&
156 (queueNode.queueLen == queueNode.readWriteableCnt[OS_QUEUE_WRITE]) &&
159 LOS_ListEmpty(&queueNode.memList)) {
160 PRINTK("Queue ID <0x%x> may leak, No task uses it, "
161 "QueueLen is 0x%x, ",
162 queueNode.queueID,
163 queueNode.queueLen);
164 OsQueueOpsOutput(&queueDebugNode);
165 } else {
166 if (indexArray != NULL) {
167 *(indexArray + count) = index;
168 count++;
169 } else {
170 OsQueueInfoOutPut(&queueNode);
171 OsQueueOpsOutput(&queueDebugNode);
172 }
173 }
174 }
175
176 if (indexArray != NULL) {
177 SortQueueIndexArray(indexArray, count);
178 }
179
180 return;
181}
LITE_OS_SEC_ALW_INLINE STATIC INLINE BOOL LOS_ListEmpty(LOS_DL_LIST *list)
Identify whether a specified doubly linked list is empty. | 判断链表是否为空
Definition: los_list.h:321
VOID * LOS_MemAlloc(VOID *pool, UINT32 size)
从指定内存池中申请size长度的内存,注意这可不是从内核堆空间中申请内存
Definition: los_memory.c:1123
STATIC QueueDebugCB * g_queueDebugArray
STATIC VOID SortQueueIndexArray(UINT32 *indexArray, UINT32 count)
STATIC INLINE VOID OsQueueInfoOutPut(const LosQueueCB *node)
STATIC INLINE VOID OsQueueOpsOutput(const QueueDebugCB *node)
@ OS_QUEUE_WRITE
写队列
Definition: los_queue_pri.h:64
@ OS_QUEUE_READ
读队列
Definition: los_queue_pri.h:63
unsigned int UINT32
Definition: los_typedef.h:57
UINT16 readWriteableCnt[OS_QUEUE_N_RW]
Definition: los_queue_pri.h:96
UINT16 queueLen
Definition: los_queue_pri.h:91
LOS_DL_LIST memList
UINT16 queueState
Definition: los_queue_pri.h:90
UINT32 queueID
Definition: los_queue_pri.h:93
LOS_DL_LIST readWriteList[OS_QUEUE_N_RW]
Definition: los_queue_pri.h:98
TSK_ENTRY_FUNC creater
函数调用图:
这是这个函数的调用关系图:

◆ OsQueueDbgInit()

UINT32 OsQueueDbgInit ( VOID  )

在文件 los_queue_debug.c54 行定义.

55{
56 UINT32 size = LOSCFG_BASE_IPC_QUEUE_LIMIT * sizeof(QueueDebugCB);
57 /* system resident memory, don't free */
59 if (g_queueDebugArray == NULL) {
60 PRINT_ERR("%s: malloc failed!\n", __FUNCTION__);
61 return LOS_NOK;
62 }
63 (VOID)memset_s(g_queueDebugArray, size, 0, size);
64 return LOS_OK;
65}
UINT8 * m_aucSysMem1
系统动态内存池地址的起始地址 @note_thinking 能否不要用 0,1来命名核心变量 ???
Definition: los_memory.c:108
函数调用图:
这是这个函数的调用关系图:

◆ OsQueueDbgTimeUpdate()

VOID OsQueueDbgTimeUpdate ( UINT32  queueID)

在文件 los_queue_debug.c67 行定义.

68{
69 QueueDebugCB *queueDebug = &g_queueDebugArray[GET_QUEUE_INDEX(queueID)];
70 queueDebug->lastAccessTime = LOS_TickCountGet();
71 return;
72}
LITE_OS_SEC_TEXT_MINOR UINT64 LOS_TickCountGet(VOID)
获取自系统启动以来的Tick数
Definition: los_sys.c:82
UINT64 lastAccessTime
函数调用图:
这是这个函数的调用关系图:

◆ OsQueueDbgUpdate()

VOID OsQueueDbgUpdate ( UINT32  queueID,
TSK_ENTRY_FUNC  entry 
)

在文件 los_queue_debug.c74 行定义.

75{
76 QueueDebugCB *queueDebug = &g_queueDebugArray[GET_QUEUE_INDEX(queueID)];
77 queueDebug->creater = entry;
78 queueDebug->lastAccessTime = LOS_TickCountGet();
79 return;
80}
函数调用图:
这是这个函数的调用关系图:

◆ OsQueueInfoOutPut()

STATIC INLINE VOID OsQueueInfoOutPut ( const LosQueueCB node)

在文件 los_queue_debug.c82 行定义.

83{
84 PRINTK("Queue ID <0x%x> may leak, queue len is 0x%x, "
85 "readable cnt:0x%x, writable cnt:0x%x, ",
86 node->queueID,
87 node->queueLen,
90}
这是这个函数的调用关系图:

◆ OsQueueOpsOutput()

STATIC INLINE VOID OsQueueOpsOutput ( const QueueDebugCB node)

在文件 los_queue_debug.c92 行定义.

93{
94 PRINTK("TaskEntry of creater:0x%p, Latest operation time: 0x%llx\n",
95 node->creater, node->lastAccessTime);
96}
这是这个函数的调用关系图:

◆ OsShellCmdQueueInfoGet()

LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdQueueInfoGet ( UINT32  argc,
const CHAR **  argv 
)

在文件 los_queue_debug.c184 行定义.

185{
186 if (argc > 0) {
187 PRINTK("\nUsage: queue\n");
188 return OS_ERROR;
189 }
190 PRINTK("used queues information: \n");
191 OsQueueCheck();
192 return LOS_OK;
193}
VOID OsQueueCheck(VOID)
函数调用图:

◆ QueueCompareValue()

STATIC BOOL QueueCompareValue ( const IpcSortParam sortParam,
UINT32  left,
UINT32  right 
)

在文件 los_queue_debug.c48 行定义.

49{
50 return (*((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, left)) >
51 *((UINT64 *)(VOID *)SORT_ELEM_ADDR(sortParam, right)));
52}
long unsigned int UINT64
Definition: los_typedef.h:66
这是这个函数的调用关系图:

◆ SHELLCMD_ENTRY()

SHELLCMD_ENTRY ( queue_shellcmd  ,
CMD_TYPE_EX  ,
"queue"  ,
,
(CmdCallBackFunc OsShellCmdQueueInfoGet 
)

◆ SortQueueIndexArray()

STATIC VOID SortQueueIndexArray ( UINT32 indexArray,
UINT32  count 
)

在文件 los_queue_debug.c98 行定义.

99{
100 LosQueueCB queueNode = {0};
101 QueueDebugCB queueDebugNode = {0};
102 UINT32 index, intSave;
103 IpcSortParam queueSortParam;
104 queueSortParam.buf = (CHAR *)g_queueDebugArray;
105 queueSortParam.ipcDebugCBSize = sizeof(QueueDebugCB);
106 queueSortParam.ipcDebugCBCnt = LOSCFG_BASE_IPC_SEM_LIMIT;
107 queueSortParam.sortElemOff = LOS_OFF_SET_OF(QueueDebugCB, lastAccessTime);
108
109 if (count > 0) {
110 SCHEDULER_LOCK(intSave);
111 OsArraySortByTime(indexArray, 0, count - 1, &queueSortParam, QueueCompareValue);
112 SCHEDULER_UNLOCK(intSave);
113 for (index = 0; index < count; index++) {
114 SCHEDULER_LOCK(intSave);
115 (VOID)memcpy_s(&queueNode, sizeof(LosQueueCB),
116 GET_QUEUE_HANDLE(indexArray[index]), sizeof(LosQueueCB));
117 (VOID)memcpy_s(&queueDebugNode, sizeof(QueueDebugCB),
118 &g_queueDebugArray[indexArray[index]], sizeof(QueueDebugCB));
119 SCHEDULER_UNLOCK(intSave);
120 if (queueNode.queueState == OS_QUEUE_UNUSED) {
121 continue;
122 }
123 OsQueueInfoOutPut(&queueNode);
124 OsQueueOpsOutput(&queueDebugNode);
125 }
126 }
127 (VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, indexArray);
128}
UINT32 LOS_MemFree(VOID *pool, VOID *ptr)
释放从指定动态内存中申请的内存
Definition: los_memory.c:1369
VOID OsArraySortByTime(UINT32 *sortArray, UINT32 start, UINT32 end, const IpcSortParam *sortParam, OsCompareFunc compareFunc)
Definition: los_ipcdebug.c:37
STATIC BOOL QueueCompareValue(const IpcSortParam *sortParam, UINT32 left, UINT32 right)
char CHAR
Definition: los_typedef.h:63
size_t ipcDebugCBCnt
size_t ipcDebugCBSize
函数调用图:
这是这个函数的调用关系图:

变量说明

◆ g_queueDebugArray

STATIC QueueDebugCB* g_queueDebugArray = NULL

在文件 los_queue_debug.c46 行定义.