/*#*
*#* $Log$
+ *#* Revision 1.7 2006/02/20 02:01:56 bernie
+ *#* Depend on cfg/os.h.
+ *#*
+ *#* Revision 1.6 2006/02/17 22:28:37 bernie
+ *#* Support TRACE() and TRACEMSG() on hosted targets.
+ *#*
+ *#* Revision 1.5 2005/11/04 16:09:03 bernie
+ *#* Doxygen workaround.
+ *#*
+ *#* Revision 1.4 2005/07/03 15:18:52 bernie
+ *#* Typo.
+ *#*
+ *#* Revision 1.3 2005/06/27 21:23:55 bernie
+ *#* Rename cfg/config.h to appconfig.h.
+ *#*
*#* Revision 1.2 2005/04/11 19:10:27 bernie
*#* Include top-level headers from cfg/ subdir.
*#*
#ifndef DEVLIB_DEBUG_H
#define DEVLIB_DEBUG_H
-/*
- * Try to guess whether we're running in a hosted or embedded environment.
- */
-#ifndef OS_HOSTED
- #if defined(__unix__) || defined(_WIN32)
- #define OS_HOSTED 1
- #else
- #define OS_HOSTED 0
- #endif
-#endif /* !OS_HOSTED */
+#include <cfg/os.h>
#if OS_HOSTED
/*
* This preprocessor symbol is defined only in debug builds.
*
* The build infrastructure must arrange for _DEBUG to
- * be prepredefined for all source files being compiled.
+ * be predefined for all source files being compiled.
*
* This is compatible with the Microsoft convention for
* the default Debug and Release targets.
/*!
* This macro can be used to conditionally exclude one or more
* statements conditioned on \c _DEBUG, avoiding the clutter
- * of #ifdef/#endif pairs.
+ * of ifdef/endif pairs.
*
* \code
* struct FooBar
}
/* G++ can't inline functions with variable arguments... */
#define kprintf(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
+ #define kvprintf(fmt, ap) vfprintf(stderr, fmt, ap)
void kdump(const void *buf, size_t len); /* UNIMPLEMENTED */
#ifndef ASSERT
#include <assert.h>
#define ASSERT(x) assert(x)
#endif /* ASSERT */
+ #define ASSERT2(x, help) ASSERT(help && x)
/*!
* Check that the given pointer is not NULL or pointing to raw memory.
#define ASSERT_VALID_PTR(p) ASSERT((unsigned long)(p) > 0x200)
#define ASSERT_VALID_PTR_OR_NULL(p) ASSERT((((p) == NULL) || ((unsigned long)(p) >= 0x200)))
+
+ #if !CONFIG_KDEBUG_DISABLE_TRACE
+ #define TRACE kporintf("%s()\n", __func__)
+ #define TRACEMSG(msg,...) kprintf("%s(): " msg, __func__, ## __VA_ARGS__)
+ #else
+ #define TRACE do {} while(0)
+ #define TRACEMSG(...) do {} while(0)
+ #endif
+
#else /* !OS_HOSTED */
- #include <cfg/config.h> /* CONFIG_KDEBUG_ASSERT_NO_TEXT */
+ #include <appconfig.h> /* CONFIG_KDEBUG_ASSERT_NO_TEXT */
#include <cfg/cpu.h> /* CPU_HARVARD */
/* These are implemented in drv/kdebug.c */