Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 namespace crashpad { | |
| 21 | |
| 22 //! \brief A context structure carrying 32-bit x86 CPU state. | |
| 23 struct CPUContextX86 { | |
|
Robert Sesek
2014/09/25 15:44:08
I understand why this is mostly duplicated from mi
Mark Mentovai
2014/10/02 20:27:00
Robert Sesek wrote:
| |
| 24 typedef uint8_t X87Register[10]; | |
| 25 | |
| 26 union X87OrMMXRegister { | |
| 27 struct { | |
| 28 X87Register st; | |
| 29 uint8_t st_reserved[6]; | |
| 30 }; | |
| 31 struct { | |
| 32 uint8_t mm_value[8]; | |
| 33 uint8_t mm_reserved[8]; | |
| 34 }; | |
| 35 }; | |
| 36 | |
| 37 typedef uint8_t XMMRegister[16]; | |
| 38 | |
| 39 struct Fxsave { | |
| 40 uint16_t fcw; // FPU control word | |
| 41 uint16_t fsw; // FPU status word | |
| 42 uint8_t ftw; // abridged FPU tag word | |
| 43 uint8_t reserved_1; | |
| 44 uint16_t fop; // FPU opcode | |
| 45 uint32_t fpu_ip; // FPU instruction pointer offset | |
| 46 uint16_t fpu_cs; // FPU instruction pointer segment selector | |
| 47 uint16_t reserved_2; | |
| 48 uint32_t fpu_dp; // FPU data pointer offset | |
| 49 uint16_t fpu_ds; // FPU data pointer segment selector | |
| 50 uint16_t reserved_3; | |
| 51 uint32_t mxcsr; // multimedia extensions status and control register | |
| 52 uint32_t mxcsr_mask; // valid bits in mxcsr | |
| 53 X87OrMMXRegister st_mm[8]; | |
| 54 XMMRegister xmm[8]; | |
| 55 uint8_t reserved_4[176]; | |
| 56 uint8_t available[48]; | |
| 57 }; | |
| 58 | |
| 59 // Integer registers. | |
| 60 uint32_t eax; | |
| 61 uint32_t ebx; | |
| 62 uint32_t ecx; | |
| 63 uint32_t edx; | |
| 64 uint32_t edi; // destination index | |
| 65 uint32_t esi; // source index | |
| 66 uint32_t ebp; // base pointer | |
| 67 uint32_t esp; // stack pointer | |
| 68 uint32_t eip; // instruction pointer | |
| 69 uint32_t eflags; | |
| 70 uint16_t cs; // code segment selector | |
| 71 uint16_t ds; // data segment selector | |
| 72 uint16_t es; // extra segment selector | |
| 73 uint16_t fs; | |
| 74 uint16_t gs; | |
| 75 uint16_t ss; // stack segment selector | |
| 76 | |
| 77 // Floating-point and vector registers. | |
| 78 Fxsave fxsave; | |
| 79 | |
| 80 // Debug registers. | |
| 81 uint32_t dr0; | |
| 82 uint32_t dr1; | |
| 83 uint32_t dr2; | |
| 84 uint32_t dr3; | |
| 85 uint32_t dr4; // obsolete, normally an alias for dr6 | |
| 86 uint32_t dr5; // obsolete, normally an alias for dr7 | |
| 87 uint32_t dr6; | |
| 88 uint32_t dr7; | |
| 89 }; | |
| 90 | |
| 91 //! \brief A context structure carrying x86_64 CPU state. | |
| 92 struct CPUContextX86_64 { | |
| 93 typedef CPUContextX86::X87Register X87Register; | |
| 94 typedef CPUContextX86::X87OrMMXRegister X87OrMMXRegister; | |
| 95 typedef CPUContextX86::XMMRegister XMMRegister; | |
| 96 | |
| 97 struct Fxsave64 { | |
| 98 uint16_t fcw; // FPU control word | |
| 99 uint16_t fsw; // FPU status word | |
| 100 uint8_t ftw; // abridged FPU tag word | |
| 101 uint8_t reserved_1; | |
| 102 uint16_t fop; // FPU opcode | |
| 103 uint64_t fpu_ip; // FPU instruction pointer | |
| 104 uint64_t fpu_dp; // FPU data pointer | |
| 105 uint32_t mxcsr; // multimedia extensions status and control register | |
| 106 uint32_t mxcsr_mask; // valid bits in mxcsr | |
| 107 X87OrMMXRegister st_mm[8]; | |
| 108 XMMRegister xmm[16]; | |
| 109 uint8_t reserved_2[48]; | |
| 110 uint8_t available[48]; | |
| 111 }; | |
| 112 | |
| 113 // Integer registers. | |
| 114 uint64_t rax; | |
| 115 uint64_t rbx; | |
| 116 uint64_t rcx; | |
| 117 uint64_t rdx; | |
| 118 uint64_t rdi; // destination index | |
| 119 uint64_t rsi; // source index | |
| 120 uint64_t rbp; // base pointer | |
| 121 uint64_t rsp; // stack pointer | |
| 122 uint64_t r8; | |
| 123 uint64_t r9; | |
| 124 uint64_t r10; | |
| 125 uint64_t r11; | |
| 126 uint64_t r12; | |
| 127 uint64_t r13; | |
| 128 uint64_t r14; | |
| 129 uint64_t r15; | |
| 130 uint64_t rip; // instruction pointer | |
| 131 uint64_t rflags; | |
| 132 uint16_t cs; // code segment selector | |
| 133 uint16_t fs; | |
| 134 uint16_t gs; | |
| 135 | |
| 136 // Floating-point and vector registers. | |
| 137 Fxsave64 fxsave64; | |
| 138 | |
| 139 // Debug registers. | |
| 140 uint64_t dr0; | |
| 141 uint64_t dr1; | |
| 142 uint64_t dr2; | |
| 143 uint64_t dr3; | |
| 144 uint64_t dr4; // obsolete, normally an alias for dr6 | |
| 145 uint64_t dr5; // obsolete, normally an alias for dr7 | |
| 146 uint64_t dr6; | |
| 147 uint64_t dr7; | |
| 148 }; | |
| 149 | |
| 150 //! \brief A context structure capable of carrying the context of any supported | |
| 151 //! CPU architecture. | |
| 152 struct CPUContext { | |
| 153 //! \brief The type of context represented in a CPUContext structure. | |
| 154 enum ContextFlavor { | |
| 155 //! \brief The CPU architecture is unknown. | |
| 156 kContextFlavorUnknown = 0, | |
| 157 | |
| 158 //! \brief 32-bit x86. | |
| 159 kContextFlavorX86, | |
| 160 | |
| 161 //! \brief x86_64. | |
| 162 kContextFlavorX86_64, | |
| 163 }; | |
| 164 | |
| 165 //! \brief Returns the instruction pointer value from the context structure. | |
| 166 //! | |
| 167 //! This is a CPU architecture-independent method that is capable of | |
| 168 //! recovering the instruction pointer from any supported CPU architecture’s | |
| 169 //! context structure. | |
| 170 uint64_t InstructionPointer() const; | |
| 171 | |
| 172 //! \brief The CPU architecture of a context structure. This field controls | |
| 173 //! the expression of the union. | |
| 174 ContextFlavor flavor; | |
| 175 union { | |
| 176 CPUContextX86* x86; | |
| 177 CPUContextX86_64* x86_64; | |
| 178 }; | |
| 179 }; | |
| 180 | |
| 181 } // namespace crashpad | |
| 182 | |
| 183 #endif // CRASHPAD_SNAPSHOT_SNAPSHOT_CPU_CONTEXT_H_ | |
| OLD | NEW |