sys: DEBUGBREAK macro

This commit is contained in:
Bill Zissimopoulos 2015-12-21 14:34:00 -08:00
parent 7e4c875d50
commit 09a462b26e
2 changed files with 16 additions and 24 deletions

View File

@ -10,18 +10,6 @@
#define SYM(x) case x: return #x; #define SYM(x) case x: return #x;
#define SYMBRC(x) case x: return "[" #x "]"; #define SYMBRC(x) case x: return "[" #x "]";
int fsp_bp_global = 1;
static ANSI_STRING DbgBreakPointInc = RTL_CONSTANT_STRING("Fsp*");
BOOLEAN HasDbgBreakPoint(const char *Function)
{
/* poor man's breakpoints; work around 32 breakpoints kernel limit */
if (KeGetCurrentIrql() > APC_LEVEL) /* FsRtlIsDbcsInExpression restriction */
return TRUE;
ANSI_STRING Name;
RtlInitAnsiString(&Name, Function);
return FsRtlIsDbcsInExpression(&DbgBreakPointInc, &Name);
}
const char *NtStatusSym(NTSTATUS Status) const char *NtStatusSym(NTSTATUS Status)
{ {
switch (Status) switch (Status)

View File

@ -38,6 +38,20 @@
#define DEBUGLOG(fmt, ...) ((void)0) #define DEBUGLOG(fmt, ...) ((void)0)
#endif #endif
/* DEBUGBREAK */
#if DBG
extern __declspec(selectany) int bpglobal = 1;
#define DEBUGBREAK() \
do \
{ \
static int bp = 1; \
if (bp && bpglobal && !KD_DEBUGGER_NOT_PRESENT)\
DbgBreakPoint(); \
} while (0,0)
#else
#define DEBUGBREAK() do {} while (0,0)
#endif
/* FSP_ENTER/FSP_LEAVE */ /* FSP_ENTER/FSP_LEAVE */
#if DBG #if DBG
#define FSP_DEBUGLOG_(fmt, rfmt, ...) \ #define FSP_DEBUGLOG_(fmt, rfmt, ...) \
@ -49,21 +63,12 @@
DbgPrint( \ DbgPrint( \
"[%d] " DRIVER_NAME "!" __FUNCTION__ "(" fmt ")" rfmt "\n",\ "[%d] " DRIVER_NAME "!" __FUNCTION__ "(" fmt ")" rfmt "\n",\
KeGetCurrentIrql(), __VA_ARGS__) KeGetCurrentIrql(), __VA_ARGS__)
#define FSP_DEBUGBRK_() \
do \
{ \
extern int fsp_bp_global; \
static int fsp_bp = 1; \
if (fsp_bp && fsp_bp_global && !KD_DEBUGGER_NOT_PRESENT && HasDbgBreakPoint(__FUNCTION__))\
DbgBreakPoint(); \
} while (0,0)
#else #else
#define FSP_DEBUGLOG_(fmt, rfmt, ...) ((void)0) #define FSP_DEBUGLOG_(fmt, rfmt, ...) ((void)0)
#define FSP_DEBUGLOG_NOCRIT_(fmt, rfmt, ...)((void)0) #define FSP_DEBUGLOG_NOCRIT_(fmt, rfmt, ...)((void)0)
#define FSP_DEBUGBRK_() ((void)0)
#endif #endif
#define FSP_ENTER_(...) \ #define FSP_ENTER_(...) \
FSP_DEBUGBRK_(); \ DEBUGBREAK(); \
FsRtlEnterFileSystem(); \ FsRtlEnterFileSystem(); \
try \ try \
{ \ { \
@ -78,7 +83,7 @@
FsRtlExitFileSystem(); \ FsRtlExitFileSystem(); \
} }
#define FSP_ENTER_NOCRIT_(...) \ #define FSP_ENTER_NOCRIT_(...) \
FSP_DEBUGBRK_(); \ DEBUGBREAK(); \
{ \ { \
__VA_ARGS__ __VA_ARGS__
#define FSP_LEAVE_NOCRIT_(...) \ #define FSP_LEAVE_NOCRIT_(...) \
@ -417,7 +422,6 @@ typedef struct
/* debug */ /* debug */
#if DBG #if DBG
BOOLEAN HasDbgBreakPoint(const char *Function);
const char *NtStatusSym(NTSTATUS Status); const char *NtStatusSym(NTSTATUS Status);
const char *IrpMajorFunctionSym(UCHAR MajorFunction); const char *IrpMajorFunctionSym(UCHAR MajorFunction);
const char *IrpMinorFunctionSym(UCHAR MajorFunction, UCHAR MinorFunction); const char *IrpMinorFunctionSym(UCHAR MajorFunction, UCHAR MinorFunction);