diff options
author | Joseph Lo <jlo@marvell.com> | 2010-10-28 10:45:58 +0800 |
---|---|---|
committer | Joseph Lo <jlo@marvell.com> | 2010-10-28 10:45:58 +0800 |
commit | 828f4288fc25b202efc51db1f047240afa61dfb5 (patch) | |
tree | 7ed5e3cb205fb54ecb973ae650764b9dd9e0c049 | |
parent | 9014dc8b10cda10477cfae228979b12f2fa92132 (diff) |
vmeta add debug file option
Under Android, we cannot use printf. So we write to a debug file instead.
It's useful under Android.
-rwxr-xr-x | vmeta_lib.c | 46 | ||||
-rwxr-xr-x | vmeta_lib.h | 2 |
2 files changed, 40 insertions, 8 deletions
diff --git a/vmeta_lib.c b/vmeta_lib.c index 023a128..a1a69bf 100755 --- a/vmeta_lib.c +++ b/vmeta_lib.c @@ -403,11 +403,25 @@ SIGN32 vdec_os_driver_init(void) int ret = 0; int rv; +#if VMETA_LOG_ON + FILE *fp_log; +#endif + if(vdec_iface != NULL) { // already been initiated in this process vdec_iface->refcount++; return ret; } +#if (VMETA_LOG_ON && 0) + + fp_log = fopen(VMETA_LOG_FILE,"w"); + if(fp_log == NULL) { + return -1; + } + fclose(fp_log); + +#endif + // Prepare the vdec os driver control interface vdec_iface = (vdec_os_driver_cb_t*)malloc(sizeof(vdec_os_driver_cb_t)); memset((void*)vdec_iface, 0, sizeof(vdec_os_driver_cb_t)); @@ -423,7 +437,7 @@ SIGN32 vdec_os_driver_init(void) ret = -VDEC_OS_DRIVER_OPEN_FAIL; goto err_open_fail; } - dbg_printf(VDEC_DEBUG_ALL, "vdec os driver open: %s\n", UIO_DEV); + dbg_printf(VDEC_DEBUG_ALL, "vdec os driver open: %s uiofd=%d\n", UIO_DEV,vdec_iface->uiofd); vdec_iface->kern_ver = get_version(UIO_IO_VERSION); if(vdec_iface->kern_ver < VMETA_KERN_MIN_VER) { @@ -512,26 +526,42 @@ SIGN32 vdec_os_driver_clean(void) int dbg_printf(UNSG32 dbglevel, const char* format, ...) { char dbgBuf[256] = {'\0'}; va_list var; +#if VMETA_LOG_ON + FILE *fp_log = fopen(VMETA_LOG_FILE,"a+"); + if(fp_log == NULL) { + return -1; + } +#endif if(VDEC_DEBUG_NONE == globalDbgLevel) - return 0; + goto DBG_EXIT; else { va_start(var, format); vsprintf(dbgBuf, format, var); va_end(var); if(VDEC_DEBUG_ALL & globalDbgLevel) - printf(dbgBuf); + goto DBG_PRINT; else if((VDEC_DEBUG_MEM & globalDbgLevel) && (dbglevel == VDEC_DEBUG_MEM)) - printf(dbgBuf); + goto DBG_PRINT; else if((VDEC_DEBUG_LOCK & globalDbgLevel) && (dbglevel == VDEC_DEBUG_LOCK)) - printf(dbgBuf); + goto DBG_PRINT; else if((VDEC_DEBUG_VER & globalDbgLevel) && (dbglevel == VDEC_DEBUG_VER)) - printf(dbgBuf); + goto DBG_PRINT; else - return 0; + goto DBG_EXIT; } - +DBG_PRINT: +#if VMETA_LOG_ON + fprintf(fp_log,dbgBuf); +#else + printf(dbgBuf); +#endif + +DBG_EXIT: +#if VMETA_LOG_ON + fclose(fp_log); +#endif return 0; } diff --git a/vmeta_lib.h b/vmeta_lib.h index dd9a262..5f8e93f 100755 --- a/vmeta_lib.h +++ b/vmeta_lib.h @@ -171,6 +171,8 @@ typedef enum _LOCK_RET_CODE { }LOCK_RET_CODE; /* display debug message */ +#define VMETA_LOG_ON 0 +#define VMETA_LOG_FILE "/data/vmeta_dbg.log" int dbg_printf(UNSG32 dbglevel, const char* format, ...); typedef sem_t lock_t; |