/** * @file oh_debug.h * @version $Id$ * * The header file that has the debug message control functions. * All functions defined in it are called actually only if OH_DEBUG is defined. * If OH_DEBUG is not defined, then all function calls are changed into * ((void)0) or (0) by the macros. */ #ifndef _OH_DEBUG_H_ #define _OH_DEBUG_H_ #include "oh_port.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** * The enum of the debug message level. */ typedef enum oh_db_level_t { /** * The critical error level that can't be recovered. */ OL_ERR = 0x00000001, /** * The warning level that is dangerous but can be recovered. */ OL_WRN = 0x00000003, /** * The message level that is a plain debug message. */ OL_MSG = 0x00000007, /** * The debug level that is a very verbose debug message. */ OL_DBG = 0x0000000f } oh_db_level_t; /** * The enum of the debug message type. */ typedef enum oh_db_type_t { OD_DEF = 0, OD_ASSERT = 1, OD_BOOT = 2, OD_PORT = 3, OD_NES = 4, OD_SYSTEM = 5, OD_EVENT = 6, OD_FILESYS = 7, OD_TESTKIT = 8 } oh_db_type_t; #ifdef OH_DEBUG #define oh_db_log(x) oh_db_log x extern oh_void oh_db_log((oh_db_level_t level, oh_db_type_t type, const oh_char *format, ...)); extern oh_void oh_db_vlog(oh_db_level_t level, oh_db_type_t type, const oh_char *format, va_list args); extern oh_int oh_db_getLevel(oh_db_type_t type); extern oh_void oh_db_setLevel(oh_db_type_t type, oh_db_level_t level); extern oh_int oh_db_checkLevel(oh_db_type_t type, oh_db_level_t level); /** * Asserts expr is true. * * If expr is not true, then it prints critical error message and call * oh_c_exit(). * It works only if OH_DEBUG is defined. Otherwise, it is ignored. */ #define OH_ASSERT(expr) ((expr) ? ((void)0) : (void)(oh_db_log((OL_ERR, OD_ASSERT, "%s:%d:%s", __FILE__, __LINE__, " Assertion " #expr " failed.")), oh_c_exit(-1))) #else /* OH_DEBUG */ #define OH_ASSERT(expr) ((oh_void)0) #define oh_db_log(x) ((oh_void)0) #define oh_db_vlog(x) ((oh_void)0) #define oh_db_getLevel(x) (0) #define oh_db_setLevel(x,y) ((oh_void)0) #define oh_db_checkLevel(x,y) (0) #endif /* OH_DEBUG */ #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* _OH_DEBUG_H_ */