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