📄 dy4debug.h
字号:
/********************************************************************************* Filename: dy4Debug.h** Copyright 2003 by DY4 Systems. All Rights Reserved.** Project Name: debug utilities** Target: 182** Description: Debug print routines** Usage:** Log:* Date: 12 April 2001 * originally developed for 642/643. * added to osiapi package* added to dy4mms package********************************************************************************//* ****************************************************************************** * * DESCRIPTION * This file contains the prtotypes and defines for the debug print routines * * FEATURES * This package supports multiple levels of debug printout, configurable * at runtime or compile. Prints may be printf, logMsg, sprintf to memory * or socket sends * * INTERRUPT HANDLING * There are routines for printing from interrupt level * * INITIALIZATION * If using sockets, the global fdSock must be initialized to an open socket * handle before the first print. Runtime printout is managed with * dy4DebugFlags, compile time uses macros defined in the Makefile, or in * the specific C file to be debugged. * * USER CALLABLE ROUTINES * DEBUGP(( fmt, ... )); normal debug output * DEBUGMP(( fmt, ... )); message output * DEBUGEP(( fmt, ... )); error output * DEBUGRP(( fmt, ... )); resource output * DEBUGIP(( fmt, ... )); extra info output * DEBUGXP(( fmt, ... )); temporary messages * DEBUGINTDP(( fmt, ... )); interrupt level normal debug output * DEBUGINTMP(( fmt, ... )); interrupt level message output * DEBUGINTEP(( fmt, ... )); interrupt level error output * DEBUGINTIP(( fmt, ... )); interrupt level extra info output * DEBUGINTXP(( fmt, ... )); interrupt level temporary messages * ****************************************************************************** */#ifndef __DBGPRNT_H__#define __DBGPRNT_H__#ifdef __cplusplusextern "C" {#endif#define STRSIZE 256#define MAX_DLOG_MSGS 128#define MAX_DLOG_MSGS_LEN 256 /* Need big buffs for some errors *//* ------------------------------------------------------------------------- *//* 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 *//* *//* ------------------------------------------------------------------------- *//* RUNTIME DEBUG LEVEL MASKS *//* ------------------------------------------------------------------------- */#define DBG_MASK_OFF 0x00000000#define DBG_MASK_DEBUG 0x00000001#define DBG_MASK_MSG 0x00000002#define DBG_MASK_ERROR 0x00000004#define DBG_MASK_INTM 0x00000008#define DBG_MASK_INTD 0x00000010#define DBG_MASK_INTI 0x00000020#define DBG_MASK_INTE 0x00000040#define DBG_MASK_INTX 0x00000080#define DBG_MASK_RESOURCE 0x00000100#define DBG_MASK_EXTRA_INFO 0x00000200#define DBG_MASK_X 0x00000400/* ------------------------------------------------------------------------- *//* ------------------------------------------------------------------------- */#ifdef DBG_RUNTIME #ifdef DBG_COMPILE #error Define only one or none of DBG_RUNTIME or DBG_COMPILE #endif #define DEBUG #define DEBUG_MSG #define DEBUG_ERROR #define DEBUG_INTM #define DEBUG_INTD #define DEBUG_INTI #define DEBUG_INTE #define DEBUG_RESOURCE #define DEBUG_EXTRA_INFO #define DEBUGX#endif /* DBG_RUNTIME *//* ------------------------------------------------------------------------- *//* ------------------------------------------------------------------------- *//* Declare the matching variable to the output type in the first file loaded *//* You need to have the variable declared and initialized before the first *//* DEBUGxxx msg *//* ------------------------------------------------------------------------- */extern char debugBuff[MAX_DLOG_MSGS][MAX_DLOG_MSGS_LEN];extern int debugIndex;extern int fdSock;extern int dy4DebugFlags;extern void dlogMsg( char *fmt, ... );extern void dsprintf( char *fmt, ... );extern void dsend( char *fmt, ... );/* ------------------------------------------------------------------------- *//* ------------------------------------------------------------------------- *//* These macros use a local string buffer because of a usage issue with *//* logMsg. *//* logMsg will take the var args string and return to the calling function *//* quickly later when logMsg goes to print the message, it will evaluate the *//* var args, if any var was a local var, then logMsg will print out the *//* current stack location of that var if the calling function has since *//* exited, (likely) then the variable value is no longer valid. This is *//* avioded by evaluating the var args at call time, and passing an addr to *//* a global buffer which has scope beyond the calling function *//* ------------------------------------------------------------------------- */#define SHOW_MSG(a) SMSG( a )#ifdef DBG_LOGMSG #define DMSG( a ) dlogMsg a #define LMSG( a ) dlogMsg a #if 0 #define SMSG( a ) printf a #else #define SMSG( a ) dlogMsg a #endif#endif /* DBG_LOGMSG *//* ------------------------------------------------------------------------- */#ifdef DBG_SPRINTF #define DMSG( a ) dsprintf a #define LMSG( a ) dsprintf a #define SMSG( a ) printf a #endif /* DBG_SPRINTF *//* ------------------------------------------------------------------------- */#ifdef DBG_PRINTF #define DMSG( a ) printf a #define LMSG( a ) dlogMsg a #define SMSG( a ) printf a #endif /* DBG_PRINTF *//* ------------------------------------------------------------------------- */#ifdef DBG_SEND #define DMSG( a ) dsend a #if 0 #define LMSG( a ) dlogMsg a #else #define LMSG( a ) dsend a #endif #define SMSG( a ) dsend a #endif /* DBG_SEND *//* ------------------------------------------------------------------------- *//* ------------------------------------------------------------------------- *//* ------------------------------------------------------------------------- *//* ------------------------------------------------------------------------- *//* ------------------------------------------------------------------------- *//* DEBUGMP *//* *//* Description: *//* Print the MESSAGE message *//* *//* Prototype: *//* DEBUGMP((a, ...)) *//* *//* Arguments: *//* * A standard printf string with the correct number of arguments. *//* The argument 'a' is the string. *//* *//* Return Values: */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -