📄 debug.h
字号:
/*+++ *******************************************************************\
*
* Copyright and Disclaimer:
*
* ---------------------------------------------------------------
* This software is provided "AS IS" without warranty of any kind,
* either expressed or implied, including but not limited to the
* implied warranties of noninfringement, merchantability and/or
* fitness for a particular purpose.
* ---------------------------------------------------------------
*
* Copyright (c) 2008 Conexant Systems, Inc.
* All rights reserved.
*
\******************************************************************* ---*/
#ifndef __DEBUG_H
#define __DEBUG_H
extern "C" {
#define DRIVER_POOL_TAG 'Cnxt'
#define DEBUG_PREFIX_ERROR "CxPolaris (Error): "
#define DEBUG_PREFIX_WARNING "CxPolaris (Warning): "
#define DEBUG_PREFIX_INFO "CxPolaris: "
#define DEBUG_PREFIX_TRACE "CxPolaris: "
#define DEBUG_PREFIX "CxPolaris: "
extern LONG g_debug_level;
extern BOOL g_break_on_error;
class DbgTracer
{
private:
char _name[256];
// declare as private to disallow default constructor
DbgTracer();
public:
DbgTracer(char *scope_name);
~DbgTracer();
};
#if DBG
// Debug Logging
// 0 = Errors only
// 1 = Info, stream state changes, stream open close
// 2 = Verbose trace
#define DbgLog(x) {if(g_debug_level >= 0) {KdPrint((DEBUG_PREFIX));KdPrint(x);}}
#define DbgLogInfo(x) {if(g_debug_level >= 1) {KdPrint((DEBUG_PREFIX_INFO));KdPrint(x);}}
#define DbgLogTrace(x) {if(g_debug_level >= 2) {KdPrint((DEBUG_PREFIX_TRACE));KdPrint(x);}}
#define DbgLogWarn(x) {if(g_debug_level >= 0) {KdPrint((DEBUG_PREFIX));KdPrint(x);}}
#define DbgLogError(x) {\
if (g_debug_level >= 0) {\
KdPrint((DEBUG_PREFIX_ERROR));\
KdPrint(x);\
if (g_break_on_error) {\
KdBreakPoint();\
}\
}\
}
/**
* Use when writing worker code which assumes that it runs at
* passive level. Similar to PAGED_CODE() in implementation
* but not purpose.
*
* Possible cause of failure would be that someone was holding
* a spinlock when they called this worker code.
*/
#define WORKER_CODE() \
{ if (KeGetCurrentIrql() > PASSIVE_LEVEL) { \
DbgLogError(( "Worker code called at IRQL %d, expected PASSIVE_LEVEL\n", KeGetCurrentIrql() )); \
} \
}
#else //_DEBUG
#define DbgLog(x) NOP_FUNCTION;
#define DbgLogInfo(x) NOP_FUNCTION;
#define DbgLogWarn(x) NOP_FUNCTION;
#define DbgLogTrace(x) NOP_FUNCTION;
#define DbgLogError(x) NOP_FUNCTION;
#define WORKER_CODE() NOP_FUNCTION;
#endif //_DEBUG
}
#endif // #ifndef __DEBUG_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -