mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-26 15:31:35 +00:00
IOC mediator: DEBUG: support IOC log file
This patch is used for IOC mediator debugging. Due to IOC message logs are too much, need to save into one file instead of output stdout directly. By default, the debug log is disabled. Signed-off-by: Liu Yuan <yuan1.liu@intel.com> Reviewed-by: Wang Yu <yu1.wang@intel.com> Reviewed-by: Liu Shuo <shuo.a.liu@intel.com> Reviewed-by: Zhao Yakui <yakui.zhao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
746d437642
commit
75b5e670d5
@ -90,14 +90,21 @@
|
||||
|
||||
#include "ioc.h"
|
||||
|
||||
/*
|
||||
* Debug printf
|
||||
*/
|
||||
/* For debugging log to a file */
|
||||
static int ioc_debug;
|
||||
#define DPRINTF(fmt, args...) \
|
||||
do { if (ioc_debug) printf(fmt, ##args); } while (0)
|
||||
#define WPRINTF(fmt, args...) printf(fmt, ##args)
|
||||
|
||||
static FILE *dbg_file;
|
||||
#define IOC_LOG_INIT do { if (ioc_debug) {\
|
||||
dbg_file = fopen("/tmp/ioc_log", "w+");\
|
||||
if (!dbg_file)\
|
||||
printf("ioc log open failed\r\n"); else cbc_set_log_file(dbg_file);\
|
||||
} } while (0)
|
||||
#define IOC_LOG_DEINIT do { if (dbg_file) fclose(dbg_file); dbg_file = NULL;\
|
||||
cbc_set_log_file(dbg_file);\
|
||||
} while (0)
|
||||
#define DPRINTF(format, arg...) \
|
||||
do { if (ioc_debug && dbg_file) { fprintf(dbg_file, format, arg);\
|
||||
fflush(dbg_file); } } while (0)
|
||||
#define WPRINTF(format, arg...) printf(format, ##arg)
|
||||
|
||||
/*
|
||||
* Type definition for thread function.
|
||||
@ -1096,7 +1103,7 @@ ioc_create_thread(const char *name, pthread_t *tid,
|
||||
ioc_work func, void *arg)
|
||||
{
|
||||
if (pthread_create(tid, NULL, func, arg) != 0) {
|
||||
DPRINTF("ioc can not create thread\r\n");
|
||||
DPRINTF("%s", "ioc can not create thread\r\n");
|
||||
return -1;
|
||||
}
|
||||
pthread_setname_np(*tid, name);
|
||||
@ -1146,6 +1153,8 @@ ioc_init(void)
|
||||
int i;
|
||||
struct ioc_dev *ioc;
|
||||
|
||||
IOC_LOG_INIT;
|
||||
|
||||
if (ioc_is_platform_supported() != 0)
|
||||
goto ioc_err;
|
||||
|
||||
@ -1261,6 +1270,7 @@ alloc_err:
|
||||
free(ioc->pool);
|
||||
free(ioc);
|
||||
ioc_err:
|
||||
IOC_LOG_DEINIT;
|
||||
DPRINTF("%s", "ioc mediator startup failed!!\r\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -1281,4 +1291,5 @@ ioc_deinit(struct ioc_dev *ioc)
|
||||
free(ioc->evts);
|
||||
free(ioc->pool);
|
||||
free(ioc);
|
||||
IOC_LOG_DEINIT;
|
||||
}
|
||||
|
@ -41,9 +41,11 @@
|
||||
* Debug printf
|
||||
*/
|
||||
static int ioc_cbc_debug;
|
||||
#define DPRINTF(fmt, args...) \
|
||||
do { if (ioc_cbc_debug) printf(fmt, ##args); } while (0)
|
||||
#define WPRINTF(fmt, args...) printf(fmt, ##args)
|
||||
static FILE *dbg_file;
|
||||
#define DPRINTF(format, arg...) \
|
||||
do { if (ioc_cbc_debug && dbg_file) { fprintf(dbg_file, format, arg);\
|
||||
fflush(dbg_file); } } while (0)
|
||||
#define WPRINTF(format, arg...) printf(format, ##arg)
|
||||
|
||||
static void cbc_send_pkt(struct cbc_pkt *pkt);
|
||||
|
||||
@ -895,3 +897,12 @@ wlist_init_signal(struct cbc_signal *cbc_tbl, size_t cbc_size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Share log file with IOC.
|
||||
*/
|
||||
void
|
||||
cbc_set_log_file(FILE *f)
|
||||
{
|
||||
dbg_file = f;
|
||||
}
|
||||
|
@ -735,4 +735,7 @@ void wlist_init_signal(struct cbc_signal *cbc_tbl, size_t cbc_size,
|
||||
struct wlist_signal *wlist_tbl, size_t wlist_size);
|
||||
void wlist_init_group(struct cbc_group *cbc_tbl, size_t cbc_size,
|
||||
struct wlist_group *wlist_tbl, size_t wlist_size);
|
||||
|
||||
/* Set CBC log file */
|
||||
void cbc_set_log_file(FILE *f);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user