| 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_writable.h" | 
|  | 30 #include "util/file/file_writer.h" | 
|  | 31 | 
|  | 32 namespace crashpad { | 
|  | 33 | 
|  | 34 namespace internal { | 
|  | 35 class MinidumpUTF16StringWriter; | 
|  | 36 }  // namespace internal | 
|  | 37 | 
|  | 38 //! \brief The writer for a MINIDUMP_SYSTEM_INFO stream in a minidump file. | 
|  | 39 class MinidumpSystemInfoWriter final : public internal::MinidumpStreamWriter { | 
|  | 40  public: | 
|  | 41   MinidumpSystemInfoWriter(); | 
|  | 42   ~MinidumpSystemInfoWriter(); | 
|  | 43 | 
|  | 44   //! \brief Sets MINIDUMP_SYSTEM_INFO::ProcessorArchitecture. | 
|  | 45   void SetCPUArchitecture(MinidumpCPUArchitecture processor_architecture) { | 
|  | 46     system_info_.ProcessorArchitecture = processor_architecture; | 
|  | 47   } | 
|  | 48 | 
|  | 49   //! \brief Sets MINIDUMP_SYSTEM_INFO::ProcessorLevel and | 
|  | 50   //!     MINIDUMP_SYSTEM_INFO::ProcessorRevision. | 
|  | 51   void SetCPULevelAndRevision(uint16_t processor_level, | 
|  | 52                               uint16_t processor_revision) { | 
|  | 53     system_info_.ProcessorLevel = processor_level; | 
|  | 54     system_info_.ProcessorRevision = processor_revision; | 
|  | 55   } | 
|  | 56 | 
|  | 57   //! \brief Sets MINIDUMP_SYSTEM_INFO::NumberOfProcessors. | 
|  | 58   void SetCPUCount(uint8_t number_of_processors) { | 
|  | 59     system_info_.NumberOfProcessors = number_of_processors; | 
|  | 60   } | 
|  | 61 | 
|  | 62   //! \brief Sets MINIDUMP_SYSTEM_INFO::PlatformId. | 
|  | 63   void SetOS(MinidumpOS platform_id) { system_info_.PlatformId = platform_id; } | 
|  | 64 | 
|  | 65   //! \brief Sets MINIDUMP_SYSTEM_INFO::ProductType. | 
|  | 66   void SetOSType(MinidumpOSType product_type) { | 
|  | 67     system_info_.ProductType = product_type; | 
|  | 68   } | 
|  | 69 | 
|  | 70   //! \brief Sets MINIDUMP_SYSTEM_INFO::MajorVersion, | 
|  | 71   //!     MINIDUMP_SYSTEM_INFO::MinorVersion, and | 
|  | 72   //!     MINIDUMP_SYSTEM_INFO::BuildNumber. | 
|  | 73   void SetOSVersion(uint32_t major_version, | 
|  | 74                     uint32_t minor_version, | 
|  | 75                     uint32_t build_number) { | 
|  | 76     system_info_.MajorVersion = major_version; | 
|  | 77     system_info_.MinorVersion = minor_version; | 
|  | 78     system_info_.BuildNumber = build_number; | 
|  | 79   } | 
|  | 80 | 
|  | 81   //! \brief Arranges for MINIDUMP_SYSTEM_INFO::CSDVersionRva to point to a | 
|  | 82   //!     MINIDUMP_STRING containing the supplied string. | 
|  | 83   //! | 
|  | 84   //! This method must be called prior to Freeze(). A CSD version is required | 
|  | 85   //! in all MINIDUMP_SYSTEM_INFO streams. An empty string is an acceptable | 
|  | 86   //! value. | 
|  | 87   void SetCSDVersion(const std::string& csd_version); | 
|  | 88 | 
|  | 89   //! \brief Sets MINIDUMP_SYSTEM_INFO::SuiteMask. | 
|  | 90   void SetSuiteMask(uint16_t suite_mask) { | 
|  | 91     system_info_.SuiteMask = suite_mask; | 
|  | 92   } | 
|  | 93 | 
|  | 94   //! \brief Sets \ref CPU_INFORMATION::VendorId | 
|  | 95   //!     "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfo::VendorId". | 
|  | 96   //! | 
|  | 97   //! This is only valid if SetCPUArchitecture() has been used to set the CPU | 
|  | 98   //! architecture to #kMinidumpCPUArchitectureX86 or | 
|  | 99   //! #kMinidumpCPUArchitectureX86Win64. | 
|  | 100   //! | 
|  | 101   //! \param[in] ebx The first 4 bytes of the CPU vendor string, the value | 
|  | 102   //!     reported in `cpuid 0` `ebx`. | 
|  | 103   //! \param[in] edx The middle 4 bytes of the CPU vendor string, the value | 
|  | 104   //!     reported in `cpuid 0` `edx`. | 
|  | 105   //! \param[in] ecx The last 4 bytes of the CPU vendor string, the value | 
|  | 106   //!     reported by `cpuid 0` `ecx`. | 
|  | 107   //! | 
|  | 108   //! \note Do not call this method if SetCPUArchitecture() has been used to set | 
|  | 109   //!     the CPU architecture to #kMinidumpCPUArchitectureAMD64. | 
|  | 110   //! | 
|  | 111   //! \sa SetCPUX86VendorString() | 
|  | 112   void SetCPUX86Vendor(uint32_t ebx, uint32_t edx, uint32_t ecx); | 
|  | 113 | 
|  | 114   //! \brief Sets \ref CPU_INFORMATION::VendorId | 
|  | 115   //!     "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfo::VendorId". | 
|  | 116   //! | 
|  | 117   //! This is only valid if SetCPUArchitecture() has been used to set the CPU | 
|  | 118   //! architecture to #kMinidumpCPUArchitectureX86 or | 
|  | 119   //! #kMinidumpCPUArchitectureX86Win64. | 
|  | 120   //! | 
|  | 121   //! \param[in] vendor The entire CPU vendor string, which must be exactly 12 | 
|  | 122   //!     bytes long. | 
|  | 123   //! | 
|  | 124   //! \note Do not call this method if SetCPUArchitecture() has been used to set | 
|  | 125   //!     the CPU architecture to #kMinidumpCPUArchitectureAMD64. | 
|  | 126   //! | 
|  | 127   //! \sa SetCPUX86Vendor() | 
|  | 128   void SetCPUX86VendorString(const std::string& vendor); | 
|  | 129 | 
|  | 130   //! \brief Sets \ref CPU_INFORMATION::VersionInformation | 
|  | 131   //!     "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfo::VersionInformation" and | 
|  | 132   //!     \ref CPU_INFORMATION::FeatureInformation | 
|  | 133   //!     "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfo::FeatureInformation". | 
|  | 134   //! | 
|  | 135   //! This is only valid if SetCPUArchitecture() has been used to set the CPU | 
|  | 136   //! architecture to #kMinidumpCPUArchitectureX86 or | 
|  | 137   //! #kMinidumpCPUArchitectureX86Win64. | 
|  | 138   //! | 
|  | 139   //! \note Do not call this method if SetCPUArchitecture() has been used to set | 
|  | 140   //!     the CPU architecture to #kMinidumpCPUArchitectureAMD64. | 
|  | 141   void SetCPUX86VersionAndFeatures(uint32_t version, uint32_t features); | 
|  | 142 | 
|  | 143   //! \brief Sets \ref CPU_INFORMATION::AMDExtendedCpuFeatures | 
|  | 144   //!     "MINIDUMP_SYSTEM_INFO::Cpu::X86CpuInfo::AMDExtendedCPUFeatures". | 
|  | 145   //! | 
|  | 146   //! This is only valid if SetCPUArchitecture() has been used to set the CPU | 
|  | 147   //! architecture to #kMinidumpCPUArchitectureX86 or | 
|  | 148   //! #kMinidumpCPUArchitectureX86Win64, and if SetCPUX86Vendor() or | 
|  | 149   //! SetCPUX86VendorString() has been used to set the CPU vendor to | 
|  | 150   //! “AuthenticAMD”. | 
|  | 151   //! | 
|  | 152   //! \note Do not call this method if SetCPUArchitecture() has been used to set | 
|  | 153   //!     the CPU architecture to #kMinidumpCPUArchitectureAMD64. | 
|  | 154   void SetCPUX86AMDExtendedFeatures(uint32_t extended_features); | 
|  | 155 | 
|  | 156   //! \brief Sets \ref CPU_INFORMATION::ProcessorFeatures | 
|  | 157   //!     "MINIDUMP_SYSTEM_INFO::Cpu::OtherCpuInfo::ProcessorFeatures". | 
|  | 158   //! | 
|  | 159   //! This is only valid if SetCPUArchitecture() has been used to set the CPU | 
|  | 160   //! architecture to an architecture other than #kMinidumpCPUArchitectureX86 | 
|  | 161   //! or #kMinidumpCPUArchitectureX86Win64. | 
|  | 162   //! | 
|  | 163   //! \note This method may be called if SetCPUArchitecture() has been used to | 
|  | 164   //!     set the CPU architecture to #kMinidumpCPUArchitectureAMD64. | 
|  | 165   void SetCPUOtherFeatures(uint64_t features_0, uint64_t features_1); | 
|  | 166 | 
|  | 167  protected: | 
|  | 168   // MinidumpWritable: | 
|  | 169   virtual bool Freeze() override; | 
|  | 170   virtual size_t SizeOfObject() override; | 
|  | 171   virtual std::vector<MinidumpWritable*> Children() override; | 
|  | 172   virtual bool WriteObject(FileWriterInterface* file_writer) override; | 
|  | 173 | 
|  | 174   // MinidumpStreamWriter: | 
|  | 175   virtual MinidumpStreamType StreamType() const override; | 
|  | 176 | 
|  | 177  private: | 
|  | 178   MINIDUMP_SYSTEM_INFO system_info_; | 
|  | 179   scoped_ptr<internal::MinidumpUTF16StringWriter> csd_version_; | 
|  | 180 | 
|  | 181   DISALLOW_COPY_AND_ASSIGN(MinidumpSystemInfoWriter); | 
|  | 182 }; | 
|  | 183 | 
|  | 184 }  // namespace crashpad | 
|  | 185 | 
|  | 186 #endif  // CRASHPAD_MINIDUMP_MINIDUMP_SYSTEM_INFO_WRITER_H_ | 
| OLD | NEW | 
|---|