1 // Copyright 2014 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/exception_snapshot.h"
16 #include "snapshot/system_snapshot.h"
17 #include "snapshot/test/test_process_snapshot.h"
18 
19 namespace crashpad {
20 namespace test {
21 
TestProcessSnapshot()22 TestProcessSnapshot::TestProcessSnapshot()
23     : process_id_(0),
24       parent_process_id_(0),
25       snapshot_time_(),
26       process_start_time_(),
27       process_cpu_user_time_(),
28       process_cpu_system_time_(),
29       report_id_(),
30       client_id_(),
31       annotations_simple_map_(),
32       system_(),
33       threads_(),
34       modules_(),
35       exception_(),
36       memory_map_(),
37       handles_(),
38       extra_memory_(),
39       process_memory_() {
40 }
41 
~TestProcessSnapshot()42 TestProcessSnapshot::~TestProcessSnapshot() {
43 }
44 
ProcessID() const45 crashpad::ProcessID TestProcessSnapshot::ProcessID() const {
46   return process_id_;
47 }
48 
ParentProcessID() const49 crashpad::ProcessID TestProcessSnapshot::ParentProcessID() const {
50   return parent_process_id_;
51 }
52 
SnapshotTime(timeval * snapshot_time) const53 void TestProcessSnapshot::SnapshotTime(timeval* snapshot_time) const {
54   *snapshot_time = snapshot_time_;
55 }
56 
ProcessStartTime(timeval * start_time) const57 void TestProcessSnapshot::ProcessStartTime(timeval* start_time) const {
58   *start_time = process_start_time_;
59 }
60 
ProcessCPUTimes(timeval * user_time,timeval * system_time) const61 void TestProcessSnapshot::ProcessCPUTimes(timeval* user_time,
62                                           timeval* system_time) const {
63   *user_time = process_cpu_user_time_;
64   *system_time = process_cpu_system_time_;
65 }
66 
ReportID(UUID * report_id) const67 void TestProcessSnapshot::ReportID(UUID* report_id) const {
68   *report_id = report_id_;
69 }
70 
ClientID(UUID * client_id) const71 void TestProcessSnapshot::ClientID(UUID* client_id) const {
72   *client_id = client_id_;
73 }
74 
75 const std::map<std::string, std::string>&
AnnotationsSimpleMap() const76 TestProcessSnapshot::AnnotationsSimpleMap() const {
77   return annotations_simple_map_;
78 }
79 
System() const80 const SystemSnapshot* TestProcessSnapshot::System() const {
81   return system_.get();
82 }
83 
Threads() const84 std::vector<const ThreadSnapshot*> TestProcessSnapshot::Threads() const {
85   std::vector<const ThreadSnapshot*> threads;
86   for (const auto& thread : threads_) {
87     threads.push_back(thread.get());
88   }
89   return threads;
90 }
91 
Modules() const92 std::vector<const ModuleSnapshot*> TestProcessSnapshot::Modules() const {
93   std::vector<const ModuleSnapshot*> modules;
94   for (const auto& module : modules_) {
95     modules.push_back(module.get());
96   }
97   return modules;
98 }
99 
UnloadedModules() const100 std::vector<UnloadedModuleSnapshot> TestProcessSnapshot::UnloadedModules()
101     const {
102   return unloaded_modules_;
103 }
104 
Exception() const105 const ExceptionSnapshot* TestProcessSnapshot::Exception() const {
106   return exception_.get();
107 }
108 
MemoryMap() const109 std::vector<const MemoryMapRegionSnapshot*> TestProcessSnapshot::MemoryMap()
110     const {
111   std::vector<const MemoryMapRegionSnapshot*> memory_map;
112   for (const auto& item : memory_map_) {
113     memory_map.push_back(item.get());
114   }
115   return memory_map;
116 }
117 
Handles() const118 std::vector<HandleSnapshot> TestProcessSnapshot::Handles() const {
119   return handles_;
120 }
121 
ExtraMemory() const122 std::vector<const MemorySnapshot*> TestProcessSnapshot::ExtraMemory() const {
123   std::vector<const MemorySnapshot*> extra_memory;
124   for (const auto& em : extra_memory_) {
125     extra_memory.push_back(em.get());
126   }
127   return extra_memory;
128 }
129 
Memory() const130 const ProcessMemory* TestProcessSnapshot::Memory() const {
131   return process_memory_.get();
132 }
133 
134 }  // namespace test
135 }  // namespace crashpad
136