2013-11-27 16:28:31 +01:00
|
|
|
/*
|
2013-06-18 17:21:38 +02:00
|
|
|
* Copyright (C) 2013 Freie Universität Berlin
|
2010-09-22 15:10:42 +02:00
|
|
|
*
|
2013-11-22 20:47:05 +01:00
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser General
|
2013-06-18 17:21:38 +02:00
|
|
|
* Public License. See the file LICENSE in the top level directory for more
|
|
|
|
* details.
|
2013-11-27 16:28:31 +01:00
|
|
|
*/
|
2014-02-11 18:15:43 +01:00
|
|
|
|
2013-11-27 16:28:31 +01:00
|
|
|
/**
|
|
|
|
* @addtogroup core_util
|
2010-09-22 15:10:42 +02:00
|
|
|
* @{
|
2013-11-27 16:28:31 +01:00
|
|
|
*
|
|
|
|
* @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
|
2014-01-28 11:50:12 +01:00
|
|
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
2010-09-22 15:10:42 +02:00
|
|
|
*/
|
2014-02-11 18:15:43 +01:00
|
|
|
|
2013-11-27 16:28:31 +01:00
|
|
|
#ifndef __DEBUG_H
|
|
|
|
#define __DEBUG_H
|
2014-02-11 18:15:43 +01:00
|
|
|
|
2010-09-22 15:10:42 +02:00
|
|
|
#include <stdio.h>
|
2014-03-03 10:37:50 +01:00
|
|
|
#include "sched.h"
|
2010-09-22 15:10:42 +02:00
|
|
|
|
2014-03-03 00:25:09 +01:00
|
|
|
#if DEVELHELP
|
|
|
|
#include "cpu-conf.h"
|
|
|
|
#define DEBUG_PRINT(...) \
|
|
|
|
do { \
|
2014-03-19 14:22:26 +01:00
|
|
|
if ((active_thread == NULL) || (active_thread->stack_size > KERNEL_CONF_STACKSIZE_PRINTF)) { \
|
2014-03-03 00:25:09 +01:00
|
|
|
printf(__VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
else { \
|
|
|
|
puts("Cannot debug, stack too small"); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
#define DEBUG_PRINT(...) printf(__VA_ARGS__)
|
|
|
|
#endif
|
|
|
|
|
2013-07-24 00:36:06 +02:00
|
|
|
#if ENABLE_DEBUG
|
2014-03-03 10:37:50 +01:00
|
|
|
#include "tcb.h"
|
2014-03-03 00:25:09 +01:00
|
|
|
#define DEBUG(...) DEBUG_PRINT(__VA_ARGS__)
|
2014-03-03 10:37:50 +01:00
|
|
|
#define DEBUGF(...) \
|
|
|
|
do { \
|
|
|
|
DEBUG_PRINT("DEBUG(%s): %s:%d in %s: ", \
|
2014-03-19 14:22:26 +01:00
|
|
|
active_thread ? active_thread->name : "NO THREAD", \
|
|
|
|
__FILE__, __LINE__, __func__); \
|
2014-03-03 10:37:50 +01:00
|
|
|
DEBUG_PRINT(__VA_ARGS__); \
|
|
|
|
} while (0)
|
2013-07-25 21:56:37 +02:00
|
|
|
#undef ENABLE_DEBUG
|
2010-09-22 15:10:42 +02:00
|
|
|
#else
|
|
|
|
#define DEBUG(...)
|
2014-03-03 10:37:50 +01:00
|
|
|
#define DEBUGF(...)
|
2010-09-22 15:10:42 +02:00
|
|
|
#endif
|
2013-06-09 18:02:30 +02:00
|
|
|
|
2013-11-27 16:28:31 +01:00
|
|
|
/** @} */
|
|
|
|
#endif /* __DEBUG_H */
|