mirror of
https://github.com/reactos/reactos.git
synced 2024-07-01 18:24:24 +00:00
[CMAKE][INCLUDE]
- In DPRINT1(), ASSERT(), etc. - print relative (to REACTOS_SOURCE_DIR) paths to reduce debug log spam. - Unify GCC and MSVC versions of _WARN() macro. svn path=/trunk/; revision=61265
This commit is contained in:
parent
66d21d8cd9
commit
e819fe007e
14
reactos/include/reactos/builddir.h.cmake
Normal file
14
reactos/include/reactos/builddir.h.cmake
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* Do not edit - Machine generated */
|
||||
|
||||
#pragma once
|
||||
|
||||
#define REACTOS_SOURCE_DIR "@REACTOS_SOURCE_DIR@"
|
||||
#define REACTOS_BINARY_DIR "@REACTOS_BINARY_DIR@"
|
||||
|
||||
#if defined(__GNUC__) && defined(__OPTIMIZE__)
|
||||
#define __RELFILE__ \
|
||||
(!__builtin_strncmp(__FILE__, REACTOS_SOURCE_DIR, sizeof(REACTOS_SOURCE_DIR) - 1) \
|
||||
? __FILE__ + sizeof(REACTOS_SOURCE_DIR) : __FILE__)
|
||||
#endif
|
||||
|
||||
/* EOF */
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: include/internal/debug.h
|
||||
* FILE: include/reactos/debug.h
|
||||
* PURPOSE: Useful debugging macros
|
||||
* PROGRAMMERS: David Welch (welch@mcmail.com)
|
||||
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
|
||||
|
@ -12,8 +12,13 @@
|
|||
* to disable debugging macros.
|
||||
*/
|
||||
|
||||
#ifndef __INTERNAL_DEBUG
|
||||
#define __INTERNAL_DEBUG
|
||||
#pragma once
|
||||
|
||||
#include <builddir.h>
|
||||
|
||||
#if !defined(__RELFILE__)
|
||||
#define __RELFILE__ __FILE__
|
||||
#endif
|
||||
|
||||
/* Define DbgPrint/DbgPrintEx/RtlAssert unless the NDK is used */
|
||||
#if !defined(_RTLFUNCS_H) && !defined(_NTDDK_)
|
||||
|
@ -63,7 +68,7 @@ RtlAssert(
|
|||
|
||||
#ifndef assert
|
||||
#if DBG && !defined(NASSERT)
|
||||
#define assert(x) if (!(x)) { RtlAssert((PVOID)#x, (PVOID)__FILE__, __LINE__, ""); }
|
||||
#define assert(x) if (!(x)) { RtlAssert((PVOID)#x, (PVOID)__RELFILE__, __LINE__, ""); }
|
||||
#else
|
||||
#define assert(x) ((VOID) 0)
|
||||
#endif
|
||||
|
@ -71,7 +76,7 @@ RtlAssert(
|
|||
|
||||
#ifndef ASSERT
|
||||
#if DBG && !defined(NASSERT)
|
||||
#define ASSERT(x) if (!(x)) { RtlAssert((PVOID)#x, (PVOID)__FILE__, __LINE__, ""); }
|
||||
#define ASSERT(x) if (!(x)) { RtlAssert((PVOID)#x, (PVOID)__RELFILE__, __LINE__, ""); }
|
||||
#else
|
||||
#define ASSERT(x) ((VOID) 0)
|
||||
#endif
|
||||
|
@ -79,14 +84,14 @@ RtlAssert(
|
|||
|
||||
#ifndef ASSERTMSG
|
||||
#if DBG && !defined(NASSERT)
|
||||
#define ASSERTMSG(m, x) if (!(x)) { RtlAssert((PVOID)#x, __FILE__, __LINE__, m); }
|
||||
#define ASSERTMSG(m, x) if (!(x)) { RtlAssert((PVOID)#x, __RELFILE__, __LINE__, m); }
|
||||
#else
|
||||
#define ASSERTMSG(m, x) ((VOID) 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* For internal purposes only */
|
||||
#define __NOTICE(level, fmt, ...) DbgPrint(#level ": %s at %s:%d " fmt, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__)
|
||||
#define __NOTICE(level, fmt, ...) DbgPrint(#level ": %s at %s:%d " fmt, __FUNCTION__, __RELFILE__, __LINE__, ##__VA_ARGS__)
|
||||
|
||||
/* Print stuff only on Debug Builds*/
|
||||
#define DPFLTR_DEFAULT_ID -1
|
||||
|
@ -94,16 +99,16 @@ RtlAssert(
|
|||
|
||||
/* These are always printed */
|
||||
#define DPRINT1(fmt, ...) do { \
|
||||
if (DbgPrint("(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)) \
|
||||
DbgPrint("(%s:%d) DbgPrint() failed!\n", __FILE__, __LINE__); \
|
||||
if (DbgPrint("(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)) \
|
||||
DbgPrint("(%s:%d) DbgPrint() failed!\n", __RELFILE__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
/* These are printed only if NDEBUG is NOT defined */
|
||||
#ifndef NDEBUG
|
||||
|
||||
#define DPRINT(fmt, ...) do { \
|
||||
if (DbgPrint("(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)) \
|
||||
DbgPrint("(%s:%d) DbgPrint() failed!\n", __FILE__, __LINE__); \
|
||||
if (DbgPrint("(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)) \
|
||||
DbgPrint("(%s:%d) DbgPrint() failed!\n", __RELFILE__, __LINE__); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
@ -114,15 +119,15 @@ RtlAssert(
|
|||
|
||||
#define UNIMPLEMENTED __NOTICE(WARNING, "is UNIMPLEMENTED!\n");
|
||||
|
||||
#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__)
|
||||
#define ERR_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_ERROR_LEVEL, "(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)
|
||||
#define WARN_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_WARNING_LEVEL, "(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)
|
||||
#define TRACE_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_TRACE_LEVEL, "(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)
|
||||
#define INFO_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_INFO_LEVEL, "(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)
|
||||
|
||||
#define ERR__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_ERROR_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
|
||||
#define WARN__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_WARNING_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
|
||||
#define TRACE__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_TRACE_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
|
||||
#define INFO__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_INFO_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
|
||||
#define ERR__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_ERROR_LEVEL, "(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)
|
||||
#define WARN__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_WARNING_LEVEL, "(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)
|
||||
#define TRACE__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_TRACE_LEVEL, "(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)
|
||||
#define INFO__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_INFO_LEVEL, "(%s:%d) " fmt, __RELFILE__, __LINE__, ##__VA_ARGS__)
|
||||
|
||||
#else /* not DBG */
|
||||
|
||||
|
@ -234,14 +239,10 @@ do { \
|
|||
#define __STRING__(x) __STRING2__(x)
|
||||
#define __STRLINE__ __STRING__(__LINE__)
|
||||
|
||||
#define __TOKENPASTE2__(x, y) x ## y
|
||||
#define __TOKENPASTE__(x, y) __TOKENPASTE2__(x, y)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _WARN(msg) __pragma(message("WARNING! Line " __STRLINE__ ": " msg))
|
||||
#else
|
||||
#define _WARN1(_func1, _func2, _msg) void __attribute__((warning (_msg))) _func1(void); void __attribute__((used)) _func2(void) { _func1(); }
|
||||
#define _WARN(_msg) _WARN1(__TOKENPASTE__(__warn_func1__, __LINE__), __TOKENPASTE__(__warn_func2__, __LINE__), _msg)
|
||||
#if !defined(_MSC_VER) && !defined(__pragma)
|
||||
#define __pragma(x) _Pragma(#x)
|
||||
#endif
|
||||
|
||||
#endif /* __INTERNAL_DEBUG */
|
||||
#define _WARN(msg) __pragma(message("WARNING! Line " __STRLINE__ ": " msg))
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -65,3 +65,4 @@ endif()
|
|||
|
||||
configure_file(include/reactos/version.h.cmake ${REACTOS_BINARY_DIR}/include/reactos/version.h)
|
||||
configure_file(include/reactos/buildno.h.cmake ${REACTOS_BINARY_DIR}/include/reactos/buildno.h)
|
||||
configure_file(include/reactos/builddir.h.cmake ${REACTOS_BINARY_DIR}/include/reactos/builddir.h)
|
||||
|
|
Loading…
Reference in a new issue