diff --git a/src/sys/debug.c b/src/sys/debug.c index 583a2730..dcfe4f7a 100644 --- a/src/sys/debug.c +++ b/src/sys/debug.c @@ -10,18 +10,6 @@ #define SYM(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) { switch (Status) diff --git a/src/sys/driver.h b/src/sys/driver.h index 35d64a22..c9edb192 100644 --- a/src/sys/driver.h +++ b/src/sys/driver.h @@ -38,6 +38,20 @@ #define DEBUGLOG(fmt, ...) ((void)0) #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 */ #if DBG #define FSP_DEBUGLOG_(fmt, rfmt, ...) \ @@ -49,21 +63,12 @@ DbgPrint( \ "[%d] " DRIVER_NAME "!" __FUNCTION__ "(" fmt ")" rfmt "\n",\ 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 #define FSP_DEBUGLOG_(fmt, rfmt, ...) ((void)0) #define FSP_DEBUGLOG_NOCRIT_(fmt, rfmt, ...)((void)0) -#define FSP_DEBUGBRK_() ((void)0) #endif #define FSP_ENTER_(...) \ - FSP_DEBUGBRK_(); \ + DEBUGBREAK(); \ FsRtlEnterFileSystem(); \ try \ { \ @@ -78,7 +83,7 @@ FsRtlExitFileSystem(); \ } #define FSP_ENTER_NOCRIT_(...) \ - FSP_DEBUGBRK_(); \ + DEBUGBREAK(); \ { \ __VA_ARGS__ #define FSP_LEAVE_NOCRIT_(...) \ @@ -417,7 +422,6 @@ typedef struct /* debug */ #if DBG -BOOLEAN HasDbgBreakPoint(const char *Function); const char *NtStatusSym(NTSTATUS Status); const char *IrpMajorFunctionSym(UCHAR MajorFunction); const char *IrpMinorFunctionSym(UCHAR MajorFunction, UCHAR MinorFunction);