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_MISC_INFO_WRITER_H_ |
| 16 #define CRASHPAD_MINIDUMP_MINIDUMP_MISC_INFO_WRITER_H_ |
| 17 |
| 18 #include <dbghelp.h> |
| 19 #include <stdint.h> |
| 20 #include <sys/types.h> |
| 21 #include <time.h> |
| 22 |
| 23 #include <string> |
| 24 |
| 25 #include "base/basictypes.h" |
| 26 #include "minidump/minidump_stream_writer.h" |
| 27 #include "minidump/minidump_writable.h" |
| 28 #include "util/file/file_writer.h" |
| 29 |
| 30 namespace crashpad { |
| 31 |
| 32 //! \brief The writer for a stream in the MINIDUMP_MISC_INFO family in a |
| 33 //! minidump file. |
| 34 //! |
| 35 //! The actual stream written will be a MINIDUMP_MISC_INFO, |
| 36 //! MINIDUMP_MISC_INFO_2, MINIDUMP_MISC_INFO_3, or MINIDUMP_MISC_INFO_4 stream. |
| 37 //! Later versions of MINIDUMP_MISC_INFO are supersets of earlier versions. The |
| 38 //! earliest version that supports all of the information that an object of this |
| 39 //! class contains will be used. |
| 40 class MinidumpMiscInfoWriter final : public internal::MinidumpStreamWriter { |
| 41 public: |
| 42 MinidumpMiscInfoWriter(); |
| 43 ~MinidumpMiscInfoWriter() {} |
| 44 |
| 45 //! \brief Sets the field referenced by #MINIDUMP_MISC1_PROCESS_ID. |
| 46 void SetProcessId(uint32_t process_id); |
| 47 |
| 48 //! \brief Sets the fields referenced by #MINIDUMP_MISC1_PROCESS_TIMES. |
| 49 void SetProcessTimes(time_t process_create_time, |
| 50 uint32_t process_user_time, |
| 51 uint32_t process_kernel_time); |
| 52 |
| 53 //! \brief Sets the fields referenced by #MINIDUMP_MISC1_PROCESSOR_POWER_INFO. |
| 54 void SetProcessorPowerInfo(uint32_t processor_max_mhz, |
| 55 uint32_t processor_current_mhz, |
| 56 uint32_t processor_mhz_limit, |
| 57 uint32_t processor_max_idle_state, |
| 58 uint32_t processor_current_idle_state); |
| 59 |
| 60 //! \brief Sets the field referenced by #MINIDUMP_MISC3_PROCESS_INTEGRITY. |
| 61 void SetProcessIntegrityLevel(uint32_t process_integrity_level); |
| 62 |
| 63 //! \brief Sets the field referenced by #MINIDUMP_MISC3_PROCESS_EXECUTE_FLAGS. |
| 64 void SetProcessExecuteFlags(uint32_t process_execute_flags); |
| 65 |
| 66 //! \brief Sets the field referenced by #MINIDUMP_MISC3_PROTECTED_PROCESS. |
| 67 void SetProtectedProcess(uint32_t protected_process); |
| 68 |
| 69 //! \brief Sets the fields referenced by #MINIDUMP_MISC3_TIMEZONE. |
| 70 void SetTimeZone(uint32_t time_zone_id, |
| 71 int32_t bias, |
| 72 const std::string& standard_name, |
| 73 const SYSTEMTIME& standard_date, |
| 74 int32_t standard_bias, |
| 75 const std::string& daylight_name, |
| 76 const SYSTEMTIME& daylight_date, |
| 77 int32_t daylight_bias); |
| 78 |
| 79 //! \brief Sets the fields referenced by #MINIDUMP_MISC4_BUILDSTRING. |
| 80 void SetBuildString(const std::string& build_string, |
| 81 const std::string& debug_build_string); |
| 82 |
| 83 protected: |
| 84 // MinidumpWritable: |
| 85 virtual bool Freeze() override; |
| 86 virtual size_t SizeOfObject() override; |
| 87 virtual bool WriteObject(FileWriterInterface* file_writer) override; |
| 88 virtual MinidumpStreamType StreamType() const override; |
| 89 |
| 90 private: |
| 91 //! \brief Returns the size of the object to be written based on |
| 92 //! MINIDUMP_MISC_INFO_N::Flags1. |
| 93 //! |
| 94 //! The smallest defined structure type in the MINIDUMP_MISC_INFO family that |
| 95 //! can hold all of the data that has been populated will be used. |
| 96 size_t CalculateSizeOfObjectFromFlags() const; |
| 97 |
| 98 MINIDUMP_MISC_INFO_N misc_info_; |
| 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(MinidumpMiscInfoWriter); |
| 101 }; |
| 102 |
| 103 } // namespace crashpad |
| 104 |
| 105 #endif // CRASHPAD_MINIDUMP_MINIDUMP_MISC_INFO_WRITER_H_ |
OLD | NEW |