Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/include/lwip/debug.h need to be fixed.

0001 /*
0002  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
0003  * All rights reserved. 
0004  * 
0005  * Redistribution and use in source and binary forms, with or without modification, 
0006  * are permitted provided that the following conditions are met:
0007  *
0008  * 1. Redistributions of source code must retain the above copyright notice,
0009  *    this list of conditions and the following disclaimer.
0010  * 2. Redistributions in binary form must reproduce the above copyright notice,
0011  *    this list of conditions and the following disclaimer in the documentation
0012  *    and/or other materials provided with the distribution.
0013  * 3. The name of the author may not be used to endorse or promote products
0014  *    derived from this software without specific prior written permission. 
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
0017  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
0018  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
0019  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
0020  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
0021  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
0022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
0023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
0024  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
0025  * OF SUCH DAMAGE.
0026  *
0027  * This file is part of the lwIP TCP/IP stack.
0028  * 
0029  * Author: Adam Dunkels <adam@sics.se>
0030  *
0031  */
0032 #ifndef __LWIP_DEBUG_H__
0033 #define __LWIP_DEBUG_H__
0034 
0035 #include "lwip/arch.h"
0036 
0037 /** lower two bits indicate debug level
0038  * - 0 all
0039  * - 1 warning
0040  * - 2 serious
0041  * - 3 severe
0042  */
0043 #define LWIP_DBG_LEVEL_ALL     0x00
0044 #define LWIP_DBG_LEVEL_OFF     LWIP_DBG_LEVEL_ALL /* compatibility define only */
0045 #define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */
0046 #define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */
0047 #define LWIP_DBG_LEVEL_SEVERE  0x03
0048 #define LWIP_DBG_MASK_LEVEL    0x03
0049 
0050 /** flag for LWIP_DEBUGF to enable that debug message */
0051 #define LWIP_DBG_ON            0x80U
0052 /** flag for LWIP_DEBUGF to disable that debug message */
0053 #define LWIP_DBG_OFF           0x00U
0054 
0055 /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */
0056 #define LWIP_DBG_TRACE         0x40U
0057 /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */
0058 #define LWIP_DBG_STATE         0x20U
0059 /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */
0060 #define LWIP_DBG_FRESH         0x10U
0061 /** flag for LWIP_DEBUGF to halt after printing this debug message */
0062 #define LWIP_DBG_HALT          0x08U
0063 
0064 #ifndef LWIP_NOASSERT
0065 #define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \
0066   LWIP_PLATFORM_ASSERT(message); } while(0)
0067 #else  /* LWIP_NOASSERT */
0068 #define LWIP_ASSERT(message, assertion) 
0069 #endif /* LWIP_NOASSERT */
0070 
0071 /** if "expression" isn't true, then print "message" and execute "handler" expression */
0072 #ifndef LWIP_ERROR
0073 #define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \
0074   LWIP_PLATFORM_ASSERT(message); handler;}} while(0)
0075 #endif /* LWIP_ERROR */
0076 
0077 #ifdef LWIP_DEBUG
0078 /** print debug message only if debug message type is enabled...
0079  *  AND is of correct type AND is at least LWIP_DBG_LEVEL
0080  */
0081 #define LWIP_DEBUGF(debug, message) do { \
0082                                if ( \
0083                                    ((debug) & LWIP_DBG_ON) && \
0084                                    ((debug) & LWIP_DBG_TYPES_ON) && \
0085                                    ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
0086                                  LWIP_PLATFORM_DIAG(message); \
0087                                  if ((debug) & LWIP_DBG_HALT) { \
0088                                    while(1); \
0089                                  } \
0090                                } \
0091                              } while(0)
0092 
0093 #else  /* LWIP_DEBUG */
0094 #define LWIP_DEBUGF(debug, message) 
0095 #endif /* LWIP_DEBUG */
0096 
0097 #endif /* __LWIP_DEBUG_H__ */
0098