| 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 { |
| 41 public: | 42 public: |
| 42 virtual ~MinidumpModuleCodeViewRecordWriter(); | 43 ~MinidumpModuleCodeViewRecordWriter() override; |
| 43 | 44 |
| 44 protected: | 45 protected: |
| 45 MinidumpModuleCodeViewRecordWriter() : MinidumpWritable() {} | 46 MinidumpModuleCodeViewRecordWriter() : MinidumpWritable() {} |
| 46 | 47 |
| 47 private: | 48 private: |
| 48 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCodeViewRecordWriter); | 49 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCodeViewRecordWriter); |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 namespace internal { | 52 namespace internal { |
| 52 | 53 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCodeViewRecordPDB70Writer); | 128 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCodeViewRecordPDB70Writer); |
| 128 }; | 129 }; |
| 129 | 130 |
| 130 //! \brief The writer for an IMAGE_DEBUG_MISC object in a minidump file. | 131 //! \brief The writer for an IMAGE_DEBUG_MISC object in a minidump file. |
| 131 //! | 132 //! |
| 132 //! Most users will want MinidumpModuleCodeViewRecordPDB70Writer instead. | 133 //! Most users will want MinidumpModuleCodeViewRecordPDB70Writer instead. |
| 133 class MinidumpModuleMiscDebugRecordWriter final | 134 class MinidumpModuleMiscDebugRecordWriter final |
| 134 : public internal::MinidumpWritable { | 135 : public internal::MinidumpWritable { |
| 135 public: | 136 public: |
| 136 MinidumpModuleMiscDebugRecordWriter(); | 137 MinidumpModuleMiscDebugRecordWriter(); |
| 137 ~MinidumpModuleMiscDebugRecordWriter() {} | 138 ~MinidumpModuleMiscDebugRecordWriter() override; |
| 138 | 139 |
| 139 //! \brief Sets IMAGE_DEBUG_MISC::DataType. | 140 //! \brief Sets IMAGE_DEBUG_MISC::DataType. |
| 140 void SetDataType(uint32_t data_type) { | 141 void SetDataType(uint32_t data_type) { |
| 141 image_debug_misc_.DataType = data_type; | 142 image_debug_misc_.DataType = data_type; |
| 142 } | 143 } |
| 143 | 144 |
| 144 //! \brief Sets IMAGE_DEBUG_MISC::Data, IMAGE_DEBUG_MISC::Length, and | 145 //! \brief Sets IMAGE_DEBUG_MISC::Data, IMAGE_DEBUG_MISC::Length, and |
| 145 //! IMAGE_DEBUG_MISC::Unicode. | 146 //! IMAGE_DEBUG_MISC::Unicode. |
| 146 //! | 147 //! |
| 147 //! If \a utf16 is `true`, \a data will be treated as UTF-8 data and will be | 148 //! If \a utf16 is `true`, \a data will be treated as UTF-8 data and will be |
| (...skipping 18 matching lines...) Expand all Loading... |
| 166 | 167 |
| 167 //! \brief The writer for a MINIDUMP_MODULE object in a minidump file. | 168 //! \brief The writer for a MINIDUMP_MODULE object in a minidump file. |
| 168 //! | 169 //! |
| 169 //! Because MINIDUMP_MODULE objects only appear as elements of | 170 //! Because MINIDUMP_MODULE objects only appear as elements of |
| 170 //! MINIDUMP_MODULE_LIST objects, this class does not write any data on its own. | 171 //! MINIDUMP_MODULE_LIST objects, this class does not write any data on its own. |
| 171 //! It makes its MINIDUMP_MODULE data available to its MinidumpModuleListWriter | 172 //! It makes its MINIDUMP_MODULE data available to its MinidumpModuleListWriter |
| 172 //! parent, which writes it as part of a MINIDUMP_MODULE_LIST. | 173 //! parent, which writes it as part of a MINIDUMP_MODULE_LIST. |
| 173 class MinidumpModuleWriter final : public internal::MinidumpWritable { | 174 class MinidumpModuleWriter final : public internal::MinidumpWritable { |
| 174 public: | 175 public: |
| 175 MinidumpModuleWriter(); | 176 MinidumpModuleWriter(); |
| 176 ~MinidumpModuleWriter(); | 177 ~MinidumpModuleWriter() override; |
| 177 | 178 |
| 178 //! \brief Returns a MINIDUMP_MODULE referencing this object’s data. | 179 //! \brief Returns a MINIDUMP_MODULE referencing this object’s data. |
| 179 //! | 180 //! |
| 180 //! This method is expected to be called by a MinidumpModuleListWriter in | 181 //! This method is expected to be called by a MinidumpModuleListWriter in |
| 181 //! order to obtain a MINIDUMP_MODULE to include in its list. | 182 //! order to obtain a MINIDUMP_MODULE to include in its list. |
| 182 //! | 183 //! |
| 183 //! \note Valid in #kStateWritable. | 184 //! \note Valid in #kStateWritable. |
| 184 const MINIDUMP_MODULE* MinidumpModule() const; | 185 const MINIDUMP_MODULE* MinidumpModule() const; |
| 185 | 186 |
| 186 //! \brief Arranges for MINIDUMP_MODULE::ModuleNameRva to point to a | 187 //! \brief Arranges for MINIDUMP_MODULE::ModuleNameRva to point to a |
| 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 |