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 | #ifndef DEBUGGER_DUMPCOMMON_H |
6 | #define DEBUGGER_DUMPCOMMON_H |
7 | |
8 | #ifdef FEATURE_PAL |
9 | typedef enum _MINIDUMP_TYPE { |
10 | MiniDumpNormal = 0x00000000, |
11 | MiniDumpWithDataSegs = 0x00000001, |
12 | MiniDumpWithFullMemory = 0x00000002, |
13 | MiniDumpWithHandleData = 0x00000004, |
14 | MiniDumpFilterMemory = 0x00000008, |
15 | MiniDumpScanMemory = 0x00000010, |
16 | MiniDumpWithUnloadedModules = 0x00000020, |
17 | MiniDumpWithIndirectlyReferencedMemory = 0x00000040, |
18 | MiniDumpFilterModulePaths = 0x00000080, |
19 | MiniDumpWithProcessThreadData = 0x00000100, |
20 | MiniDumpWithPrivateReadWriteMemory = 0x00000200, |
21 | MiniDumpWithoutOptionalData = 0x00000400, |
22 | MiniDumpWithFullMemoryInfo = 0x00000800, |
23 | MiniDumpWithThreadInfo = 0x00001000, |
24 | MiniDumpWithCodeSegs = 0x00002000, |
25 | MiniDumpWithoutAuxiliaryState = 0x00004000, |
26 | MiniDumpWithFullAuxiliaryState = 0x00008000, |
27 | MiniDumpWithPrivateWriteCopyMemory = 0x00010000, |
28 | MiniDumpIgnoreInaccessibleMemory = 0x00020000, |
29 | MiniDumpWithTokenInformation = 0x00040000, |
30 | = 0x00080000, |
31 | MiniDumpFilterTriage = 0x00100000, |
32 | MiniDumpWithAvxXStateContext = 0x00200000, |
33 | MiniDumpValidTypeFlags = 0x003fffff, |
34 | } MINIDUMP_TYPE; |
35 | #endif // FEATURE_PAL |
36 | |
37 | #if defined(DACCESS_COMPILE) || defined(RIGHT_SIDE_COMPILE) |
38 | |
39 | // When debugging against minidumps, we frequently need to ignore errors |
40 | // due to the dump not having memory content. |
41 | // You should be VERY careful using these macros. Because our code does not |
42 | // distinguish target types, when you allow memory to be missing because a dump |
43 | // target may not have that memory content by-design you are also implicitly |
44 | // allowing that same data to be missing from a live debugging target. |
45 | // Also, be aware that these macros exist in code under vm\. You must be careful to |
46 | // only allow them to change execution for DAC and DBI. |
47 | // Be careful state is such that execution can continue if the target is missing |
48 | // memory. |
49 | // In general, there are two solutions to this problem: |
50 | // a) add the memory to all minidumps |
51 | // b) stop forcing the memory to always be present |
52 | // All decisions between a & b focus on cost. For a, cost is adding the memory & a complete |
53 | // path to locate it to the dump, both in terms of dump generation time and most |
54 | // especially in terms of dump size (we cannot make MiniDumpNormal many MB for trivial |
55 | // apps). |
56 | // For b, cost is that we lose some of our validation when we have to turn off asserts |
57 | // and other checks for targets that should always have the missing memory present |
58 | // because we have no concept of allowing it to be missing only from a dump. |
59 | |
60 | // This seemingly awkward try block starting tag is so that when the macro is used over |
61 | // multiple source lines we don't create a useless try/catch block. This is important |
62 | // when using the macros in vm\ code. |
63 | #define EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY EX_TRY |
64 | #define EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY \ |
65 | EX_CATCH \ |
66 | { \ |
67 | if ((GET_EXCEPTION()->GetHR() != HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY)) && \ |
68 | (GET_EXCEPTION()->GetHR() != CORDBG_E_READVIRTUAL_FAILURE) ) \ |
69 | { \ |
70 | EX_RETHROW; \ |
71 | } \ |
72 | } \ |
73 | EX_END_CATCH(SwallowAllExceptions) |
74 | |
75 | #define EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER EX_TRY |
76 | #define EX_CATCH_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \ |
77 | EX_CATCH \ |
78 | { \ |
79 | if ((GET_EXCEPTION()->GetHR() != HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY)) && \ |
80 | (GET_EXCEPTION()->GetHR() != CORDBG_E_READVIRTUAL_FAILURE) ) \ |
81 | { \ |
82 | EX_RETHROW; \ |
83 | } \ |
84 | else \ |
85 | |
86 | #define EX_TRY_ALLOW_DATATARGET_MISSING_OR_INCONSISTENT_MEMORY EX_TRY |
87 | #define EX_END_CATCH_ALLOW_DATATARGET_MISSING_OR_INCONSISTENT_MEMORY \ |
88 | EX_CATCH \ |
89 | { \ |
90 | if ((GET_EXCEPTION()->GetHR() != HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY)) && \ |
91 | (GET_EXCEPTION()->GetHR() != CORDBG_E_READVIRTUAL_FAILURE) && \ |
92 | (GET_EXCEPTION()->GetHR() != CORDBG_E_TARGET_INCONSISTENT)) \ |
93 | { \ |
94 | EX_RETHROW; \ |
95 | } \ |
96 | } \ |
97 | EX_END_CATCH(SwallowAllExceptions) |
98 | |
99 | |
100 | #define EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \ |
101 | } \ |
102 | EX_END_CATCH(SwallowAllExceptions) |
103 | |
104 | // Only use this version for wrapping single source lines, or you'll make debugging |
105 | // painful. |
106 | #define ALLOW_DATATARGET_MISSING_MEMORY(sourceCode) \ |
107 | EX_TRY \ |
108 | { \ |
109 | sourceCode \ |
110 | } \ |
111 | EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY |
112 | |
113 | #define ALLOW_DATATARGET_MISSING_OR_INCONSISTENT_MEMORY(sourceCode) \ |
114 | EX_TRY \ |
115 | { \ |
116 | sourceCode \ |
117 | } \ |
118 | EX_END_CATCH_ALLOW_DATATARGET_MISSING_OR_INCONSISTENT_MEMORY |
119 | |
120 | #else |
121 | #define EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY |
122 | #define EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY |
123 | #define EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \ |
124 | #error This macro is only intended for use in DAC code! |
125 | #define EX_CATCH_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \ |
126 | #error This macro is only intended for use in DAC code! |
127 | #define EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \ |
128 | #error This macro is only intended for use in DAC code! |
129 | |
130 | |
131 | #define ALLOW_DATATARGET_MISSING_MEMORY(sourceCode) \ |
132 | sourceCode |
133 | |
134 | #endif // defined(DACCESS_COMPILE) || defined(RIGHT_SIDE_COMPILE) |
135 | |
136 | |
137 | #endif //DEBUGGER_DUMPCOMMON_H |
138 | |