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_SNAPSHOT_MAC_SYSTEM_SNAPSHOT_MAC_H_ 16 #define CRASHPAD_SNAPSHOT_MAC_SYSTEM_SNAPSHOT_MAC_H_ 17 18 #include <stdint.h> 19 20 #include <string> 21 22 #include "base/macros.h" 23 #include "snapshot/system_snapshot.h" 24 #include "util/misc/initialization_state_dcheck.h" 25 26 namespace crashpad { 27 28 class ProcessReaderMac; 29 30 namespace internal { 31 32 //! \brief A SystemSnapshot of the running system, when the system runs macOS. 33 class SystemSnapshotMac final : public SystemSnapshot { 34 public: 35 SystemSnapshotMac(); 36 ~SystemSnapshotMac() override; 37 38 //! \brief Initializes the object. 39 //! 40 //! \param[in] process_reader A reader for the process being snapshotted. 41 //! \n\n 42 //! It seems odd that a system snapshot implementation would need a 43 //! ProcessReaderMac, but some of the information reported about the 44 //! system depends on the process it’s being reported for. For example, 45 //! the architecture returned by GetCPUArchitecture() should be the 46 //! architecture of the process, which may be different than the native 47 //! architecture of the system: an x86_64 system can run both x86_64 and 48 //! 32-bit x86 processes. 49 //! \param[in] snapshot_time The time of the snapshot being taken. 50 //! \n\n 51 //! This parameter is necessary for TimeZone() to determine whether 52 //! daylight saving time was in effect at the time the snapshot was taken. 53 //! Otherwise, it would need to base its determination on the current 54 //! time, which may be different than the snapshot time for snapshots 55 //! generated around the daylight saving transition time. 56 void Initialize(ProcessReaderMac* process_reader, 57 const timeval* snapshot_time); 58 59 // SystemSnapshot: 60 61 CPUArchitecture GetCPUArchitecture() const override; 62 uint32_t CPURevision() const override; 63 uint8_t CPUCount() const override; 64 std::string CPUVendor() const override; 65 void CPUFrequency(uint64_t* current_hz, uint64_t* max_hz) const override; 66 uint32_t CPUX86Signature() const override; 67 uint64_t CPUX86Features() const override; 68 uint64_t CPUX86ExtendedFeatures() const override; 69 uint32_t CPUX86Leaf7Features() const override; 70 bool CPUX86SupportsDAZ() const override; 71 OperatingSystem GetOperatingSystem() const override; 72 bool OSServer() const override; 73 void OSVersion( 74 int* major, int* minor, int* bugfix, std::string* build) const override; 75 std::string OSVersionFull() const override; 76 bool NXEnabled() const override; 77 std::string MachineDescription() const override; 78 void TimeZone(DaylightSavingTimeStatus* dst_status, 79 int* standard_offset_seconds, 80 int* daylight_offset_seconds, 81 std::string* standard_name, 82 std::string* daylight_name) const override; 83 84 private: 85 std::string os_version_full_; 86 std::string os_version_build_; 87 ProcessReaderMac* process_reader_; // weak 88 const timeval* snapshot_time_; // weak 89 int os_version_major_; 90 int os_version_minor_; 91 int os_version_bugfix_; 92 bool os_server_; 93 InitializationStateDcheck initialized_; 94 95 DISALLOW_COPY_AND_ASSIGN(SystemSnapshotMac); 96 }; 97 98 } // namespace internal 99 } // namespace crashpad 100 101 #endif // CRASHPAD_SNAPSHOT_MAC_SYSTEM_SNAPSHOT_MAC_H_ 102