debug.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
24 #ifndef DEBUG_H
25 #define DEBUG_H
26 
27 #include <stdio.h>
28 #include "sched.h"
29 #include "thread.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
51 #ifdef DEVELHELP
52 #include "cpu_conf.h"
53 #define DEBUG_PRINT(...) \
54  do { \
55  if ((sched_active_thread == NULL) || (sched_active_thread->stack_size > THREAD_EXTRA_STACKSIZE_PRINTF)) { \
56  printf(__VA_ARGS__); \
57  } \
58  else { \
59  puts("Cannot debug, stack too small"); \
60  } \
61  } while (0)
62 #else
63 #define DEBUG_PRINT(...) printf(__VA_ARGS__)
64 #endif
65 
70 #if ENABLE_DEBUG
71 
78 # if defined(__cplusplus) && defined(__GNUC__)
79 # define DEBUG_FUNC __PRETTY_FUNCTION__
80 # elif __STDC_VERSION__ >= 199901L
81 # define DEBUG_FUNC __func__
82 # elif __GNUC__ >= 2
83 # define DEBUG_FUNC __FUNCTION__
84 # else
85 # define DEBUG_FUNC ""
86 # endif
87 
95 #define DEBUG(...) DEBUG_PRINT(__VA_ARGS__)
96 #else
97 #define DEBUG(...)
98 #endif
99 
106 #if ENABLE_DEBUG
107 #define DEBUG_EXTRA_STACKSIZE THREAD_EXTRA_STACKSIZE_PRINTF
108 #else
109 #define DEBUG_EXTRA_STACKSIZE (0)
110 #endif
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif /* DEBUG_H */
117 
Threading API.
Scheduler API definition.
stdio.h wrapper for MSP430