-
Notifications
You must be signed in to change notification settings - Fork 14
/
debug.h
102 lines (85 loc) · 2.78 KB
/
debug.h
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
#pragma once
#include "core/dll.h"
#include "core/types.h"
namespace Core
{
/**
* Log to debug channel of the platform.
*/
CORE_DLL void LogV(const char* Text, va_list ArgList);
/**
* Log to debug channel of the platform.
*/
CORE_DLL void Log(const char* Text, ...);
/**
* Internal assertion.
*/
CORE_DLL bool AssertInternal(const char* pMessage, const char* pFile, int Line, ...);
/**
* @return Is debugger attached?
*/
CORE_DLL bool IsDebuggerAttached();
enum class MessageBoxType
{
OK = 0,
OK_CANCEL,
YES_NO,
YES_NO_CANCEL
};
enum class MessageBoxIcon
{
WARNING = 0,
ERROR,
QUESTION
};
enum class MessageBoxReturn
{
OK = 0,
YES = 0,
NO = 1,
CANCEL = 2,
};
/**
* Open a message box.
*/
CORE_DLL MessageBoxReturn MessageBox(const char* title, const char* message,
MessageBoxType type = MessageBoxType::OK, MessageBoxIcon icon = MessageBoxIcon::WARNING);
/**
* Get callstack.
* @return Number of addresses.
*/
CORE_DLL i32 GetCallstack(i32 skipFrames, void** addresses, i32 maxAddresses, i32* stackHash = nullptr);
/**
* Set break on assertion.
*/
CORE_DLL void SetBreakOnAssertion(bool enableBreak);
} // namespace Core
//////////////////////////////////////////////////////////////////////////
// Macros
#if !defined(_RELEASE)
#if PLATFORM_WINDOWS
#define DBG_BREAK __debugbreak()
#else
#define DBG_BREAK
#endif
#define DBG_ASSERT_MSG(Condition, Message, ...) \
if(!(Condition)) \
{ \
if(Core::AssertInternal(Message, __FILE__, __LINE__, __VA_ARGS__)) \
DBG_BREAK; \
}
#define DBG_ASSERT(Condition) \
if(!(Condition)) \
{ \
if(Core::AssertInternal(#Condition, __FILE__, __LINE__)) \
DBG_BREAK; \
}
#define DBG_VERIFY(Condition) DBG_ASSERT(Condition)
#define DBG_LOG(...) Core::Log(__VA_ARGS__)
#else
#define DBG_BREAK
#define DBG_ASSERT_MSG(Condition, Message, ...)
#define DBG_ASSERT(Condition)
#define DBG_VERIFY(Condition) Condition
#define DBG_LOG(...)
#endif