From afbc9a593b61461072556cb5531d90b30ce2e394 Mon Sep 17 00:00:00 2001 From: LiteOS2021 Date: Wed, 13 Oct 2021 16:00:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96trace=20buffer?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=EF=BC=8C=E5=88=A0=E9=99=A4swtmr=20?= =?UTF-8?q?=E6=A1=A9=E4=B8=AD=E7=9A=84=E6=97=A0=E6=95=88=E5=8F=82=E6=95=B0?= =?UTF-8?q?=20close=20#I4DPR7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LiteOS2021 --- components/trace/cnv/trace_cnv.c | 2 +- components/trace/los_trace.c | 15 ++++++++------- components/trace/los_trace.h | 29 +---------------------------- components/trace/los_trace_pri.h | 3 ++- components/trace/trace_offline.c | 10 ++++------ components/trace/trace_online.c | 7 ------- kernel/src/los_init.c | 4 ++-- 7 files changed, 18 insertions(+), 52 deletions(-) diff --git a/components/trace/cnv/trace_cnv.c b/components/trace/cnv/trace_cnv.c index 3be7a07a..30416334 100644 --- a/components/trace/cnv/trace_cnv.c +++ b/components/trace/cnv/trace_cnv.c @@ -218,7 +218,7 @@ STATIC VOID LOS_TraceSwtmrExpired(const SWTMR_CTRL_S *swtmr) STATIC VOID LOS_TraceSwtmrStart(const SWTMR_CTRL_S *swtmr) { - LOS_TRACE(SWTMR_START, swtmr->usTimerID, swtmr->ucMode, swtmr->uwCount, swtmr->uwInterval, 0); + LOS_TRACE(SWTMR_START, swtmr->usTimerID, swtmr->ucMode, swtmr->uwInterval); } STATIC VOID LOS_TraceSwtmrStop(const SWTMR_CTRL_S *swtmr) diff --git a/components/trace/los_trace.c b/components/trace/los_trace.c index 838db540..523eea95 100644 --- a/components/trace/los_trace.c +++ b/components/trace/los_trace.c @@ -240,7 +240,7 @@ STATIC UINT32 OsCreateTraceAgentTask(VOID) } #endif -UINT32 LOS_TraceInit(VOID *buf, UINT32 size) +UINT32 OsTraceInit(VOID) { UINT32 intSave; UINT32 ret; @@ -267,10 +267,15 @@ UINT32 LOS_TraceInit(VOID *buf, UINT32 size) } #endif - ret = OsTraceBufInit(buf, size); +#if (LOSCFG_RECORDER_MODE_OFFLINE == 1) + ret = OsTraceBufInit(LOSCFG_TRACE_BUFFER_SIZE); if (ret != LOS_OK) { - goto LOS_RELEASE; +#if (LOSCFG_TRACE_CONTROL_AGENT == 1) + (VOID)LOS_TaskDelete(g_traceTaskId); +#endif + goto LOS_ERREND; } +#endif OsTraceHookInstall(); OsTraceCnvInit(); @@ -286,10 +291,6 @@ UINT32 LOS_TraceInit(VOID *buf, UINT32 size) #endif TRACE_UNLOCK(intSave); return LOS_OK; -LOS_RELEASE: -#if (LOSCFG_TRACE_CONTROL_AGENT == 1) - LOS_TaskDelete(g_traceTaskId); -#endif LOS_ERREND: TRACE_UNLOCK(intSave); return ret; diff --git a/components/trace/los_trace.h b/components/trace/los_trace.h index cc13a126..fd8ead92 100644 --- a/components/trace/los_trace.h +++ b/components/trace/los_trace.h @@ -320,7 +320,7 @@ extern TRACE_EVENT_HOOK g_traceEventHook; #define TASK_RESUME_PARAMS(taskId, taskStatus, prio) taskId, taskStatus, prio #define TASK_SIGNAL_PARAMS(taskId, signal, schedFlag) // taskId, signal, schedFlag -#define SWTMR_START_PARAMS(swtmrId, mode, overrun, interval, expiry) swtmrId, mode, overrun, interval, expiry +#define SWTMR_START_PARAMS(swtmrId, mode, interval) swtmrId, mode, interval #define SWTMR_DELETE_PARAMS(swtmrId) swtmrId #define SWTMR_EXPIRED_PARAMS(swtmrId) swtmrId #define SWTMR_STOP_PARAMS(swtmrId) swtmrId @@ -434,33 +434,6 @@ extern TRACE_EVENT_HOOK g_traceEventHook; #define LOS_TRACE_EASY(...) #endif -/** - * @ingroup los_trace - * @brief Intialize the trace when the system startup. - * - * @par Description: - * This API is used to intilize the trace for system level. - * @attention - * - * - * @param buf [IN] Type #VOID *. The ptr is trace buffer address, if ptr is NULL, system will malloc a new one in - * trace offline mode. - * @param size [IN] Type #UINT32. The trace buffer's size. - * - * @retval #LOS_ERRNO_TRACE_ERROR_STATUS 0x02001400: The trace status is not TRACE_UNINIT. - * @retval #LOS_ERRNO_TRACE_NO_MEMORY 0x02001401: The memory is not enough for initilize. - * @retval #LOS_ERRNO_TRACE_BUF_TOO_SMALL 0x02001402: Trace buf size not enough. - * @retval #LOS_ERRNO_TSK_TCB_UNAVAILABLE 0x02000211: No free task control block is available. - * @retval #LOS_ERRNO_TSK_MP_SYNC_RESOURCE 0x02000225: Mp sync resource create failed - * @retval #LOS_OK 0x00000000: The intialization is successful. - * @par Dependency: - * - * @see LOS_TraceInit - */ -extern UINT32 LOS_TraceInit(VOID *buf, UINT32 size); - /** * @ingroup los_trace * @brief Start trace. diff --git a/components/trace/los_trace_pri.h b/components/trace/los_trace_pri.h index 6d8d1abd..a011e425 100644 --- a/components/trace/los_trace_pri.h +++ b/components/trace/los_trace_pri.h @@ -119,10 +119,10 @@ typedef struct { OfflineHead *head; } TraceOfflineHeaderInfo; +extern UINT32 OsTraceInit(VOID); extern UINT32 OsTraceGetMaskTid(UINT32 taskId); extern VOID OsTraceSetObj(ObjData *obj, const LosTaskCB *tcb); extern VOID OsTraceWriteOrSendEvent(const TraceEventFrame *frame); -extern UINT32 OsTraceBufInit(VOID *buf, UINT32 size); extern VOID OsTraceObjAdd(UINT32 eventType, UINT32 taskId); extern BOOL OsTraceIsEnable(VOID); extern OfflineHead *OsTraceRecordGet(VOID); @@ -145,6 +145,7 @@ extern VOID OsTraceSendNotify(UINT32 type, UINT32 value); #define OsTraceReset() #define OsTraceRecordDump(toClient) #else +extern UINT32 OsTraceBufInit(UINT32 size); extern VOID OsTraceReset(VOID); extern VOID OsTraceRecordDump(BOOL toClient); #define OsTraceNotifyStart() diff --git a/components/trace/trace_offline.c b/components/trace/trace_offline.c index 0d972996..37d361e6 100644 --- a/components/trace/trace_offline.c +++ b/components/trace/trace_offline.c @@ -49,21 +49,19 @@ UINT32 OsTraceGetMaskTid(UINT32 tid) return tid | ((tid < LOSCFG_BASE_CORE_TSK_LIMIT) ? g_tidMask[tid] << BITS_NUM_FOR_TASK_ID : 0); /* tid < 65535 */ } -UINT32 OsTraceBufInit(VOID *buf, UINT32 size) +UINT32 OsTraceBufInit(UINT32 size) { UINT32 headSize; - + VOID *buf = NULL; headSize = sizeof(OfflineHead) + sizeof(ObjData) * LOSCFG_TRACE_OBJ_MAX_NUM; if (size <= headSize) { TRACE_ERROR("trace buf size not enough than 0x%x\n", headSize); return LOS_ERRNO_TRACE_BUF_TOO_SMALL; } + buf = LOS_MemAlloc(m_aucSysMem0, size); if (buf == NULL) { - buf = LOS_MemAlloc(m_aucSysMem0, size); - if (buf == NULL) { - return LOS_ERRNO_TRACE_NO_MEMORY; - } + return LOS_ERRNO_TRACE_NO_MEMORY; } (VOID)memset_s(buf, size, 0, size); diff --git a/components/trace/trace_online.c b/components/trace/trace_online.c index 57be79ec..a8d23edd 100644 --- a/components/trace/trace_online.c +++ b/components/trace/trace_online.c @@ -44,13 +44,6 @@ UINT32 OsTraceGetMaskTid(UINT32 taskId) return taskId; } -UINT32 OsTraceBufInit(VOID *buf, UINT32 size) -{ - (VOID)buf; - (VOID)size; - return LOS_OK; -} - VOID OsTraceSendHead(VOID) { TraceBaseHeaderInfo head = { diff --git a/kernel/src/los_init.c b/kernel/src/los_init.c index 72e143af..f4ae35fb 100644 --- a/kernel/src/los_init.c +++ b/kernel/src/los_init.c @@ -187,9 +187,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID) } #if (LOSCFG_KERNEL_TRACE == 1) - ret = LOS_TraceInit(NULL, LOSCFG_TRACE_BUFFER_SIZE); + ret = OsTraceInit(LOSCFG_TRACE_BUFFER_SIZE); if (ret != LOS_OK) { - PRINT_ERR("LOS_TraceInit error\n"); + PRINT_ERR("OsTraceInit error\n"); return ret; } #endif -- GitLab