-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
dumpcommon.h
136 lines (119 loc) · 7.68 KB
/
dumpcommon.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#ifndef DEBUGGER_DUMPCOMMON_H
#define DEBUGGER_DUMPCOMMON_H
#ifdef HOST_UNIX
typedef enum _MINIDUMP_TYPE {
MiniDumpNormal = 0x00000000,
MiniDumpWithDataSegs = 0x00000001,
MiniDumpWithFullMemory = 0x00000002,
MiniDumpWithHandleData = 0x00000004,
MiniDumpFilterMemory = 0x00000008,
MiniDumpScanMemory = 0x00000010,
MiniDumpWithUnloadedModules = 0x00000020,
MiniDumpWithIndirectlyReferencedMemory = 0x00000040,
MiniDumpFilterModulePaths = 0x00000080,
MiniDumpWithProcessThreadData = 0x00000100,
MiniDumpWithPrivateReadWriteMemory = 0x00000200,
MiniDumpWithoutOptionalData = 0x00000400,
MiniDumpWithFullMemoryInfo = 0x00000800,
MiniDumpWithThreadInfo = 0x00001000,
MiniDumpWithCodeSegs = 0x00002000,
MiniDumpWithoutAuxiliaryState = 0x00004000,
MiniDumpWithFullAuxiliaryState = 0x00008000,
MiniDumpWithPrivateWriteCopyMemory = 0x00010000,
MiniDumpIgnoreInaccessibleMemory = 0x00020000,
MiniDumpWithTokenInformation = 0x00040000,
MiniDumpWithModuleHeaders = 0x00080000,
MiniDumpFilterTriage = 0x00100000,
MiniDumpWithAvxXStateContext = 0x00200000,
MiniDumpValidTypeFlags = 0x003fffff,
} MINIDUMP_TYPE;
#endif // HOST_UNIX
#if defined(DACCESS_COMPILE) || defined(RIGHT_SIDE_COMPILE)
// When debugging against minidumps, we frequently need to ignore errors
// due to the dump not having memory content.
// You should be VERY careful using these macros. Because our code does not
// distinguish target types, when you allow memory to be missing because a dump
// target may not have that memory content by-design you are also implicitly
// allowing that same data to be missing from a live debugging target.
// Also, be aware that these macros exist in code under vm\. You must be careful to
// only allow them to change execution for DAC and DBI.
// Be careful state is such that execution can continue if the target is missing
// memory.
// In general, there are two solutions to this problem:
// a) add the memory to all minidumps
// b) stop forcing the memory to always be present
// All decisions between a & b focus on cost. For a, cost is adding the memory & a complete
// path to locate it to the dump, both in terms of dump generation time and most
// especially in terms of dump size (we cannot make MiniDumpNormal many MB for trivial
// apps).
// For b, cost is that we lose some of our validation when we have to turn off asserts
// and other checks for targets that should always have the missing memory present
// because we have no concept of allowing it to be missing only from a dump.
// This seemingly awkward try block starting tag is so that when the macro is used over
// multiple source lines we don't create a useless try/catch block. This is important
// when using the macros in vm\ code.
#define EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY EX_TRY
#define EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY \
EX_CATCH \
{ \
if ((GET_EXCEPTION()->GetHR() != HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY)) && \
(GET_EXCEPTION()->GetHR() != CORDBG_E_READVIRTUAL_FAILURE) ) \
{ \
EX_RETHROW; \
} \
} \
EX_END_CATCH(SwallowAllExceptions)
#define EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER EX_TRY
#define EX_CATCH_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \
EX_CATCH \
{ \
if ((GET_EXCEPTION()->GetHR() != HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY)) && \
(GET_EXCEPTION()->GetHR() != CORDBG_E_READVIRTUAL_FAILURE) ) \
{ \
EX_RETHROW; \
} \
else \
#define EX_TRY_ALLOW_DATATARGET_MISSING_OR_INCONSISTENT_MEMORY EX_TRY
#define EX_END_CATCH_ALLOW_DATATARGET_MISSING_OR_INCONSISTENT_MEMORY \
EX_CATCH \
{ \
if ((GET_EXCEPTION()->GetHR() != HRESULT_FROM_WIN32(ERROR_PARTIAL_COPY)) && \
(GET_EXCEPTION()->GetHR() != CORDBG_E_READVIRTUAL_FAILURE) && \
(GET_EXCEPTION()->GetHR() != CORDBG_E_TARGET_INCONSISTENT)) \
{ \
EX_RETHROW; \
} \
} \
EX_END_CATCH(SwallowAllExceptions)
#define EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \
} \
EX_END_CATCH(SwallowAllExceptions)
// Only use this version for wrapping single source lines, or you'll make debugging
// painful.
#define ALLOW_DATATARGET_MISSING_MEMORY(sourceCode) \
EX_TRY \
{ \
sourceCode \
} \
EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY
#define ALLOW_DATATARGET_MISSING_OR_INCONSISTENT_MEMORY(sourceCode) \
EX_TRY \
{ \
sourceCode \
} \
EX_END_CATCH_ALLOW_DATATARGET_MISSING_OR_INCONSISTENT_MEMORY
#else
#define EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY
#define EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY
#define EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \
#error This macro is only intended for use in DAC code!
#define EX_CATCH_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \
#error This macro is only intended for use in DAC code!
#define EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY_WITH_HANDLER \
#error This macro is only intended for use in DAC code!
#define ALLOW_DATATARGET_MISSING_MEMORY(sourceCode) \
sourceCode
#endif // defined(DACCESS_COMPILE) || defined(RIGHT_SIDE_COMPILE)
#endif //DEBUGGER_DUMPCOMMON_H