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_MINIDUMP_MINIDUMP_SYSTEM_INFO_WRITER_H_ | |
| 16 #define CRASHPAD_MINIDUMP_MINIDUMP_SYSTEM_INFO_WRITER_H_ | |
| 17 | |
| 18 #include <dbghelp.h> | |
| 19 #include <stdint.h> | |
| 20 #include <sys/types.h> | |
| 21 | |
| 22 #include <string> | |
| 23 #include <vector> | |
| 24 | |
| 25 #include "base/basictypes.h" | |
| 26 #include "base/memory/scoped_ptr.h" | |
| 27 #include "minidump/minidump_extensions.h" | |
| 28 #include "minidump/minidump_stream_writer.h" | |
| 29 #include "minidump/minidump_string_writer.h" | |
|
Robert Sesek
2014/08/06 17:35:46
You could forward-declare this instead.
Mark Mentovai
2014/08/06 18:14:03
rsesek wrote:
| |
| 30 #include "minidump/minidump_writable.h" | |
| 31 #include "util/file/file_writer.h" | |
| 32 | |
| 33 namespace crashpad { | |
| 34 | |
| 35 //! \brief The writer for a MINIDUMP_SYSTEM_INFO stream in a minidump file. | |
|
Robert Sesek
2014/08/06 17:35:47
\ref MINIDUMP_SYSTEM_INFO ?
Mark Mentovai
2014/08/06 18:14:03
rsesek wrote:
| |
| 36 class MinidumpSystemInfoWriter final : public internal::MinidumpStreamWriter { | |
| 37 public: | |
| 38 MinidumpSystemInfoWriter(); | |
| 39 ~MinidumpSystemInfoWriter(); | |
| 40 | |
| 41 //! \brief Sets MINIDUMP_SYSTEM_INFO::ProcessorArchitecture. | |
|
Robert Sesek
2014/08/06 17:35:47
Doxygen auto-hyperlinks with the :: right?
Mark Mentovai
2014/08/06 18:14:03
rsesek wrote:
| |
| 42 void SetCPUArchitecture(MinidumpCPUArchitecture processor_architecture) { | |
| 43 system_info_.ProcessorArchitecture = processor_architecture; | |
| 44 } | |
| 45 | |
| 46 //! \brief Sets MINIDUMP_SYSTEM_INFO::ProcessorLevel and | |
| 47 //! MINIDUMP_SYSTEM_INFO::ProcessorRevision. | |
| 48 void SetCPULevelAndRevision(uint16_t processor_level, | |
| 49 uint16_t processor_revision) { | |
| 50 system_info_.ProcessorLevel = processor_level; | |
| 51 system_info_.ProcessorRevision = processor_revision; | |
| 52 } | |
| 53 | |
| 54 //! \brief Sets MINIDUMP_SYSTEM_INFO::NumberOfProcessors. | |
| 55 void SetCPUCount(uint8_t number_of_processors) { | |
| 56 system_info_.NumberOfProcessors = number_of_processors; | |
| 57 } | |
| 58 | |
| 59 //! \brief Sets MINIDUMP_SYSTEM_INFO::PlatformId. | |
| 60 void SetOS(MinidumpOS platform_id) { system_info_.PlatformId = platform_id; } | |
| 61 | |
| 62 //! \brief Sets MINIDUMP_SYSTEM_INFO::ProductType. | |
| 63 void SetOSType(MinidumpOSType product_type) { | |
| 64 system_info_.ProductType = product_type; | |
| 65 } | |
| 66 | |
| 67 //! \brief Sets MINIDUMP_SYSTEM_INFO::MajorVersion, | |
| 68 //! MINIDUMP_SYSTEM_INFO::MinorVersion, and | |
| 69 //! MINIDUMP_SYSTEM_INFO::BuildNumber. | |
| 70 void SetOSVersion(uint32_t major_version, | |
| 71 uint32_t minor_version, | |
| 72 uint32_t build_number) { | |
| 73 system_info_.MajorVersion = major_version; | |
| 74 system_info_.MinorVersion = minor_version; | |
| 75 system_info_.BuildNumber = build_number; | |
| 76 } | |
| 77 | |
| 78 //! \brief Arranges for MINIDUMP_SYSTEM_INFO::CSDVersionRva to point to a | |
| 79 //! MINIDUMP_STRING containing the supplied string. | |
| 80 //! | |
| 81 //! This method must be called prior to Freeze(). A CSD version is required | |
| 82 //! in all MINIDUMP_SYSTEM_INFO streams. An empty string is an acceptable | |
| 83 //! value. | |
| 84 void SetCSDVersion(const std::string& csd_version); | |
| 85 | |
| 86 //! \brief Sets MINIDUMP_SYSTEM_INFO::SuiteMask. | |
| 87 void SetSuiteMask(uint16_t suite_mask) { | |
| 88 system_info_.SuiteMask = suite_mask; | |
| 89 } | |
| 90 | |
| 91 //! \brief Sets \ref CPU_INFORMATION::VendorId | |
|
Robert Sesek
2014/08/06 17:35:47
Why do you \ref here and on line 108, but not abov
Mark Mentovai
2014/08/06 18:14:03
rsesek wrote:
| |
| 92 //! "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfoInfo::VendorId". | |
| 93 //! | |
| 94 //! This is only valid if SetCPUArchitecture() has been used to set the CPU | |
| 95 //! architecture to #kMinidumpCPUArchitectureX86 or | |
| 96 //! #kMinidumpCPUArchitectureX86Win64. | |
| 97 //! | |
| 98 //! \param[in] ebx The first 4 bytes of the CPU vendor string, the value | |
| 99 //! reported in `cpuid 0` `ebx`. | |
| 100 //! \param[in] edx The middle 4 bytes of the CPU vendor string, the value | |
| 101 //! reported in `cpuid 0` `edx`. | |
| 102 //! \param[in] ecx The last 4 bytes of the CPU vendor string, the value | |
| 103 //! reported by `cpuid 0` `ecx`. | |
| 104 //! | |
| 105 //! \sa SetCPUX86VendorString() | |
| 106 void SetCPUX86Vendor(uint32_t ebx, uint32_t edx, uint32_t ecx); | |
| 107 | |
| 108 //! \brief Sets \ref CPU_INFORMATION::VendorId | |
| 109 //! "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfoInfo::VendorId". | |
| 110 //! | |
| 111 //! This is only valid if SetCPUArchitecture() has been used to set the CPU | |
| 112 //! architecture to #kMinidumpCPUArchitectureX86 or | |
| 113 //! #kMinidumpCPUArchitectureX86Win64. | |
| 114 //! | |
| 115 //! \param[in] vendor The entire CPU vendor string, which must be exactly 12 | |
| 116 //! bytes long. | |
| 117 //! | |
| 118 //! \sa SetCPUX86Vendor() | |
| 119 void SetCPUX86VendorString(const std::string& vendor); | |
| 120 | |
| 121 //! \brief Sets \ref CPU_INFORMATION::VersionInformation | |
| 122 //! "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfoInfo::VersionInformation" and | |
| 123 //! \ref CPU_INFORMATION::FeatureInformation | |
| 124 //! "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfoInfo::FeatureInformation". | |
| 125 //! | |
| 126 //! This is only valid if SetCPUArchitecture() has been used to set the CPU | |
| 127 //! architecture to #kMinidumpCPUArchitectureX86 or | |
| 128 //! #kMinidumpCPUArchitectureX86Win64. | |
| 129 void SetCPUX86VersionAndFeatures(uint32_t version, uint32_t features); | |
| 130 | |
| 131 //! \brief Sets \ref CPU_INFORMATION::AMDExtendedCpuFeatures | |
| 132 //! "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfoInfo::AMDExtendedCPUFeatures". | |
| 133 //! | |
| 134 //! This is only valid if SetCPUArchitecture() has been used to set the CPU | |
| 135 //! architecture to #kMinidumpCPUArchitectureX86 or | |
| 136 //! #kMinidumpCPUArchitectureX86Win64, and if SetCPUX86Vendor() or | |
| 137 //! SetCPUX86VendorString() has been used to set the CPU vendor to | |
| 138 //! “AuthenticAMD”. | |
| 139 void SetCPUX86AMDExtendedFeatures(uint32_t extended_features); | |
| 140 | |
| 141 //! \brief Sets \ref CPU_INFORMATION::ProcessorFeatures | |
| 142 //! "MINIDUMP_SYSTEM_INFO::Cpu::OtherCpuInfoInfo::ProcessorFeatures". | |
| 143 //! | |
| 144 //! This is only valid if SetCPUArchitecture() has been used to set the CPU | |
| 145 //! architecture to an architecture other than #kMinidumpCPUArchitectureX86 | |
| 146 //! or #kMinidumpCPUArchitectureX86Win64. | |
| 147 void SetCPUOtherFeatures(uint64_t features_0, uint64_t features_1); | |
| 148 | |
| 149 protected: | |
| 150 // MinidumpWritable: | |
| 151 virtual bool Freeze() override; | |
| 152 virtual size_t SizeOfObject() override; | |
| 153 virtual std::vector<MinidumpWritable*> Children() override; | |
| 154 virtual bool WriteObject(FileWriterInterface* file_writer) override; | |
| 155 | |
| 156 // MinidumpStreamWriter: | |
| 157 virtual MinidumpStreamType StreamType() const override; | |
| 158 | |
| 159 private: | |
| 160 MINIDUMP_SYSTEM_INFO system_info_; | |
| 161 scoped_ptr<internal::MinidumpUTF16StringWriter> csd_version_; | |
| 162 | |
| 163 DISALLOW_COPY_AND_ASSIGN(MinidumpSystemInfoWriter); | |
| 164 }; | |
| 165 | |
| 166 } // namespace crashpad | |
| 167 | |
| 168 #endif // CRASHPAD_MINIDUMP_MINIDUMP_SYSTEM_INFO_WRITER_H_ | |
| OLD | NEW |