Modify DPRINT / DRPINT1 macros, check if DbgPrint crashed. Bug #4420.

svn path=/trunk/; revision=43300
This commit is contained in:
Dmitry Gorbachev 2009-10-05 14:12:49 +00:00
parent 69d7cf729d
commit c2448f19d9

View file

@ -51,7 +51,7 @@ RtlAssert(
PCHAR Message
);
#endif
#endif /* !defined(_RTLFUNCS_H) && !defined(_NTDDK_) */
#ifndef assert
#ifndef NASSERT
@ -82,12 +82,18 @@ RtlAssert(
#if DBG
/* These are always printed */
#define DPRINT1 DbgPrint("(%s:%d) ",__FILE__,__LINE__), DbgPrint
#define DPRINT1(fmt, ...) do { \
if (DbgPrint("(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)) \
DbgPrint("(%s:%d) DbgPrint() failed!\n", __FILE__, __LINE__); \
} while (0)
/* These are printed only if NDEBUG is NOT defined */
#ifndef NDEBUG
#define DPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__), DbgPrint
#define DPRINT(fmt, ...) do { \
if (DbgPrint("(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)) \
DbgPrint("(%s:%d) DbgPrint() failed!\n", __FILE__, __LINE__); \
} while (0)
#else
@ -95,16 +101,13 @@ RtlAssert(
#endif
#define UNIMPLEMENTED DbgPrint("WARNING: %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__FILE__,__LINE__);
#define UNIMPLEMENTED DbgPrint("WARNING: %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__FILE__,__LINE__);
/* The ##__VA_ARGS__ syntax is not a standard and was only tested with MSVC and GCC. If other compilers support them as well, add them to this #if block. */
#if defined(_MSC_VER) || defined(__GNUC__)
#define ERR_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_ERROR_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define WARN_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_WARNING_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define TRACE_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_TRACE_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define INFO_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_INFO_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#endif
#else
#define ERR_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_ERROR_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define WARN_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_WARNING_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define TRACE_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_TRACE_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define INFO_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_INFO_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#else /* not DBG */
/* On non-debug builds, we never show these */
#define DPRINT1(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
@ -116,7 +119,7 @@ RtlAssert(
#define WARN_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
#define TRACE_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
#define INFO_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
#endif
#endif /* not DBG */
#define ASSERT_IRQL_LESS_OR_EQUAL(x) ASSERT(KeGetCurrentIrql()<=(x))
#define ASSERT_IRQL_EQUAL(x) ASSERT(KeGetCurrentIrql()==(x))