📄 dy4debug.c
字号:
/* ------------------------------------------------------------------------- *//* --- Operating System Independent Binding Layer -------------------------- *//* File: dy4Debug.c *//* Author: Jeff Sanderson *//* Date: 12 April 2001 *//* Description: *//* History: */ /* 18nov03 rcd -Removed config.h include *//* ------------------------------------------------------------------------- *//* ------------------------------------------------------------------------- *//* Debug Print Evaluation type *//* ************************************************************************* *//* -DDBG_COMPILE Evaluate at compile if prints are included *//* -DDBG_RUNTIME Test a variable to see if we want to print *//* *//* ------------------------------------------------------------------------- *//* Type of DEBUG print (logMsg, sprintf, send ) defined in Makefile *//* ************************************************************************* *//* -DDBG_LOGMSG use logMsg to output *//* -DDBG_SPRINTF use sprintf to output to memory array, buff ptr is *//* logBuf global *//* -DDBG_SEND use socket (autotest) to output, socket is fdSock *//* global *//* *//* ------------------------------------------------------------------------- *//* Level of output controlled by define in Makefile, or in file above *//* include of dbgprnt *//* ************************************************************************* *//* -DDEBUG (DEBUGPx()) basic debugging messages *//* -DDEBUG_MSG (DEBUGMPx()) test and info messages *//* -DDEBUG_ERROR (DEBUGEPx()) messages when errors occur *//* -DDEBUG_INTM (DEBUGINTMPx()) messages from interrupt service *//* routines *//* -DDEBUG_INTD (DEBUGINTDPx()) debug messages from interrupt service *//* routines *//* -DDEBUG_INTI (DEBUGINTIPx()) extra info messages from interrupt *//* service routines *//* -DDEBUG_INTE (DEBUGINTEPx()) error messages from interrupt service *//* routines *//* -DDEBUG_INTX (DEBUGINTXPx()) temp messages from interrupt service *//* routines *//* -DDEBUG_RESOURCE (DEBUGRPx()) memory allocation and free *//* -DDEBUG_EXTRA_INFO (DEBUGIPx()) detailed debugging information *//* -DDEBUGX (DEBUGXPx()) temporary debug messages, easily *//* searched *//* *//* ------------------------------------------------------------------------- */#include "vxWorks.h"#if 0 /* removed for BSP */#if (CPU_FAMILY == PPC) #include "config.h"#endif#endif#include "logLib.h"#include "ioLib.h"#include "intLib.h"#include "string.h"#include "stdio.h"#include "stdarg.h"#include "socket.h"#include "netinet/tcp.h"#include "sockLib.h"#include "usrLib.h"#include "h/drv/dy4Debug/dy4Debug.h"/* ------------------------------------------------------------------------- *//* Globals used for various types of output *//* ------------------------------------------------------------------------- */char debugBuff[MAX_DLOG_MSGS][MAX_DLOG_MSGS_LEN];int debugIndex;int fdSock;int dy4DebugFlags = DBG_MASK_ERROR | DBG_MASK_INTE;/* ------------------------------------------------------------------------- *//* forward declaration *//* ------------------------------------------------------------------------- */void dbgPrintDelay(void);/* ------------------------------------------------------------------------- *//* logMsg output, pre-process format so that local vars will be correctly *//* handled. *//* ------------------------------------------------------------------------- */void dlogMsg( char *fmt, ... ) { va_list ap; char *bp; int oldVect; oldVect = intLock(); bp = &debugBuff[debugIndex][0]; debugIndex = ((debugIndex + 1) % MAX_DLOG_MSGS); intUnlock( oldVect ); va_start( ap, fmt); vsprintf(bp,fmt,ap); va_end( ap ); logMsg(bp,0,0,0,0,0,0);#if 0 dbgPrintDelay();#endif }/* ------------------------------------------------------------------------- *//* sprintf output, pre-process format and print to debug buffer *//* ------------------------------------------------------------------------- */void dsprintf( char *fmt, ... ) { va_list ap; char *bp; int oldVect; oldVect = intLock(); bp = &debugBuff[debugIndex][0]; debugIndex = ((debugIndex + 1) % MAX_DLOG_MSGS); intUnlock( oldVect ); va_start( ap, fmt); vsprintf(bp,fmt,ap); va_end( ap );#if 0 dbgPrintDelay();#endif }/* ------------------------------------------------------------------------- *//* socket output, expects an open socket, with a server task on the other *//* end of the socket to manage the output. Used with the autotest facility *//* ------------------------------------------------------------------------- */void dsend( char *fmt, ... ) { va_list ap; char *bp; int oldVect; oldVect = intLock(); bp = &debugBuff[debugIndex][0]; debugIndex = ((debugIndex + 1) % MAX_DLOG_MSGS); intUnlock( oldVect ); va_start( ap, fmt); vsprintf(bp,fmt,ap); va_end( ap ); send( fdSock, bp, MAX_DLOG_MSGS_LEN, (int)NULL );#if 0 dbgPrintDelay();#endif }/* ------------------------------------------------------------------------- *//* Add a busy wait to the output. Used in early debug when exceptions *//* prevent obtaining all output before the crash. *//* ------------------------------------------------------------------------- */void dbgPrintDelay(void) {#if 0 int i, j; for ( i = 0, j = 0; i < 0x02000000; i++ ) { j+=i; }#endif }/* ------------------------------------------------------------------------- *//* End of File *//* ------------------------------------------------------------------------- */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -