2014-11-05 18:15:19 -05:00
|
|
|
// Copyright 2014 The Crashpad Authors. All rights reserved.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
#ifndef CRASHPAD_SNAPSHOT_TEST_TEST_PROCESS_SNAPSHOT_H_
|
|
|
|
#define CRASHPAD_SNAPSHOT_TEST_TEST_PROCESS_SNAPSHOT_H_
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2015-02-17 17:38:02 -05:00
|
|
|
#include <map>
|
2016-04-25 12:13:07 -07:00
|
|
|
#include <memory>
|
2015-02-17 17:38:02 -05:00
|
|
|
#include <string>
|
2015-12-09 17:36:32 -05:00
|
|
|
#include <utility>
|
2014-11-05 18:15:19 -05:00
|
|
|
#include <vector>
|
|
|
|
|
2016-01-06 12:22:50 -05:00
|
|
|
#include "base/macros.h"
|
2014-11-05 18:15:19 -05:00
|
|
|
#include "snapshot/exception_snapshot.h"
|
2015-10-13 12:37:44 -07:00
|
|
|
#include "snapshot/memory_map_region_snapshot.h"
|
2015-09-25 10:31:02 -07:00
|
|
|
#include "snapshot/memory_snapshot.h"
|
2015-02-05 09:25:14 -08:00
|
|
|
#include "snapshot/module_snapshot.h"
|
2014-11-05 18:15:19 -05:00
|
|
|
#include "snapshot/process_snapshot.h"
|
|
|
|
#include "snapshot/system_snapshot.h"
|
2015-02-05 09:25:14 -08:00
|
|
|
#include "snapshot/thread_snapshot.h"
|
2016-02-11 17:19:30 -08:00
|
|
|
#include "snapshot/unloaded_module_snapshot.h"
|
2015-03-11 17:10:50 -04:00
|
|
|
#include "util/misc/uuid.h"
|
2014-11-05 18:15:19 -05:00
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
//! \brief A test ProcessSnapshot that can carry arbitrary data for testing
|
|
|
|
//! purposes.
|
|
|
|
class TestProcessSnapshot final : public ProcessSnapshot {
|
|
|
|
public:
|
|
|
|
TestProcessSnapshot();
|
|
|
|
~TestProcessSnapshot() override;
|
|
|
|
|
|
|
|
void SetProcessID(pid_t process_id) { process_id_ = process_id; }
|
|
|
|
void SetParentProcessID(pid_t parent_process_id) {
|
|
|
|
parent_process_id_ = parent_process_id;
|
|
|
|
}
|
|
|
|
void SetSnapshotTime(const timeval& snapshot_time) {
|
|
|
|
snapshot_time_ = snapshot_time;
|
|
|
|
}
|
|
|
|
void SetProcessStartTime(const timeval& start_time) {
|
|
|
|
process_start_time_ = start_time;
|
|
|
|
}
|
|
|
|
void SetProcessCPUTimes(const timeval& user_time,
|
|
|
|
const timeval& system_time) {
|
|
|
|
process_cpu_user_time_ = user_time;
|
|
|
|
process_cpu_system_time_ = system_time;
|
|
|
|
}
|
2015-03-13 13:00:56 -04:00
|
|
|
void SetReportID(const UUID& report_id) { report_id_ = report_id; }
|
2015-03-11 17:10:50 -04:00
|
|
|
void SetClientID(const UUID& client_id) { client_id_ = client_id; }
|
2015-02-17 17:38:02 -05:00
|
|
|
void SetAnnotationsSimpleMap(
|
|
|
|
const std::map<std::string, std::string>& annotations_simple_map) {
|
|
|
|
annotations_simple_map_ = annotations_simple_map;
|
|
|
|
}
|
2014-11-05 18:15:19 -05:00
|
|
|
|
|
|
|
//! \brief Sets the system snapshot to be returned by System().
|
|
|
|
//!
|
|
|
|
//! \param[in] system The system snapshot that System() will return. The
|
|
|
|
//! TestProcessSnapshot object takes ownership of \a system.
|
2016-04-25 12:13:07 -07:00
|
|
|
void SetSystem(std::unique_ptr<SystemSnapshot> system) {
|
2015-12-09 17:36:32 -05:00
|
|
|
system_ = std::move(system);
|
2015-11-30 14:20:54 -08:00
|
|
|
}
|
2014-11-05 18:15:19 -05:00
|
|
|
|
|
|
|
//! \brief Adds a thread snapshot to be returned by Threads().
|
|
|
|
//!
|
|
|
|
//! \param[in] thread The thread snapshot that will be included in Threads().
|
|
|
|
//! The TestProcessSnapshot object takes ownership of \a thread.
|
2016-04-25 12:13:07 -07:00
|
|
|
void AddThread(std::unique_ptr<ThreadSnapshot> thread) {
|
2017-10-19 00:26:38 -04:00
|
|
|
threads_.push_back(std::move(thread));
|
2014-11-05 18:15:19 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//! \brief Adds a module snapshot to be returned by Modules().
|
|
|
|
//!
|
|
|
|
//! \param[in] module The module snapshot that will be included in Modules().
|
|
|
|
//! The TestProcessSnapshot object takes ownership of \a module.
|
2016-04-25 12:13:07 -07:00
|
|
|
void AddModule(std::unique_ptr<ModuleSnapshot> module) {
|
2017-10-19 00:26:38 -04:00
|
|
|
modules_.push_back(std::move(module));
|
2014-11-05 18:15:19 -05:00
|
|
|
}
|
|
|
|
|
2016-02-11 17:19:30 -08:00
|
|
|
//! \brief Adds an unloaded module snapshot to be returned by
|
|
|
|
//! UnloadedModules().
|
|
|
|
//!
|
|
|
|
//! \param[in] unloaded_module The unloaded module snapshot that will be
|
|
|
|
//! included in UnloadedModules().
|
|
|
|
void AddModule(const UnloadedModuleSnapshot& unloaded_module) {
|
|
|
|
unloaded_modules_.push_back(unloaded_module);
|
|
|
|
}
|
|
|
|
|
2014-11-05 18:15:19 -05:00
|
|
|
//! \brief Sets the exception snapshot to be returned by Exception().
|
|
|
|
//!
|
|
|
|
//! \param[in] exception The exception snapshot that Exception() will return.
|
|
|
|
//! The TestProcessSnapshot object takes ownership of \a exception.
|
2016-04-25 12:13:07 -07:00
|
|
|
void SetException(std::unique_ptr<ExceptionSnapshot> exception) {
|
2015-12-09 17:36:32 -05:00
|
|
|
exception_ = std::move(exception);
|
2014-11-05 18:15:19 -05:00
|
|
|
}
|
|
|
|
|
2015-10-13 12:37:44 -07:00
|
|
|
//! \brief Adds a memory map region snapshot to be returned by MemoryMap().
|
|
|
|
//!
|
|
|
|
//! \param[in] region The memory map region snapshot that will be included in
|
|
|
|
//! MemoryMap(). The TestProcessSnapshot object takes ownership of \a
|
|
|
|
//! region.
|
2016-04-25 12:13:07 -07:00
|
|
|
void AddMemoryMapRegion(std::unique_ptr<MemoryMapRegionSnapshot> region) {
|
2017-10-19 00:26:38 -04:00
|
|
|
memory_map_.push_back(std::move(region));
|
2015-10-13 12:37:44 -07:00
|
|
|
}
|
|
|
|
|
2015-10-16 15:58:40 -07:00
|
|
|
//! \brief Adds a handle snapshot to be returned by Handles().
|
|
|
|
//!
|
doc: Fix all Doxygen warnings, cleaning up some generated documentation
This makes Doxygen’s output more actionable by setting QUIET = YES to
suppress verbose progress spew, and WARN_IF_UNDOCUMENTED = NO to prevent
warnings for undocumented classes and members from being generated. The
latter is too noisy, producing 721 warnings in the current codebase.
The remaining warnings produced by Doxygen were useful and actionable.
They fell into two categories: abuses of Doxygen’s markup syntax, and
missing (or misspelled) parameter documentation. In a small number of
cases, pass-through parameters had intentionally been left undocumented.
In these cases, they are now given blank \param descriptions. This is
not optimal, but there doesn’t appear to be any other way to tell
Doxygen to allow a single parameter to be undocumented.
Some tricky Doxygen errors were resolved by asking it to not enter
directiores that we do not provide documentation in (such as the
“on-platform” compat directories, compat/mac and compat/win, as well as
compat/non_cxx11_lib) while allowing it to enter the
“off-platform” directories that we do document (compat/non_mac and
compat/non_win).
A Doxygen run (doc/support/generate_doxygen.sh) now produces no output
at all. It would produce warnings if any were triggered.
Not directly related, but still relevant to documentation,
doc/support/generate.sh is updated to remove temporary removals of
now-extinct files and directories. doc/appengine/README is updated so
that a consistent path to “goapp” is used throughout the file.
Change-Id: I300730c04de4d3340551ea3086ca70cc5ff862d1
Reviewed-on: https://chromium-review.googlesource.com/408812
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-08 14:23:09 -05:00
|
|
|
//! \param[in] handle The handle snapshot that will be included in Handles().
|
2015-10-16 15:58:40 -07:00
|
|
|
void AddHandle(const HandleSnapshot& handle) {
|
|
|
|
handles_.push_back(handle);
|
|
|
|
}
|
|
|
|
|
2015-09-25 10:31:02 -07:00
|
|
|
//! \brief Add a memory snapshot to be returned by ExtraMemory().
|
|
|
|
//!
|
2015-10-01 14:04:49 -07:00
|
|
|
//! \param[in] extra_memory The memory snapshot that will be included in
|
|
|
|
//! ExtraMemory(). The TestProcessSnapshot object takes ownership of \a
|
|
|
|
//! extra_memory.
|
2016-04-25 12:13:07 -07:00
|
|
|
void AddExtraMemory(std::unique_ptr<MemorySnapshot> extra_memory) {
|
2017-10-19 00:26:38 -04:00
|
|
|
extra_memory_.push_back(std::move(extra_memory));
|
2015-09-25 10:31:02 -07:00
|
|
|
}
|
|
|
|
|
2014-11-05 18:15:19 -05:00
|
|
|
// ProcessSnapshot:
|
|
|
|
|
|
|
|
pid_t ProcessID() const override;
|
|
|
|
pid_t ParentProcessID() const override;
|
|
|
|
void SnapshotTime(timeval* snapshot_time) const override;
|
|
|
|
void ProcessStartTime(timeval* start_time) const override;
|
|
|
|
void ProcessCPUTimes(timeval* user_time, timeval* system_time) const override;
|
2015-03-13 13:00:56 -04:00
|
|
|
void ReportID(UUID* report_id) const override;
|
2015-03-11 17:10:50 -04:00
|
|
|
void ClientID(UUID* client_id) const override;
|
2015-02-17 17:38:02 -05:00
|
|
|
const std::map<std::string, std::string>& AnnotationsSimpleMap()
|
|
|
|
const override;
|
2014-11-05 18:15:19 -05:00
|
|
|
const SystemSnapshot* System() const override;
|
|
|
|
std::vector<const ThreadSnapshot*> Threads() const override;
|
|
|
|
std::vector<const ModuleSnapshot*> Modules() const override;
|
2016-02-11 17:19:30 -08:00
|
|
|
std::vector<UnloadedModuleSnapshot> UnloadedModules() const override;
|
2014-11-05 18:15:19 -05:00
|
|
|
const ExceptionSnapshot* Exception() const override;
|
2015-10-13 12:37:44 -07:00
|
|
|
std::vector<const MemoryMapRegionSnapshot*> MemoryMap() const override;
|
2015-10-16 15:58:40 -07:00
|
|
|
std::vector<HandleSnapshot> Handles() const override;
|
2015-09-25 10:31:02 -07:00
|
|
|
std::vector<const MemorySnapshot*> ExtraMemory() const override;
|
2014-11-05 18:15:19 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
pid_t process_id_;
|
|
|
|
pid_t parent_process_id_;
|
|
|
|
timeval snapshot_time_;
|
|
|
|
timeval process_start_time_;
|
|
|
|
timeval process_cpu_user_time_;
|
|
|
|
timeval process_cpu_system_time_;
|
2015-03-13 13:00:56 -04:00
|
|
|
UUID report_id_;
|
2015-03-11 17:10:50 -04:00
|
|
|
UUID client_id_;
|
2015-02-17 17:38:02 -05:00
|
|
|
std::map<std::string, std::string> annotations_simple_map_;
|
2016-04-25 12:13:07 -07:00
|
|
|
std::unique_ptr<SystemSnapshot> system_;
|
2017-10-19 00:26:38 -04:00
|
|
|
std::vector<std::unique_ptr<ThreadSnapshot>> threads_;
|
|
|
|
std::vector<std::unique_ptr<ModuleSnapshot>> modules_;
|
2016-02-11 17:19:30 -08:00
|
|
|
std::vector<UnloadedModuleSnapshot> unloaded_modules_;
|
2016-04-25 12:13:07 -07:00
|
|
|
std::unique_ptr<ExceptionSnapshot> exception_;
|
2017-10-19 00:26:38 -04:00
|
|
|
std::vector<std::unique_ptr<MemoryMapRegionSnapshot>> memory_map_;
|
2015-10-16 15:58:40 -07:00
|
|
|
std::vector<HandleSnapshot> handles_;
|
2017-10-19 00:26:38 -04:00
|
|
|
std::vector<std::unique_ptr<MemorySnapshot>> extra_memory_;
|
2014-11-05 18:15:19 -05:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(TestProcessSnapshot);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace test
|
|
|
|
} // namespace crashpad
|
|
|
|
|
|
|
|
#endif // CRASHPAD_SNAPSHOT_TEST_TEST_PROCESS_SNAPSHOT_H_
|