| 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 #include "minidump/minidump_module_writer.h" | 15 #include "minidump/minidump_module_writer.h" |
| 16 | 16 |
| 17 #include <sys/types.h> | 17 #include <sys/types.h> |
| 18 | 18 |
| 19 #include <limits> | 19 #include <limits> |
| 20 #include <utility> |
| 20 | 21 |
| 21 #include "base/logging.h" | 22 #include "base/logging.h" |
| 22 #include "base/numerics/safe_conversions.h" | 23 #include "base/numerics/safe_conversions.h" |
| 23 #include "minidump/minidump_string_writer.h" | 24 #include "minidump/minidump_string_writer.h" |
| 24 #include "minidump/minidump_writer_util.h" | 25 #include "minidump/minidump_writer_util.h" |
| 25 #include "snapshot/module_snapshot.h" | 26 #include "snapshot/module_snapshot.h" |
| 26 #include "util/file/file_writer.h" | 27 #include "util/file/file_writer.h" |
| 27 #include "util/misc/implicit_cast.h" | 28 #include "util/misc/implicit_cast.h" |
| 28 #include "util/stdlib/move.h" | |
| 29 #include "util/numeric/in_range_cast.h" | 29 #include "util/numeric/in_range_cast.h" |
| 30 #include "util/numeric/safe_assignment.h" | 30 #include "util/numeric/safe_assignment.h" |
| 31 | 31 |
| 32 namespace crashpad { | 32 namespace crashpad { |
| 33 | 33 |
| 34 MinidumpModuleCodeViewRecordWriter::~MinidumpModuleCodeViewRecordWriter() { | 34 MinidumpModuleCodeViewRecordWriter::~MinidumpModuleCodeViewRecordWriter() { |
| 35 } | 35 } |
| 36 | 36 |
| 37 namespace internal { | 37 namespace internal { |
| 38 | 38 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 break; | 238 break; |
| 239 default: | 239 default: |
| 240 file_type = VFT_UNKNOWN; | 240 file_type = VFT_UNKNOWN; |
| 241 break; | 241 break; |
| 242 } | 242 } |
| 243 SetFileTypeAndSubtype(file_type, VFT2_UNKNOWN); | 243 SetFileTypeAndSubtype(file_type, VFT2_UNKNOWN); |
| 244 | 244 |
| 245 auto codeview_record = | 245 auto codeview_record = |
| 246 make_scoped_ptr(new MinidumpModuleCodeViewRecordPDB70Writer()); | 246 make_scoped_ptr(new MinidumpModuleCodeViewRecordPDB70Writer()); |
| 247 codeview_record->InitializeFromSnapshot(module_snapshot); | 247 codeview_record->InitializeFromSnapshot(module_snapshot); |
| 248 SetCodeViewRecord(crashpad::move(codeview_record)); | 248 SetCodeViewRecord(std::move(codeview_record)); |
| 249 } | 249 } |
| 250 | 250 |
| 251 const MINIDUMP_MODULE* MinidumpModuleWriter::MinidumpModule() const { | 251 const MINIDUMP_MODULE* MinidumpModuleWriter::MinidumpModule() const { |
| 252 DCHECK_EQ(state(), kStateWritable); | 252 DCHECK_EQ(state(), kStateWritable); |
| 253 | 253 |
| 254 return &module_; | 254 return &module_; |
| 255 } | 255 } |
| 256 | 256 |
| 257 void MinidumpModuleWriter::SetName(const std::string& name) { | 257 void MinidumpModuleWriter::SetName(const std::string& name) { |
| 258 DCHECK_EQ(state(), kStateMutable); | 258 DCHECK_EQ(state(), kStateMutable); |
| 259 | 259 |
| 260 if (!name_) { | 260 if (!name_) { |
| 261 name_.reset(new internal::MinidumpUTF16StringWriter()); | 261 name_.reset(new internal::MinidumpUTF16StringWriter()); |
| 262 } | 262 } |
| 263 name_->SetUTF8(name); | 263 name_->SetUTF8(name); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void MinidumpModuleWriter::SetCodeViewRecord( | 266 void MinidumpModuleWriter::SetCodeViewRecord( |
| 267 scoped_ptr<MinidumpModuleCodeViewRecordWriter> codeview_record) { | 267 scoped_ptr<MinidumpModuleCodeViewRecordWriter> codeview_record) { |
| 268 DCHECK_EQ(state(), kStateMutable); | 268 DCHECK_EQ(state(), kStateMutable); |
| 269 | 269 |
| 270 codeview_record_ = crashpad::move(codeview_record); | 270 codeview_record_ = std::move(codeview_record); |
| 271 } | 271 } |
| 272 | 272 |
| 273 void MinidumpModuleWriter::SetMiscDebugRecord( | 273 void MinidumpModuleWriter::SetMiscDebugRecord( |
| 274 scoped_ptr<MinidumpModuleMiscDebugRecordWriter> misc_debug_record) { | 274 scoped_ptr<MinidumpModuleMiscDebugRecordWriter> misc_debug_record) { |
| 275 DCHECK_EQ(state(), kStateMutable); | 275 DCHECK_EQ(state(), kStateMutable); |
| 276 | 276 |
| 277 misc_debug_record_ = crashpad::move(misc_debug_record); | 277 misc_debug_record_ = std::move(misc_debug_record); |
| 278 } | 278 } |
| 279 | 279 |
| 280 void MinidumpModuleWriter::SetTimestamp(time_t timestamp) { | 280 void MinidumpModuleWriter::SetTimestamp(time_t timestamp) { |
| 281 DCHECK_EQ(state(), kStateMutable); | 281 DCHECK_EQ(state(), kStateMutable); |
| 282 | 282 |
| 283 internal::MinidumpWriterUtil::AssignTimeT(&module_.TimeDateStamp, timestamp); | 283 internal::MinidumpWriterUtil::AssignTimeT(&module_.TimeDateStamp, timestamp); |
| 284 } | 284 } |
| 285 | 285 |
| 286 void MinidumpModuleWriter::SetFileVersion(uint16_t version_0, | 286 void MinidumpModuleWriter::SetFileVersion(uint16_t version_0, |
| 287 uint16_t version_1, | 287 uint16_t version_1, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 379 } |
| 380 | 380 |
| 381 void MinidumpModuleListWriter::InitializeFromSnapshot( | 381 void MinidumpModuleListWriter::InitializeFromSnapshot( |
| 382 const std::vector<const ModuleSnapshot*>& module_snapshots) { | 382 const std::vector<const ModuleSnapshot*>& module_snapshots) { |
| 383 DCHECK_EQ(state(), kStateMutable); | 383 DCHECK_EQ(state(), kStateMutable); |
| 384 DCHECK(modules_.empty()); | 384 DCHECK(modules_.empty()); |
| 385 | 385 |
| 386 for (const ModuleSnapshot* module_snapshot : module_snapshots) { | 386 for (const ModuleSnapshot* module_snapshot : module_snapshots) { |
| 387 auto module = make_scoped_ptr(new MinidumpModuleWriter()); | 387 auto module = make_scoped_ptr(new MinidumpModuleWriter()); |
| 388 module->InitializeFromSnapshot(module_snapshot); | 388 module->InitializeFromSnapshot(module_snapshot); |
| 389 AddModule(crashpad::move(module)); | 389 AddModule(std::move(module)); |
| 390 } | 390 } |
| 391 } | 391 } |
| 392 | 392 |
| 393 void MinidumpModuleListWriter::AddModule( | 393 void MinidumpModuleListWriter::AddModule( |
| 394 scoped_ptr<MinidumpModuleWriter> module) { | 394 scoped_ptr<MinidumpModuleWriter> module) { |
| 395 DCHECK_EQ(state(), kStateMutable); | 395 DCHECK_EQ(state(), kStateMutable); |
| 396 | 396 |
| 397 modules_.push_back(module.release()); | 397 modules_.push_back(module.release()); |
| 398 } | 398 } |
| 399 | 399 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 } | 445 } |
| 446 | 446 |
| 447 return file_writer->WriteIoVec(&iovecs); | 447 return file_writer->WriteIoVec(&iovecs); |
| 448 } | 448 } |
| 449 | 449 |
| 450 MinidumpStreamType MinidumpModuleListWriter::StreamType() const { | 450 MinidumpStreamType MinidumpModuleListWriter::StreamType() const { |
| 451 return kMinidumpStreamTypeModuleList; | 451 return kMinidumpStreamTypeModuleList; |
| 452 } | 452 } |
| 453 | 453 |
| 454 } // namespace crashpad | 454 } // namespace crashpad |
| OLD | NEW |