Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: minidump/minidump_module_crashpad_info_writer.h

Issue 978463003: minidump: Reorganize MinidumpModuleCrashpadInfo to improve linking between structures (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Minor update Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <sys/types.h>
20 20
21 #include <vector> 21 #include <vector>
22 22
23 #include "base/basictypes.h" 23 #include "base/basictypes.h"
24 #include "base/memory/scoped_ptr.h" 24 #include "base/memory/scoped_ptr.h"
25 #include "minidump/minidump_extensions.h" 25 #include "minidump/minidump_extensions.h"
26 #include "minidump/minidump_location_descriptor_list_writer.h"
27 #include "minidump/minidump_string_writer.h" 26 #include "minidump/minidump_string_writer.h"
28 #include "minidump/minidump_writable.h" 27 #include "minidump/minidump_writable.h"
29 #include "util/stdlib/pointer_container.h" 28 #include "util/stdlib/pointer_container.h"
30 29
31 namespace crashpad { 30 namespace crashpad {
32 31
33 class MinidumpSimpleStringDictionaryWriter; 32 class MinidumpSimpleStringDictionaryWriter;
34 class ModuleSnapshot; 33 class ModuleSnapshot;
35 34
36 //! \brief The writer for a MinidumpModuleCrashpadInfo object in a minidump 35 //! \brief The writer for a MinidumpModuleCrashpadInfo object in a minidump
37 //! file. 36 //! file.
38 class MinidumpModuleCrashpadInfoWriter final 37 class MinidumpModuleCrashpadInfoWriter final
39 : public internal::MinidumpWritable { 38 : public internal::MinidumpWritable {
40 public: 39 public:
41 MinidumpModuleCrashpadInfoWriter(); 40 MinidumpModuleCrashpadInfoWriter();
42 ~MinidumpModuleCrashpadInfoWriter() override; 41 ~MinidumpModuleCrashpadInfoWriter() override;
43 42
44 //! \brief Initializes MinidumpModuleCrashpadInfo based on \a module_snapshot. 43 //! \brief Initializes MinidumpModuleCrashpadInfo based on \a module_snapshot.
45 //! 44 //!
46 //! Only data in \a module_snapshot that is considered useful will be 45 //! Only data in \a module_snapshot that is considered useful will be
47 //! included. For simple annotations, usefulness is determined by 46 //! included. For simple annotations, usefulness is determined by
48 //! MinidumpSimpleStringDictionaryWriter::IsUseful(). 47 //! MinidumpSimpleStringDictionaryWriter::IsUseful().
49 //! 48 //!
50 //! \param[in] module_snapshot The module snapshot to use as source data. 49 //! \param[in] module_snapshot The module snapshot to use as source data.
51 //! \param[in] module_list_index The index of the MINIDUMP_MODULE initialized
52 //! from \a module_snapshot in the minidump file’s MINIDUMP_MODULE_LIST
53 //! stream.
54 //! 50 //!
55 //! \note Valid in #kStateMutable. No mutator methods may be called before 51 //! \note Valid in #kStateMutable. No mutator methods may be called before
56 //! this method, and it is not normally necessary to call any mutator 52 //! this method, and it is not normally necessary to call any mutator
57 //! methods after this method. 53 //! methods after this method.
58 void InitializeFromSnapshot(const ModuleSnapshot* module_snapshot, 54 void InitializeFromSnapshot(const ModuleSnapshot* module_snapshot);
59 size_t module_list_index);
60
61 //! \brief Sets MinidumpModuleCrashpadInfo::minidump_module_list_index.
62 void SetMinidumpModuleListIndex(uint32_t minidump_module_list_index) {
63 module_.minidump_module_list_index = minidump_module_list_index;
64 }
65 55
66 //! \brief Arranges for MinidumpModuleCrashpadInfo::list_annotations to point 56 //! \brief Arranges for MinidumpModuleCrashpadInfo::list_annotations to point
67 //! to the internal::MinidumpUTF8StringListWriter object to be written by 57 //! to the internal::MinidumpUTF8StringListWriter object to be written by
68 //! \a list_annotations. 58 //! \a list_annotations.
69 //! 59 //!
70 //! This object takes ownership of \a simple_annotations and becomes its 60 //! This object takes ownership of \a simple_annotations and becomes its
71 //! parent in the overall tree of internal::MinidumpWritable objects. 61 //! parent in the overall tree of internal::MinidumpWritable objects.
72 //! 62 //!
73 //! \note Valid in #kStateMutable. 63 //! \note Valid in #kStateMutable.
74 void SetListAnnotations( 64 void SetListAnnotations(
(...skipping 30 matching lines...) Expand all
105 MinidumpModuleCrashpadInfo module_; 95 MinidumpModuleCrashpadInfo module_;
106 scoped_ptr<MinidumpUTF8StringListWriter> list_annotations_; 96 scoped_ptr<MinidumpUTF8StringListWriter> list_annotations_;
107 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations_; 97 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations_;
108 98
109 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoWriter); 99 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoWriter);
110 }; 100 };
111 101
112 //! \brief The writer for a MinidumpModuleCrashpadInfoList object in a minidump 102 //! \brief The writer for a MinidumpModuleCrashpadInfoList object in a minidump
113 //! file, containing a list of MinidumpModuleCrashpadInfo objects. 103 //! file, containing a list of MinidumpModuleCrashpadInfo objects.
114 class MinidumpModuleCrashpadInfoListWriter final 104 class MinidumpModuleCrashpadInfoListWriter final
115 : public internal::MinidumpLocationDescriptorListWriter { 105 : public internal::MinidumpWritable {
116 public: 106 public:
117 MinidumpModuleCrashpadInfoListWriter(); 107 MinidumpModuleCrashpadInfoListWriter();
118 ~MinidumpModuleCrashpadInfoListWriter() override; 108 ~MinidumpModuleCrashpadInfoListWriter() override;
119 109
120 //! \brief Adds an initialized MinidumpModuleCrashpadInfo for modules in \a 110 //! \brief Adds an initialized MinidumpModuleCrashpadInfo for modules in \a
121 //! module_snapshots to the MinidumpModuleCrashpadInfoList. 111 //! module_snapshots to the MinidumpModuleCrashpadInfoList.
122 //! 112 //!
123 //! Only modules in \a module_snapshots that would produce a useful 113 //! Only modules in \a module_snapshots that would produce a useful
124 //! MinidumpModuleCrashpadInfo structure are included. Usefulness is 114 //! MinidumpModuleCrashpadInfo structure are included. Usefulness is
125 //! determined by MinidumpModuleCrashpadInfoWriter::IsUseful(). 115 //! determined by MinidumpModuleCrashpadInfoWriter::IsUseful().
126 //! 116 //!
127 //! \param[in] module_snapshots The module snapshots to use as source data. 117 //! \param[in] module_snapshots The module snapshots to use as source data.
128 //! 118 //!
129 //! \note Valid in #kStateMutable. AddModule() may not be called before this 119 //! \note Valid in #kStateMutable. AddModule() may not be called before this
130 //! method, and it is not normally necessary to call AddModule() after 120 //! method, and it is not normally necessary to call AddModule() after
131 //! this method. 121 //! this method.
132 void InitializeFromSnapshot( 122 void InitializeFromSnapshot(
133 const std::vector<const ModuleSnapshot*>& module_snapshots); 123 const std::vector<const ModuleSnapshot*>& module_snapshots);
134 124
135 //! \brief Adds a MinidumpModuleCrashpadInfo to the 125 //! \brief Adds a MinidumpModuleCrashpadInfo to the
136 //! MinidumpModuleCrashpadInfoList. 126 //! MinidumpModuleCrashpadInfoList.
137 //! 127 //!
138 //! This object takes ownership of \a module and becomes its parent in the 128 //! \param[in] module Extended Crashpad-specific information about the module.
139 //! overall tree of internal::MinidumpWritable objects. 129 //! This object takes ownership of \a module and becomes its parent in the
130 //! overall tree of internal::MinidumpWritable objects.
131 //! \param[in] module_list_index The index of the MINIDUMP_MODULE in the
132 //! minidump file’s MINIDUMP_MODULE_LIST stream that corresponds to \a
133 //! module_crashpad_info.
140 //! 134 //!
141 //! \note Valid in #kStateMutable. 135 //! \note Valid in #kStateMutable.
142 void AddModule(scoped_ptr<MinidumpModuleCrashpadInfoWriter> module); 136 void AddModule(
137 scoped_ptr<MinidumpModuleCrashpadInfoWriter> module_crashpad_info,
138 size_t minidump_module_list_index);
143 139
144 //! \brief Determines whether the object is useful. 140 //! \brief Determines whether the object is useful.
145 //! 141 //!
146 //! A useful object is one that carries data that makes a meaningful 142 //! A useful object is one that carries data that makes a meaningful
147 //! contribution to a minidump file. An object carrying children would be 143 //! contribution to a minidump file. An object carrying children would be
148 //! considered useful. 144 //! considered useful.
149 //! 145 //!
150 //! \return `true` if the object is useful, `false` otherwise. 146 //! \return `true` if the object is useful, `false` otherwise.
151 bool IsUseful() const; 147 bool IsUseful() const;
152 148
149 protected:
150 // MinidumpWritable:
151 bool Freeze() override;
152 size_t SizeOfObject() override;
153 std::vector<MinidumpWritable*> Children() override;
154 bool WriteObject(FileWriterInterface* file_writer) override;
155
153 private: 156 private:
157 PointerVector<MinidumpModuleCrashpadInfoWriter> module_crashpad_infos_;
158 std::vector<MinidumpModuleCrashpadInfoLink> module_crashpad_info_links_;
159 MinidumpModuleCrashpadInfoList module_crashpad_info_list_base_;
160
154 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoListWriter); 161 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoListWriter);
155 }; 162 };
156 163
157 } // namespace crashpad 164 } // namespace crashpad
158 165
159 #endif // CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ 166 #endif // CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_
OLDNEW
« no previous file with comments | « minidump/minidump_location_descriptor_list_writer_test.cc ('k') | minidump/minidump_module_crashpad_info_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698