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 the MinidumpModuleCrashpadInfo based on \a |
| 43 //! module_snapshot. |
| 44 //! |
| 45 //! Only data in \a module_snapshot that is considered useful will be |
| 46 //! included. For simple annotations, usefulness is determined by |
| 47 //! MinidumpSimpleStringDictionaryWriter::IsUseful(). |
| 48 //! |
| 49 //! \param[in] module_snapshot The module snapshot to use as source data. |
| 50 //! \param[in] module_list_index The index of the MINIDUMP_MODULE initialized |
| 51 //! from \a module_snapshot in the minidump file’s MINIDUMP_MODULE_LIST |
| 52 //! stream. |
| 53 //! |
| 54 //! \note Valid in #kStateMutable. No mutator methods may be called before |
| 55 //! this method, and it is not normally necessary to call any mutator |
| 56 //! methods after this method. |
| 57 void InitializeFromSnapshot(const ModuleSnapshot* module_snapshot, |
| 58 size_t module_list_index); |
| 59 |
40 //! \brief Sets MinidumpModuleCrashpadInfo::minidump_module_list_index. | 60 //! \brief Sets MinidumpModuleCrashpadInfo::minidump_module_list_index. |
41 void SetMinidumpModuleListIndex(uint32_t minidump_module_list_index) { | 61 void SetMinidumpModuleListIndex(uint32_t minidump_module_list_index) { |
42 module_.minidump_module_list_index = minidump_module_list_index; | 62 module_.minidump_module_list_index = minidump_module_list_index; |
43 } | 63 } |
44 | 64 |
45 //! \brief Arranges for MinidumpModuleCrashpadInfo::simple_annotations to | 65 //! \brief Arranges for MinidumpModuleCrashpadInfo::simple_annotations to |
46 //! point to the MinidumpSimpleStringDictionaryWriter object to be written | 66 //! point to the MinidumpSimpleStringDictionaryWriter object to be written |
47 //! by \a simple_annotations. | 67 //! by \a simple_annotations. |
48 //! | 68 //! |
49 //! This object takes ownership of \a simple_annotations and becomes its | 69 //! This object takes ownership of \a simple_annotations and becomes its |
50 //! parent in the overall tree of internal::MinidumpWritable objects. | 70 //! parent in the overall tree of internal::MinidumpWritable objects. |
51 //! | 71 //! |
52 //! \note Valid in #kStateMutable. | 72 //! \note Valid in #kStateMutable. |
53 void SetSimpleAnnotations( | 73 void SetSimpleAnnotations( |
54 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations); | 74 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations); |
55 | 75 |
| 76 //! \brief Determines whether the object is useful. |
| 77 //! |
| 78 //! A useful object is one that carries data that makes a meaningful |
| 79 //! contribution to a minidump file. An object carrying simple annotations |
| 80 //! would be considered useful. |
| 81 //! |
| 82 //! \return `true` if the object is useful, `false` otherwise. |
| 83 bool IsUseful() const; |
| 84 |
56 protected: | 85 protected: |
57 // MinidumpWritable: | 86 // MinidumpWritable: |
58 bool Freeze() override; | 87 bool Freeze() override; |
59 size_t SizeOfObject() override; | 88 size_t SizeOfObject() override; |
60 std::vector<MinidumpWritable*> Children() override; | 89 std::vector<MinidumpWritable*> Children() override; |
61 bool WriteObject(FileWriterInterface* file_writer) override; | 90 bool WriteObject(FileWriterInterface* file_writer) override; |
62 | 91 |
63 private: | 92 private: |
64 MinidumpModuleCrashpadInfo module_; | 93 MinidumpModuleCrashpadInfo module_; |
65 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations_; | 94 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations_; |
66 | 95 |
67 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoWriter); | 96 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoWriter); |
68 }; | 97 }; |
69 | 98 |
70 //! \brief The writer for a MinidumpModuleCrashpadInfoList object in a minidump | 99 //! \brief The writer for a MinidumpModuleCrashpadInfoList object in a minidump |
71 //! file, containing a list of MinidumpModuleCrashpadInfo objects. | 100 //! file, containing a list of MinidumpModuleCrashpadInfo objects. |
72 class MinidumpModuleCrashpadInfoListWriter final | 101 class MinidumpModuleCrashpadInfoListWriter final |
73 : public internal::MinidumpWritable { | 102 : public internal::MinidumpWritable { |
74 public: | 103 public: |
75 MinidumpModuleCrashpadInfoListWriter(); | 104 MinidumpModuleCrashpadInfoListWriter(); |
76 ~MinidumpModuleCrashpadInfoListWriter() override; | 105 ~MinidumpModuleCrashpadInfoListWriter() override; |
77 | 106 |
| 107 //! \brief Adds an initialized MinidumpModuleCrashpadInfo for modules in \a |
| 108 //! module_snapshots to the MinidumpModuleCrashpadInfoList. |
| 109 //! |
| 110 //! Only modules in \a module_snapshots that would produce a useful |
| 111 //! MinidumpModuleCrashpadInfo structure are included. Usefulness is |
| 112 //! determined by MinidumpModuleCrashpadInfoWriter::IsUseful(). |
| 113 //! |
| 114 //! \param[in] module_snapshots The module snapshots to use as source data. |
| 115 //! |
| 116 //! \note Valid in #kStateMutable. No mutator methods may be called before |
| 117 //! this method, and it is not normally necessary to call any mutator |
| 118 //! methods after this method. |
| 119 void InitializeFromSnapshot( |
| 120 const std::vector<const ModuleSnapshot*>& module_snapshots); |
| 121 |
78 //! \brief Adds a MinidumpModuleCrashpadInfo to the | 122 //! \brief Adds a MinidumpModuleCrashpadInfo to the |
79 //! MinidumpModuleCrashpadInfoList. | 123 //! MinidumpModuleCrashpadInfoList. |
80 //! | 124 //! |
81 //! This object takes ownership of \a module and becomes its parent in the | 125 //! This object takes ownership of \a module and becomes its parent in the |
82 //! overall tree of internal::MinidumpWritable objects. | 126 //! overall tree of internal::MinidumpWritable objects. |
83 //! | 127 //! |
84 //! \note Valid in #kStateMutable. | 128 //! \note Valid in #kStateMutable. |
85 void AddModule(scoped_ptr<MinidumpModuleCrashpadInfoWriter> module); | 129 void AddModule(scoped_ptr<MinidumpModuleCrashpadInfoWriter> module); |
86 | 130 |
87 protected: | 131 protected: |
88 // MinidumpWritable: | 132 // MinidumpWritable: |
89 bool Freeze() override; | 133 bool Freeze() override; |
90 size_t SizeOfObject() override; | 134 size_t SizeOfObject() override; |
91 std::vector<MinidumpWritable*> Children() override; | 135 std::vector<MinidumpWritable*> Children() override; |
92 bool WriteObject(FileWriterInterface* file_writer) override; | 136 bool WriteObject(FileWriterInterface* file_writer) override; |
93 | 137 |
94 private: | 138 private: |
95 MinidumpModuleCrashpadInfoList module_list_base_; | 139 MinidumpModuleCrashpadInfoList module_list_base_; |
96 PointerVector<MinidumpModuleCrashpadInfoWriter> modules_; | 140 PointerVector<MinidumpModuleCrashpadInfoWriter> modules_; |
97 std::vector<MINIDUMP_LOCATION_DESCRIPTOR> module_location_descriptors_; | 141 std::vector<MINIDUMP_LOCATION_DESCRIPTOR> module_location_descriptors_; |
98 | 142 |
99 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoListWriter); | 143 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoListWriter); |
100 }; | 144 }; |
101 | 145 |
102 } // namespace crashpad | 146 } // namespace crashpad |
103 | 147 |
104 #endif // CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ | 148 #endif // CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ |
OLD | NEW |