Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (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 | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 | |
| 15 #include "snapshot/win/module_snapshot_win.h" | |
| 16 | |
| 17 #include "base/strings/stringprintf.h" | |
|
Mark Mentovai
2015/05/01 20:00:14
Unused.
scottmg
2015/05/01 20:45:58
Done.
| |
| 18 #include "base/strings/utf_string_conversions.h" | |
| 19 #include "snapshot/win/pe_image_reader.h" | |
| 20 #include "util/misc/tri_state.h" | |
| 21 #include "util/misc/uuid.h" | |
| 22 #include "util/stdlib/strnlen.h" | |
|
Mark Mentovai
2015/05/01 20:00:14
Unused.
scottmg
2015/05/01 20:45:58
Done.
| |
| 23 | |
| 24 namespace crashpad { | |
| 25 namespace internal { | |
| 26 | |
| 27 ModuleSnapshotWin::ModuleSnapshotWin() | |
| 28 : ModuleSnapshot(), | |
| 29 name_(), | |
| 30 timestamp_(0), | |
| 31 process_reader_(nullptr), | |
| 32 initialized_() { | |
| 33 } | |
| 34 | |
| 35 ModuleSnapshotWin::~ModuleSnapshotWin() { | |
| 36 } | |
| 37 | |
| 38 bool ModuleSnapshotWin::Initialize( | |
| 39 ProcessReaderWin* process_reader, | |
| 40 const ProcessInfo::Module& process_reader_module) { | |
| 41 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); | |
| 42 | |
| 43 process_reader_ = process_reader; | |
| 44 name_ = base::UTF16ToUTF8(process_reader_module.name); | |
| 45 timestamp_ = process_reader_module.timestamp; | |
| 46 pe_image_reader_.reset(new PEImageReader()); | |
| 47 if (!pe_image_reader_->Initialize(process_reader_, | |
| 48 process_reader_module.dll_base, | |
| 49 process_reader_module.size, | |
| 50 name_)) { | |
| 51 return false; | |
| 52 } | |
| 53 | |
| 54 INITIALIZATION_STATE_SET_VALID(initialized_); | |
| 55 return true; | |
| 56 } | |
| 57 | |
| 58 void ModuleSnapshotWin::GetCrashpadOptions(CrashpadInfoClientOptions* options) { | |
| 59 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 60 | |
| 61 process_types::CrashpadInfo crashpad_info; | |
| 62 if (!pe_image_reader_->GetCrashpadInfo(&crashpad_info)) { | |
| 63 options->crashpad_handler_behavior = TriState::kUnset; | |
| 64 options->system_crash_reporter_forwarding = TriState::kUnset; | |
| 65 return; | |
| 66 } | |
| 67 | |
| 68 options->crashpad_handler_behavior = | |
| 69 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( | |
| 70 crashpad_info.crashpad_handler_behavior); | |
| 71 | |
| 72 options->system_crash_reporter_forwarding = | |
| 73 CrashpadInfoClientOptions::TriStateFromCrashpadInfo( | |
| 74 crashpad_info.system_crash_reporter_forwarding); | |
| 75 } | |
| 76 | |
| 77 std::string ModuleSnapshotWin::Name() const { | |
| 78 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 79 return name_; | |
| 80 } | |
| 81 | |
| 82 uint64_t ModuleSnapshotWin::Address() const { | |
| 83 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 84 return pe_image_reader_->Address(); | |
| 85 } | |
| 86 | |
| 87 uint64_t ModuleSnapshotWin::Size() const { | |
| 88 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 89 return pe_image_reader_->Size(); | |
| 90 } | |
| 91 | |
| 92 time_t ModuleSnapshotWin::Timestamp() const { | |
| 93 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 94 return timestamp_; | |
| 95 } | |
| 96 | |
| 97 void ModuleSnapshotWin::FileVersion(uint16_t* version_0, | |
| 98 uint16_t* version_1, | |
| 99 uint16_t* version_2, | |
| 100 uint16_t* version_3) const { | |
| 101 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 102 CHECK(false) << "TODO(scottmg)"; | |
| 103 } | |
| 104 | |
| 105 void ModuleSnapshotWin::SourceVersion(uint16_t* version_0, | |
| 106 uint16_t* version_1, | |
| 107 uint16_t* version_2, | |
| 108 uint16_t* version_3) const { | |
| 109 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 110 CHECK(false) << "TODO(scottmg)"; | |
| 111 } | |
| 112 | |
| 113 ModuleSnapshot::ModuleType ModuleSnapshotWin::GetModuleType() const { | |
| 114 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 115 CHECK(false) << "TODO(scottmg)"; | |
| 116 return ModuleSnapshot::ModuleType(); | |
| 117 } | |
| 118 | |
| 119 void ModuleSnapshotWin::UUID(crashpad::UUID* uuid) const { | |
| 120 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 121 CHECK(false) << "TODO(scottmg)"; | |
| 122 } | |
| 123 | |
| 124 std::vector<std::string> ModuleSnapshotWin::AnnotationsVector() const { | |
| 125 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 126 CHECK(false) << "TODO(scottmg)"; | |
| 127 return std::vector<std::string>(); | |
| 128 } | |
| 129 | |
| 130 std::map<std::string, std::string> ModuleSnapshotWin::AnnotationsSimpleMap() | |
| 131 const { | |
| 132 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 133 CHECK(false) << "TODO(scottmg)"; | |
| 134 return std::map<std::string, std::string>(); | |
| 135 } | |
| 136 | |
| 137 } // namespace internal | |
| 138 } // namespace crashpad | |
| OLD | NEW |