| 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, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 #include "snapshot/cpu_context.h" | 15 #include "snapshot/cpu_context.h" |
| 16 | 16 |
| 17 #include "base/basictypes.h" |
| 17 #include "base/logging.h" | 18 #include "base/logging.h" |
| 18 | 19 |
| 19 namespace crashpad { | 20 namespace crashpad { |
| 20 | 21 |
| 21 // static | 22 // static |
| 22 uint16_t CPUContextX86::FxsaveToFsaveTagWord( | 23 uint16_t CPUContextX86::FxsaveToFsaveTagWord( |
| 23 uint16_t fsw, | 24 uint16_t fsw, |
| 24 uint8_t fxsave_tag, | 25 uint8_t fxsave_tag, |
| 25 const CPUContextX86::X87OrMMXRegister st_mm[8]) { | 26 const CPUContextX86::X87OrMMXRegister st_mm[8]) { |
| 26 enum { | 27 enum { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 uint32_t exponent = ((st[9] & 0x7f) << 8) | st[8]; | 49 uint32_t exponent = ((st[9] & 0x7f) << 8) | st[8]; |
| 49 if (exponent == 0x7fff) { | 50 if (exponent == 0x7fff) { |
| 50 // Infinity, NaN, pseudo-infinity, or pseudo-NaN. If it was important to | 51 // Infinity, NaN, pseudo-infinity, or pseudo-NaN. If it was important to |
| 51 // distinguish between these, the J bit and the M bit (the most | 52 // distinguish between these, the J bit and the M bit (the most |
| 52 // significant bit of |fraction|) could be consulted. | 53 // significant bit of |fraction|) could be consulted. |
| 53 fsave_bits = kX87TagSpecial; | 54 fsave_bits = kX87TagSpecial; |
| 54 } else { | 55 } else { |
| 55 // The integer bit the “J bit”. | 56 // The integer bit the “J bit”. |
| 56 bool integer_bit = st[7] & 0x80; | 57 bool integer_bit = st[7] & 0x80; |
| 57 if (exponent == 0) { | 58 if (exponent == 0) { |
| 58 uint64_t fraction = ((static_cast<uint64_t>(st[7]) & 0x7f) << 56) | | 59 uint64_t fraction = ((implicit_cast<uint64_t>(st[7]) & 0x7f) << 56) | |
| 59 (static_cast<uint64_t>(st[6]) << 48) | | 60 (implicit_cast<uint64_t>(st[6]) << 48) | |
| 60 (static_cast<uint64_t>(st[5]) << 40) | | 61 (implicit_cast<uint64_t>(st[5]) << 40) | |
| 61 (static_cast<uint64_t>(st[4]) << 32) | | 62 (implicit_cast<uint64_t>(st[4]) << 32) | |
| 62 (static_cast<uint32_t>(st[3]) << 24) | | 63 (implicit_cast<uint32_t>(st[3]) << 24) | |
| 63 (st[2] << 16) | (st[1] << 8) | st[0]; | 64 (st[2] << 16) | (st[1] << 8) | st[0]; |
| 64 if (!integer_bit && fraction == 0) { | 65 if (!integer_bit && fraction == 0) { |
| 65 fsave_bits = kX87TagZero; | 66 fsave_bits = kX87TagZero; |
| 66 } else { | 67 } else { |
| 67 // Denormal (if the J bit is clear) or pseudo-denormal. | 68 // Denormal (if the J bit is clear) or pseudo-denormal. |
| 68 fsave_bits = kX87TagSpecial; | 69 fsave_bits = kX87TagSpecial; |
| 69 } | 70 } |
| 70 } else if (integer_bit) { | 71 } else if (integer_bit) { |
| 71 fsave_bits = kX87TagValid; | 72 fsave_bits = kX87TagValid; |
| 72 } else { | 73 } else { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 90 return x86->eip; | 91 return x86->eip; |
| 91 case kCPUArchitectureX86_64: | 92 case kCPUArchitectureX86_64: |
| 92 return x86_64->rip; | 93 return x86_64->rip; |
| 93 default: | 94 default: |
| 94 NOTREACHED(); | 95 NOTREACHED(); |
| 95 return -1; | 96 return -1; |
| 96 } | 97 } |
| 97 } | 98 } |
| 98 | 99 |
| 99 } // namespace crashpad | 100 } // namespace crashpad |
| OLD | NEW |