WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
Trace
Trace 的协作图:

结构体

struct  TraceClientCmd
 
struct  TraceNotifyFrame
 
struct  TraceOfflineHeaderInfo
 
struct  TraceBaseHeaderInfo
 
struct  TraceEventFrame
 
struct  ObjData
 
struct  OfflineHead
 

宏定义

#define _T(x)   x
 
#define LOSCFG_TRACE_OBJ_MAX_NUM   0
 
#define LOSCFG_TRACE_TLV_BUF_SIZE   100
 
#define LOS_ERRNO_TRACE_ERROR_STATUS   LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x00)
 
#define LOS_ERRNO_TRACE_NO_MEMORY   LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x01)
 
#define LOS_ERRNO_TRACE_BUF_TOO_SMALL   LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x02)
 
#define LOS_ERRNO_TRACE_BUF_IS_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x03)
 

类型定义

typedef BOOL(* TRACE_HWI_FILTER_HOOK) (UINT32 hwiNum)
 Define the type of trace hardware interrupt filter hook function.
 

枚举

enum  TraceState { TRACE_UNINIT = 0 , TRACE_INITED , TRACE_STARTED , TRACE_STOPED }
 
enum  LOS_TRACE_MASK {
  TRACE_SYS_FLAG = 0x10 , TRACE_HWI_FLAG = 0x20 , TRACE_TASK_FLAG = 0x40 , TRACE_SWTMR_FLAG = 0x80 ,
  TRACE_MEM_FLAG = 0x100 , TRACE_QUE_FLAG = 0x200 , TRACE_EVENT_FLAG = 0x400 , TRACE_SEM_FLAG = 0x800 ,
  TRACE_MUX_FLAG = 0x1000 , TRACE_MAX_FLAG = 0x80000000 , TRACE_USER_DEFAULT_FLAG = 0xFFFFFFF0
}
 
enum  LOS_TRACE_TYPE {
  SYS_ERROR = TRACE_SYS_FLAG | 0 , SYS_START = TRACE_SYS_FLAG | 1 , SYS_STOP = TRACE_SYS_FLAG | 2 , HWI_CREATE = TRACE_HWI_FLAG | 0 ,
  HWI_CREATE_NODE = TRACE_HWI_FLAG | 1 , HWI_DELETE = TRACE_HWI_FLAG | 2 , HWI_DELETE_NODE = TRACE_HWI_FLAG | 3 , HWI_RESPONSE_IN = TRACE_HWI_FLAG | 4 ,
  HWI_RESPONSE_OUT = TRACE_HWI_FLAG | 5 , HWI_ENABLE = TRACE_HWI_FLAG | 6 , HWI_DISABLE = TRACE_HWI_FLAG | 7 , HWI_TRIGGER = TRACE_HWI_FLAG | 8 ,
  HWI_SETPRI = TRACE_HWI_FLAG | 9 , HWI_CLEAR = TRACE_HWI_FLAG | 10 , HWI_SETAFFINITY = TRACE_HWI_FLAG | 11 , HWI_SENDIPI = TRACE_HWI_FLAG | 12 ,
  TASK_CREATE = TRACE_TASK_FLAG | 0 , TASK_PRIOSET = TRACE_TASK_FLAG | 1 , TASK_DELETE = TRACE_TASK_FLAG | 2 , TASK_SUSPEND = TRACE_TASK_FLAG | 3 ,
  TASK_RESUME = TRACE_TASK_FLAG | 4 , TASK_SWITCH = TRACE_TASK_FLAG | 5 , TASK_SIGNAL = TRACE_TASK_FLAG | 6 , SWTMR_CREATE = TRACE_SWTMR_FLAG | 0 ,
  SWTMR_DELETE = TRACE_SWTMR_FLAG | 1 , SWTMR_START = TRACE_SWTMR_FLAG | 2 , SWTMR_STOP = TRACE_SWTMR_FLAG | 3 , SWTMR_EXPIRED = TRACE_SWTMR_FLAG | 4 ,
  MEM_ALLOC = TRACE_MEM_FLAG | 0 , MEM_ALLOC_ALIGN = TRACE_MEM_FLAG | 1 , MEM_REALLOC = TRACE_MEM_FLAG | 2 , MEM_FREE = TRACE_MEM_FLAG | 3 ,
  MEM_INFO_REQ = TRACE_MEM_FLAG | 4 , MEM_INFO = TRACE_MEM_FLAG | 5 , QUEUE_CREATE = TRACE_QUE_FLAG | 0 , QUEUE_DELETE = TRACE_QUE_FLAG | 1 ,
  QUEUE_RW = TRACE_QUE_FLAG | 2 , EVENT_CREATE = TRACE_EVENT_FLAG | 0 , EVENT_DELETE = TRACE_EVENT_FLAG | 1 , EVENT_READ = TRACE_EVENT_FLAG | 2 ,
  EVENT_WRITE = TRACE_EVENT_FLAG | 3 , EVENT_CLEAR = TRACE_EVENT_FLAG | 4 , EVENT_COND_READ = TRACE_EVENT_FLAG | 5 , EVENT_COND_WRITE = TRACE_EVENT_FLAG | 6 ,
  SEM_CREATE = TRACE_SEM_FLAG | 0 , SEM_DELETE = TRACE_SEM_FLAG | 1 , SEM_PEND = TRACE_SEM_FLAG | 2 , SEM_POST = TRACE_SEM_FLAG | 3 ,
  MUX_CREATE = TRACE_MUX_FLAG | 0 , MUX_DELETE = TRACE_MUX_FLAG | 1 , MUX_PEND = TRACE_MUX_FLAG | 2 , MUX_POST = TRACE_MUX_FLAG | 3
}
 

