Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: minidump/minidump_context.h

Issue 593583004: Add MinidumpContext (X86 and AMD64 variants) and their writers (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_H_
16 #define CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_H_
17
18 #include <stdint.h>
19
20 #include "util/numeric/int128.h"
21
22 namespace crashpad {
23
24 //! \brief Architecture-independent flags for `context_flags` fields in Minidump
25 //! context structures.
26 enum MinidumpContextFlags : uint32_t {
27 //! \brief `CONTEXT_EXCEPTION_ACTIVE`.
28 kMinidumpContextExceptionActive = 0x08000000,
29
30 //! \brief `CONTEXT_SERVICE_ACTIVE`.
Robert Sesek 2014/09/24 15:42:15 Am I supposed to know what these mean?
31 kMinidumpContextServiceActive = 0x10000000,
32
33 //! \brief `CONTEXT_EXCEPTION_REQUEST`.
34 kMinidumpContextExceptionRequest = 0x40000000,
35
36 //! \brief `CONTEXT_EXCEPTION_REPORTING`.
37 kMinidumpContextExceptionReporting = 0x80000000,
38 };
39
40 //! \brief 32-bit x86-specifc flags for MinidumpContextX86::context_flags.
41 enum MinidumpContextX86Flags : uint32_t {
42 //! \brief Identifies the context structure as 32-bit x86. This is the same as
43 //! `CONTEXT_i386` and `CONTEXT_i486` on Windows for this architecture.
44 kMinidumpContextX86 = 0x00010000,
45
46 //! \brief Indicates the validity of control registers (`CONTEXT_CONTROL`).
47 //!
48 //! The `ebp`, `eip`, `cs`, `eflags`, `esp`, and `ss` fields are valid.
49 kMinidumpContextX86Control = kMinidumpContextX86 | 0x00000001,
50
51 //! \brief Indicates the validity of non-control integer registers
52 //! (`CONTEXT_INTEGER`).
53 //!
54 //! The `edi`, `esi`, `ebx`, `edx`, `ecx, and `eax` fields are valid.
55 kMinidumpContextX86Integer = kMinidumpContextX86 | 0x00000002,
56
57 //! \brief Indicates the validity of non-control segment registers
58 //! (`CONTEXT_SEGMENTS`).
59 //!
60 //! The `gs`, `fs`, `es`, and `ds` fields are valid.
61 kMinidumpContextX86Segment = kMinidumpContextX86 | 0x00000004,
62
63 //! \brief Indicates the validity of floating-point state
64 //! (`CONTEXT_FLOATING_POINT`).
65 //!
66 //! The `float_save` field is valid.
67 kMinidumpContextX86FloatingPoint = kMinidumpContextX86 | 0x00000008,
68
69 //! \brief Indicates the validity of debug registers
70 //! (`CONTEXT_DEBUG_REGISTERS`).
71 //!
72 //! The `dr0` through `dr3`, `dr6`, and `dr7` fields are valid.
73 kMinidumpContextX86Debug = kMinidumpContextX86 | 0x00000010,
74
75 //! \brief Indicates the validity of extended registers in `fxsave` format
76 //! (`CONTEXT_EXTENDED_REGISTERS`).
77 //!
78 //! The `extended_registers` field is valid and contains `fxsave` data.
79 kMinidumpContextX86Extended = kMinidumpContextX86 | 0x00000020,
80
81 //! \brief Indicates the validity of `xsave` data (`CONTEXT_XSTATE`).
82 //!
83 //! The context contains `xsave` data. This is used with an extended context
84 //! structure not currently defined here.
85 kMinidumpContextX86Xstate = kMinidumpContextX86 | 0x00000040,
86
87 //! \brief Indicates the validity of control, integer, and segment registers.
88 kMinidumpContextX86Full = kMinidumpContextX86Control |
89 kMinidumpContextX86Integer |
90 kMinidumpContextX86Segment,
91
92 //! \brief Indicates the validity of all registers except `xsave` data.
93 kMinidumpContextX86All = kMinidumpContextX86Full |
94 kMinidumpContextX86FloatingPoint |
95 kMinidumpContextX86Debug |
96 kMinidumpContextX86Extended,
97 };
98
99 //! \brief A 32-bit x86 CPU context (register state) carried in a minidump file.
100 //!
101 //! This is analogous to the `CONTEXT` structure on Windows when targeting
102 //! 32-bit x86. This structure is used instead of `CONTEXT` to make it available
103 //! when targeting other architectures.
104 struct MinidumpContextX86 {
105 //! \brief A bitfield composed of values of #MinidumpContextFlags and
106 //! #MinidumpContextX86Flags.
107 //!
108 //! This field identifies the context structure as a 32-bit x86 CPU context,
109 //! and indicates which other fields in the structure are valid.
110 uint32_t context_flags;
111
112 uint32_t dr0;
113 uint32_t dr1;
114 uint32_t dr2;
115 uint32_t dr3;
116 uint32_t dr6;
117 uint32_t dr7;
118
119 struct {
120 uint32_t control_word;
121 uint32_t status_word;
122 uint32_t tag_word;
123 uint32_t error_offset;
124 uint32_t error_selector;
125 uint32_t data_offset;
126 uint32_t data_selector;
127 uint8_t register_area[80];
128 uint32_t spare_0;
129 } float_save;
130
131 uint32_t gs;
132 uint32_t fs;
133 uint32_t es;
134 uint32_t ds;
135
136 uint32_t edi;
137 uint32_t esi;
138 uint32_t ebx;
139 uint32_t edx;
140 uint32_t ecx;
141 uint32_t eax;
142
143 uint32_t ebp;
144 uint32_t eip;
145 uint32_t cs;
146 uint32_t eflags;
147 uint32_t esp;
148 uint32_t ss;
149
150 uint8_t extended_registers[512];
151 };
152
153 //! \brief x86_64-specifc flags for MinidumpContextAMD64::context_flags.
154 enum MinidumpContextAMD64Flags : uint32_t {
155 //! \brief Identifies the context structure as x86_64. This is the same as
156 //! `CONTEXT_AMD64` on Windows for this architecture.
157 kMinidumpContextAMD64 = 0x00100000,
158
159 //! \brief Indicates the validity of control registers (`CONTEXT_CONTROL`).
160 //!
161 //! The `cs`, `ss`, `eflags`, `rsp`, and `rip` fields are valid.
162 kMinidumpContextAMD64Control = kMinidumpContextAMD64 | 0x00000001,
163
164 //! \brief Indicates the validity of non-control integer registers
165 //! (`CONTEXT_INTEGER`).
166 //!
167 //! The `rax`, `rcx`, `rdx`, `rbx`, `rbp`, `rsi`, `rdi`, and `r8` through
168 //! `r15` fields are valid.
169 kMinidumpContextAMD64Integer = kMinidumpContextAMD64 | 0x00000002,
170
171 //! \brief Indicates the validity of non-control segment registers
172 //! (`CONTEXT_SEGMENTS`).
173 //!
174 //! The `ds`, `es`, `fs`, and `gs` fields are valid.
175 kMinidumpContextAMD64Segment = kMinidumpContextAMD64 | 0x00000004,
176
177 //! \brief Indicates the validity of floating-point state
178 //! (`CONTEXT_FLOATING_POINT`).
179 //!
180 //! The `xmm0` through `xmm15` fields are valid.
181 kMinidumpContextAMD64FloatingPoint = kMinidumpContextAMD64 | 0x00000008,
182
183 //! \brief Indicates the validity of debug registers
184 //! (`CONTEXT_DEBUG_REGISTERS`).
185 //!
186 //! The `dr0` through `dr3`, `dr6`, and `dr7` fields are valid.
187 kMinidumpContextAMD64Debug = kMinidumpContextAMD64 | 0x00000010,
188
189 //! \brief Indicates the validity of `xsave` data (`CONTEXT_XSTATE`).
190 //!
191 //! The context contains `xsave` data. This is used with an extended context
192 //! structure not currently defined here.
193 kMinidumpContextX86Xstate = kMinidumpContextAMD64 | 0x00000040,
194
195 //! \brief Indicates the validity of control, integer, and segment registers.
196 kMinidumpContextAMD64Full = kMinidumpContextAMD64Control |
197 kMinidumpContextAMD64Integer |
198 kMinidumpContextAMD64Segment,
199
200 //! \brief Indicates the validity of all registers except `xsave` data.
201 kMinidumpContextAMD64All = kMinidumpContextAMD64Full |
202 kMinidumpContextAMD64FloatingPoint |
203 kMinidumpContextAMD64Debug,
204 };
205
206 //! \brief An x86_64 (AMD64) CPU context (register state) carried in a minidump
207 //! file.
208 //!
209 //! This is analogous to the `CONTEXT` structure on Windows when targeting
210 //! x86_64. This structure is used instead of `CONTEXT` to make it available
211 //! when targeting other architectures.
212 struct __attribute__((aligned(16))) MinidumpContextAMD64 {
213 uint64_t p1_home;
Robert Sesek 2014/09/24 15:42:15 What are these used for?
214 uint64_t p2_home;
215 uint64_t p3_home;
216 uint64_t p4_home;
217 uint64_t p5_home;
218 uint64_t p6_home;
219
220 //! \brief A bitfield composed of values of #MinidumpContextFlags and
221 //! #MinidumpContextAMD64Flags.
222 //!
223 //! This field identifies the context structure as an x86_64 CPU context, and
224 //! indicates which other fields in the structure are valid.
225 uint32_t context_flags;
226
227 uint32_t mx_csr;
228
229 uint16_t cs;
230 uint16_t ds;
231 uint16_t es;
232 uint16_t fs;
233 uint16_t gs;
234 uint16_t ss;
235
236 uint32_t eflags;
237
238 uint64_t dr0;
239 uint64_t dr1;
240 uint64_t dr2;
241 uint64_t dr3;
242 uint64_t dr6;
243 uint64_t dr7;
244
245 uint64_t rax;
246 uint64_t rcx;
247 uint64_t rdx;
248 uint64_t rbx;
249 uint64_t rsp;
250 uint64_t rbp;
251 uint64_t rsi;
252 uint64_t rdi;
253 uint64_t r8;
254 uint64_t r9;
255 uint64_t r10;
256 uint64_t r11;
257 uint64_t r12;
258 uint64_t r13;
259 uint64_t r14;
260 uint64_t r15;
261
262 uint64_t rip;
263
264 union {
265 struct {
266 uint16_t control_word;
267 uint16_t status_word;
268 uint8_t tag_word;
269 uint8_t reserved_1;
270 uint16_t error_opcode;
271 uint32_t error_offset;
272 uint16_t error_selector;
273 uint16_t reserved_2;
274 uint32_t data_offset;
275 uint16_t data_selector;
276 uint16_t reserved_3;
277 uint32_t mx_csr;
278 uint32_t mx_csr_mask;
279 uint128_struct float_registers[8];
280 uint128_struct xmm_registers[16];
281 uint8_t reserved_4[96];
282 } float_save;
283 struct {
284 uint128_struct header[2];
285 uint128_struct legacy[8];
286 uint128_struct xmm0;
287 uint128_struct xmm1;
288 uint128_struct xmm2;
289 uint128_struct xmm3;
290 uint128_struct xmm4;
291 uint128_struct xmm5;
292 uint128_struct xmm6;
293 uint128_struct xmm7;
294 uint128_struct xmm8;
295 uint128_struct xmm9;
296 uint128_struct xmm10;
297 uint128_struct xmm11;
298 uint128_struct xmm12;
299 uint128_struct xmm13;
300 uint128_struct xmm14;
301 uint128_struct xmm15;
302 };
303 };
304
305 uint128_struct vector_register[26];
306 uint64_t vector_control;
307
308 uint64_t debug_control;
309 uint64_t last_branch_to_rip;
310 uint64_t last_branch_from_rip;
311 uint64_t last_exception_to_rip;
312 uint64_t last_exception_from_rip;
313 };
314
315 } // namespace crashpad
316
317 #endif // CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698