A version of LWIP, provided for backwards compatibility.

Dependents:   AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers debug.h Source File

debug.h

00001 /*
00002  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
00003  * All rights reserved. 
00004  * 
00005  * Redistribution and use in source and binary forms, with or without modification, 
00006  * are permitted provided that the following conditions are met:
00007  *
00008  * 1. Redistributions of source code must retain the above copyright notice,
00009  *    this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright notice,
00011  *    this list of conditions and the following disclaimer in the documentation
00012  *    and/or other materials provided with the distribution.
00013  * 3. The name of the author may not be used to endorse or promote products
00014  *    derived from this software without specific prior written permission. 
00015  *
00016  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
00017  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00018  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
00019  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00020  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
00021  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
00024  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
00025  * OF SUCH DAMAGE.
00026  *
00027  * This file is part of the lwIP TCP/IP stack.
00028  * 
00029  * Author: Adam Dunkels <adam@sics.se>
00030  *
00031  */
00032 #ifndef __LWIP_DEBUG_H__
00033 #define __LWIP_DEBUG_H__
00034 
00035 #include "lwip/arch.h"
00036 
00037 /** lower two bits indicate debug level
00038  * - 0 off
00039  * - 1 warning
00040  * - 2 serious
00041  * - 3 severe
00042  */
00043 #define LWIP_DBG_LEVEL_OFF     0x00
00044 #define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */
00045 #define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */
00046 #define LWIP_DBG_LEVEL_SEVERE  0x03
00047 #define LWIP_DBG_MASK_LEVEL    0x03
00048 
00049 /** flag for LWIP_DEBUGF to enable that debug message */
00050 #define LWIP_DBG_ON            0x80U
00051 /** flag for LWIP_DEBUGF to disable that debug message */
00052 #define LWIP_DBG_OFF           0x00U
00053 
00054 /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */
00055 #define LWIP_DBG_TRACE         0x40U
00056 /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */
00057 #define LWIP_DBG_STATE         0x20U
00058 /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */
00059 #define LWIP_DBG_FRESH         0x10U
00060 /** flag for LWIP_DEBUGF to halt after printing this debug message */
00061 #define LWIP_DBG_HALT          0x08U
00062 
00063 #ifndef LWIP_NOASSERT
00064 #define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x); } while(0)
00065 #else  /* LWIP_NOASSERT */
00066 #define LWIP_ASSERT(x,y) 
00067 #endif /* LWIP_NOASSERT */
00068 
00069 /** print "m" message only if "e" is true, and execute "h" expression */
00070 #ifndef LWIP_ERROR
00071 #define LWIP_ERROR(m,e,h) do { if (!(e)) { LWIP_PLATFORM_ASSERT(m); h;}} while(0)
00072 #endif /* LWIP_ERROR */
00073 
00074 #ifdef LWIP_DEBUG
00075 /** print debug message only if debug message type is enabled...
00076  *  AND is of correct type AND is at least LWIP_DBG_LEVEL
00077  */
00078 #define LWIP_DEBUGF(debug,x) do { \
00079                                if ( \
00080                                    ((debug) & LWIP_DBG_ON) && \
00081                                    ((debug) & LWIP_DBG_TYPES_ON) && \
00082                                    ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
00083                                  LWIP_PLATFORM_DIAG(x); \
00084                                  if ((debug) & LWIP_DBG_HALT) { \
00085                                    while(1); \
00086                                  } \
00087                                } \
00088                              } while(0)
00089 
00090 #else  /* LWIP_DEBUG */
00091 #ifndef LWIP_DEBUGF
00092 #define LWIP_DEBUGF(debug,x) 
00093 #endif
00094 #endif /* LWIP_DEBUG */
00095 
00096 #endif /* __LWIP_DEBUG_H__ */
00097