函数

UINT32 LOS_TraceInit (void *buf, UINT32 size)
 Initialize the trace when the system startup.
 
UINT32 LOS_TraceStart (void)
 Start trace.
 
void LOS_TraceStop (void)
 Stop trace sample.
 
void LOS_TraceReset (void)
 Clear the trace buf.
 
void LOS_TraceEventMaskSet (UINT32 mask)
 Set trace event mask.
 
void LOS_TraceRecordDump (BOOL toClient)
 Offline trace buffer display.
 
OfflineHeadLOS_TraceRecordGet (void)
 Offline trace buffer export.
 
void LOS_TraceHwiFilterHookReg (TRACE_HWI_FILTER_HOOK hook)
 Hwi num filter hook.
 

详细描述

宏定义说明

◆ _T

#define _T (   x)    x

It's the total size of trace buffer. Its unit is char. When dynamic memory not enabled, the address and size is calculated by symbols defined in the linker script. Recommended to define the section size using #LOSCFG_TRACE_BUFFER_SIZE. Version number

◆ LOS_ERRNO_TRACE_BUF_IS_NULL

#define LOS_ERRNO_TRACE_BUF_IS_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x03)

Trace error code: Passed NULL to LOS_TraceInit and dynamic memory not enabled.

Value: 0x02001403

Solution: Pass a valid memory address or enable dynamic memory allocation.

◆ LOS_ERRNO_TRACE_BUF_TOO_SMALL

#define LOS_ERRNO_TRACE_BUF_TOO_SMALL   LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x02)

Trace error code: Insufficient memory for trace struct.

Value: 0x02001402

Solution: Increase trace buffer's size.

◆ LOS_ERRNO_TRACE_ERROR_STATUS

#define LOS_ERRNO_TRACE_ERROR_STATUS   LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x00)

Trace error code: init trace failed.

Value: 0x02001400

Solution: Follow the trace State Machine.

◆ LOS_ERRNO_TRACE_NO_MEMORY

#define LOS_ERRNO_TRACE_NO_MEMORY   LOS_ERRNO_OS_ERROR(LOS_MOD_TRACE, 0x01)

Trace error code: Insufficient memory for trace buf init.

Value: 0x02001401

Solution: Expand the configured system memory or decrease the value defined by LOS_TRACE_BUFFER_SIZE.

◆ LOSCFG_TRACE_OBJ_MAX_NUM

#define LOSCFG_TRACE_OBJ_MAX_NUM   0

Trace records the max number of objects(kernel object, like tasks). if set to 0, trace will not record any object.

◆ LOSCFG_TRACE_TLV_BUF_SIZE

#define LOSCFG_TRACE_TLV_BUF_SIZE   100

Trace tlv encode buffer size, the buffer is used to encode one piece raw frame to tlv message in online mode.

类型定义说明

◆ TRACE_HWI_FILTER_HOOK

typedef BOOL(* TRACE_HWI_FILTER_HOOK) (UINT32 hwiNum)

