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

Side by Side Diff: minidump/minidump_memory_writer.h

Issue 674153002: minidump: Change the ownership model (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 6 years, 1 month 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
« no previous file with comments | « minidump/minidump_file_writer_test.cc ('k') | minidump/minidump_memory_writer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_MEMORY_WRITER_H_ 15 #ifndef CRASHPAD_MINIDUMP_MINIDUMP_MEMORY_WRITER_H_
16 #define CRASHPAD_MINIDUMP_MINIDUMP_MEMORY_WRITER_H_ 16 #define CRASHPAD_MINIDUMP_MINIDUMP_MEMORY_WRITER_H_
17 17
18 #include <dbghelp.h> 18 #include <dbghelp.h>
19 #include <stdint.h> 19 #include <stdint.h>
20 #include <sys/types.h> 20 #include <sys/types.h>
21 21
22 #include <vector> 22 #include <vector>
23 23
24 #include "base/basictypes.h" 24 #include "base/basictypes.h"
25 #include "base/memory/scoped_ptr.h"
25 #include "minidump/minidump_stream_writer.h" 26 #include "minidump/minidump_stream_writer.h"
26 #include "minidump/minidump_writable.h" 27 #include "minidump/minidump_writable.h"
28 #include "util/stdlib/pointer_container.h"
27 29
28 namespace crashpad { 30 namespace crashpad {
29 31
30 //! \brief The base class for writers of memory ranges pointed to by 32 //! \brief The base class for writers of memory ranges pointed to by
31 //! MINIDUMP_MEMORY_DESCRIPTOR objects in a minidump file. 33 //! MINIDUMP_MEMORY_DESCRIPTOR objects in a minidump file.
32 //! 34 //!
33 //! This is an abstract base class because users are expected to provide their 35 //! This is an abstract base class because users are expected to provide their
34 //! own implementations that, when possible, obtain the memory contents 36 //! own implementations that, when possible, obtain the memory contents
35 //! on-demand in their WriteObject() methods. Memory ranges may be large, and 37 //! on-demand in their WriteObject() methods. Memory ranges may be large, and
36 //! the alternative construction would require the contents of multiple ranges 38 //! the alternative construction would require the contents of multiple ranges
37 //! to be held in memory simultaneously while a minidump file is being written. 39 //! to be held in memory simultaneously while a minidump file is being written.
38 class MinidumpMemoryWriter : public internal::MinidumpWritable { 40 class MinidumpMemoryWriter : public internal::MinidumpWritable {
39 public: 41 public:
42 ~MinidumpMemoryWriter() override;
43
40 //! \brief Returns a MINIDUMP_MEMORY_DESCRIPTOR referencing the data that this 44 //! \brief Returns a MINIDUMP_MEMORY_DESCRIPTOR referencing the data that this
41 //! object writes. 45 //! object writes.
42 //! 46 //!
43 //! This method is expected to be called by a MinidumpMemoryListWriter in 47 //! This method is expected to be called by a MinidumpMemoryListWriter in
44 //! order to obtain a MINIDUMP_MEMORY_DESCRIPTOR to include in its list. 48 //! order to obtain a MINIDUMP_MEMORY_DESCRIPTOR to include in its list.
45 //! 49 //!
46 //! \note Valid in #kStateWritable. 50 //! \note Valid in #kStateWritable.
47 const MINIDUMP_MEMORY_DESCRIPTOR* MinidumpMemoryDescriptor() const; 51 const MINIDUMP_MEMORY_DESCRIPTOR* MinidumpMemoryDescriptor() const;
48 52
49 //! \brief Registers a memory descriptor as one that should point to the 53 //! \brief Registers a memory descriptor as one that should point to the
50 //! object on which this method is called. 54 //! object on which this method is called.
51 //! 55 //!
52 //! This method is expected to be called by objects of other classes, when 56 //! This method is expected to be called by objects of other classes, when
53 //! those other classes have their own memory descriptors that need to point 57 //! those other classes have their own memory descriptors that need to point
54 //! to memory ranges within a minidump file. MinidumpThreadWriter is one such 58 //! to memory ranges within a minidump file. MinidumpThreadWriter is one such
55 //! class. This method is public for this reason, otherwise it would suffice 59 //! class. This method is public for this reason, otherwise it would suffice
56 //! to be private. 60 //! to be private.
57 //! 61 //!
58 //! \note Valid in #kStateFrozen or any preceding state. 62 //! \note Valid in #kStateFrozen or any preceding state.
59 void RegisterMemoryDescriptor(MINIDUMP_MEMORY_DESCRIPTOR* memory_descriptor); 63 void RegisterMemoryDescriptor(MINIDUMP_MEMORY_DESCRIPTOR* memory_descriptor);
60 64
61 protected: 65 protected:
62 MinidumpMemoryWriter(); 66 MinidumpMemoryWriter();
63 ~MinidumpMemoryWriter() {}
64 67
65 //! \brief Returns the base address of the memory region in the address space 68 //! \brief Returns the base address of the memory region in the address space
66 //! of the process that the snapshot describes. 69 //! of the process that the snapshot describes.
67 //! 70 //!
68 //! \note This method will only be called in #kStateFrozen. 71 //! \note This method will only be called in #kStateFrozen.
69 virtual uint64_t MemoryRangeBaseAddress() const = 0; 72 virtual uint64_t MemoryRangeBaseAddress() const = 0;
70 73
71 //! \brief Returns the size of the memory region in bytes. 74 //! \brief Returns the size of the memory region in bytes.
72 //! 75 //!
73 //! \note This method will only be called in #kStateFrozen or a subsequent 76 //! \note This method will only be called in #kStateFrozen or a subsequent
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 std::vector<MINIDUMP_MEMORY_DESCRIPTOR*> registered_memory_descriptors_; 112 std::vector<MINIDUMP_MEMORY_DESCRIPTOR*> registered_memory_descriptors_;
110 113
111 DISALLOW_COPY_AND_ASSIGN(MinidumpMemoryWriter); 114 DISALLOW_COPY_AND_ASSIGN(MinidumpMemoryWriter);
112 }; 115 };
113 116
114 //! \brief The writer for a MINIDUMP_MEMORY_LIST stream in a minidump file, 117 //! \brief The writer for a MINIDUMP_MEMORY_LIST stream in a minidump file,
115 //! containing a list of MINIDUMP_MEMORY_DESCRIPTOR objects. 118 //! containing a list of MINIDUMP_MEMORY_DESCRIPTOR objects.
116 class MinidumpMemoryListWriter final : public internal::MinidumpStreamWriter { 119 class MinidumpMemoryListWriter final : public internal::MinidumpStreamWriter {
117 public: 120 public:
118 MinidumpMemoryListWriter(); 121 MinidumpMemoryListWriter();
119 ~MinidumpMemoryListWriter(); 122 ~MinidumpMemoryListWriter() override;
120 123
121 //! \brief Adds a MinidumpMemoryWriter to the MINIDUMP_MEMORY_LIST. 124 //! \brief Adds a MinidumpMemoryWriter to the MINIDUMP_MEMORY_LIST.
122 //! 125 //!
123 //! \a memory_writer will become a child of this object in the overall tree of 126 //! This object takes ownership of \a memory_writer and becomes its parent in
124 //! internal::MinidumpWritable objects. 127 //! the overall tree of internal::MinidumpWritable objects.
125 //! 128 //!
126 //! \note Valid in #kStateMutable. 129 //! \note Valid in #kStateMutable.
127 void AddMemory(MinidumpMemoryWriter* memory_writer); 130 void AddMemory(scoped_ptr<MinidumpMemoryWriter> memory_writer);
128 131
129 //! \brief Adds a MinidumpMemoryWriter that’s a child of another 132 //! \brief Adds a MinidumpMemoryWriter that’s a child of another
130 //! internal::MinidumpWritable object to the MINIDUMP_MEMORY_LIST. 133 //! internal::MinidumpWritable object to the MINIDUMP_MEMORY_LIST.
131 //! 134 //!
132 //! \a memory_writer does not become a child of this object, but the 135 //! \a memory_writer does not become a child of this object, but the
133 //! MINIDUMP_MEMORY_LIST will still contain a MINIDUMP_MEMORY_DESCRIPTOR for 136 //! MINIDUMP_MEMORY_LIST will still contain a MINIDUMP_MEMORY_DESCRIPTOR for
134 //! it. \a memory_writer must be a child of another object in the 137 //! it. \a memory_writer must be a child of another object in the
135 //! internal::MinidumpWritable tree. 138 //! internal::MinidumpWritable tree.
136 //! 139 //!
137 //! This method exists to be called by objects that have their own 140 //! This method exists to be called by objects that have their own
(...skipping 10 matching lines...) Expand all
148 size_t SizeOfObject() override; 151 size_t SizeOfObject() override;
149 std::vector<MinidumpWritable*> Children() override; 152 std::vector<MinidumpWritable*> Children() override;
150 bool WriteObject(FileWriterInterface* file_writer) override; 153 bool WriteObject(FileWriterInterface* file_writer) override;
151 154
152 // MinidumpStreamWriter: 155 // MinidumpStreamWriter:
153 MinidumpStreamType StreamType() const override; 156 MinidumpStreamType StreamType() const override;
154 157
155 private: 158 private:
156 MINIDUMP_MEMORY_LIST memory_list_base_; 159 MINIDUMP_MEMORY_LIST memory_list_base_;
157 std::vector<MinidumpMemoryWriter*> memory_writers_; // weak 160 std::vector<MinidumpMemoryWriter*> memory_writers_; // weak
158 std::vector<MinidumpWritable*> children_; // weak 161 PointerVector<MinidumpMemoryWriter> children_;
159 162
160 DISALLOW_COPY_AND_ASSIGN(MinidumpMemoryListWriter); 163 DISALLOW_COPY_AND_ASSIGN(MinidumpMemoryListWriter);
161 }; 164 };
162 165
163 } // namespace crashpad 166 } // namespace crashpad
164 167
165 #endif // CRASHPAD_MINIDUMP_MINIDUMP_MEMORY_WRITER_H_ 168 #endif // CRASHPAD_MINIDUMP_MINIDUMP_MEMORY_WRITER_H_
OLDNEW
« no previous file with comments | « minidump/minidump_file_writer_test.cc ('k') | minidump/minidump_memory_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698