-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebug.cpp
More file actions
121 lines (94 loc) · 3.5 KB
/
Debug.cpp
File metadata and controls
121 lines (94 loc) · 3.5 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
121
/*
Copyright (C) 1998-2007 Emil Maskovsky
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
@file
Debugging functions (interface).
@author Emil Maskovsky
*/
/* Framework libraries. */
/* Application specific. */
#include "mx/Debug.hpp"
/**
Handle check failure.
@internal
This handler is raised in case of the check failure, i.e. the check
condition evaluated to @c false.
@param [in] xFileInfo Debug checkpoint information.
@param [in] sCondition The string representation of the condition, which was
failed.
@param [in] sMessage The extra message (optional).
*/
/**
@note
This handler is not to be used directly, use the @ref debugging_macros
"debugging macros" instead.
@see mxCheck()
*/
/* static */ void mx::Debug::HandleCheck(
const Checkpoint & xFileInfo,
const Char * const sCondition,
const Char * const sMessage)
{
// This is the check of the condition string. It will be always set, if the
// method is used properly through mxCheck() etc., but when
// used improperly (direct call of the function) we must be sure that
// following code will not trigger segmentation fault.
//
// We use mxReleaseAssert() here for the test, because the method is
// available even in release builds.
mxReleaseAssert(sCondition != NULL);
Log(Log::LOG_Check, xFileInfo).LogMessage(
sMessage ? _T("%s (%s)") : _T("%s"),
sCondition, sMessage);
}
/**
Handle assertion failure.
@internal
This handler is raised in case of the assertion failure, i.e. the assert
condition evaluated to @c false.
@param [in] xFileInfo Debug checkpoint information.
@param [in] sCondition The string representation of the condition, which was
failed.
@param [in] sMessage The extra message (optional).
This handler never returns and causes the application to be shut down
(abort).
*/
/**
@note
This handler is not to be used directly, use the @ref debugging_macros
"debugging macros" instead.
@see mxAssert(), mxReleaseAssert(), mxTest()
*/
/* static */ MX_NORETURN mx::Debug::HandleAssert(
const Checkpoint & xFileInfo,
const Char * const sCondition,
const Char * const sMessage)
{
// This is the check of the condition string. It will be always set, if the
// method is used properly through mxAssert(), mxTest() etc., but when
// used improperly (direct call of the function) we must be sure that
// following code will not trigger segmentation fault.
//
// We use mxReleaseAssert() here for the test, because the method is
// available even in release builds.
mxReleaseAssert(sCondition != NULL);
Log(Log::LOG_Assert, xFileInfo).LogAssert(
sMessage ? _T("%s (%s)") : _T("%s"),
sCondition, sMessage);
}
// Define inline methods here if inlining is disabled.
#ifndef MX_INLINE_ENABLED
#include "mx/Debug.inl"
#endif
/* EOF */