Dependencies:   mbed

Committer:
gbeardall
Date:
Mon Oct 17 10:39:17 2011 +0000
Revision:
0:715023d993d6

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gbeardall 0:715023d993d6 1
gbeardall 0:715023d993d6 2 /*
gbeardall 0:715023d993d6 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
gbeardall 0:715023d993d6 4
gbeardall 0:715023d993d6 5 Permission is hereby granted, free of charge, to any person obtaining a copy
gbeardall 0:715023d993d6 6 of this software and associated documentation files (the "Software"), to deal
gbeardall 0:715023d993d6 7 in the Software without restriction, including without limitation the rights
gbeardall 0:715023d993d6 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
gbeardall 0:715023d993d6 9 copies of the Software, and to permit persons to whom the Software is
gbeardall 0:715023d993d6 10 furnished to do so, subject to the following conditions:
gbeardall 0:715023d993d6 11
gbeardall 0:715023d993d6 12 The above copyright notice and this permission notice shall be included in
gbeardall 0:715023d993d6 13 all copies or substantial portions of the Software.
gbeardall 0:715023d993d6 14
gbeardall 0:715023d993d6 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
gbeardall 0:715023d993d6 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
gbeardall 0:715023d993d6 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
gbeardall 0:715023d993d6 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
gbeardall 0:715023d993d6 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
gbeardall 0:715023d993d6 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
gbeardall 0:715023d993d6 21 THE SOFTWARE.
gbeardall 0:715023d993d6 22 */
gbeardall 0:715023d993d6 23
gbeardall 0:715023d993d6 24 /** \file
gbeardall 0:715023d993d6 25 Debugging helpers header file
gbeardall 0:715023d993d6 26 */
gbeardall 0:715023d993d6 27
gbeardall 0:715023d993d6 28 //#ifdef DBG_H
gbeardall 0:715023d993d6 29 //#define DBG_H
gbeardall 0:715023d993d6 30
gbeardall 0:715023d993d6 31 #ifdef __LWIP_DEBUG
gbeardall 0:715023d993d6 32 #define __DEBUG
gbeardall 0:715023d993d6 33 #endif
gbeardall 0:715023d993d6 34
gbeardall 0:715023d993d6 35 /*!
gbeardall 0:715023d993d6 36 \def __DEBUG
gbeardall 0:715023d993d6 37 To define to enable debugging in one file
gbeardall 0:715023d993d6 38 */
gbeardall 0:715023d993d6 39
gbeardall 0:715023d993d6 40 #ifdef __DEBUG
gbeardall 0:715023d993d6 41
gbeardall 0:715023d993d6 42 #ifndef __DEBUGSTREAM
gbeardall 0:715023d993d6 43 #define __DEBUGSTREAM
gbeardall 0:715023d993d6 44
gbeardall 0:715023d993d6 45
gbeardall 0:715023d993d6 46 class DebugStream
gbeardall 0:715023d993d6 47 {
gbeardall 0:715023d993d6 48 public:
gbeardall 0:715023d993d6 49 static void debug(const char* format, ...);
gbeardall 0:715023d993d6 50 static void release();
gbeardall 0:715023d993d6 51 static void breakPoint(const char* file, int line);
gbeardall 0:715023d993d6 52 private:
gbeardall 0:715023d993d6 53
gbeardall 0:715023d993d6 54 };
gbeardall 0:715023d993d6 55
gbeardall 0:715023d993d6 56 #undef DBG
gbeardall 0:715023d993d6 57 #undef DBG_END
gbeardall 0:715023d993d6 58 #undef BREAK
gbeardall 0:715023d993d6 59
gbeardall 0:715023d993d6 60 ///Debug output (if enabled), same syntax as printf, with heading info
gbeardall 0:715023d993d6 61 #define DBG(...) do{ DebugStream::debug("[%s:%s@%d] ", __FILE__, __FUNCTION__, __LINE__); DebugStream::debug(__VA_ARGS__); } while(0);
gbeardall 0:715023d993d6 62
gbeardall 0:715023d993d6 63 ///Debug output (if enabled), same syntax as printf, no heading info
gbeardall 0:715023d993d6 64 #define DBGL(...) do{ DebugStream::debug(__VA_ARGS__); } while(0);
gbeardall 0:715023d993d6 65 #define DBG_END DebugStream::release
gbeardall 0:715023d993d6 66
gbeardall 0:715023d993d6 67 ///Break point usin serial debug interface (if debug enbaled)
gbeardall 0:715023d993d6 68 #define BREAK() DebugStream::breakPoint(__FILE__, __LINE__)
gbeardall 0:715023d993d6 69 #endif
gbeardall 0:715023d993d6 70
gbeardall 0:715023d993d6 71 #else
gbeardall 0:715023d993d6 72 #undef DBG
gbeardall 0:715023d993d6 73 #undef DBG_END
gbeardall 0:715023d993d6 74 #undef BREAK
gbeardall 0:715023d993d6 75 #define DBG(...)
gbeardall 0:715023d993d6 76 #define DBG_END()
gbeardall 0:715023d993d6 77 #define BREAK()
gbeardall 0:715023d993d6 78 #endif
gbeardall 0:715023d993d6 79
gbeardall 0:715023d993d6 80 #ifdef __LWIP_DEBUG
gbeardall 0:715023d993d6 81 #ifndef __SNPRINTF
gbeardall 0:715023d993d6 82 #define __SNPRINTF
gbeardall 0:715023d993d6 83 #include "mbed.h"
gbeardall 0:715023d993d6 84
gbeardall 0:715023d993d6 85 //int snprintf(char *str, int size, const char *format, ...);
gbeardall 0:715023d993d6 86 #endif
gbeardall 0:715023d993d6 87 #endif
gbeardall 0:715023d993d6 88
gbeardall 0:715023d993d6 89 #ifdef __LWIP_DEBUG
gbeardall 0:715023d993d6 90 #undef __DEBUG
gbeardall 0:715023d993d6 91 #endif
gbeardall 0:715023d993d6 92
gbeardall 0:715023d993d6 93 //#endif
gbeardall 0:715023d993d6 94