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 29 matching lines...) Expand all Loading... | |
40 } | 40 } |
41 | 41 |
42 void MinidumpSystemInfoWriter::SetCPUX86Vendor(uint32_t ebx, | 42 void MinidumpSystemInfoWriter::SetCPUX86Vendor(uint32_t ebx, |
43 uint32_t edx, | 43 uint32_t edx, |
44 uint32_t ecx) { | 44 uint32_t ecx) { |
45 DCHECK_EQ(state(), kStateMutable); | 45 DCHECK_EQ(state(), kStateMutable); |
46 DCHECK(system_info_.ProcessorArchitecture == kMinidumpCPUArchitectureX86 || | 46 DCHECK(system_info_.ProcessorArchitecture == kMinidumpCPUArchitectureX86 || |
47 system_info_.ProcessorArchitecture == | 47 system_info_.ProcessorArchitecture == |
48 kMinidumpCPUArchitectureX86Win64); | 48 kMinidumpCPUArchitectureX86Win64); |
49 | 49 |
50 COMPILE_ASSERT(arraysize(system_info_.Cpu.X86CpuInfo.VendorId) == 3, | 50 static_assert(arraysize(system_info_.Cpu.X86CpuInfo.VendorId) == 3, |
51 vendor_id_must_have_3_elements); | 51 "vendor id must have 3 elements"); |
Mark Mentovai
2014/10/01 18:57:55
I’d say to call this one VendorId, and the same on
scottmg
2014/10/01 19:27:40
Done.
| |
52 | 52 |
53 system_info_.Cpu.X86CpuInfo.VendorId[0] = ebx; | 53 system_info_.Cpu.X86CpuInfo.VendorId[0] = ebx; |
54 system_info_.Cpu.X86CpuInfo.VendorId[1] = edx; | 54 system_info_.Cpu.X86CpuInfo.VendorId[1] = edx; |
55 system_info_.Cpu.X86CpuInfo.VendorId[2] = ecx; | 55 system_info_.Cpu.X86CpuInfo.VendorId[2] = ecx; |
56 } | 56 } |
57 | 57 |
58 void MinidumpSystemInfoWriter::SetCPUX86VendorString( | 58 void MinidumpSystemInfoWriter::SetCPUX86VendorString( |
59 const std::string& vendor) { | 59 const std::string& vendor) { |
60 DCHECK_EQ(state(), kStateMutable); | 60 DCHECK_EQ(state(), kStateMutable); |
61 CHECK_EQ(vendor.size(), sizeof(system_info_.Cpu.X86CpuInfo.VendorId)); | 61 CHECK_EQ(vendor.size(), sizeof(system_info_.Cpu.X86CpuInfo.VendorId)); |
62 | 62 |
63 uint32_t registers[3]; | 63 uint32_t registers[3]; |
64 COMPILE_ASSERT( | 64 static_assert( |
65 sizeof(registers) == sizeof(system_info_.Cpu.X86CpuInfo.VendorId), | 65 sizeof(registers) == sizeof(system_info_.Cpu.X86CpuInfo.VendorId), |
66 vendor_id_sizes_must_be_equal); | 66 "vendor id sizes must be equal"); |
67 | 67 |
68 for (size_t index = 0; index < arraysize(registers); ++index) { | 68 for (size_t index = 0; index < arraysize(registers); ++index) { |
69 memcpy(®isters[index], | 69 memcpy(®isters[index], |
70 &vendor[index * sizeof(*registers)], | 70 &vendor[index * sizeof(*registers)], |
71 sizeof(*registers)); | 71 sizeof(*registers)); |
72 } | 72 } |
73 | 73 |
74 SetCPUX86Vendor(registers[0], registers[1], registers[2]); | 74 SetCPUX86Vendor(registers[0], registers[1], registers[2]); |
75 } | 75 } |
76 | 76 |
(...skipping 21 matching lines...) Expand all Loading... | |
98 system_info_.Cpu.X86CpuInfo.AMDExtendedCpuFeatures = extended_features; | 98 system_info_.Cpu.X86CpuInfo.AMDExtendedCpuFeatures = extended_features; |
99 } | 99 } |
100 | 100 |
101 void MinidumpSystemInfoWriter::SetCPUOtherFeatures(uint64_t features_0, | 101 void MinidumpSystemInfoWriter::SetCPUOtherFeatures(uint64_t features_0, |
102 uint64_t features_1) { | 102 uint64_t features_1) { |
103 DCHECK_EQ(state(), kStateMutable); | 103 DCHECK_EQ(state(), kStateMutable); |
104 DCHECK(system_info_.ProcessorArchitecture != kMinidumpCPUArchitectureX86 && | 104 DCHECK(system_info_.ProcessorArchitecture != kMinidumpCPUArchitectureX86 && |
105 system_info_.ProcessorArchitecture != | 105 system_info_.ProcessorArchitecture != |
106 kMinidumpCPUArchitectureX86Win64); | 106 kMinidumpCPUArchitectureX86Win64); |
107 | 107 |
108 COMPILE_ASSERT( | 108 static_assert(arraysize(system_info_.Cpu.OtherCpuInfo.ProcessorFeatures) == 2, |
109 arraysize(system_info_.Cpu.OtherCpuInfo.ProcessorFeatures) == 2, | 109 "processor features must have 2 elements"); |
110 processor_features_must_have_2_elements); | |
111 | 110 |
112 system_info_.Cpu.OtherCpuInfo.ProcessorFeatures[0] = features_0; | 111 system_info_.Cpu.OtherCpuInfo.ProcessorFeatures[0] = features_0; |
113 system_info_.Cpu.OtherCpuInfo.ProcessorFeatures[1] = features_1; | 112 system_info_.Cpu.OtherCpuInfo.ProcessorFeatures[1] = features_1; |
114 } | 113 } |
115 | 114 |
116 bool MinidumpSystemInfoWriter::Freeze() { | 115 bool MinidumpSystemInfoWriter::Freeze() { |
117 DCHECK_EQ(state(), kStateMutable); | 116 DCHECK_EQ(state(), kStateMutable); |
118 CHECK(csd_version_); | 117 CHECK(csd_version_); |
119 | 118 |
120 if (!MinidumpStreamWriter::Freeze()) { | 119 if (!MinidumpStreamWriter::Freeze()) { |
(...skipping 23 matching lines...) Expand all Loading... | |
144 DCHECK_EQ(state(), kStateWritable); | 143 DCHECK_EQ(state(), kStateWritable); |
145 | 144 |
146 return file_writer->Write(&system_info_, sizeof(system_info_)); | 145 return file_writer->Write(&system_info_, sizeof(system_info_)); |
147 } | 146 } |
148 | 147 |
149 MinidumpStreamType MinidumpSystemInfoWriter::StreamType() const { | 148 MinidumpStreamType MinidumpSystemInfoWriter::StreamType() const { |
150 return kMinidumpStreamTypeSystemInfo; | 149 return kMinidumpStreamTypeSystemInfo; |
151 } | 150 } |
152 | 151 |
153 } // namespace crashpad | 152 } // namespace crashpad |
OLD | NEW |