Define the type of trace hardware interrupt filter hook function.

Description:
User can register fliter function by LOS_TraceHwiFilterHookReg to filter hardware interrupt events. Return true if user don't need trace the certain number.
注意
None.
参数
hwiNum[IN] Type UINT32. The hardware interrupt number.
返回值
TRUE0x00000001: Not record the certain number.
FALSE0x00000000: Need record the certain number.
Dependency:
  • los_trace.h: the header file that contains the API declaration.
自从
Huawei LiteOS V200R005C00

枚举类型说明

◆ LOS_TRACE_MASK

Trace mask is used to filter events in runtime. Each mask keep only one unique bit to 1, and user can define own module's trace mask.

枚举值
TRACE_SYS_FLAG 
TRACE_HWI_FLAG 
TRACE_TASK_FLAG 
TRACE_SWTMR_FLAG 
TRACE_MEM_FLAG 
TRACE_QUE_FLAG 
TRACE_EVENT_FLAG 
TRACE_SEM_FLAG 
TRACE_MUX_FLAG 
TRACE_MAX_FLAG 
TRACE_USER_DEFAULT_FLAG 

◆ LOS_TRACE_TYPE

Trace event type which indicate the exactly happend events, user can define own module's event type like TRACE_::MODULE::_FLAG | NUMBER. 28 4 0 0 0 0 0 0 0 0 X X X X X X X X 0 0 0 0 0 0 | | | trace_module_flag number

枚举值
SYS_ERROR 
SYS_START 
SYS_STOP 
HWI_CREATE 
HWI_CREATE_NODE 
HWI_DELETE 
HWI_DELETE_NODE 
HWI_RESPONSE_IN 
HWI_RESPONSE_OUT 
HWI_ENABLE 
HWI_DISABLE 
HWI_TRIGGER 
HWI_SETPRI 
HWI_CLEAR 
HWI_SETAFFINITY 
HWI_SENDIPI 
TASK_CREATE 
TASK_PRIOSET 
TASK_DELETE 
TASK_SUSPEND 
TASK_RESUME 
TASK_SWITCH 
TASK_SIGNAL 
SWTMR_CREATE 
SWTMR_DELETE 
SWTMR_START 
SWTMR_STOP 
SWTMR_EXPIRED 
MEM_ALLOC 
MEM_ALLOC_ALIGN 
MEM_REALLOC 
MEM_FREE 
MEM_INFO_REQ 
MEM_INFO 
QUEUE_CREATE 
QUEUE_DELETE 
QUEUE_RW 
EVENT_CREATE 
EVENT_DELETE 
EVENT_READ 
EVENT_WRITE 
EVENT_CLEAR 
EVENT_COND_READ 
EVENT_COND_WRITE 
SEM_CREATE 
SEM_DELETE 
SEM_PEND 
SEM_POST 
MUX_CREATE 
MUX_DELETE 
MUX_PEND 
MUX_POST 

◆ TraceState

enum TraceState

Trace state.

枚举值
TRACE_UNINIT 

trace isn't inited

TRACE_INITED 

trace is inited but not started yet

TRACE_STARTED 

trace is started and system is tracing

TRACE_STOPED 

trace is stopped

函数说明

◆ LOS_TraceEventMaskSet()

void LOS_TraceEventMaskSet ( UINT32  mask)
extern

Set trace event mask.

Description:
Set trace event mask.
注意
  • Set trace event filter mask.
  • The Default mask is (TRACE_HWI_FLAG | TRACE_TASK_FLAG), stands for switch on task and hwi events.
  • Customize mask according to the type defined in enum LOS_TRACE_MASK to switch on corresponding module's trace.
  • The system's trace mask will be overrode by the input parameter.
参数
mask[IN] Type UINT32. The mask used to filter events of LOS_TRACE_MASK.
返回值
#NA.
Dependency:
  • los_trace.h: the header file that contains the API declaration.
参见
LOS_TraceEventMaskSet
自从
Huawei LiteOS V200R005C00

◆ LOS_TraceHwiFilterHookReg()

void LOS_TraceHwiFilterHookReg ( TRACE_HWI_FILTER_HOOK  hook)
extern

Hwi num filter hook.

Description:
Hwi filter function.
注意
  • Filter the hwi events by hwi num
