-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgnudebug.h
More file actions
120 lines (90 loc) · 3.38 KB
/
gnudebug.h
File metadata and controls
120 lines (90 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
*
* gnudebug.h
*
* Author: Markku Rossi <[email protected]>
*
* Copyright (c) 2001-2009 Markku Rossi.
*
* What is this file for?
*
*/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef GNUDEBUG_H
#define GNUDEBUG_H
/************************** Types and definitions ***************************/
struct GnuDebugModuleRec
{
struct GnuDebugModuleRec *next;
const char *name;
unsigned int initialized : 1;
unsigned int debug_level : 8;
};
typedef struct GnuDebugModuleRec GnuDebugModuleStruct;
typedef struct GnuDebugModuleRec *GnuDebugModule;
#ifdef _MSC_VER
/* Fetch some missing symbols from Windows' CRT. */
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define strtoll _strtoi64
#endif /* _MSC_VER */
#ifdef __GNUC__
#define GNU__FUNCTION__ __FUNCTION__
#endif /* __GNUC__ */
#if !defined(GNU__FUNCTION__)
#define GNU__FUNCTION__ "<unknown>"
#endif /* not GNU__FUNCTION__ */
#define GNU_DEBUG_MODULE(name) \
static GnuDebugModuleStruct gnu_debug_module = \
{ \
NULL, \
name, \
0, \
0, \
}
#define GNU_DEBUG(level, vacall) \
do \
{ \
if (!gnu_debug_module.initialized) \
gnu_debug_init_module(&gnu_debug_module); \
\
if (gnu_debug_module.debug_level >= (level)) \
{ \
gnu_debug_lock(); \
gnu_debug_set_line(__FILE__, __LINE__); \
gnu_debug_set_function(GNU__FUNCTION__); \
gnu_debug vacall; \
gnu_debug_unlock(); \
} \
} \
while (0)
/******************************* Debug levels *******************************/
#define GNU_D_ERROR 0
/************************ Public debugging functions ************************/
/* XXX */
void gnu_debug_set_level_string(const char *string);
/* XXX */
void gnu_debug(char *fmt, ...);
/***************** Prototypes for internal debug functions ******************/
/* XXX */
void gnu_debug_init_module(GnuDebugModule module);
void gnu_debug_lock(void);
void gnu_debug_unlock(void);
void gnu_debug_set_line(const char *file, int line);
void gnu_debug_set_function(const char *function);
#endif /* not GNUDEBUG_H */