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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/* $Id: VBoxVideoLog.h $ */
/** @file
* VBox Video drivers, logging helper
*/
/*
* Copyright (C) 2011-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef VBOXVIDEOLOG_H
#define VBOXVIDEOLOG_H
#ifndef VBOX_VIDEO_LOG_NAME
# error VBOX_VIDEO_LOG_NAME should be defined!
#endif
#ifndef VBOX_VIDEO_LOG_LOGGER
# define VBOX_VIDEO_LOG_LOGGER Log
#endif
#ifndef VBOX_VIDEO_LOGREL_LOGGER
# define VBOX_VIDEO_LOGREL_LOGGER LogRel
#endif
#ifndef VBOX_VIDEO_LOGFLOW_LOGGER
# define VBOX_VIDEO_LOGFLOW_LOGGER LogFlow
#endif
#ifndef VBOX_VIDEO_LOG_FN_FMT
# define VBOX_VIDEO_LOG_FN_FMT LOG_FN_FMT
#endif
#ifndef VBOX_VIDEO_LOG_FORMATTER
# define VBOX_VIDEO_LOG_FORMATTER(_logger, _severity, _a) \
do \
{ \
_logger((VBOX_VIDEO_LOG_PREFIX_FMT _severity, VBOX_VIDEO_LOG_PREFIX_PARMS)); \
_logger(_a); \
_logger((VBOX_VIDEO_LOG_SUFFIX_FMT VBOX_VIDEO_LOG_SUFFIX_PARMS)); \
} while (0)
#endif
/* Uncomment to show file/line info in the log */
/*#define VBOX_VIDEO_LOG_SHOWLINEINFO*/
#define VBOX_VIDEO_LOG_PREFIX_FMT VBOX_VIDEO_LOG_NAME"::"VBOX_VIDEO_LOG_FN_FMT": "
#define VBOX_VIDEO_LOG_PREFIX_PARMS __PRETTY_FUNCTION__
#ifdef VBOX_VIDEO_LOG_SHOWLINEINFO
# define VBOX_VIDEO_LOG_SUFFIX_FMT " (%s:%d)\n"
# define VBOX_VIDEO_LOG_SUFFIX_PARMS ,__FILE__, __LINE__
#else
# define VBOX_VIDEO_LOG_SUFFIX_FMT "\n"
# define VBOX_VIDEO_LOG_SUFFIX_PARMS
#endif
#ifdef DEBUG_misha
# define BP_WARN() AssertFailed()
#else
# define BP_WARN() do {} while(0)
#endif
#define _LOGMSG_EXACT(_logger, _a) \
do \
{ \
_logger(_a); \
} while (0)
#define _LOGMSG(_logger, _severity, _a) \
do \
{ \
VBOX_VIDEO_LOG_FORMATTER(_logger, _severity, _a); \
} while (0)
/* we can not print paged strings to RT logger, do it this way */
#define _LOGMSG_STR(_logger, _a, _f) do {\
int _i = 0; \
for (;(_a)[_i];++_i) { \
_logger(("%"_f, (_a)[_i])); \
}\
_logger(("\n")); \
} while (0)
#ifdef VBOX_WDDM_MINIPORT
# define _WARN_LOGGER VBOX_VIDEO_LOGREL_LOGGER
#else
# define _WARN_LOGGER VBOX_VIDEO_LOG_LOGGER
#endif
#define WARN_NOBP(_a) _LOGMSG(_WARN_LOGGER, "WARNING! :", _a)
#define WARN(_a) \
do \
{ \
WARN_NOBP(_a); \
BP_WARN(); \
} while (0)
#define ASSERT_WARN(_a, _w) do {\
if(!(_a)) { \
WARN(_w); \
}\
} while (0)
#define STOP_FATAL() do { \
AssertReleaseFailed(); \
} while (0)
#define ERR(_a) do { \
_LOGMSG(VBOX_VIDEO_LOGREL_LOGGER, "FATAL! :", _a); \
STOP_FATAL(); \
} while (0)
#define _DBGOP_N_TIMES(_count, _op) do { \
static int fDoWarnCount = (_count); \
if (fDoWarnCount) { \
--fDoWarnCount; \
_op; \
} \
} while (0)
#define WARN_ONCE(_a) do { \
_DBGOP_N_TIMES(1, WARN(_a)); \
} while (0)
#define LOG(_a) _LOGMSG(VBOX_VIDEO_LOG_LOGGER, "", _a)
#define LOGREL(_a) _LOGMSG(VBOX_VIDEO_LOGREL_LOGGER, "", _a)
#define LOGF(_a) _LOGMSG(VBOX_VIDEO_LOGFLOW_LOGGER, "", _a)
#define LOGF_ENTER() LOGF(("ENTER"))
#define LOGF_LEAVE() LOGF(("LEAVE"))
#define LOG_EXACT(_a) _LOGMSG_EXACT(VBOX_VIDEO_LOG_LOGGER, _a)
#define LOGREL_EXACT(_a) _LOGMSG_EXACT(VBOX_VIDEO_LOGREL_LOGGER, _a)
#define LOGF_EXACT(_a) _LOGMSG_EXACT(VBOX_VIDEO_LOGFLOW_LOGGER, _a)
/* we can not print paged strings to RT logger, do it this way */
#define LOG_STRA(_a) do {\
_LOGMSG_STR(VBOX_VIDEO_LOG_LOGGER, _a, "c"); \
} while (0)
#define LOG_STRW(_a) do {\
_LOGMSG_STR(VBOX_VIDEO_LOG_LOGGER, _a, "c"); \
} while (0)
#define LOGREL_STRA(_a) do {\
_LOGMSG_STR(VBOX_VIDEO_LOGREL_LOGGER, _a, "c"); \
} while (0)
#define LOGREL_STRW(_a) do {\
_LOGMSG_STR(VBOX_VIDEO_LOGREL_LOGGER, _a, "c"); \
} while (0)
#endif /*VBOXVIDEOLOG_H*/
|