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