Loading...
Searching...
No Matches
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
32extern "C" {
33#endif
34
45#ifdef DEVELHELP
46#include "cpu_conf.h"
47#define DEBUG_PRINT(...) \
48 do { \
49 if ((thread_get_active() == NULL) || \
50 (thread_get_active()->stack_size >= \
51 THREAD_EXTRA_STACKSIZE_PRINTF)) { \
52 printf(__VA_ARGS__); \
53 } \
54 else { \
55 puts("Cannot debug, stack too small. Consider using DEBUG_PUTS()."); \
56 } \
57 } while (0)
58#else
59#define DEBUG_PRINT(...) printf(__VA_ARGS__)
60#endif
61
76#ifdef DEVELHELP
77#include "architecture.h"
78#define DEBUG_BREAKPOINT(val) ARCHITECTURE_BREAKPOINT(val)
79#else
80#define DEBUG_BREAKPOINT(val) (void)0
81#endif
82
91#if !defined(ENABLE_DEBUG) || defined(DOXYGEN)
92#define ENABLE_DEBUG 0
93#endif
94
101# if defined(__cplusplus) && defined(__GNUC__)
102# define DEBUG_FUNC __PRETTY_FUNCTION__
103# elif __STDC_VERSION__ >= 199901L
104# define DEBUG_FUNC __func__
105# elif __GNUC__ >= 2
106# define DEBUG_FUNC __FUNCTION__
107# else
108# define DEBUG_FUNC ""
109# endif
110
118#define DEBUG(...) do { if (ENABLE_DEBUG) { DEBUG_PRINT(__VA_ARGS__); } } while (0)
119
126#define DEBUG_PUTS(str) do { if (ENABLE_DEBUG) { puts(str); } } while (0)
134#if ENABLE_DEBUG
135#define DEBUG_EXTRA_STACKSIZE THREAD_EXTRA_STACKSIZE_PRINTF
136#else
137#define DEBUG_EXTRA_STACKSIZE (0)
138#endif
139
140#ifdef __cplusplus
141}
142#endif
143
144#endif /* DEBUG_H */
Platform-independent access to architecture details.
Scheduler API definition.
stdio wrapper to extend the C libs stdio