amiro-os / core / inc / aos_debug.h @ 42247107
History | View | Annotate | Download (5.169 KB)
1 | e545e620 | Thomas Schöpping | /*
|
---|---|---|---|
2 | AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
||
3 | 96621a83 | Thomas Schöpping | Copyright (C) 2016..2020 Thomas Schöpping et al.
|
4 | e545e620 | Thomas Schöpping | |
5 | This program is free software: you can redistribute it and/or modify
|
||
6 | it under the terms of the GNU General Public License as published by
|
||
7 | the Free Software Foundation, either version 3 of the License, or
|
||
8 | (at your option) any later version.
|
||
9 | |||
10 | This program is distributed in the hope that it will be useful,
|
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | GNU General Public License for more details.
|
||
14 | |||
15 | You should have received a copy of the GNU General Public License
|
||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
17 | */
|
||
18 | |||
19 | 53710ca3 | Marc Rothmann | /**
|
20 | * @file aos_debug.h
|
||
21 | * @brief Macros used for debugging.
|
||
22 | *
|
||
23 | * @addtogroup aos_debug
|
||
24 | * @{
|
||
25 | */
|
||
26 | |||
27 | 6ff06bbf | Thomas Schöpping | #ifndef AMIROOS_DEBUG_H
|
28 | #define AMIROOS_DEBUG_H
|
||
29 | e545e620 | Thomas Schöpping | |
30 | 3940ba8a | Thomas Schöpping | #include <amiroos.h> |
31 | |||
32 | f3ac1c96 | Thomas Schöpping | /******************************************************************************/
|
33 | /* CONSTANTS */
|
||
34 | /******************************************************************************/
|
||
35 | |||
36 | /******************************************************************************/
|
||
37 | /* SETTINGS */
|
||
38 | /******************************************************************************/
|
||
39 | |||
40 | /******************************************************************************/
|
||
41 | /* CHECKS */
|
||
42 | /******************************************************************************/
|
||
43 | |||
44 | /******************************************************************************/
|
||
45 | /* DATA STRUCTURES AND TYPES */
|
||
46 | /******************************************************************************/
|
||
47 | |||
48 | /******************************************************************************/
|
||
49 | /* MACROS */
|
||
50 | /******************************************************************************/
|
||
51 | e545e620 | Thomas Schöpping | |
52 | #if (AMIROOS_CFG_DBG == true) || defined(__DOXYGEN__) |
||
53 | |||
54 | /**
|
||
55 | f3ac1c96 | Thomas Schöpping | * @brief Printf function for messages only printed in debug builds.
|
56 | *
|
||
57 | * @param[in] fmt Formatted string to print.
|
||
58 | */
|
||
59 | #define aosDbgPrintf(fmt, ...) aosprintf(fmt, ##__VA_ARGS__) |
||
60 | |||
61 | /**
|
||
62 | e545e620 | Thomas Schöpping | * @brief Function parameters check.
|
63 | 9487b4cd | Thomas Schöpping | * @details If the condition check fails, the thread complains and exits.
|
64 | e545e620 | Thomas Schöpping | *
|
65 | * @param[in] c The condition to be verified to be true.
|
||
66 | */
|
||
67 | 83e58975 | Thomas Schöpping | #define aosDbgCheck(c) do { \ |
68 | 9487b4cd | Thomas Schöpping | if (!(c)) { \
|
69 | aosDbgPrintf("%s(%u): aosDbgCheck failed", __FILE__, __LINE__); \
|
||
70 | chThdExit(MSG_RESET); \ |
||
71 | } \ |
||
72 | 83e58975 | Thomas Schöpping | } while (false) |
73 | e545e620 | Thomas Schöpping | |
74 | /**
|
||
75 | * @brief Condition assertion.
|
||
76 | 9487b4cd | Thomas Schöpping | * @details If the condition check fails, the thread complains and exits.
|
77 | e545e620 | Thomas Schöpping | *
|
78 | * @param[in] c The condition to be verified to be true.
|
||
79 | */
|
||
80 | 83e58975 | Thomas Schöpping | #define aosDbgAssert(c) do { \ |
81 | 9487b4cd | Thomas Schöpping | if (!(c)) { \
|
82 | aosDbgPrintf("%s(%u): aosDbgAssert failed", __FILE__, __LINE__); \
|
||
83 | chThdExit(MSG_RESET); \ |
||
84 | } \ |
||
85 | 83e58975 | Thomas Schöpping | } while (false) |
86 | e545e620 | Thomas Schöpping | |
87 | /**
|
||
88 | * @brief Condition assertion.
|
||
89 | 9487b4cd | Thomas Schöpping | * @details If the condition check fails, the thread complains and exits.
|
90 | e545e620 | Thomas Schöpping | *
|
91 | * @param[in] c The condition to be verified to be true.
|
||
92 | * @param[in] r A custom remark string.
|
||
93 | */
|
||
94 | 83e58975 | Thomas Schöpping | #define aosDbgAssertMsg(c, fmt, ...) do { \ |
95 | 9487b4cd | Thomas Schöpping | if (!(c)) { \
|
96 | aosDbgPrintf(fmt, ##__VA_ARGS__); \ |
||
97 | chThdExit(MSG_RESET); \ |
||
98 | } \ |
||
99 | 83e58975 | Thomas Schöpping | } while (false) |
100 | e545e620 | Thomas Schöpping | |
101 | 7de0cc90 | Thomas Schöpping | #else /* (AMIROOS_CFG_DBG == true) */ |
102 | e545e620 | Thomas Schöpping | |
103 | 83e58975 | Thomas Schöpping | #define aosDbgPrintf(fmt, ...) \
|
104 | (void)(fmt)
|
||
105 | f3ac1c96 | Thomas Schöpping | |
106 | 83e58975 | Thomas Schöpping | #define aosDbgCheck(c) \
|
107 | (void)(c)
|
||
108 | e545e620 | Thomas Schöpping | |
109 | 83e58975 | Thomas Schöpping | #define aosDbgAssert(c) \
|
110 | (void)(c)
|
||
111 | e545e620 | Thomas Schöpping | |
112 | 83e58975 | Thomas Schöpping | #define aosDbgAssertMsg(c, r) \
|
113 | (void)(c); \
|
||
114 | (void)(r)
|
||
115 | e545e620 | Thomas Schöpping | |
116 | 7de0cc90 | Thomas Schöpping | #endif /* (AMIROOS_CFG_DBG == true) */ |
117 | f3ac1c96 | Thomas Schöpping | |
118 | /******************************************************************************/
|
||
119 | /* EXTERN DECLARATIONS */
|
||
120 | /******************************************************************************/
|
||
121 | 933df08e | Thomas Schöpping | |
122 | f3ac1c96 | Thomas Schöpping | /******************************************************************************/
|
123 | /* INLINE FUNCTIONS */
|
||
124 | /******************************************************************************/
|
||
125 | e545e620 | Thomas Schöpping | |
126 | 6ff06bbf | Thomas Schöpping | #endif /* AMIROOS_DEBUG_H */ |
127 | 53710ca3 | Marc Rothmann | |
128 | /** @} */ |