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 16 matching lines...) Expand all Loading... |
27 namespace { | 27 namespace { |
28 | 28 |
29 uint64_t AMD64FeaturesFromSystemSnapshot( | 29 uint64_t AMD64FeaturesFromSystemSnapshot( |
30 const SystemSnapshot* system_snapshot) { | 30 const SystemSnapshot* system_snapshot) { |
31 #define ADD_FEATURE(minidump_bit) (UINT64_C(1) << (minidump_bit)) | 31 #define ADD_FEATURE(minidump_bit) (UINT64_C(1) << (minidump_bit)) |
32 | 32 |
33 // Features for which no cpuid bits are present, but that always exist on | 33 // Features for which no cpuid bits are present, but that always exist on |
34 // x86_64. cmpxchg is supported on 486 and later. | 34 // x86_64. cmpxchg is supported on 486 and later. |
35 uint64_t minidump_features = ADD_FEATURE(PF_COMPARE_EXCHANGE_DOUBLE); | 35 uint64_t minidump_features = ADD_FEATURE(PF_COMPARE_EXCHANGE_DOUBLE); |
36 | 36 |
37 #define MAP_FEATURE(features, cpuid_bit, minidump_bit) \ | 37 #define MAP_FEATURE(features, cpuid_bit, minidump_bit) \ |
38 do { \ | 38 do { \ |
39 if ((features) & (static_cast<decltype(features)>(1) << (cpuid_bit))) { \ | 39 if ((features) & (implicit_cast<decltype(features)>(1) << (cpuid_bit))) { \ |
40 minidump_features |= ADD_FEATURE(minidump_bit); \ | 40 minidump_features |= ADD_FEATURE(minidump_bit); \ |
41 } \ | 41 } \ |
42 } while (false) | 42 } while (false) |
43 | 43 |
44 #define F_TSC 4 | 44 #define F_TSC 4 |
45 #define F_PAE 6 | 45 #define F_PAE 6 |
46 #define F_MMX 23 | 46 #define F_MMX 23 |
47 #define F_SSE 25 | 47 #define F_SSE 25 |
48 #define F_SSE2 26 | 48 #define F_SSE2 26 |
49 #define F_SSE3 32 | 49 #define F_SSE3 32 |
50 #define F_CX16 45 | 50 #define F_CX16 45 |
51 #define F_XSAVE 58 | 51 #define F_XSAVE 58 |
52 #define F_RDRAND 62 | 52 #define F_RDRAND 62 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 cpu_architecture = kMinidumpCPUArchitectureAMD64; | 121 cpu_architecture = kMinidumpCPUArchitectureAMD64; |
122 break; | 122 break; |
123 default: | 123 default: |
124 NOTREACHED(); | 124 NOTREACHED(); |
125 cpu_architecture = kMinidumpCPUArchitectureUnknown; | 125 cpu_architecture = kMinidumpCPUArchitectureUnknown; |
126 break; | 126 break; |
127 } | 127 } |
128 SetCPUArchitecture(cpu_architecture); | 128 SetCPUArchitecture(cpu_architecture); |
129 | 129 |
130 uint32_t cpu_revision = system_snapshot->CPURevision(); | 130 uint32_t cpu_revision = system_snapshot->CPURevision(); |
131 SetCPULevelAndRevision( | 131 SetCPULevelAndRevision((cpu_revision & 0xffff0000) >> 16, |
132 (cpu_revision & 0xffff0000) >> 16, cpu_revision & 0x0000ffff); | 132 cpu_revision & 0x0000ffff); |
133 SetCPUCount(system_snapshot->CPUCount()); | 133 SetCPUCount(system_snapshot->CPUCount()); |
134 | 134 |
135 if (cpu_architecture == kMinidumpCPUArchitectureX86) { | 135 if (cpu_architecture == kMinidumpCPUArchitectureX86) { |
136 std::string cpu_vendor = system_snapshot->CPUVendor(); | 136 std::string cpu_vendor = system_snapshot->CPUVendor(); |
137 SetCPUX86VendorString(cpu_vendor); | 137 SetCPUX86VendorString(cpu_vendor); |
138 | 138 |
139 // The minidump file format only has room for the bottom 32 bits of CPU | 139 // The minidump file format only has room for the bottom 32 bits of CPU |
140 // features and extended CPU features. | 140 // features and extended CPU features. |
141 SetCPUX86VersionAndFeatures(system_snapshot->CPUX86Signature(), | 141 SetCPUX86VersionAndFeatures(system_snapshot->CPUX86Signature(), |
142 system_snapshot->CPUX86Features() & 0xffffffff); | 142 system_snapshot->CPUX86Features() & 0xffffffff); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 DCHECK_EQ(state(), kStateWritable); | 287 DCHECK_EQ(state(), kStateWritable); |
288 | 288 |
289 return file_writer->Write(&system_info_, sizeof(system_info_)); | 289 return file_writer->Write(&system_info_, sizeof(system_info_)); |
290 } | 290 } |
291 | 291 |
292 MinidumpStreamType MinidumpSystemInfoWriter::StreamType() const { | 292 MinidumpStreamType MinidumpSystemInfoWriter::StreamType() const { |
293 return kMinidumpStreamTypeSystemInfo; | 293 return kMinidumpStreamTypeSystemInfo; |
294 } | 294 } |
295 | 295 |
296 } // namespace crashpad | 296 } // namespace crashpad |
OLD | NEW |