📄 dbg.h
字号:
// dbg.h
#ifndef __DBG_H__
#define __DBG_H__
#ifdef DEBUG
#include "ndis.h"
#define DBG_DEFAULT 0xffff
#define DBG_MSG_MARKER TEXT("GSPX")
#define MAX_BUF_DUMP_SIZE 256
// WindowsCE debug zones
#define ZONE_INIT DEBUGZONE(0)
#define ZONE_INTR DEBUGZONE(1)
#define ZONE_XMIT DEBUGZONE(2)
#define ZONE_RCV DEBUGZONE(3)
#define ZONE_FUNC DEBUGZONE(4)
#define ZONE_MISC DEBUGZONE(5)
#define ZONE_XX06 DEBUGZONE(6)
#define ZONE_XX07 DEBUGZONE(7)
#define ZONE_XX08 DEBUGZONE(8)
#define ZONE_XX09 DEBUGZONE(9)
#define ZONE_XX10 DEBUGZONE(10)
#define ZONE_XX11 DEBUGZONE(11)
#define ZONE_XX12 DEBUGZONE(12)
#define ZONE_XX13 DEBUGZONE(13)
#define ZONE_WARN DEBUGZONE(14)
#define ZONE_ERROR DEBUGZONE(15)
extern DBGPARAM dpCurSettings;
extern FILE *LogFile;
#ifdef DBG_LOG_FILE
#define DEBUG_INIT() {LogFile =_wfreopen(TEXT("GspxDbg.txt"), TEXT("w"), stdout);}
#define DEBUG_HALT() if (LogFile) {fflush(LogFile); fclose(LogFile);}
#define DEBUG_FLUSH_FILE() {if (LogFile) fflush(LogFile);}
#undef DEBUGMSG
#define DEBUGMSG(cond, printf_exp) \
if (cond) { \
_tprintf(DBG_MSG_MARKER TEXT(" %d "), GetTickCount()); \
_tprintf printf_exp; \
}
#else //ifdef DBG_LOG_FILE
#define DEBUG_INIT()
#define DEBUG_HALT()
#define DEBUG_FLUSH_FILE()
#endif //ifdef DBG_LOG_FILE
//Hex-dumping a buffer
static __inline DEBUGBUF(UINT cond, TCHAR *msg, PUCHAR buf, int size)
{
if (cond)
{
char str[3*MAX_BUF_DUMP_SIZE+1];
UCHAR *p = (PUCHAR)buf;
char *q = str;
int i;
for (i = 1; i <= min(size, MAX_BUF_DUMP_SIZE); i++)
{
if ((i & 0x0f) == 0) //16 bytes per line
sprintf(q, "%02x\n", *p++);
else
sprintf(q, "%02x ", *p++);
q += 3;
}
*(--q) = 0;
if (size > 16)
{
DEBUGMSG(cond, (TEXT("%s\n%hs\n"), msg, str));
}
else
{
DEBUGMSG(cond, (TEXT("%s %hs\n"), msg, str));
}
}
}
#else //ifdef DEBUG
#define DEBUG_INIT()
#define DEBUG_HALT()
#define DEBUG_FLUSH_FILE()
#define DEBUGBUF(cond, msg, buf, size)
#endif //ifdef DEBUG
#endif //ifndef __DBG_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -