Debian Codegraph @

IGC/OCLFE/igd_fcl_mcl/headers/clang_debug.h

raw symbols SCIP
1 /*========================== begin_copyright_notice ============================
2
3 Copyright (C) 2017-2021 Intel Corporation
4
5 SPDX-License-Identifier: MIT
6
7 ============================= end_copyright_notice ===========================*/
8
9 #ifndef CLANG_DEBUG_H
10 #define CLANG_DEBUG_H
11
12 #if defined _WIN32
13
14 #if defined(_DEBUG) || defined(_INTERNAL)
15
16 #include "../headers/RegistryAccess.h"
17
18 using namespace std;
19
20 #define CLANG_REGKEY "Software\\Intel\\IGFX\\OCL"
21
22 namespace clang {
23
24 /*****************************************************************************
25 MACRO: OCL_CLANG_DeclareBool
26 PURPOSE: Declares a new BOOL debug variable. Use only inside
27 DEBUG_VARIABLES struct definition.
28 \*****************************************************************************/
29 #define OCL_CLANG_DeclareBool(name, group, description) \
30 struct SDebugVariableMetaData_##name : public SDebugVariableMetaData { \
31 const char *GetName() const { return #name; } \
32 const char *GetGroup() const { return group; } \
33 const char *GetType() const { return "bool"; } \
34 const char *GetDescription() const { return description; } \
35 const DWORD Value() const { return m_Value; } \
36 } name
37
38 /*****************************************************************************\
39 MACRO: OCL_CLANG_DeclareDword
40 PURPOSE: Declares a new DWORD debug variable. Use only inside
41 DEBUG_VARIABLES struct definition.
42 \*****************************************************************************/
43 #define OCL_CLANG_DeclareDword(name, group, description) \
44 struct SDebugVariableMetaData_##name : public SDebugVariableMetaData { \
45 const char *GetName() const { return #name; } \
46 const char *GetGroup() const { return group; } \
47 const char *GetType() const { return "dword"; } \
48 const char *GetDescription() const { return description; } \
49 const DWORD Value() const { return m_Value; } \
50 } name
51
52 /*****************************************************************************\
53 MACRO: OCL_CLANG_DeclareBitmask
54 PURPOSE: Declares a new bitmask debug variable. Use only inside
55 DEBUG_VARIABLES struct definition.
56 \*****************************************************************************/
57 #define OCL_CLANG_DeclareBitmask(name, group, description, values) \
58 struct SDebugVariableMetaData_##name : public SDebugVariableMetaData { \
59 const char *GetName() const { return #name; } \
60 const char *GetGroup() const { return group; } \
61 const char *GetType() const { return "bitmask"; } \
62 const char *GetDescription() const { return description; } \
63 const DWORD Value() const { return m_Value; } \
64 virtual void DumpDefinition(FILE *fp) const { \
65 DumpBitmaskDefinition(fp, values, sizeof(values) / sizeof(SDebugVariableBitmaskValue)); \
66 } \
67 } name
68
69 /*****************************************************************************\
70 MACRO: OCL_CLANG_DeclareString
71 PURPOSE: Declares a new string debug variable. Use only inside
72 DEBUG_VARIABLES struct definition.
73 \*****************************************************************************/
74 #define OCL_CLANG_DeclareString(name, group, description) \
75 struct SDebugVariableMetaData_##name : public SDebugVariableMetaData { \
76 const char *GetName() const { return #name; } \
77 const char *GetGroup() const { return group; } \
78 const char *GetType() const { return "string"; } \
79 const char *GetDescription() const { return description; } \
80 } name
81
82 /*****************************************************************************\
83 MACRO: OCL_CLANG_DeclareEnum
84 PURPOSE: Declares a new enum debug variable. Use only inside
85 DEBUG_VARIABLES struct definition.
86 \*****************************************************************************/
87 #define OCL_CLANG_DeclareEnum(name, group, description, values) \
88 struct SDebugVariableMetaData_##name : public SDebugVariableMetaData { \
89 const char *GetName() const { return #name; } \
90 const char *GetGroup() const { return group; } \
91 const char *GetType() const { return "enum"; } \
92 const char *GetDescription() const { return description; } \
93 const DWORD Value() const { return m_Value; } \
94 virtual void DumpDefinition(FILE *fp) const { \
95 DumpEnumDefinition(fp, values, sizeof(values) / sizeof(SDebugVariableEnumValue)); \
96 } \
97 } name
98
99 // 00
100 /*****************************************************************************\
101 STRUCT: SDebugVariableBitmaskValue
102 PURPOSE: Defines a possible debug variable bitmask value
103 \*****************************************************************************/
104 struct SDebugVariableBitmaskValue {
105 const char *Name;
106 const DWORD Value;
107 };
108
109 // 01
110 /*****************************************************************************\
111 STRUCT: SDebugVariableEnumValue
112 PURPOSE: Defines a possible debug variable enum value
113 \*****************************************************************************/
114 struct SDebugVariableEnumValue {
115 const char *Name;
116 const DWORD Value;
117 };
118
119 // 02
120 /*****************************************************************************\
121 STRUCT: SDebugVariableMetaData
122 PURPOSE: Defines meta data for holding/defining debug variables
123 \*****************************************************************************/
124 struct SDebugVariableMetaData {
125 DWORD m_Value;
126 BOOL m_IsSet;
127
128 SDebugVariableMetaData() : m_Value(0), m_IsSet(FALSE) {}
129
130 virtual const char *GetName() const = 0;
131 virtual const char *GetDescription() const = 0;
132 virtual const char *GetType() const = 0;
133 virtual const char *GetGroup() const = 0;
134
135 virtual void DumpDefinition(FILE *fp) const {
136 fprintf(fp, " <Key name=\"%s\" type=\"%s\" location=\"%s\" description=\"%s\" />\n", GetName(), GetType(),
137 "HKLM\\" CLANG_REGKEY, GetDescription());
138 }
139
140 void DumpEnumDefinition(FILE *fp, const SDebugVariableEnumValue *pList, const size_t count) const {
141 fprintf(fp, " <Key name=\"%s\" type=\"%s\" location=\"%s\" description=\"%s [VALUES] ", GetName(), GetType(),
142 "HKLM\\" CLANG_REGKEY, GetDescription());
143 for (size_t i = 0; i < count; i++) {
144 const char *comma = (i == 0) ? "" : ",";
145 fprintf(fp, "%s%s=0x%08x", comma, pList[i].Name, pList[i].Value);
146 }
147 fprintf(fp, "\" />\n");
148 }
149
150 void DumpBitmaskDefinition(FILE *fp, const SDebugVariableBitmaskValue *pList, const size_t count) const {
151 fprintf(fp, " <Key name=\"%s\" type=\"%s\" location=\"%s\" description=\"%s [VALUES] ", GetName(), GetType(),
152 "HKLM\\" CLANG_REGKEY, GetDescription());
153 for (size_t i = 0; i < count; i++) {
154 const char *comma = (i == 0) ? "" : ",";
155 fprintf(fp, "%s%s=0x%08x", comma, pList[i].Name, pList[i].Value);
156 }
157 fprintf(fp, "\" />\n");
158 }
159 };
160
161 /*****************************************************************************\
162 External API call to DumpRegistryDefinations
163 \*****************************************************************************/
164
165 struct DEBUG_VARIABLES_REGKEY;
166
167 extern DEBUG_VARIABLES_REGKEY g_DebugVariables;
168
169 typedef void(__cdecl *PFNLOADDEBUGVARIABLES)(void);
170
171 extern PFNLOADDEBUGVARIABLES pfnLoadDebugVariables;
172
173 extern "C" __declspec(dllexport) void __cdecl DumpRegistryKeyDefinitions(void);
174
175 } // namespace clang
176
177 #endif // defined(_DEBUG) || defined(_INTERNAL)
178
179 #endif // _WIN32
180
181 #endif // CLANG_DEBUG_H