1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/core/include/debug.h
Hauke Petersen 7df411e7b7 core: improved doxygen documentation
improved files complient to issue #950
- thread.h
- flags.h
- debug.h
- crash.h
2014-05-15 10:52:34 +02:00

86 lines
2.2 KiB
C

/*
* Copyright (C) 2014 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License. See the file LICENSE in the top level directory for more
* details.
*/
/**
* @addtogroup core_util
* @{
*
* @file debug.h
* @brief Debug-header
*
* #define ENABLE_DEBUG, include this and then use DEBUG as printf you can toggle.
*
* @author Freie Universität Berlin, Computer Systems & Telematics
* @author Kaspar Schleiser <kaspar@schleiser.de>
*/
#ifndef __DEBUG_H
#define __DEBUG_H
#include <stdio.h>
#include "sched.h"
/**
* @name Print debug information if the calling thread stack is large enough
*
* Use this macro the same as printf. When DEVHELP is defined inside an
* implementation file, all usages of *DEBUG_PRINTF* will print the given
* information to std-out. If DEVHELP is not set, all occurrences of
* *DEBUG_PRINTF* will be ignored.
*
* @{
*/
#if DEVELHELP
#include "cpu-conf.h"
#define DEBUG_PRINT(...) \
do { \
if ((active_thread == NULL) || (active_thread->stack_size > KERNEL_CONF_STACKSIZE_PRINTF)) { \
printf(__VA_ARGS__); \
} \
else { \
puts("Cannot debug, stack too small"); \
} \
} while (0)
#else
#define DEBUG_PRINT(...) printf(__VA_ARGS__)
#endif
/** @} */
/**
* @brief Print debug information to std-out
*
* If *ENABLE_DEBUG* is defined inside an implementation file, all calls to
* *DEBUG* and *DEBUGF* will work the same as *printf* and output the given
* information to stdout. If *ENABLE_DEBUG* is not defined, all calls to
* *DEBUG* and *DEBUGF* will be ignored.
*
* In addition to just printing the given information *DEBUGF* will further
* print extended debug information about the current thread and function.
*
* @{
*/
#if ENABLE_DEBUG
#include "tcb.h"
#define DEBUG(...) DEBUG_PRINT(__VA_ARGS__)
#define DEBUGF(...) \
do { \
DEBUG_PRINT("DEBUG(%s): %s:%d in %s: ", \
active_thread ? active_thread->name : "NO THREAD", \
__FILE__, __LINE__, __func__); \
DEBUG_PRINT(__VA_ARGS__); \
} while (0)
#undef ENABLE_DEBUG
#else
#define DEBUG(...)
#define DEBUGF(...)
#endif
/** @} */
#endif /* __DEBUG_H */
/** @} */