1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | // |
5 | // File: Debug_MetaData.h |
6 | // |
7 | |
8 | // |
9 | // This file defines special macros for debugging MetaData (even in special retail builds). |
10 | // The level of debugging is set by these (input) macros: |
11 | // * code:#_DEBUG_METADATA |
12 | // * code:#_DEBUG_MDSCHEMA |
13 | // |
14 | // |
15 | // #_DEBUG_METADATA |
16 | // _DEBUG_METADATA ... Enables debugging information in MetaData implementation. It's useful for debugging |
17 | // retail builds in MetaData (when using CHK build is too slow). |
18 | // Note: Enabled by default if _DEBUG is defined (see code:#DefaultSetting_DEBUG_METADATA), can be |
19 | // enabled externally/explicitly also in retail builds (without _DEBUG defined). |
20 | // |
21 | // Defines macros (see code:#Macros_DEBUG_METADATA): |
22 | // * code:#INDEBUG_MD |
23 | // * code:#COMMA_INDEBUG_MD |
24 | // * code:#INDEBUG_MD_COMMA |
25 | // |
26 | // #_DEBUG_MDSCHEMA |
27 | // _DEBUG_MDSCHEMA ... Enables additional debugging of MetaData schema. |
28 | // Note: Allowed to be enabled only if _DEBUG is defined (see code:#Check_DEBUG_MDSCHEMA). |
29 | // |
30 | // Defines macros (see code:#Macros_DEBUG_MDSCHEMA): |
31 | // * code:#_ASSERTE_MDSCHEMA |
32 | // |
33 | // ====================================================================================== |
34 | |
35 | #pragma once |
36 | |
37 | // Include for REGUTIL class used in Debug_ReportError |
38 | #include <utilcode.h> |
39 | |
40 | // -------------------------------------------------------------------------------------- |
41 | //#DefaultSetting_DEBUG_METADATA |
42 | // |
43 | // Enable _DEBUG_METADATA by default if _DEBUG is defined (code:#_DEBUG_METADATA). |
44 | // |
45 | #ifdef _DEBUG |
46 | #define _DEBUG_METADATA |
47 | #endif //_DEBUG |
48 | |
49 | // -------------------------------------------------------------------------------------- |
50 | //#Macros_DEBUG_METADATA |
51 | // |
52 | // Define macros for MetaData implementation debugging (see code:#_DEBUG_METADATA). |
53 | // |
54 | #ifdef _DEBUG_METADATA |
55 | //#INDEBUG_MD |
56 | #define INDEBUG_MD(expr) expr |
57 | //#COMMA_INDEBUG_MD |
58 | #define COMMA_INDEBUG_MD(expr) , expr |
59 | //#INDEBUG_MD_COMMA |
60 | #define INDEBUG_MD_COMMA(expr) expr, |
61 | |
62 | #define Debug_ReportError(strMessage) \ |
63 | do { \ |
64 | if (REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::INTERNAL_AssertOnBadImageFormat, 0)) \ |
65 | { _ASSERTE_MSG(FALSE, (strMessage)); } \ |
66 | } while(0) |
67 | #define Debug_ReportInternalError(strMessage) _ASSERTE_MSG(FALSE, (strMessage)) |
68 | #else //!_DEBUG_METADATA |
69 | #define INDEBUG_MD(expr) |
70 | #define COMMA_INDEBUG_MD(expr) |
71 | #define INDEBUG_MD_COMMA(expr) |
72 | |
73 | #define Debug_ReportError(strMessage) |
74 | #define Debug_ReportInternalError(strMessage) _ASSERTE(!strMessage) |
75 | #endif //!_DEBUG_METADATA |
76 | |
77 | // -------------------------------------------------------------------------------------- |
78 | //#Check_DEBUG_MDSCHEMA |
79 | // |
80 | // Check that _DEBUG_MDSCHEMA is defined only if _DEBUG is defined (see code:#_DEBUG_MDSCHEMA). |
81 | // |
82 | #ifdef _DEBUG_MDSCHEMA |
83 | #ifndef _DEBUG |
84 | #error _DEBUG_MDSCHEMA is defined while _DEBUG is not defined. |
85 | #endif //!_DEBUG |
86 | #endif //_DEBUG_MDSCHEMA |
87 | |
88 | // -------------------------------------------------------------------------------------- |
89 | //#Macros_DEBUG_MDSCHEMA |
90 | // |
91 | // Define macros for MetaData schema debugging (see code:#_DEBUG_MDSCHEMA). |
92 | // |
93 | #ifdef _DEBUG_MDSCHEMA |
94 | //#_ASSERTE_MDSCHEMA |
95 | // This assert is useful only to catch errors in schema (tables and columns) definitions. It is useful e.g. |
96 | // for verifying consistency between table record classes (e.g. code:MethodDefRecord) and columns' |
97 | // offsets/sizes as defined in code:ColumnDefinition. |
98 | #define _ASSERTE_MDSCHEMA(expr) _ASSERTE(expr) |
99 | #else //!_DEBUG_MDSCHEMA |
100 | #define _ASSERTE_MDSCHEMA(expr) |
101 | #endif //!_DEBUG_MDSCHEMA |
102 | |