Rtos API example
Embed:
(wiki syntax)
Show/hide line numbers
debug.h
Go to the documentation of this file.
00001 /** 00002 * @file 00003 * Debug messages infrastructure 00004 */ 00005 00006 /* 00007 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without modification, 00011 * are permitted provided that the following conditions are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. The name of the author may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00024 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00026 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00029 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00030 * OF SUCH DAMAGE. 00031 * 00032 * This file is part of the lwIP TCP/IP stack. 00033 * 00034 * Author: Adam Dunkels <adam@sics.se> 00035 * 00036 */ 00037 #ifndef LWIP_HDR_DEBUG_H 00038 #define LWIP_HDR_DEBUG_H 00039 00040 #include "lwip/arch.h" 00041 #include "lwip/opt.h" 00042 00043 /** 00044 * @defgroup debugging_levels LWIP_DBG_MIN_LEVEL and LWIP_DBG_TYPES_ON values 00045 * @ingroup lwip_opts_debugmsg 00046 * @{ 00047 */ 00048 00049 /** @name Debug level (LWIP_DBG_MIN_LEVEL) 00050 * @{ 00051 */ 00052 /** Debug level: ALL messages*/ 00053 #define LWIP_DBG_LEVEL_ALL 0x00 00054 /** Debug level: Warnings. bad checksums, dropped packets, ... */ 00055 #define LWIP_DBG_LEVEL_WARNING 0x01 00056 /** Debug level: Serious. memory allocation failures, ... */ 00057 #define LWIP_DBG_LEVEL_SERIOUS 0x02 00058 /** Debug level: Severe */ 00059 #define LWIP_DBG_LEVEL_SEVERE 0x03 00060 /** 00061 * @} 00062 */ 00063 00064 #define LWIP_DBG_MASK_LEVEL 0x03 00065 /* compatibility define only */ 00066 #define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL 00067 00068 /** @name Enable/disable debug messages completely (LWIP_DBG_TYPES_ON) 00069 * @{ 00070 */ 00071 /** flag for LWIP_DEBUGF to enable that debug message */ 00072 #define LWIP_DBG_ON 0x80U 00073 /** flag for LWIP_DEBUGF to disable that debug message */ 00074 #define LWIP_DBG_OFF 0x00U 00075 /** 00076 * @} 00077 */ 00078 00079 /** @name Debug message types (LWIP_DBG_TYPES_ON) 00080 * @{ 00081 */ 00082 /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ 00083 #define LWIP_DBG_TRACE 0x40U 00084 /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ 00085 #define LWIP_DBG_STATE 0x20U 00086 /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ 00087 #define LWIP_DBG_FRESH 0x10U 00088 /** flag for LWIP_DEBUGF to halt after printing this debug message */ 00089 #define LWIP_DBG_HALT 0x08U 00090 /** 00091 * @} 00092 */ 00093 00094 /** 00095 * @} 00096 */ 00097 00098 /** 00099 * @defgroup lwip_assertions Assertion handling 00100 * @ingroup lwip_opts_debug 00101 * @{ 00102 */ 00103 /** 00104 * LWIP_NOASSERT: Disable LWIP_ASSERT checks: 00105 * To disable assertions define LWIP_NOASSERT in arch/cc.h. 00106 */ 00107 #ifdef __DOXYGEN__ 00108 #define LWIP_NOASSERT 00109 #undef LWIP_NOASSERT 00110 #endif 00111 /** 00112 * @} 00113 */ 00114 00115 #ifndef LWIP_NOASSERT 00116 #define LWIP_ASSERT(message, assertion) do { if (!(assertion)) { \ 00117 LWIP_PLATFORM_ASSERT(message); }} while(0) 00118 #ifndef LWIP_PLATFORM_ASSERT 00119 #error "If you want to use LWIP_ASSERT, LWIP_PLATFORM_ASSERT(message) needs to be defined in your arch/cc.h" 00120 #endif 00121 #else /* LWIP_NOASSERT */ 00122 #define LWIP_ASSERT(message, assertion) 00123 #endif /* LWIP_NOASSERT */ 00124 00125 #ifndef LWIP_ERROR 00126 #ifndef LWIP_NOASSERT 00127 #define LWIP_PLATFORM_ERROR(message) LWIP_PLATFORM_ASSERT(message) 00128 #elif defined LWIP_DEBUG 00129 #define LWIP_PLATFORM_ERROR(message) LWIP_PLATFORM_DIAG((message)) 00130 #else 00131 #define LWIP_PLATFORM_ERROR(message) 00132 #endif 00133 00134 /* if "expression" isn't true, then print "message" and execute "handler" expression */ 00135 #define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ 00136 LWIP_PLATFORM_ERROR(message); handler;}} while(0) 00137 #endif /* LWIP_ERROR */ 00138 00139 /** Enable debug message printing, but only if debug message type is enabled 00140 * AND is of correct type AND is at least LWIP_DBG_LEVEL. 00141 */ 00142 #ifdef __DOXYGEN__ 00143 #define LWIP_DEBUG 00144 #undef LWIP_DEBUG 00145 #endif 00146 00147 #ifdef LWIP_DEBUG 00148 #ifndef LWIP_PLATFORM_DIAG 00149 #error "If you want to use LWIP_DEBUG, LWIP_PLATFORM_DIAG(message) needs to be defined in your arch/cc.h" 00150 #endif 00151 #ifdef LWIP_PLATFORM_DIAG_SERIOUS 00152 #define LWIP_DEBUGF(debug, message) do { \ 00153 if ( \ 00154 ((debug) & LWIP_DBG_ON) && \ 00155 ((debug) & LWIP_DBG_TYPES_ON) && \ 00156 ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ 00157 switch ((debug) & LWIP_DBG_MASK_LEVEL) { \ 00158 case LWIP_DBG_LEVEL_SERIOUS: LWIP_PLATFORM_DIAG_SERIOUS(message); break; \ 00159 case LWIP_DBG_LEVEL_SEVERE: LWIP_PLATFORM_DIAG_SEVERE(message); break; \ 00160 case LWIP_DBG_LEVEL_WARNING: LWIP_PLATFORM_DIAG_WARNING(message); break; \ 00161 default: LWIP_PLATFORM_DIAG(message); break; \ 00162 } \ 00163 if ((debug) & LWIP_DBG_HALT) { \ 00164 while(1); \ 00165 } \ 00166 } \ 00167 } while(0) 00168 #else 00169 #define LWIP_DEBUGF(debug, message) do { \ 00170 if ( \ 00171 ((debug) & LWIP_DBG_ON) && \ 00172 ((debug) & LWIP_DBG_TYPES_ON) && \ 00173 ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ 00174 LWIP_PLATFORM_DIAG(message); \ 00175 if ((debug) & LWIP_DBG_HALT) { \ 00176 while(1); \ 00177 } \ 00178 } \ 00179 } while(0) 00180 #endif 00181 #else /* LWIP_DEBUG */ 00182 #define LWIP_DEBUGF(debug, message) 00183 #endif /* LWIP_DEBUG */ 00184 00185 #endif /* LWIP_HDR_DEBUG_H */
Generated on Sun Jul 17 2022 08:25:21 by
1.7.2