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

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: Address review feedback 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
« no previous file with comments | « minidump/minidump.gyp ('k') | minidump/minidump_context_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 //
27 // http://zachsaw.blogspot.com/2010/11/wow64-bug-getthreadcontext-may-return.htm l#c5639760895973344002
28 enum MinidumpContextFlags : uint32_t {
29 //! \brief The thread was executing a trap handler in kernel mode
30 //! (`CONTEXT_EXCEPTION_ACTIVE`).
31 //!
32 //! If this bit is set, it indicates that the context is from a thread that
33 //! was executing a trap handler in the kernel. This bit is only valid when
34 //! ::kMinidumpContextExceptionReporting is also set. This bit is only used on
35 //! Windows.
36 kMinidumpContextExceptionActive = 0x08000000,
37
38 //! \brief The thread was executing a system call in kernel mode
39 //! (`CONTEXT_SERVICE_ACTIVE`).
40 //!
41 //! If this bit is set, it indicates that the context is from a thread that
42 //! was executing a system call in the kernel. This bit is only valid when
43 //! ::kMinidumpContextExceptionReporting is also set. This bit is only used on
44 //! Windows.
45 kMinidumpContextServiceActive = 0x10000000,
46
47 //! \brief Kernel-mode state reporting is desired
48 //! (`CONTEXT_EXCEPTION_REQUEST`).
49 //!
50 //! This bit is not used in context structures containing snapshots of thread
51 //! CPU context. It used when calling `GetThreadContext()` on Windows to
52 //! specify that kernel-mode state reporting
53 //! (::kMinidumpContextExceptionReporting) is desired in the returned context
54 //! structure.
55 kMinidumpContextExceptionRequest = 0x40000000,
56
57 //! \brief Kernel-mode state reporting is provided
58 //! (`CONTEXT_EXCEPTION_REPORTING`).
59 //!
60 //! If this bit is set, it indicates that the bits indicating how the thread
61 //! had entered kernel mode (::kMinidumpContextExceptionActive and
62 //! and ::kMinidumpContextServiceActive) are valid. This bit is only used on
63 //! Windows.
64 kMinidumpContextExceptionReporting = 0x80000000,
65 };
66
67 //! \brief 32-bit x86-specifc flags for MinidumpContextX86::context_flags.
68 enum MinidumpContextX86Flags : uint32_t {
69 //! \brief Identifies the context structure as 32-bit x86. This is the same as
70 //! `CONTEXT_i386` and `CONTEXT_i486` on Windows for this architecture.
71 kMinidumpContextX86 = 0x00010000,
72
73 //! \brief Indicates the validity of control registers (`CONTEXT_CONTROL`).
74 //!
75 //! The `ebp`, `eip`, `cs`, `eflags`, `esp`, and `ss` fields are valid.
76 kMinidumpContextX86Control = kMinidumpContextX86 | 0x00000001,
77
78 //! \brief Indicates the validity of non-control integer registers
79 //! (`CONTEXT_INTEGER`).
80 //!
81 //! The `edi`, `esi`, `ebx`, `edx`, `ecx, and `eax` fields are valid.
82 kMinidumpContextX86Integer = kMinidumpContextX86 | 0x00000002,
83
84 //! \brief Indicates the validity of non-control segment registers
85 //! (`CONTEXT_SEGMENTS`).
86 //!
87 //! The `gs`, `fs`, `es`, and `ds` fields are valid.
88 kMinidumpContextX86Segment = kMinidumpContextX86 | 0x00000004,
89
90 //! \brief Indicates the validity of floating-point state
91 //! (`CONTEXT_FLOATING_POINT`).
92 //!
93 //! The `float_save` field is valid.
94 kMinidumpContextX86FloatingPoint = kMinidumpContextX86 | 0x00000008,
95
96 //! \brief Indicates the validity of debug registers
97 //! (`CONTEXT_DEBUG_REGISTERS`).
98 //!
99 //! The `dr0` through `dr3`, `dr6`, and `dr7` fields are valid.
100 kMinidumpContextX86Debug = kMinidumpContextX86 | 0x00000010,
101
102 //! \brief Indicates the validity of extended registers in `fxsave` format
103 //! (`CONTEXT_EXTENDED_REGISTERS`).
104 //!
105 //! The `extended_registers` field is valid and contains `fxsave` data.
106 kMinidumpContextX86Extended = kMinidumpContextX86 | 0x00000020,
107
108 //! \brief Indicates the validity of `xsave` data (`CONTEXT_XSTATE`).
109 //!
110 //! The context contains `xsave` data. This is used with an extended context
111 //! structure not currently defined here.
112 kMinidumpContextX86Xstate = kMinidumpContextX86 | 0x00000040,
113
114 //! \brief Indicates the validity of control, integer, and segment registers.
115 kMinidumpContextX86Full = kMinidumpContextX86Control |
116 kMinidumpContextX86Integer |
117 kMinidumpContextX86Segment,
118
119 //! \brief Indicates the validity of all registers except `xsave` data.
120 kMinidumpContextX86All = kMinidumpContextX86Full |
121 kMinidumpContextX86FloatingPoint |
122 kMinidumpContextX86Debug |
123 kMinidumpContextX86Extended,
124 };
125
126 //! \brief A 32-bit x86 CPU context (register state) carried in a minidump file.
127 //!
128 //! This is analogous to the `CONTEXT` structure on Windows when targeting
129 //! 32-bit x86. This structure is used instead of `CONTEXT` to make it available
130 //! when targeting other architectures.
131 struct MinidumpContextX86 {
132 //! \brief A bitfield composed of values of #MinidumpContextFlags and
133 //! #MinidumpContextX86Flags.
134 //!
135 //! This field identifies the context structure as a 32-bit x86 CPU context,
136 //! and indicates which other fields in the structure are valid.
137 uint32_t context_flags;
138
139 uint32_t dr0;
140 uint32_t dr1;
141 uint32_t dr2;
142 uint32_t dr3;
143 uint32_t dr6;
144 uint32_t dr7;
145
146 struct {
147 uint32_t control_word;
148 uint32_t status_word;
149 uint32_t tag_word;
150 uint32_t error_offset;
151 uint32_t error_selector;
152 uint32_t data_offset;
153 uint32_t data_selector;
154 uint8_t register_area[80];
155 uint32_t spare_0;
156 } float_save;
157
158 uint32_t gs;
159 uint32_t fs;
160 uint32_t es;
161 uint32_t ds;
162
163 uint32_t edi;
164 uint32_t esi;
165 uint32_t ebx;
166 uint32_t edx;
167 uint32_t ecx;
168 uint32_t eax;
169
170 uint32_t ebp;
171 uint32_t eip;
172 uint32_t cs;
173 uint32_t eflags;
174 uint32_t esp;
175 uint32_t ss;
176
177 uint8_t extended_registers[512];
178 };
179
180 //! \brief x86_64-specifc flags for MinidumpContextAMD64::context_flags.
181 enum MinidumpContextAMD64Flags : uint32_t {
182 //! \brief Identifies the context structure as x86_64. This is the same as
183 //! `CONTEXT_AMD64` on Windows for this architecture.
184 kMinidumpContextAMD64 = 0x00100000,
185
186 //! \brief Indicates the validity of control registers (`CONTEXT_CONTROL`).
187 //!
188 //! The `cs`, `ss`, `eflags`, `rsp`, and `rip` fields are valid.
189 kMinidumpContextAMD64Control = kMinidumpContextAMD64 | 0x00000001,
190
191 //! \brief Indicates the validity of non-control integer registers
192 //! (`CONTEXT_INTEGER`).
193 //!
194 //! The `rax`, `rcx`, `rdx`, `rbx`, `rbp`, `rsi`, `rdi`, and `r8` through
195 //! `r15` fields are valid.
196 kMinidumpContextAMD64Integer = kMinidumpContextAMD64 | 0x00000002,
197
198 //! \brief Indicates the validity of non-control segment registers
199 //! (`CONTEXT_SEGMENTS`).
200 //!
201 //! The `ds`, `es`, `fs`, and `gs` fields are valid.
202 kMinidumpContextAMD64Segment = kMinidumpContextAMD64 | 0x00000004,
203
204 //! \brief Indicates the validity of floating-point state
205 //! (`CONTEXT_FLOATING_POINT`).
206 //!
207 //! The `xmm0` through `xmm15` fields are valid.
208 kMinidumpContextAMD64FloatingPoint = kMinidumpContextAMD64 | 0x00000008,
209
210 //! \brief Indicates the validity of debug registers
211 //! (`CONTEXT_DEBUG_REGISTERS`).
212 //!
213 //! The `dr0` through `dr3`, `dr6`, and `dr7` fields are valid.
214 kMinidumpContextAMD64Debug = kMinidumpContextAMD64 | 0x00000010,
215
216 //! \brief Indicates the validity of `xsave` data (`CONTEXT_XSTATE`).
217 //!
218 //! The context contains `xsave` data. This is used with an extended context
219 //! structure not currently defined here.
220 kMinidumpContextX86Xstate = kMinidumpContextAMD64 | 0x00000040,
221
222 //! \brief Indicates the validity of control, integer, and segment registers.
223 kMinidumpContextAMD64Full = kMinidumpContextAMD64Control |
224 kMinidumpContextAMD64Integer |
225 kMinidumpContextAMD64Segment,
226
227 //! \brief Indicates the validity of all registers except `xsave` data.
228 kMinidumpContextAMD64All = kMinidumpContextAMD64Full |
229 kMinidumpContextAMD64FloatingPoint |
230 kMinidumpContextAMD64Debug,
231 };
232
233 //! \brief An x86_64 (AMD64) CPU context (register state) carried in a minidump
234 //! file.
235 //!
236 //! This is analogous to the `CONTEXT` structure on Windows when targeting
237 //! x86_64. This structure is used instead of `CONTEXT` to make it available
238 //! when targeting other architectures.
239 struct __attribute__((aligned(16))) MinidumpContextAMD64 {
240 //! \brief Register parameter home address.
241 //!
242 //! On Windows, this field may contain the “home” address (on-stack, in the
243 //! shadow area) of a parameter passed by register. This field is present for
244 //! convenience but is not necessarily populated, even if a corresponding
245 //! parameter was passed by register.
246 //!
247 //! \{
248 uint64_t p1_home;
249 uint64_t p2_home;
250 uint64_t p3_home;
251 uint64_t p4_home;
252 uint64_t p5_home;
253 uint64_t p6_home;
254 //! \}
255
256 //! \brief A bitfield composed of values of #MinidumpContextFlags and
257 //! #MinidumpContextAMD64Flags.
258 //!
259 //! This field identifies the context structure as an x86_64 CPU context, and
260 //! indicates which other fields in the structure are valid.
261 uint32_t context_flags;
262
263 uint32_t mx_csr;
264
265 uint16_t cs;
266 uint16_t ds;
267 uint16_t es;
268 uint16_t fs;
269 uint16_t gs;
270 uint16_t ss;
271
272 uint32_t eflags;
273
274 uint64_t dr0;
275 uint64_t dr1;
276 uint64_t dr2;
277 uint64_t dr3;
278 uint64_t dr6;
279 uint64_t dr7;
280
281 uint64_t rax;
282 uint64_t rcx;
283 uint64_t rdx;
284 uint64_t rbx;
285 uint64_t rsp;
286 uint64_t rbp;
287 uint64_t rsi;
288 uint64_t rdi;
289 uint64_t r8;
290 uint64_t r9;
291 uint64_t r10;
292 uint64_t r11;
293 uint64_t r12;
294 uint64_t r13;
295 uint64_t r14;
296 uint64_t r15;
297
298 uint64_t rip;
299
300 union {
301 struct {
302 uint16_t control_word;
303 uint16_t status_word;
304 uint8_t tag_word;
305 uint8_t reserved_1;
306 uint16_t error_opcode;
307 uint32_t error_offset;
308 uint16_t error_selector;
309 uint16_t reserved_2;
310 uint32_t data_offset;
311 uint16_t data_selector;
312 uint16_t reserved_3;
313 uint32_t mx_csr;
314 uint32_t mx_csr_mask;
315 uint128_struct float_registers[8];
316 uint128_struct xmm_registers[16];
317 uint8_t reserved_4[96];
318 } float_save;
319 struct {
320 uint128_struct header[2];
321 uint128_struct legacy[8];
322 uint128_struct xmm0;
323 uint128_struct xmm1;
324 uint128_struct xmm2;
325 uint128_struct xmm3;
326 uint128_struct xmm4;
327 uint128_struct xmm5;
328 uint128_struct xmm6;
329 uint128_struct xmm7;
330 uint128_struct xmm8;
331 uint128_struct xmm9;
332 uint128_struct xmm10;
333 uint128_struct xmm11;
334 uint128_struct xmm12;
335 uint128_struct xmm13;
336 uint128_struct xmm14;
337 uint128_struct xmm15;
338 };
339 };
340
341 uint128_struct vector_register[26];
342 uint64_t vector_control;
343
344 //! \brief Model-specific debug extension register.
345 //!
346 //! See Intel Software Developer’s Manual, Volume 3B: System Programming, Part
347 //! 2 (253669-051), 17.4 “Last Branch, Interrupt, and Exception Recording
348 //! Overview”, and AMD Architecture Programmer’s Manual, Volume 2:
349 //! System Programming (24593-3.24), 13.1.6 “Control-Transfer Breakpoint
350 //! Features”.
351 //!
352 //! \{
353 uint64_t debug_control;
354 uint64_t last_branch_to_rip;
355 uint64_t last_branch_from_rip;
356 uint64_t last_exception_to_rip;
357 uint64_t last_exception_from_rip;
358 //! \}
359 };
360
361 } // namespace crashpad
362
363 #endif // CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_H_
OLDNEW
« no previous file with comments | « minidump/minidump.gyp ('k') | minidump/minidump_context_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698