Chromium Code Reviews| 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, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 #ifndef CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ | 15 #ifndef CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ |
| 16 #define CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ | 16 #define CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ |
| 17 | 17 |
| 18 #include <stdint.h> | 18 #include <stdint.h> |
| 19 #include <sys/types.h> | |
| 19 | 20 |
| 20 #include <vector> | 21 #include <vector> |
| 21 | 22 |
| 22 #include "base/basictypes.h" | 23 #include "base/basictypes.h" |
| 23 #include "base/memory/scoped_ptr.h" | 24 #include "base/memory/scoped_ptr.h" |
| 24 #include "minidump/minidump_extensions.h" | 25 #include "minidump/minidump_extensions.h" |
| 25 #include "minidump/minidump_writable.h" | 26 #include "minidump/minidump_writable.h" |
| 26 #include "util/stdlib/pointer_container.h" | 27 #include "util/stdlib/pointer_container.h" |
| 27 | 28 |
| 28 namespace crashpad { | 29 namespace crashpad { |
| 29 | 30 |
| 30 class MinidumpSimpleStringDictionaryWriter; | 31 class MinidumpSimpleStringDictionaryWriter; |
| 32 class ModuleSnapshot; | |
| 31 | 33 |
| 32 //! \brief The writer for a MinidumpModuleCrashpadInfo object in a minidump | 34 //! \brief The writer for a MinidumpModuleCrashpadInfo object in a minidump |
| 33 //! file. | 35 //! file. |
| 34 class MinidumpModuleCrashpadInfoWriter final | 36 class MinidumpModuleCrashpadInfoWriter final |
| 35 : public internal::MinidumpWritable { | 37 : public internal::MinidumpWritable { |
| 36 public: | 38 public: |
| 37 MinidumpModuleCrashpadInfoWriter(); | 39 MinidumpModuleCrashpadInfoWriter(); |
| 38 ~MinidumpModuleCrashpadInfoWriter() override; | 40 ~MinidumpModuleCrashpadInfoWriter() override; |
| 39 | 41 |
| 42 //! \brief Initializes MinidumpModuleCrashpadInfo based on \a module_snapshot. | |
| 43 //! | |
| 44 //! \param[in] module_snapshot The module snapshot to use as source data. | |
| 45 //! \param[in] module_list_index The index of the MINIDUMP_MODULE initialized | |
| 46 //! from \a module_snapshot in the minidump file’s MINIDUMP_MODULE_LIST | |
| 47 //! stream. | |
| 48 //! | |
| 49 //! \note Valid in #kStateMutable. No mutator methods may be called before | |
|
Robert Sesek
2014/10/28 19:39:16
Do you want to mention that this will ignore !IsUs
| |
| 50 //! this method, and it is not normally necessary to call any mutator | |
| 51 //! methods after this method. | |
| 52 void InitializeFromSnapshot(const ModuleSnapshot* module_snapshot, | |
| 53 size_t module_list_index); | |
| 54 | |
| 40 //! \brief Sets MinidumpModuleCrashpadInfo::minidump_module_list_index. | 55 //! \brief Sets MinidumpModuleCrashpadInfo::minidump_module_list_index. |
| 41 void SetMinidumpModuleListIndex(uint32_t minidump_module_list_index) { | 56 void SetMinidumpModuleListIndex(uint32_t minidump_module_list_index) { |
| 42 module_.minidump_module_list_index = minidump_module_list_index; | 57 module_.minidump_module_list_index = minidump_module_list_index; |
| 43 } | 58 } |
| 44 | 59 |
| 45 //! \brief Arranges for MinidumpModuleCrashpadInfo::simple_annotations to | 60 //! \brief Arranges for MinidumpModuleCrashpadInfo::simple_annotations to |
| 46 //! point to the MinidumpSimpleStringDictionaryWriter object to be written | 61 //! point to the MinidumpSimpleStringDictionaryWriter object to be written |
| 47 //! by \a simple_annotations. | 62 //! by \a simple_annotations. |
| 48 //! | 63 //! |
| 49 //! This object takes ownership of \a simple_annotations and becomes its | 64 //! This object takes ownership of \a simple_annotations and becomes its |
| 50 //! parent in the overall tree of internal::MinidumpWritable objects. | 65 //! parent in the overall tree of internal::MinidumpWritable objects. |
| 51 //! | 66 //! |
| 52 //! \note Valid in #kStateMutable. | 67 //! \note Valid in #kStateMutable. |
| 53 void SetSimpleAnnotations( | 68 void SetSimpleAnnotations( |
| 54 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations); | 69 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations); |
| 55 | 70 |
| 71 //! \brief Determines whether the object is useful. | |
| 72 //! | |
| 73 //! A useful object is one that carries data that makes a meaningful | |
| 74 //! contribution to a minidump file. An object carrying simple annotations | |
| 75 //! would be considered useful. | |
| 76 //! | |
| 77 //! \return `true` if the object is useful, `false` otherwise. | |
| 78 bool IsUseful() const; | |
| 79 | |
| 56 protected: | 80 protected: |
| 57 // MinidumpWritable: | 81 // MinidumpWritable: |
| 58 bool Freeze() override; | 82 bool Freeze() override; |
| 59 size_t SizeOfObject() override; | 83 size_t SizeOfObject() override; |
| 60 std::vector<MinidumpWritable*> Children() override; | 84 std::vector<MinidumpWritable*> Children() override; |
| 61 bool WriteObject(FileWriterInterface* file_writer) override; | 85 bool WriteObject(FileWriterInterface* file_writer) override; |
| 62 | 86 |
| 63 private: | 87 private: |
| 64 MinidumpModuleCrashpadInfo module_; | 88 MinidumpModuleCrashpadInfo module_; |
| 65 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations_; | 89 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations_; |
| 66 | 90 |
| 67 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoWriter); | 91 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoWriter); |
| 68 }; | 92 }; |
| 69 | 93 |
| 70 //! \brief The writer for a MinidumpModuleCrashpadInfoList object in a minidump | 94 //! \brief The writer for a MinidumpModuleCrashpadInfoList object in a minidump |
| 71 //! file, containing a list of MinidumpModuleCrashpadInfo objects. | 95 //! file, containing a list of MinidumpModuleCrashpadInfo objects. |
| 72 class MinidumpModuleCrashpadInfoListWriter final | 96 class MinidumpModuleCrashpadInfoListWriter final |
| 73 : public internal::MinidumpWritable { | 97 : public internal::MinidumpWritable { |
| 74 public: | 98 public: |
| 75 MinidumpModuleCrashpadInfoListWriter(); | 99 MinidumpModuleCrashpadInfoListWriter(); |
| 76 ~MinidumpModuleCrashpadInfoListWriter() override; | 100 ~MinidumpModuleCrashpadInfoListWriter() override; |
| 77 | 101 |
| 102 //! \brief Adds an initialized MinidumpModuleCrashpadInfo for modules in \a | |
| 103 //! module_snapshots to the MinidumpModuleCrashpadInfoList. | |
| 104 //! | |
| 105 //! Only modules in \a module_snapshots that would produce a useful | |
| 106 //! MinidumpModuleCrashpadInfo structure are included. Usefulness is | |
| 107 //! determined by MinidumpModuleCrashpadInfoWriter::IsUseful(). | |
| 108 //! | |
| 109 //! \param[in] module_snapshots The module snapshots to use as source data. | |
| 110 //! | |
| 111 //! \note Valid in #kStateMutable. No mutator methods may be called before | |
| 112 //! this method, and it is not normally necessary to call any mutator | |
| 113 //! methods after this method. | |
| 114 void InitializeFromSnapshot( | |
| 115 const std::vector<const ModuleSnapshot*>& module_snapshots); | |
| 116 | |
| 78 //! \brief Adds a MinidumpModuleCrashpadInfo to the | 117 //! \brief Adds a MinidumpModuleCrashpadInfo to the |
| 79 //! MinidumpModuleCrashpadInfoList. | 118 //! MinidumpModuleCrashpadInfoList. |
| 80 //! | 119 //! |
| 81 //! This object takes ownership of \a module and becomes its parent in the | 120 //! This object takes ownership of \a module and becomes its parent in the |
| 82 //! overall tree of internal::MinidumpWritable objects. | 121 //! overall tree of internal::MinidumpWritable objects. |
| 83 //! | 122 //! |
| 84 //! \note Valid in #kStateMutable. | 123 //! \note Valid in #kStateMutable. |
| 85 void AddModule(scoped_ptr<MinidumpModuleCrashpadInfoWriter> module); | 124 void AddModule(scoped_ptr<MinidumpModuleCrashpadInfoWriter> module); |
| 86 | 125 |
| 87 protected: | 126 protected: |
| 88 // MinidumpWritable: | 127 // MinidumpWritable: |
| 89 bool Freeze() override; | 128 bool Freeze() override; |
| 90 size_t SizeOfObject() override; | 129 size_t SizeOfObject() override; |
| 91 std::vector<MinidumpWritable*> Children() override; | 130 std::vector<MinidumpWritable*> Children() override; |
| 92 bool WriteObject(FileWriterInterface* file_writer) override; | 131 bool WriteObject(FileWriterInterface* file_writer) override; |
| 93 | 132 |
| 94 private: | 133 private: |
| 95 MinidumpModuleCrashpadInfoList module_list_base_; | 134 MinidumpModuleCrashpadInfoList module_list_base_; |
| 96 PointerVector<MinidumpModuleCrashpadInfoWriter> modules_; | 135 PointerVector<MinidumpModuleCrashpadInfoWriter> modules_; |
| 97 std::vector<MINIDUMP_LOCATION_DESCRIPTOR> module_location_descriptors_; | 136 std::vector<MINIDUMP_LOCATION_DESCRIPTOR> module_location_descriptors_; |
| 98 | 137 |
| 99 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoListWriter); | 138 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoListWriter); |
| 100 }; | 139 }; |
| 101 | 140 |
| 102 } // namespace crashpad | 141 } // namespace crashpad |
| 103 | 142 |
| 104 #endif // CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ | 143 #endif // CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ |
| OLD | NEW |