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

Side by Side Diff: snapshot/cpu_context.h

Issue 597673004: Add the Snapshot interface (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Make everything else const too Created 6 years, 2 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 | « snapshot/cpu_architecture.h ('k') | snapshot/cpu_context.cc » ('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_SNAPSHOT_SNAPSHOT_CPU_CONTEXT_H_
16 #define CRASHPAD_SNAPSHOT_SNAPSHOT_CPU_CONTEXT_H_
17
18 #include <stdint.h>
19
20 #include "snapshot/cpu_architecture.h"
21
22 namespace crashpad {
23
24 //! \brief A context structure carrying 32-bit x86 CPU state.
25 struct CPUContextX86 {
26 typedef uint8_t X87Register[10];
27
28 union X87OrMMXRegister {
29 struct {
30 X87Register st;
31 uint8_t st_reserved[6];
32 };
33 struct {
34 uint8_t mm_value[8];
35 uint8_t mm_reserved[8];
36 };
37 };
38
39 typedef uint8_t XMMRegister[16];
40
41 struct Fxsave {
42 uint16_t fcw; // FPU control word
43 uint16_t fsw; // FPU status word
44 uint8_t ftw; // abridged FPU tag word
45 uint8_t reserved_1;
46 uint16_t fop; // FPU opcode
47 uint32_t fpu_ip; // FPU instruction pointer offset
48 uint16_t fpu_cs; // FPU instruction pointer segment selector
49 uint16_t reserved_2;
50 uint32_t fpu_dp; // FPU data pointer offset
51 uint16_t fpu_ds; // FPU data pointer segment selector
52 uint16_t reserved_3;
53 uint32_t mxcsr; // multimedia extensions status and control register
54 uint32_t mxcsr_mask; // valid bits in mxcsr
55 X87OrMMXRegister st_mm[8];
56 XMMRegister xmm[8];
57 uint8_t reserved_4[176];
58 uint8_t available[48];
59 };
60
61 // Integer registers.
62 uint32_t eax;
63 uint32_t ebx;
64 uint32_t ecx;
65 uint32_t edx;
66 uint32_t edi; // destination index
67 uint32_t esi; // source index
68 uint32_t ebp; // base pointer
69 uint32_t esp; // stack pointer
70 uint32_t eip; // instruction pointer
71 uint32_t eflags;
72 uint16_t cs; // code segment selector
73 uint16_t ds; // data segment selector
74 uint16_t es; // extra segment selector
75 uint16_t fs;
76 uint16_t gs;
77 uint16_t ss; // stack segment selector
78
79 // Floating-point and vector registers.
80 Fxsave fxsave;
81
82 // Debug registers.
83 uint32_t dr0;
84 uint32_t dr1;
85 uint32_t dr2;
86 uint32_t dr3;
87 uint32_t dr4; // obsolete, normally an alias for dr6
88 uint32_t dr5; // obsolete, normally an alias for dr7
89 uint32_t dr6;
90 uint32_t dr7;
91 };
92
93 //! \brief A context structure carrying x86_64 CPU state.
94 struct CPUContextX86_64 {
95 typedef CPUContextX86::X87Register X87Register;
96 typedef CPUContextX86::X87OrMMXRegister X87OrMMXRegister;
97 typedef CPUContextX86::XMMRegister XMMRegister;
98
99 struct Fxsave64 {
100 uint16_t fcw; // FPU control word
101 uint16_t fsw; // FPU status word
102 uint8_t ftw; // abridged FPU tag word
103 uint8_t reserved_1;
104 uint16_t fop; // FPU opcode
105 uint64_t fpu_ip; // FPU instruction pointer
106 uint64_t fpu_dp; // FPU data pointer
107 uint32_t mxcsr; // multimedia extensions status and control register
108 uint32_t mxcsr_mask; // valid bits in mxcsr
109 X87OrMMXRegister st_mm[8];
110 XMMRegister xmm[16];
111 uint8_t reserved_2[48];
112 uint8_t available[48];
113 };
114
115 // Integer registers.
116 uint64_t rax;
117 uint64_t rbx;
118 uint64_t rcx;
119 uint64_t rdx;
120 uint64_t rdi; // destination index
121 uint64_t rsi; // source index
122 uint64_t rbp; // base pointer
123 uint64_t rsp; // stack pointer
124 uint64_t r8;
125 uint64_t r9;
126 uint64_t r10;
127 uint64_t r11;
128 uint64_t r12;
129 uint64_t r13;
130 uint64_t r14;
131 uint64_t r15;
132 uint64_t rip; // instruction pointer
133 uint64_t rflags;
134 uint16_t cs; // code segment selector
135 uint16_t fs;
136 uint16_t gs;
137
138 // Floating-point and vector registers.
139 Fxsave64 fxsave64;
140
141 // Debug registers.
142 uint64_t dr0;
143 uint64_t dr1;
144 uint64_t dr2;
145 uint64_t dr3;
146 uint64_t dr4; // obsolete, normally an alias for dr6
147 uint64_t dr5; // obsolete, normally an alias for dr7
148 uint64_t dr6;
149 uint64_t dr7;
150 };
151
152 //! \brief A context structure capable of carrying the context of any supported
153 //! CPU architecture.
154 struct CPUContext {
155 //! \brief Returns the instruction pointer value from the context structure.
156 //!
157 //! This is a CPU architecture-independent method that is capable of
158 //! recovering the instruction pointer from any supported CPU architecture’s
159 //! context structure.
160 uint64_t InstructionPointer() const;
161
162 //! \brief The CPU architecture of a context structure. This field controls
163 //! the expression of the union.
164 CPUArchitecture architecture;
165 union {
166 CPUContextX86* x86;
167 CPUContextX86_64* x86_64;
168 };
169 };
170
171 } // namespace crashpad
172
173 #endif // CRASHPAD_SNAPSHOT_SNAPSHOT_CPU_CONTEXT_H_
OLDNEW
« no previous file with comments | « snapshot/cpu_architecture.h ('k') | snapshot/cpu_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698