更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
Error handling
Error handling 的协作图:

类型定义

typedef VOID(* LOS_ERRORHANDLE_FUNC) (CHAR *fileName, UINT32 lineNo, UINT32 errorNo, UINT32 paraLen, VOID *para)
 Define the pointer to the error handling function. 更多...
 

函数

UINT32 LOS_ErrHandle (CHAR *fileName, UINT32 lineNo, UINT32 errorNo, UINT32 paraLen, VOID *para)
 Error handling function. 更多...
 
VOID LOS_SetErrHandleHook (LOS_ERRORHANDLE_FUNC fun)
 set Error handling function. 更多...
 

详细描述

类型定义说明

◆ LOS_ERRORHANDLE_FUNC

typedef VOID(* LOS_ERRORHANDLE_FUNC) (CHAR *fileName, UINT32 lineNo, UINT32 errorNo, UINT32 paraLen, VOID *para)

Define the pointer to the error handling function.

Description:
This API is used to define the pointer to the error handling function.
注意
  • None.
参数
fileName[IN] Log file that stores error information.
lineNo[IN] Line number of the erroneous line.
errorNo[IN] Error code.
paraLen[IN] Length of the input parameter pPara.
para[IN] User label of the error.
返回值
None.
Dependency:
  • los_err.h: the header file that contains the API declaration.
参见
None.

在文件 los_err.h69 行定义.

函数说明

◆ LOS_ErrHandle()

UINT32 LOS_ErrHandle ( CHAR fileName,
UINT32  lineNo,
UINT32  errorNo,
UINT32  paraLen,
VOID *  para 
)

Error handling function.

Description:
This API is used to perform different operations according to error types.
注意
  • None
参数
fileName[IN] Log file that stores error information.
lineNo[IN] Line number of the erroneous line which should not be OS_ERR_MAGIC_WORD.
errorNo[IN] Error code.
paraLen[IN] Length of the input parameter pPara.
para[IN] User label of the error.
返回值
LOS_OKThe error is successfully processed.
Dependency:
  • los_err.h: the header file that contains the API declaration.
参见
None

Error handling function.

参数
fileName存放错误日志的文件名,系统内部调用时,入参为"os_unspecific_file"
lineNo发生错误的代码行号系统内部调用时,若值为0xa1b2c3f8,表示未传递行号
errorNo错误码
paraLen入参para的长度系统内部调用时,入参为0
para错误标签系统内部调用时,入参为NULL
返回
LITE_OS_SEC_TEXT_INIT

在文件 los_err.c61 行定义.

63{
64 if (g_errHandleHook != NULL) {
65 g_errHandleHook(fileName, lineNo, errorNo, paraLen, para);
66 }
67
68 return LOS_OK;
69}
LITE_OS_SEC_BSS STATIC LOS_ERRORHANDLE_FUNC g_errHandleHook
错误接管钩子函数
Definition: los_err.c:50

◆ LOS_SetErrHandleHook()

VOID LOS_SetErrHandleHook ( LOS_ERRORHANDLE_FUNC  fun)

set Error handling function.

参数
fun[IN] the error handle function.

set Error handling function.

在文件 los_err.c71 行定义.

72{
73 g_errHandleHook = fun;
74}