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/process_snapshot_win.h" | |
| 16 | |
| 17 #include "snapshot/win/module_snapshot_win.h" | |
| 18 #include "util/win/time.h" | |
| 19 | |
| 20 namespace crashpad { | |
| 21 | |
| 22 ProcessSnapshotWin::ProcessSnapshotWin() | |
| 23 : ProcessSnapshot(), | |
| 24 system_(), | |
| 25 // TODO(scottmg): threads_(), | |
| 26 modules_(), | |
| 27 // TODO(scottmg): exception_(), | |
| 28 process_reader_(), | |
| 29 report_id_(), | |
| 30 client_id_(), | |
| 31 annotations_simple_map_(), | |
| 32 snapshot_time_(), | |
| 33 initialized_() { | |
| 34 } | |
| 35 | |
| 36 ProcessSnapshotWin::~ProcessSnapshotWin() { | |
| 37 } | |
| 38 | |
| 39 bool ProcessSnapshotWin::Initialize(HANDLE process) { | |
| 40 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); | |
| 41 | |
| 42 GetTimeOfDay(&snapshot_time_); | |
| 43 | |
| 44 if (!process_reader_.Initialize(process)) | |
| 45 return false; | |
| 46 | |
| 47 system_.Initialize(&process_reader_); | |
| 48 | |
| 49 // TODO(scottmg): InitializeThreads(); | |
| 50 InitializeModules(); | |
| 51 | |
| 52 INITIALIZATION_STATE_SET_VALID(initialized_); | |
| 53 return true; | |
| 54 } | |
| 55 | |
| 56 void ProcessSnapshotWin::GetCrashpadOptions( | |
| 57 CrashpadInfoClientOptions* options) { | |
| 58 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 59 | |
| 60 CrashpadInfoClientOptions local_options; | |
| 61 | |
| 62 for (internal::ModuleSnapshotWin* module : modules_) { | |
| 63 CrashpadInfoClientOptions module_options; | |
| 64 module->GetCrashpadOptions(&module_options); | |
| 65 | |
| 66 if (local_options.crashpad_handler_behavior == TriState::kUnset) { | |
| 67 local_options.crashpad_handler_behavior = | |
| 68 module_options.crashpad_handler_behavior; | |
| 69 } | |
| 70 if (local_options.system_crash_reporter_forwarding == TriState::kUnset) { | |
| 71 local_options.system_crash_reporter_forwarding = | |
| 72 module_options.system_crash_reporter_forwarding; | |
| 73 } | |
| 74 | |
| 75 // If non-default values have been found for all options, the loop can end | |
| 76 // early. | |
| 77 if (local_options.crashpad_handler_behavior != TriState::kUnset && | |
| 78 local_options.system_crash_reporter_forwarding != TriState::kUnset) { | |
| 79 break; | |
| 80 } | |
| 81 } | |
| 82 | |
| 83 *options = local_options; | |
| 84 } | |
| 85 | |
| 86 pid_t ProcessSnapshotWin::ProcessID() const { | |
| 87 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 88 return process_reader_.ProcessID(); | |
| 89 } | |
| 90 | |
| 91 pid_t ProcessSnapshotWin::ParentProcessID() const { | |
| 92 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 93 return process_reader_.ParentProcessID(); | |
| 94 } | |
| 95 | |
| 96 void ProcessSnapshotWin::SnapshotTime(timeval* snapshot_time) const { | |
| 97 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 98 *snapshot_time = snapshot_time_; | |
| 99 } | |
| 100 | |
| 101 void ProcessSnapshotWin::ProcessStartTime(timeval* start_time) const { | |
| 102 CHECK(false) << "TODO(scottmg)"; | |
| 103 } | |
| 104 | |
| 105 void ProcessSnapshotWin::ProcessCPUTimes(timeval* user_time, | |
| 106 timeval* system_time) const { | |
| 107 CHECK(false) << "TODO(scottmg)"; | |
| 108 } | |
| 109 | |
| 110 void ProcessSnapshotWin::ReportID(UUID* report_id) const { | |
| 111 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 112 *report_id = report_id_; | |
| 113 } | |
| 114 | |
| 115 void ProcessSnapshotWin::ClientID(UUID* client_id) const { | |
| 116 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 117 *client_id = client_id_; | |
| 118 } | |
| 119 | |
| 120 const std::map<std::string, std::string>& | |
| 121 ProcessSnapshotWin::AnnotationsSimpleMap() const { | |
| 122 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 123 return annotations_simple_map_; | |
| 124 } | |
| 125 | |
| 126 const SystemSnapshot* ProcessSnapshotWin::System() const { | |
| 127 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 128 return &system_; | |
| 129 } | |
| 130 | |
| 131 std::vector<const ThreadSnapshot*> ProcessSnapshotWin::Threads() const { | |
| 132 CHECK(false) << "TODO(scottmg)"; | |
| 133 return std::vector<const ThreadSnapshot*>(); | |
| 134 } | |
| 135 | |
| 136 std::vector<const ModuleSnapshot*> ProcessSnapshotWin::Modules() const { | |
| 137 CHECK(false) << "TODO(scottmg)"; | |
|
Mark Mentovai
2015/04/29 19:37:15
It looks like this will actually work. Remove the
scottmg
2015/04/30 03:31:32
Done.
| |
| 138 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | |
| 139 std::vector<const ModuleSnapshot*> modules; | |
| 140 for (internal::ModuleSnapshotWin* module : modules_) { | |
| 141 modules.push_back(module); | |
| 142 } | |
| 143 return modules; | |
| 144 } | |
| 145 | |
| 146 const ExceptionSnapshot* ProcessSnapshotWin::Exception() const { | |
| 147 CHECK(false) << "TODO(scottmg)"; | |
| 148 return nullptr; | |
| 149 } | |
| 150 | |
| 151 void ProcessSnapshotWin::InitializeThreads() { | |
| 152 CHECK(false) << "TODO(scottmg)"; | |
| 153 } | |
| 154 | |
| 155 void ProcessSnapshotWin::InitializeModules() { | |
| 156 const std::vector<ProcessInfo::Module>& process_reader_modules = | |
| 157 process_reader_.Modules(); | |
| 158 for (const ProcessInfo::Module& process_reader_module : | |
| 159 process_reader_modules) { | |
| 160 auto module = make_scoped_ptr(new internal::ModuleSnapshotWin()); | |
| 161 if (module->Initialize(&process_reader_, process_reader_module)) { | |
| 162 modules_.push_back(module.release()); | |
| 163 } | |
| 164 } | |
| 165 } | |
| 166 | |
| 167 } // namespace crashpad | |
| OLD | NEW |