2022-09-06 19:14:07 -04:00
|
|
|
// Copyright 2014 The Crashpad Authors
|
2014-11-05 18:15:19 -05:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#include "snapshot/exception_snapshot.h"
|
|
|
|
#include "snapshot/system_snapshot.h"
|
|
|
|
#include "snapshot/test/test_process_snapshot.h"
|
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
TestProcessSnapshot::TestProcessSnapshot()
|
|
|
|
: process_id_(0),
|
|
|
|
parent_process_id_(0),
|
|
|
|
snapshot_time_(),
|
|
|
|
process_start_time_(),
|
|
|
|
process_cpu_user_time_(),
|
|
|
|
process_cpu_system_time_(),
|
2015-03-13 13:00:56 -04:00
|
|
|
report_id_(),
|
2015-03-11 17:10:50 -04:00
|
|
|
client_id_(),
|
2015-02-17 17:38:02 -05:00
|
|
|
annotations_simple_map_(),
|
2014-11-05 18:15:19 -05:00
|
|
|
system_(),
|
|
|
|
threads_(),
|
|
|
|
modules_(),
|
2015-09-25 10:31:02 -07:00
|
|
|
exception_(),
|
2015-10-13 12:37:44 -07:00
|
|
|
memory_map_(),
|
2015-10-16 15:58:40 -07:00
|
|
|
handles_(),
|
2018-11-14 10:20:20 -08:00
|
|
|
extra_memory_(),
|
|
|
|
process_memory_() {
|
2014-11-05 18:15:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
TestProcessSnapshot::~TestProcessSnapshot() {
|
|
|
|
}
|
|
|
|
|
2019-04-24 11:22:35 -04:00
|
|
|
crashpad::ProcessID TestProcessSnapshot::ProcessID() const {
|
2014-11-05 18:15:19 -05:00
|
|
|
return process_id_;
|
|
|
|
}
|
|
|
|
|
2019-04-24 11:22:35 -04:00
|
|
|
crashpad::ProcessID TestProcessSnapshot::ParentProcessID() const {
|
2014-11-05 18:15:19 -05:00
|
|
|
return parent_process_id_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestProcessSnapshot::SnapshotTime(timeval* snapshot_time) const {
|
|
|
|
*snapshot_time = snapshot_time_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestProcessSnapshot::ProcessStartTime(timeval* start_time) const {
|
|
|
|
*start_time = process_start_time_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestProcessSnapshot::ProcessCPUTimes(timeval* user_time,
|
|
|
|
timeval* system_time) const {
|
|
|
|
*user_time = process_cpu_user_time_;
|
|
|
|
*system_time = process_cpu_system_time_;
|
|
|
|
}
|
|
|
|
|
2015-03-13 13:00:56 -04:00
|
|
|
void TestProcessSnapshot::ReportID(UUID* report_id) const {
|
|
|
|
*report_id = report_id_;
|
|
|
|
}
|
|
|
|
|
2015-03-11 17:10:50 -04:00
|
|
|
void TestProcessSnapshot::ClientID(UUID* client_id) const {
|
|
|
|
*client_id = client_id_;
|
|
|
|
}
|
|
|
|
|
2015-02-17 17:38:02 -05:00
|
|
|
const std::map<std::string, std::string>&
|
|
|
|
TestProcessSnapshot::AnnotationsSimpleMap() const {
|
|
|
|
return annotations_simple_map_;
|
|
|
|
}
|
|
|
|
|
2014-11-05 18:15:19 -05:00
|
|
|
const SystemSnapshot* TestProcessSnapshot::System() const {
|
|
|
|
return system_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<const ThreadSnapshot*> TestProcessSnapshot::Threads() const {
|
|
|
|
std::vector<const ThreadSnapshot*> threads;
|
2017-10-19 00:26:38 -04:00
|
|
|
for (const auto& thread : threads_) {
|
|
|
|
threads.push_back(thread.get());
|
2014-11-05 18:15:19 -05:00
|
|
|
}
|
|
|
|
return threads;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<const ModuleSnapshot*> TestProcessSnapshot::Modules() const {
|
|
|
|
std::vector<const ModuleSnapshot*> modules;
|
2017-10-19 00:26:38 -04:00
|
|
|
for (const auto& module : modules_) {
|
|
|
|
modules.push_back(module.get());
|
2014-11-05 18:15:19 -05:00
|
|
|
}
|
|
|
|
return modules;
|
|
|
|
}
|
|
|
|
|
2016-02-11 17:19:30 -08:00
|
|
|
std::vector<UnloadedModuleSnapshot> TestProcessSnapshot::UnloadedModules()
|
|
|
|
const {
|
|
|
|
return unloaded_modules_;
|
|
|
|
}
|
|
|
|
|
2014-11-05 18:15:19 -05:00
|
|
|
const ExceptionSnapshot* TestProcessSnapshot::Exception() const {
|
|
|
|
return exception_.get();
|
|
|
|
}
|
|
|
|
|
2015-10-13 12:37:44 -07:00
|
|
|
std::vector<const MemoryMapRegionSnapshot*> TestProcessSnapshot::MemoryMap()
|
|
|
|
const {
|
|
|
|
std::vector<const MemoryMapRegionSnapshot*> memory_map;
|
2017-10-19 00:26:38 -04:00
|
|
|
for (const auto& item : memory_map_) {
|
|
|
|
memory_map.push_back(item.get());
|
|
|
|
}
|
2015-10-13 12:37:44 -07:00
|
|
|
return memory_map;
|
|
|
|
}
|
|
|
|
|
2015-10-16 15:58:40 -07:00
|
|
|
std::vector<HandleSnapshot> TestProcessSnapshot::Handles() const {
|
|
|
|
return handles_;
|
|
|
|
}
|
|
|
|
|
2015-09-25 10:31:02 -07:00
|
|
|
std::vector<const MemorySnapshot*> TestProcessSnapshot::ExtraMemory() const {
|
|
|
|
std::vector<const MemorySnapshot*> extra_memory;
|
2017-10-19 00:26:38 -04:00
|
|
|
for (const auto& em : extra_memory_) {
|
|
|
|
extra_memory.push_back(em.get());
|
|
|
|
}
|
2015-09-25 10:31:02 -07:00
|
|
|
return extra_memory;
|
|
|
|
}
|
|
|
|
|
2018-11-14 10:20:20 -08:00
|
|
|
const ProcessMemory* TestProcessSnapshot::Memory() const {
|
|
|
|
return process_memory_.get();
|
|
|
|
}
|
|
|
|
|
2014-11-05 18:15:19 -05:00
|
|
|
} // namespace test
|
|
|
|
} // namespace crashpad
|