| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 context->x86->eax = value++; | 32 context->x86->eax = value++; |
| 33 context->x86->ebx = value++; | 33 context->x86->ebx = value++; |
| 34 context->x86->ecx = value++; | 34 context->x86->ecx = value++; |
| 35 context->x86->edx = value++; | 35 context->x86->edx = value++; |
| 36 context->x86->edi = value++; | 36 context->x86->edi = value++; |
| 37 context->x86->esi = value++; | 37 context->x86->esi = value++; |
| 38 context->x86->ebp = value++; | 38 context->x86->ebp = value++; |
| 39 context->x86->esp = value++; | 39 context->x86->esp = value++; |
| 40 context->x86->eip = value++; | 40 context->x86->eip = value++; |
| 41 context->x86->eflags = value++; | 41 context->x86->eflags = value++; |
| 42 context->x86->cs = value++; | 42 context->x86->cs = static_cast<uint16_t>(value++); |
| 43 context->x86->ds = value++; | 43 context->x86->ds = static_cast<uint16_t>(value++); |
| 44 context->x86->es = value++; | 44 context->x86->es = static_cast<uint16_t>(value++); |
| 45 context->x86->fs = value++; | 45 context->x86->fs = static_cast<uint16_t>(value++); |
| 46 context->x86->gs = value++; | 46 context->x86->gs = static_cast<uint16_t>(value++); |
| 47 context->x86->ss = value++; | 47 context->x86->ss = static_cast<uint16_t>(value++); |
| 48 InitializeCPUContextX86Fxsave(&context->x86->fxsave, &value); | 48 InitializeCPUContextX86Fxsave(&context->x86->fxsave, &value); |
| 49 context->x86->dr0 = value++; | 49 context->x86->dr0 = value++; |
| 50 context->x86->dr1 = value++; | 50 context->x86->dr1 = value++; |
| 51 context->x86->dr2 = value++; | 51 context->x86->dr2 = value++; |
| 52 context->x86->dr3 = value++; | 52 context->x86->dr3 = value++; |
| 53 context->x86->dr4 = value++; | 53 context->x86->dr4 = value++; |
| 54 context->x86->dr5 = value++; | 54 context->x86->dr5 = value++; |
| 55 context->x86->dr6 = value++; | 55 context->x86->dr6 = value++; |
| 56 context->x86->dr7 = value++; | 56 context->x86->dr7 = value++; |
| 57 } | 57 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 77 context->x86_64->r8 = value++; | 77 context->x86_64->r8 = value++; |
| 78 context->x86_64->r9 = value++; | 78 context->x86_64->r9 = value++; |
| 79 context->x86_64->r10 = value++; | 79 context->x86_64->r10 = value++; |
| 80 context->x86_64->r11 = value++; | 80 context->x86_64->r11 = value++; |
| 81 context->x86_64->r12 = value++; | 81 context->x86_64->r12 = value++; |
| 82 context->x86_64->r13 = value++; | 82 context->x86_64->r13 = value++; |
| 83 context->x86_64->r14 = value++; | 83 context->x86_64->r14 = value++; |
| 84 context->x86_64->r15 = value++; | 84 context->x86_64->r15 = value++; |
| 85 context->x86_64->rip = value++; | 85 context->x86_64->rip = value++; |
| 86 context->x86_64->rflags = value++; | 86 context->x86_64->rflags = value++; |
| 87 context->x86_64->cs = value++; | 87 context->x86_64->cs = static_cast<uint16_t>(value++); |
| 88 context->x86_64->fs = value++; | 88 context->x86_64->fs = static_cast<uint16_t>(value++); |
| 89 context->x86_64->gs = value++; | 89 context->x86_64->gs = static_cast<uint16_t>(value++); |
| 90 InitializeCPUContextX86_64Fxsave(&context->x86_64->fxsave, &value); | 90 InitializeCPUContextX86_64Fxsave(&context->x86_64->fxsave, &value); |
| 91 context->x86_64->dr0 = value++; | 91 context->x86_64->dr0 = value++; |
| 92 context->x86_64->dr1 = value++; | 92 context->x86_64->dr1 = value++; |
| 93 context->x86_64->dr2 = value++; | 93 context->x86_64->dr2 = value++; |
| 94 context->x86_64->dr3 = value++; | 94 context->x86_64->dr3 = value++; |
| 95 context->x86_64->dr4 = value++; | 95 context->x86_64->dr4 = value++; |
| 96 context->x86_64->dr5 = value++; | 96 context->x86_64->dr5 = value++; |
| 97 context->x86_64->dr6 = value++; | 97 context->x86_64->dr6 = value++; |
| 98 context->x86_64->dr7 = value++; | 98 context->x86_64->dr7 = value++; |
| 99 } | 99 } |
| 100 | 100 |
| 101 namespace { | 101 namespace { |
| 102 | 102 |
| 103 // This is templatized because the CPUContextX86::Fxsave and | 103 // This is templatized because the CPUContextX86::Fxsave and |
| 104 // CPUContextX86_64::Fxsave are nearly identical but have different sizes for | 104 // CPUContextX86_64::Fxsave are nearly identical but have different sizes for |
| 105 // the members |xmm|, |reserved_4|, and |available|. | 105 // the members |xmm|, |reserved_4|, and |available|. |
| 106 template <typename FxsaveType> | 106 template <typename FxsaveType> |
| 107 void InitializeCPUContextFxsave(FxsaveType* fxsave, uint32_t* seed) { | 107 void InitializeCPUContextFxsave(FxsaveType* fxsave, uint32_t* seed) { |
| 108 uint32_t value = *seed; | 108 uint32_t value = *seed; |
| 109 | 109 |
| 110 fxsave->fcw = value++; | 110 fxsave->fcw = static_cast<uint16_t>(value++); |
| 111 fxsave->fsw = value++; | 111 fxsave->fsw = static_cast<uint16_t>(value++); |
| 112 fxsave->ftw = value++; | 112 fxsave->ftw = static_cast<uint8_t>(value++); |
| 113 fxsave->reserved_1 = value++; | 113 fxsave->reserved_1 = static_cast<uint8_t>(value++); |
| 114 fxsave->fop = value++; | 114 fxsave->fop = static_cast<uint16_t>(value++); |
| 115 fxsave->fpu_ip = value++; | 115 fxsave->fpu_ip = value++; |
| 116 fxsave->fpu_cs = value++; | 116 fxsave->fpu_cs = static_cast<uint16_t>(value++); |
| 117 fxsave->reserved_2 = value++; | 117 fxsave->reserved_2 = static_cast<uint16_t>(value++); |
| 118 fxsave->fpu_dp = value++; | 118 fxsave->fpu_dp = value++; |
| 119 fxsave->fpu_ds = value++; | 119 fxsave->fpu_ds = static_cast<uint16_t>(value++); |
| 120 fxsave->reserved_3 = value++; | 120 fxsave->reserved_3 = static_cast<uint16_t>(value++); |
| 121 fxsave->mxcsr = value++; | 121 fxsave->mxcsr = value++; |
| 122 fxsave->mxcsr_mask = value++; | 122 fxsave->mxcsr_mask = value++; |
| 123 for (size_t st_mm_index = 0; | 123 for (size_t st_mm_index = 0; |
| 124 st_mm_index < arraysize(fxsave->st_mm); | 124 st_mm_index < arraysize(fxsave->st_mm); |
| 125 ++st_mm_index) { | 125 ++st_mm_index) { |
| 126 for (size_t byte = 0; | 126 for (size_t byte = 0; |
| 127 byte < arraysize(fxsave->st_mm[st_mm_index].st); | 127 byte < arraysize(fxsave->st_mm[st_mm_index].st); |
| 128 ++byte) { | 128 ++byte) { |
| 129 fxsave->st_mm[st_mm_index].st[byte] = value++; | 129 fxsave->st_mm[st_mm_index].st[byte] = static_cast<uint8_t>(value++); |
| 130 } | 130 } |
| 131 for (size_t byte = 0; | 131 for (size_t byte = 0; |
| 132 byte < arraysize(fxsave->st_mm[st_mm_index].st_reserved); | 132 byte < arraysize(fxsave->st_mm[st_mm_index].st_reserved); |
| 133 ++byte) { | 133 ++byte) { |
| 134 fxsave->st_mm[st_mm_index].st_reserved[byte] = value; | 134 fxsave->st_mm[st_mm_index].st_reserved[byte] = |
| 135 static_cast<uint8_t>(value); |
| 135 } | 136 } |
| 136 } | 137 } |
| 137 for (size_t xmm_index = 0; xmm_index < arraysize(fxsave->xmm); ++xmm_index) { | 138 for (size_t xmm_index = 0; xmm_index < arraysize(fxsave->xmm); ++xmm_index) { |
| 138 for (size_t byte = 0; byte < arraysize(fxsave->xmm[xmm_index]); ++byte) { | 139 for (size_t byte = 0; byte < arraysize(fxsave->xmm[xmm_index]); ++byte) { |
| 139 fxsave->xmm[xmm_index][byte] = value++; | 140 fxsave->xmm[xmm_index][byte] = static_cast<uint8_t>(value++); |
| 140 } | 141 } |
| 141 } | 142 } |
| 142 for (size_t byte = 0; byte < arraysize(fxsave->reserved_4); ++byte) { | 143 for (size_t byte = 0; byte < arraysize(fxsave->reserved_4); ++byte) { |
| 143 fxsave->reserved_4[byte] = value++; | 144 fxsave->reserved_4[byte] = static_cast<uint8_t>(value++); |
| 144 } | 145 } |
| 145 for (size_t byte = 0; byte < arraysize(fxsave->available); ++byte) { | 146 for (size_t byte = 0; byte < arraysize(fxsave->available); ++byte) { |
| 146 fxsave->available[byte] = value++; | 147 fxsave->available[byte] = static_cast<uint8_t>(value++); |
| 147 } | 148 } |
| 148 | 149 |
| 149 *seed = value; | 150 *seed = value; |
| 150 } | 151 } |
| 151 | 152 |
| 152 } // namespace | 153 } // namespace |
| 153 | 154 |
| 154 void InitializeCPUContextX86Fxsave(CPUContextX86::Fxsave* fxsave, | 155 void InitializeCPUContextX86Fxsave(CPUContextX86::Fxsave* fxsave, |
| 155 uint32_t* seed) { | 156 uint32_t* seed) { |
| 156 return InitializeCPUContextFxsave(fxsave, seed); | 157 return InitializeCPUContextFxsave(fxsave, seed); |
| 157 } | 158 } |
| 158 | 159 |
| 159 void InitializeCPUContextX86_64Fxsave(CPUContextX86_64::Fxsave* fxsave, | 160 void InitializeCPUContextX86_64Fxsave(CPUContextX86_64::Fxsave* fxsave, |
| 160 uint32_t* seed) { | 161 uint32_t* seed) { |
| 161 return InitializeCPUContextFxsave(fxsave, seed); | 162 return InitializeCPUContextFxsave(fxsave, seed); |
| 162 } | 163 } |
| 163 | 164 |
| 164 } // namespace test | 165 } // namespace test |
| 165 } // namespace crashpad | 166 } // namespace crashpad |
| OLD | NEW |