参数
hook[IN] Type TRACE_HWI_FILTER_HOOK. The user defined hook for hwi num filter, the hook should return true if you don't want trace this hwi num.
返回值
#None
Dependency:
  • los_trace.h: the header file that contains the API declaration.
参见
LOS_TraceHwiFilterHookReg
自从
Huawei LiteOS V200R005C00

◆ LOS_TraceInit()

UINT32 LOS_TraceInit ( void *  buf,
UINT32  size 
)
extern

Initialize the trace when the system startup.

Description:
This API is used to initialize the trace for system level.
注意
  • This API can be called only after the memory is initialized. Otherwise, the Trace Init will be fail.
参数
buf[IN] Type VOID *. The ptr is trace buffer address, if ptr is NULL, system will malloc a new one in trace offline mode if dynamic memory management is enabled. Otherwise, return an error.
size[IN] Type UINT32. The trace buffer's size.
返回值
LOS_ERRNO_TRACE_ERROR_STATUS0x02001400: The trace status is not TRACE_UNINIT.
LOS_ERRNO_TRACE_NO_MEMORY0x02001401: The memory is not enough for initialization.
LOS_ERRNO_TRACE_BUF_TOO_SMALL0x02001402: Trace buf size not enough.
LOS_ERRNO_TRACE_BUF_IS_NULL0x02001403: Pass NULL to ptr and dynamic memory not enabled.
LOS_ERRNO_TSK_TCB_UNAVAILABLE0x02000211: No free task control block is available.
LOS_ERRNO_TSK_MP_SYNC_RESOURCE0x02000225: Mp sync resource create failed
LOS_OK0x00000000: The initialization is successful.
Dependency:
  • los_trace.h: the header file that contains the API declaration.
参见
LOS_TraceInit
自从
Huawei LiteOS V200R005C00

◆ LOS_TraceRecordDump()

void LOS_TraceRecordDump ( BOOL  toClient)
extern

Offline trace buffer display.

Description:
Display trace buf data only at offline mode.
注意
  • This API can be called only after that trace stopped. Otherwise the trace dump will be failed.
  • Trace data will be send to pipeline when user set toClient = TRUE. Otherwise it will be formatted and printed out.
参数
toClient[IN] Type BOOL. Whether send trace data to Client through pipeline.
返回值
#NA
Dependency:
  • los_trace.h: the header file that contains the API declaration.
参见
LOS_TraceRecordDump
自从
Huawei LiteOS V200R005C00

◆ LOS_TraceRecordGet()

OfflineHead * LOS_TraceRecordGet ( void  )
extern

Offline trace buffer export.

Description:
Return the trace buf only at offline mode.
注意
  • This API can be called only after that trace buffer has been established.
  • The return buffer's address is a critical resource, user can only ready.
参数
NA
返回值
#OfflineHead*The trace buffer's address, analyze this buffer according to the structure of OfflineHead.
Dependency:
  • los_trace.h: the header file that contains the API declaration.
参见
LOS_TraceRecordGet
自从
Huawei LiteOS V200R005C00

◆ LOS_TraceReset()

void LOS_TraceReset ( void  )
extern

Clear the trace buf.

Description:
Clear the event frames in trace buf only at offline mode.
注意
  • This API can be called only after that trace buffer has been established. Otherwise, the trace will be failed.
参数
None.
返回值
#NA
Dependency:
  • los_trace.h: the header file that contains the API declaration.
参见
LOS_TraceReset
自从
Huawei LiteOS V200R005C00

◆ LOS_TraceStart()

UINT32 LOS_TraceStart ( void  )
extern

Start trace.

Description:
This API is used to start trace.
注意
  • Start trace
参数
None.
返回值
LOS_ERRNO_TRACE_ERROR_STATUS0x02001400: Trace start failed.
LOS_OK0x00000000: Trace start success.
Dependency:
  • los_trace.h: the header file that contains the API declaration.
参见
LOS_TraceStart
自从
Huawei LiteOS V200R005C00

◆ LOS_TraceStop()

void LOS_TraceStop ( void  )
extern

Stop trace sample.

Description:
This API is used to start trace sample.
注意
  • Stop trace sample
参数
None.
返回值
#None.
Dependency:
  • los_trace.h: the header file that contains the API declaration.
参见
LOS_TraceStop
自从
Huawei LiteOS V200R005C00