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_CRASHPAD_INFO_WRITER_H_ | 15 #ifndef CRASHPAD_MINIDUMP_MINIDUMP_CRASHPAD_INFO_WRITER_H_ |
16 #define CRASHPAD_MINIDUMP_MINIDUMP_CRASHPAD_INFO_WRITER_H_ | 16 #define CRASHPAD_MINIDUMP_MINIDUMP_CRASHPAD_INFO_WRITER_H_ |
17 | 17 |
18 #include <vector> | 18 #include <vector> |
19 | 19 |
20 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
22 #include "minidump/minidump_extensions.h" | 22 #include "minidump/minidump_extensions.h" |
23 #include "minidump/minidump_stream_writer.h" | 23 #include "minidump/minidump_stream_writer.h" |
24 | 24 |
25 namespace crashpad { | 25 namespace crashpad { |
26 | 26 |
27 class MinidumpModuleCrashpadInfoListWriter; | 27 class MinidumpModuleCrashpadInfoListWriter; |
| 28 class ProcessSnapshot; |
28 | 29 |
29 //! \brief The writer for a MinidumpCrashpadInfo stream in a minidump file. | 30 //! \brief The writer for a MinidumpCrashpadInfo stream in a minidump file. |
30 class MinidumpCrashpadInfoWriter final : public internal::MinidumpStreamWriter { | 31 class MinidumpCrashpadInfoWriter final : public internal::MinidumpStreamWriter { |
31 public: | 32 public: |
32 MinidumpCrashpadInfoWriter(); | 33 MinidumpCrashpadInfoWriter(); |
33 ~MinidumpCrashpadInfoWriter() override; | 34 ~MinidumpCrashpadInfoWriter() override; |
34 | 35 |
| 36 //! \brief Initializes MinidumpCrashpadInfo based on \a process_snapshot. |
| 37 //! |
| 38 //! This method may add additional structures to the minidump file as children |
| 39 //! of the MinidumpCrashpadInfo stream. To do so, it may obtain other |
| 40 //! snapshot information from \a process_snapshot, such as a list of |
| 41 //! ModuleSnapshot objects used to initialize |
| 42 //! MinidumpCrashpadInfo::module_list. Only data that is considered useful |
| 43 //! will be included. For module information, usefulness is determined by |
| 44 //! MinidumpModuleCrashpadInfoListWriter::IsUseful(). |
| 45 //! |
| 46 //! \param[in] process_snapshot The process snapshot to use as source data. |
| 47 //! |
| 48 //! \note Valid in #kStateMutable. No mutator methods may be called before |
| 49 //! this method, and it is not normally necessary to call any mutator |
| 50 //! methods after this method. |
| 51 void InitializeFromSnapshot(const ProcessSnapshot* process_snapshot); |
| 52 |
35 //! \brief Arranges for MinidumpCrashpadInfo::module_list to point to the | 53 //! \brief Arranges for MinidumpCrashpadInfo::module_list to point to the |
36 //! MinidumpModuleCrashpadInfoList object to be written by \a | 54 //! MinidumpModuleCrashpadInfoList object to be written by \a |
37 //! module_list. | 55 //! module_list. |
38 //! | 56 //! |
39 //! This object takes ownership of \a module_list and becomes its parent in | 57 //! This object takes ownership of \a module_list and becomes its parent in |
40 //! the overall tree of internal::MinidumpWritable objects. | 58 //! the overall tree of internal::MinidumpWritable objects. |
41 //! | 59 //! |
42 //! \note Valid in #kStateMutable. | 60 //! \note Valid in #kStateMutable. |
43 void SetModuleList( | 61 void SetModuleList( |
44 scoped_ptr<MinidumpModuleCrashpadInfoListWriter> module_list); | 62 scoped_ptr<MinidumpModuleCrashpadInfoListWriter> module_list); |
45 | 63 |
| 64 //! \brief Determines whether the object is useful. |
| 65 //! |
| 66 //! A useful object is one that carries data that makes a meaningful |
| 67 //! contribution to a minidump file. An object carrying children would be |
| 68 //! considered useful. |
| 69 //! |
| 70 //! \return `true` if the object is useful, `false` otherwise. |
| 71 bool IsUseful() const; |
| 72 |
46 protected: | 73 protected: |
47 // MinidumpWritable: | 74 // MinidumpWritable: |
48 bool Freeze() override; | 75 bool Freeze() override; |
49 size_t SizeOfObject() override; | 76 size_t SizeOfObject() override; |
50 std::vector<MinidumpWritable*> Children() override; | 77 std::vector<MinidumpWritable*> Children() override; |
51 bool WriteObject(FileWriterInterface* file_writer) override; | 78 bool WriteObject(FileWriterInterface* file_writer) override; |
52 | 79 |
53 // MinidumpStreamWriter: | 80 // MinidumpStreamWriter: |
54 MinidumpStreamType StreamType() const override; | 81 MinidumpStreamType StreamType() const override; |
55 | 82 |
56 private: | 83 private: |
57 MinidumpCrashpadInfo crashpad_info_; | 84 MinidumpCrashpadInfo crashpad_info_; |
58 scoped_ptr<MinidumpModuleCrashpadInfoListWriter> module_list_; | 85 scoped_ptr<MinidumpModuleCrashpadInfoListWriter> module_list_; |
59 | 86 |
60 DISALLOW_COPY_AND_ASSIGN(MinidumpCrashpadInfoWriter); | 87 DISALLOW_COPY_AND_ASSIGN(MinidumpCrashpadInfoWriter); |
61 }; | 88 }; |
62 | 89 |
63 } // namespace crashpad | 90 } // namespace crashpad |
64 | 91 |
65 #endif // CRASHPAD_MINIDUMP_MINIDUMP_CRASHPAD_INFO_WRITER_H_ | 92 #endif // CRASHPAD_MINIDUMP_MINIDUMP_CRASHPAD_INFO_WRITER_H_ |
OLD | NEW |