reactos/reactos/include/reactos/debug.h

130 lines
3.7 KiB
C
Raw Normal View History

/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: include/internal/debug.h
* PURPOSE: Useful debugging macros
* PROGRAMMER: David Welch (welch@mcmail.com)
* UPDATE HISTORY:
* 28/05/98: Created
*/
/*
* NOTE: Define NDEBUG before including this header to disable debugging
* macros
*/
#ifndef __INTERNAL_DEBUG
#define __INTERNAL_DEBUG
/* Define DbgPrint/DbgPrintEx/RtlAssert unless the NDK is used */
#if !defined(_RTLFUNCS_H) && !defined(_NTDDK_)
- Update NDK to remove zwfuncs.h and place the native functions in their respective xxfuncs.h instead, so that applications can now include only what they need. Add more xxfuncs.h files for every API. - Make the NDK smarter so that using #define NTOS_MODE_USER isn't needed anymore: the NDK can now auto-detect the presence of windows.h or ntddk.h and make the appropriate decision. - re-arrange ntndk.h to include all types in alphabetical order, and then all functions, regardless of um/kmode usage. - Make each file auto-detect if this is NTOS_MODE_USER or not and include each files it needs, instead of depending on a predefined order inside ntndk.h This way, any file can be included from both user-mode or kmode as simply as #include <iofuncs.h>, wthout any adtional work. - Update FIXME list with these changes and delay NDK release date since my trip is lasting a day longer. - Fix ntsecapi.h to define UNICODE_STRING, like it does in the PSDK. - Fix apps including ntsecapi + winternl.h These two cause a conflict even on PSDK and shouldn't be included together. - Make winlogon include only the NDK files it needs (2) instead of the whole NDK, as test for this faster newly supported method. - Remove some NDK apps from the FIXME list (the ones that weren't being built/are on my rewrite branch/are better off including the whole NDK instead of file-by-file). - Update debug.h to define RtlAssert and DbgPrint in case the NDK or DDK aren't already included, which will allow some of the apps to stop using the NDK solely for DPRINT/DPRINT1. Diabled for now since a lot of code needs to be changed to #include <debug.h> *After* they include the other headers. (so that the anti-double-definition check can work). svn path=/trunk/; revision=19538
2005-11-25 00:17:40 +00:00
/* Make sure we have basic types (some people include us *before* SDK... */
#if !defined(_NTDEF_) && !defined(_NTDEF_H) && !defined(_WINDEF_) && !defined(_WINDEF_H)
#error Please include SDK first.
#endif
- Update NDK to remove zwfuncs.h and place the native functions in their respective xxfuncs.h instead, so that applications can now include only what they need. Add more xxfuncs.h files for every API. - Make the NDK smarter so that using #define NTOS_MODE_USER isn't needed anymore: the NDK can now auto-detect the presence of windows.h or ntddk.h and make the appropriate decision. - re-arrange ntndk.h to include all types in alphabetical order, and then all functions, regardless of um/kmode usage. - Make each file auto-detect if this is NTOS_MODE_USER or not and include each files it needs, instead of depending on a predefined order inside ntndk.h This way, any file can be included from both user-mode or kmode as simply as #include <iofuncs.h>, wthout any adtional work. - Update FIXME list with these changes and delay NDK release date since my trip is lasting a day longer. - Fix ntsecapi.h to define UNICODE_STRING, like it does in the PSDK. - Fix apps including ntsecapi + winternl.h These two cause a conflict even on PSDK and shouldn't be included together. - Make winlogon include only the NDK files it needs (2) instead of the whole NDK, as test for this faster newly supported method. - Remove some NDK apps from the FIXME list (the ones that weren't being built/are on my rewrite branch/are better off including the whole NDK instead of file-by-file). - Update debug.h to define RtlAssert and DbgPrint in case the NDK or DDK aren't already included, which will allow some of the apps to stop using the NDK solely for DPRINT/DPRINT1. Diabled for now since a lot of code needs to be changed to #include <debug.h> *After* they include the other headers. (so that the anti-double-definition check can work). svn path=/trunk/; revision=19538
2005-11-25 00:17:40 +00:00
ULONG
__cdecl
DbgPrint(
IN PCCH Format,
- Update NDK to remove zwfuncs.h and place the native functions in their respective xxfuncs.h instead, so that applications can now include only what they need. Add more xxfuncs.h files for every API. - Make the NDK smarter so that using #define NTOS_MODE_USER isn't needed anymore: the NDK can now auto-detect the presence of windows.h or ntddk.h and make the appropriate decision. - re-arrange ntndk.h to include all types in alphabetical order, and then all functions, regardless of um/kmode usage. - Make each file auto-detect if this is NTOS_MODE_USER or not and include each files it needs, instead of depending on a predefined order inside ntndk.h This way, any file can be included from both user-mode or kmode as simply as #include <iofuncs.h>, wthout any adtional work. - Update FIXME list with these changes and delay NDK release date since my trip is lasting a day longer. - Fix ntsecapi.h to define UNICODE_STRING, like it does in the PSDK. - Fix apps including ntsecapi + winternl.h These two cause a conflict even on PSDK and shouldn't be included together. - Make winlogon include only the NDK files it needs (2) instead of the whole NDK, as test for this faster newly supported method. - Remove some NDK apps from the FIXME list (the ones that weren't being built/are on my rewrite branch/are better off including the whole NDK instead of file-by-file). - Update debug.h to define RtlAssert and DbgPrint in case the NDK or DDK aren't already included, which will allow some of the apps to stop using the NDK solely for DPRINT/DPRINT1. Diabled for now since a lot of code needs to be changed to #include <debug.h> *After* they include the other headers. (so that the anti-double-definition check can work). svn path=/trunk/; revision=19538
2005-11-25 00:17:40 +00:00
IN ...
);
ULONG
__cdecl
DbgPrintEx(
IN ULONG ComponentId,
IN ULONG Level,
IN PCCH Format,
IN ...
);
NTSYSAPI
- Update NDK to remove zwfuncs.h and place the native functions in their respective xxfuncs.h instead, so that applications can now include only what they need. Add more xxfuncs.h files for every API. - Make the NDK smarter so that using #define NTOS_MODE_USER isn't needed anymore: the NDK can now auto-detect the presence of windows.h or ntddk.h and make the appropriate decision. - re-arrange ntndk.h to include all types in alphabetical order, and then all functions, regardless of um/kmode usage. - Make each file auto-detect if this is NTOS_MODE_USER or not and include each files it needs, instead of depending on a predefined order inside ntndk.h This way, any file can be included from both user-mode or kmode as simply as #include <iofuncs.h>, wthout any adtional work. - Update FIXME list with these changes and delay NDK release date since my trip is lasting a day longer. - Fix ntsecapi.h to define UNICODE_STRING, like it does in the PSDK. - Fix apps including ntsecapi + winternl.h These two cause a conflict even on PSDK and shouldn't be included together. - Make winlogon include only the NDK files it needs (2) instead of the whole NDK, as test for this faster newly supported method. - Remove some NDK apps from the FIXME list (the ones that weren't being built/are on my rewrite branch/are better off including the whole NDK instead of file-by-file). - Update debug.h to define RtlAssert and DbgPrint in case the NDK or DDK aren't already included, which will allow some of the apps to stop using the NDK solely for DPRINT/DPRINT1. Diabled for now since a lot of code needs to be changed to #include <debug.h> *After* they include the other headers. (so that the anti-double-definition check can work). svn path=/trunk/; revision=19538
2005-11-25 00:17:40 +00:00
VOID
NTAPI
RtlAssert(
PVOID FailedAssertion,
PVOID FileName,
ULONG LineNumber,
PCHAR Message
);
- Update NDK to remove zwfuncs.h and place the native functions in their respective xxfuncs.h instead, so that applications can now include only what they need. Add more xxfuncs.h files for every API. - Make the NDK smarter so that using #define NTOS_MODE_USER isn't needed anymore: the NDK can now auto-detect the presence of windows.h or ntddk.h and make the appropriate decision. - re-arrange ntndk.h to include all types in alphabetical order, and then all functions, regardless of um/kmode usage. - Make each file auto-detect if this is NTOS_MODE_USER or not and include each files it needs, instead of depending on a predefined order inside ntndk.h This way, any file can be included from both user-mode or kmode as simply as #include <iofuncs.h>, wthout any adtional work. - Update FIXME list with these changes and delay NDK release date since my trip is lasting a day longer. - Fix ntsecapi.h to define UNICODE_STRING, like it does in the PSDK. - Fix apps including ntsecapi + winternl.h These two cause a conflict even on PSDK and shouldn't be included together. - Make winlogon include only the NDK files it needs (2) instead of the whole NDK, as test for this faster newly supported method. - Remove some NDK apps from the FIXME list (the ones that weren't being built/are on my rewrite branch/are better off including the whole NDK instead of file-by-file). - Update debug.h to define RtlAssert and DbgPrint in case the NDK or DDK aren't already included, which will allow some of the apps to stop using the NDK solely for DPRINT/DPRINT1. Diabled for now since a lot of code needs to be changed to #include <debug.h> *After* they include the other headers. (so that the anti-double-definition check can work). svn path=/trunk/; revision=19538
2005-11-25 00:17:40 +00:00
#endif
2002-11-13 Casper S. Hornstrup <chorns@users.sourceforge.net> * drivers/bus/acpi/ospm/osl.c (acpi_os_readable, acpi_os_writable): Match prototypes. * include/ascii.h (AbortSystemShutdownA): Correct prototype. * include/debug.h (assert): Wrap in #ifndef assert. * include/funcs.h (AbortSystemShutdown): Remove duplicate prototype. * include/ddk/rtltypes.h: Move ... * include/ntos/rtltypes.h: ... here. * include/ddk/rtl.h: Move ... * include/ntos/rtl.h: ... here. * include/ddk/zwtypes.h: Move ... * include/ntos/zwtypes.h: ... here. * include/ddk/zw.h: Move ... * include/ntos/zw.h: ... here. | include/ddk/cmfuncs.h: Remove file; Move NtCreateKey to ntos/zw.h. * include/ntos.h: #include ntos/rtltypes.h, ntos/rtl.h, ntos/zwtypes.h, and ntos/zw.h. * include/unicode.h: (AbortSystemShutdownW): Correct prototype. * include/ddk/ntddk.h: Include headers at new location; Don't include removed files. * include/defines.h: Wrap definitions in w32api in #ifndef __USE_W32API. * include/ntos/zwtypes.h: Ditto. * include/napi/lpc.h: Ditto. * include/napi/shared_data.h: Ditto. * include/napi/teb.h: Ditto. * include/napi/types.h: Ditto. * include/ntdll/ldr.h: Ditto. * include/ntdll/rtl.h: Ditto. * include/ntos/console.h: Ditto. * include/ntos/disk.h: Ditto. * include/ntos/except.h: Ditto. * include/ntos/file.h: Ditto. * include/ntos/gditypes.h: Ditto. * include/ntos/heap.h: Ditto. * include/ntos/keyboard.h: Ditto. * include/ntos/mm.h: Ditto. * include/ntos/ntdef.h: Ditto. * include/ntos/ps.h: Ditto. * include/ntos/registry.h: Ditto. * include/ntos/security.h: Ditto. * include/ntos/synch.h: Ditto. * include/ntos/time.h: Ditto. * include/ntos/types.h: Ditto. * include/ntos/port.h: Ditto. * lib/advapi32/misc/shutdown.c (AbortSystemShutdownW, AbortSystemShutdownA): Correct prototype. * lib/advapi32/reg/reg.c: #include ntos.h. * lib/advapi32/sec/misc.c: Ditto. * lib/advapi32/sec/sid.c: Ditto. * lib/advapi32/service/sctrl.c: Ditto. * lib/advapi32/token/token.c: Ditto. * lib/kernel32/misc/dllmain.c: Ditto. * ntoskrnl/ex/napi.c: Ditto. * ntoskrnl/rtl/i386/exception.c: Ditto. * lib/advapi32/sec/ac.c: Ditto. (FindFirstFreeAce, GetAce): Change PACE* to PACE_HEADER*. * lib/advapi32/service/scm.c (EnumServicesStatusExA, EnumServicesStatusExW, QueryServiceStatusEx): Correct prototype. * lib/ntdll/rtl/ppb.c (RtlDestroyProcessParameters): Match prototype. * ntoskrnl/dbg/errinfo.c (DbgGetErrorText): Use %08x, not %08lx. * ntoskrnl/io/arcname.c (IoCreateSystemRootLink): Use %u, not %lu. * ntoskrnl/ke/main.c (ExpInitializeExecutive): Ditto. * (_main): Use %d, not %ld. * ntoskrnl/include/internal/i386/ke.h: Add #pragma GCC system_header. * include/ddk/ntdef.h (NTSYSAPI, NTAPI, NTKERNELAPI): Define to STDCALL; Check if already defined. * include/base.h (STDCALL, CDECL, CALLBACK, PASCAL): Move to ntos/types.h. svn path=/trunk/; revision=3755
2002-11-14 18:21:07 +00:00
#ifndef assert
#ifndef NASSERT
#define assert(x) if (!(x)) {RtlAssert("#x",__FILE__,__LINE__, ""); }
#else
#define assert(x)
#endif
2002-11-13 Casper S. Hornstrup <chorns@users.sourceforge.net> * drivers/bus/acpi/ospm/osl.c (acpi_os_readable, acpi_os_writable): Match prototypes. * include/ascii.h (AbortSystemShutdownA): Correct prototype. * include/debug.h (assert): Wrap in #ifndef assert. * include/funcs.h (AbortSystemShutdown): Remove duplicate prototype. * include/ddk/rtltypes.h: Move ... * include/ntos/rtltypes.h: ... here. * include/ddk/rtl.h: Move ... * include/ntos/rtl.h: ... here. * include/ddk/zwtypes.h: Move ... * include/ntos/zwtypes.h: ... here. * include/ddk/zw.h: Move ... * include/ntos/zw.h: ... here. | include/ddk/cmfuncs.h: Remove file; Move NtCreateKey to ntos/zw.h. * include/ntos.h: #include ntos/rtltypes.h, ntos/rtl.h, ntos/zwtypes.h, and ntos/zw.h. * include/unicode.h: (AbortSystemShutdownW): Correct prototype. * include/ddk/ntddk.h: Include headers at new location; Don't include removed files. * include/defines.h: Wrap definitions in w32api in #ifndef __USE_W32API. * include/ntos/zwtypes.h: Ditto. * include/napi/lpc.h: Ditto. * include/napi/shared_data.h: Ditto. * include/napi/teb.h: Ditto. * include/napi/types.h: Ditto. * include/ntdll/ldr.h: Ditto. * include/ntdll/rtl.h: Ditto. * include/ntos/console.h: Ditto. * include/ntos/disk.h: Ditto. * include/ntos/except.h: Ditto. * include/ntos/file.h: Ditto. * include/ntos/gditypes.h: Ditto. * include/ntos/heap.h: Ditto. * include/ntos/keyboard.h: Ditto. * include/ntos/mm.h: Ditto. * include/ntos/ntdef.h: Ditto. * include/ntos/ps.h: Ditto. * include/ntos/registry.h: Ditto. * include/ntos/security.h: Ditto. * include/ntos/synch.h: Ditto. * include/ntos/time.h: Ditto. * include/ntos/types.h: Ditto. * include/ntos/port.h: Ditto. * lib/advapi32/misc/shutdown.c (AbortSystemShutdownW, AbortSystemShutdownA): Correct prototype. * lib/advapi32/reg/reg.c: #include ntos.h. * lib/advapi32/sec/misc.c: Ditto. * lib/advapi32/sec/sid.c: Ditto. * lib/advapi32/service/sctrl.c: Ditto. * lib/advapi32/token/token.c: Ditto. * lib/kernel32/misc/dllmain.c: Ditto. * ntoskrnl/ex/napi.c: Ditto. * ntoskrnl/rtl/i386/exception.c: Ditto. * lib/advapi32/sec/ac.c: Ditto. (FindFirstFreeAce, GetAce): Change PACE* to PACE_HEADER*. * lib/advapi32/service/scm.c (EnumServicesStatusExA, EnumServicesStatusExW, QueryServiceStatusEx): Correct prototype. * lib/ntdll/rtl/ppb.c (RtlDestroyProcessParameters): Match prototype. * ntoskrnl/dbg/errinfo.c (DbgGetErrorText): Use %08x, not %08lx. * ntoskrnl/io/arcname.c (IoCreateSystemRootLink): Use %u, not %lu. * ntoskrnl/ke/main.c (ExpInitializeExecutive): Ditto. * (_main): Use %d, not %ld. * ntoskrnl/include/internal/i386/ke.h: Add #pragma GCC system_header. * include/ddk/ntdef.h (NTSYSAPI, NTAPI, NTKERNELAPI): Define to STDCALL; Check if already defined. * include/base.h (STDCALL, CDECL, CALLBACK, PASCAL): Move to ntos/types.h. svn path=/trunk/; revision=3755
2002-11-14 18:21:07 +00:00
#endif
#ifndef ASSERT
#ifndef NASSERT
#define ASSERT(x) if (!(x)) {RtlAssert("#x",__FILE__,__LINE__, ""); }
#else
#define ASSERT(x)
#endif
#endif
#ifndef ASSERTMSG
#ifndef NASSERT
#define ASSERTMSG(x,m) if (!(x)) {RtlAssert("#x",__FILE__,__LINE__, m); }
#else
#define ASSERTMSG(x)
#endif
#endif
/* Print stuff only on Debug Builds*/
#define DPFLTR_DEFAULT_ID -1
#if DBG
/* These are always printed */
#define DPRINT1 DbgPrint("(%s:%d) ",__FILE__,__LINE__), DbgPrint
/* These are printed only if NDEBUG is NOT defined */
#ifndef NDEBUG
#define DPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__), DbgPrint
#else
#ifdef _MSC_VER
static __inline void DPRINT ( const char* fmt, ... )
{
UNREFERENCED_PARAMETER(fmt);
}
#else
#define DPRINT(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
#endif
#endif
#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
/* On non-debug builds, we never show these */
#define DPRINT1(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
#define DPRINT(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
#define UNIMPLEMENTED
#define ERR_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
#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
#define ASSERT_IRQL_LESS_OR_EQUAL(x) ASSERT(KeGetCurrentIrql()<=(x))
#define ASSERT_IRQL_EQUAL(x) ASSERT(KeGetCurrentIrql()==(x))
#define ASSERT_IRQL_LESS(x) ASSERT(KeGetCurrentIrql()<(x))
#endif /* __INTERNAL_DEBUG */