| 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, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 #include <string> | 22 #include <string> |
| 23 #include <vector> | 23 #include <vector> |
| 24 | 24 |
| 25 #include "base/basictypes.h" | 25 #include "base/basictypes.h" |
| 26 #include "base/memory/scoped_ptr.h" | 26 #include "base/memory/scoped_ptr.h" |
| 27 #include "base/strings/string16.h" | 27 #include "base/strings/string16.h" |
| 28 #include "minidump/minidump_extensions.h" | 28 #include "minidump/minidump_extensions.h" |
| 29 #include "minidump/minidump_stream_writer.h" | 29 #include "minidump/minidump_stream_writer.h" |
| 30 #include "minidump/minidump_writable.h" | 30 #include "minidump/minidump_writable.h" |
| 31 #include "util/stdlib/pointer_container.h" |
| 31 | 32 |
| 32 namespace crashpad { | 33 namespace crashpad { |
| 33 | 34 |
| 34 namespace internal { | 35 namespace internal { |
| 35 class MinidumpUTF16StringWriter; | 36 class MinidumpUTF16StringWriter; |
| 36 } // namespace internal | 37 } // namespace internal |
| 37 | 38 |
| 38 //! \brief The base class for writers of CodeView records referenced by | 39 //! \brief The base class for writers of CodeView records referenced by |
| 39 //! MINIDUMP_MODULE::CvRecord in minidump files. | 40 //! MINIDUMP_MODULE::CvRecord in minidump files. |
| 40 class MinidumpModuleCodeViewRecordWriter : public internal::MinidumpWritable { | 41 class MinidumpModuleCodeViewRecordWriter : public internal::MinidumpWritable { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 //! MINIDUMP_STRING containing \a name. | 188 //! MINIDUMP_STRING containing \a name. |
| 188 //! | 189 //! |
| 189 //! A name is required in all MINIDUMP_MODULE objects. | 190 //! A name is required in all MINIDUMP_MODULE objects. |
| 190 //! | 191 //! |
| 191 //! \note Valid in #kStateMutable. | 192 //! \note Valid in #kStateMutable. |
| 192 void SetName(const std::string& name); | 193 void SetName(const std::string& name); |
| 193 | 194 |
| 194 //! \brief Arranges for MINIDUMP_MODULE::CvRecord to point to a CodeView | 195 //! \brief Arranges for MINIDUMP_MODULE::CvRecord to point to a CodeView |
| 195 //! record to be written by \a codeview_record. | 196 //! record to be written by \a codeview_record. |
| 196 //! | 197 //! |
| 197 //! \a codeview_record will become a child of this object in the overall tree | 198 //! This object takes ownership of \a codeview_record and becomes its parent |
| 198 //! of internal::MinidumpWritable objects. | 199 //! in the overall tree of internal::MinidumpWritable objects. |
| 199 //! | 200 //! |
| 200 //! \note Valid in #kStateMutable. | 201 //! \note Valid in #kStateMutable. |
| 201 void SetCodeViewRecord(MinidumpModuleCodeViewRecordWriter* codeview_record); | 202 void SetCodeViewRecord( |
| 203 scoped_ptr<MinidumpModuleCodeViewRecordWriter> codeview_record); |
| 202 | 204 |
| 203 //! \brief Arranges for MINIDUMP_MODULE::MiscRecord to point to an | 205 //! \brief Arranges for MINIDUMP_MODULE::MiscRecord to point to an |
| 204 //! IMAGE_DEBUG_MISC object to be written by \a misc_debug_record. | 206 //! IMAGE_DEBUG_MISC object to be written by \a misc_debug_record. |
| 205 //! | 207 //! |
| 206 //! \a misc_debug_record will become a child of this object in the overall | 208 //! This object takes ownership of \a misc_debug_record and becomes its parent |
| 207 //! tree of internal::MinidumpWritable objects. | 209 //! in the overall tree of internal::MinidumpWritable objects. |
| 208 //! | 210 //! |
| 209 //! \note Valid in #kStateMutable. | 211 //! \note Valid in #kStateMutable. |
| 210 void SetMiscDebugRecord( | 212 void SetMiscDebugRecord( |
| 211 MinidumpModuleMiscDebugRecordWriter* misc_debug_record); | 213 scoped_ptr<MinidumpModuleMiscDebugRecordWriter> misc_debug_record); |
| 212 | 214 |
| 213 //! \brief Sets IMAGE_DEBUG_MISC::BaseOfImage. | 215 //! \brief Sets IMAGE_DEBUG_MISC::BaseOfImage. |
| 214 void SetImageBaseAddress(uint64_t image_base_address) { | 216 void SetImageBaseAddress(uint64_t image_base_address) { |
| 215 module_.BaseOfImage = image_base_address; | 217 module_.BaseOfImage = image_base_address; |
| 216 } | 218 } |
| 217 | 219 |
| 218 //! \brief Sets IMAGE_DEBUG_MISC::SizeOfImage. | 220 //! \brief Sets IMAGE_DEBUG_MISC::SizeOfImage. |
| 219 void SetImageSize(uint32_t image_size) { module_.SizeOfImage = image_size; } | 221 void SetImageSize(uint32_t image_size) { module_.SizeOfImage = image_size; } |
| 220 | 222 |
| 221 //! \brief Sets IMAGE_DEBUG_MISC::CheckSum. | 223 //! \brief Sets IMAGE_DEBUG_MISC::CheckSum. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 protected: | 274 protected: |
| 273 // MinidumpWritable: | 275 // MinidumpWritable: |
| 274 bool Freeze() override; | 276 bool Freeze() override; |
| 275 size_t SizeOfObject() override; | 277 size_t SizeOfObject() override; |
| 276 std::vector<MinidumpWritable*> Children() override; | 278 std::vector<MinidumpWritable*> Children() override; |
| 277 bool WriteObject(FileWriterInterface* file_writer) override; | 279 bool WriteObject(FileWriterInterface* file_writer) override; |
| 278 | 280 |
| 279 private: | 281 private: |
| 280 MINIDUMP_MODULE module_; | 282 MINIDUMP_MODULE module_; |
| 281 scoped_ptr<internal::MinidumpUTF16StringWriter> name_; | 283 scoped_ptr<internal::MinidumpUTF16StringWriter> name_; |
| 282 MinidumpModuleCodeViewRecordWriter* codeview_record_; // weak | 284 scoped_ptr<MinidumpModuleCodeViewRecordWriter> codeview_record_; |
| 283 MinidumpModuleMiscDebugRecordWriter* misc_debug_record_; // weak | 285 scoped_ptr<MinidumpModuleMiscDebugRecordWriter> misc_debug_record_; |
| 284 | 286 |
| 285 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleWriter); | 287 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleWriter); |
| 286 }; | 288 }; |
| 287 | 289 |
| 288 //! \brief The writer for a MINIDUMP_MODULE_LIST stream in a minidump file, | 290 //! \brief The writer for a MINIDUMP_MODULE_LIST stream in a minidump file, |
| 289 //! containing a list of MINIDUMP_MODULE objects. | 291 //! containing a list of MINIDUMP_MODULE objects. |
| 290 class MinidumpModuleListWriter final : public internal::MinidumpStreamWriter { | 292 class MinidumpModuleListWriter final : public internal::MinidumpStreamWriter { |
| 291 public: | 293 public: |
| 292 MinidumpModuleListWriter(); | 294 MinidumpModuleListWriter(); |
| 293 ~MinidumpModuleListWriter(); | 295 ~MinidumpModuleListWriter() override; |
| 294 | 296 |
| 295 //! \brief Adds a MinidumpModuleWriter to the MINIDUMP_MODULE_LIST. | 297 //! \brief Adds a MinidumpModuleWriter to the MINIDUMP_MODULE_LIST. |
| 296 //! | 298 //! |
| 297 //! \a module will become a child of this object in the overall tree of | 299 //! This object takes ownership of \a module and becomes its parent in the |
| 298 //! internal::MinidumpWritable objects. | 300 //! overall tree of internal::MinidumpWritable objects. |
| 299 //! | 301 //! |
| 300 //! \note Valid in #kStateMutable. | 302 //! \note Valid in #kStateMutable. |
| 301 void AddModule(MinidumpModuleWriter* module); | 303 void AddModule(scoped_ptr<MinidumpModuleWriter> module); |
| 302 | 304 |
| 303 protected: | 305 protected: |
| 304 // MinidumpWritable: | 306 // MinidumpWritable: |
| 305 bool Freeze() override; | 307 bool Freeze() override; |
| 306 size_t SizeOfObject() override; | 308 size_t SizeOfObject() override; |
| 307 std::vector<MinidumpWritable*> Children() override; | 309 std::vector<MinidumpWritable*> Children() override; |
| 308 bool WriteObject(FileWriterInterface* file_writer) override; | 310 bool WriteObject(FileWriterInterface* file_writer) override; |
| 309 | 311 |
| 310 // MinidumpStreamWriter: | 312 // MinidumpStreamWriter: |
| 311 MinidumpStreamType StreamType() const override; | 313 MinidumpStreamType StreamType() const override; |
| 312 | 314 |
| 313 private: | 315 private: |
| 314 MINIDUMP_MODULE_LIST module_list_base_; | 316 MINIDUMP_MODULE_LIST module_list_base_; |
| 315 std::vector<MinidumpModuleWriter*> modules_; // weak | 317 PointerVector<MinidumpModuleWriter> modules_; |
| 316 | 318 |
| 317 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleListWriter); | 319 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleListWriter); |
| 318 }; | 320 }; |
| 319 | 321 |
| 320 } // namespace crashpad | 322 } // namespace crashpad |
| 321 | 323 |
| 322 #endif // CRASHPAD_MINIDUMP_MINIDUMP_MODULE_WRITER_H_ | 324 #endif // CRASHPAD_MINIDUMP_MINIDUMP_MODULE_WRITER_H_ |
| OLD | NEW |