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 #ifndef ENABLE_DEBUG
71 #define ENABLE_DEBUG (0)
72 #endif
73 
80 # if defined(__cplusplus) && defined(__GNUC__)
81 # define DEBUG_FUNC __PRETTY_FUNCTION__
82 # elif __STDC_VERSION__ >= 199901L
83 # define DEBUG_FUNC __func__
84 # elif __GNUC__ >= 2
85 # define DEBUG_FUNC __FUNCTION__
86 # else
87 # define DEBUG_FUNC ""
88 # endif
89 
97 #define DEBUG(...) if (ENABLE_DEBUG) DEBUG_PRINT(__VA_ARGS__)
98 
105 #if ENABLE_DEBUG
106 #define DEBUG_EXTRA_STACKSIZE THREAD_EXTRA_STACKSIZE_PRINTF
107 #else
108 #define DEBUG_EXTRA_STACKSIZE (0)
109 #endif
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif /* DEBUG_H */
116 
Threading API.
Scheduler API definition.
stdio.h wrapper for MSP430