Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 #ifndef CRASHPAD_SNAPSHOT_PROCESS_SNAPSHOT_H_ | |
| 16 #define CRASHPAD_SNAPSHOT_PROCESS_SNAPSHOT_H_ | |
| 17 | |
| 18 #include <sys/time.h> | |
| 19 #include <sys/types.h> | |
| 20 | |
| 21 #include <vector> | |
| 22 | |
| 23 namespace crashpad { | |
| 24 | |
| 25 class ExceptionSnapshot; | |
| 26 class ModuleSnapshot; | |
| 27 class SystemSnapshot; | |
| 28 class ThreadSnapshot; | |
| 29 | |
| 30 //! \brief An abstract interface to a snapshot representing the state of a | |
| 31 //! process. | |
| 32 //! | |
| 33 //! This is the top-level object in a family of Snapshot objects, because it | |
| 34 //! gives access to a SystemSnapshot, vectors of ModuleSnapshot and | |
| 35 //! ThreadSnapshot objects, and possibly an ExceptionSnapshot. In turn, | |
| 36 //! ThreadSnapshot and ExceptionSnapshot objects both give access to CPUContext | |
| 37 //! objects, and ThreadSnapshot objects also give access to MemorySnapshot | |
| 38 //! objects corresponding to thread stacks. | |
| 39 class ProcessSnapshot { | |
| 40 public: | |
| 41 //! \brief Returns the snapshot process’ process ID. | |
| 42 virtual pid_t ProcessID() = 0; | |
| 43 | |
| 44 //! \brief Returns the snapshot process’ parent process’ process ID. | |
| 45 virtual pid_t ParentProcessID() = 0; | |
| 46 | |
| 47 //! \brief Returns the time that the snapshot was taken in \a snapshot_time. | |
| 48 //! | |
| 49 //! \param[out] snapshot_time The time that the snapshot was taken. This is | |
| 50 //! distinct from the time that a ProcessSnapshot object was created or | |
| 51 //! initialized, although it may be that time for ProcessSnapshot objects | |
| 52 //! representing live or recently-crashed process state. | |
| 53 virtual void SnapshotTime(timeval* snapshot_time) = 0; | |
| 54 | |
| 55 //! \brief Returns the time that the snapshot process was started in \a | |
| 56 //! start_time. | |
| 57 //! | |
| 58 //! Normally, process uptime in wall clock time can be computed as | |
| 59 //! SnapshotTime() − ProcessStartTime(), but this cannot be guaranteed in | |
| 60 //! cases where the real-time clock has been set during the snapshot process’ | |
| 61 //! lifetime. | |
| 62 //! | |
| 63 //! \param[out] start_time The time that the process was started. | |
| 64 virtual void ProcessStartTime(timeval* start_time) = 0; | |
| 65 | |
| 66 //! \brief Returns the snapshot process’ CPU usage times in \a user_time and | |
| 67 //! \a system_time. | |
| 68 //! | |
| 69 //! \param[out] user_time The time that the process has spent executing in | |
| 70 //! user mode. | |
| 71 //! \param[out] system_time The time that the process has spent executing in | |
| 72 //! system (kernel) mode. | |
| 73 virtual void ProcessCPUTimes(timeval* user_time, timeval* system_time) = 0; | |
| 74 | |
| 75 //! \brief Returns a SystemSnapshot reflecting the characteristics of the | |
| 76 //! system that ran the snapshot process at the time of the snapshot. | |
| 77 //! | |
| 78 //! \return A SystemSnapshot object. The caller does not take ownership of | |
| 79 //! this object, it is scoped to the lifetime of the ProcessSnapshot | |
| 80 //! object that it was obtained from. | |
| 81 virtual SystemSnapshot* System() = 0; | |
|
Robert Sesek
2014/09/25 15:44:08
Can this be const?
Mark Mentovai
2014/10/02 20:27:00
Robert Sesek wrote:
| |
| 82 | |
| 83 //! \brief Returns ModuleSnapshot objects reflecting the code modules (binary | |
| 84 //! images) loaded into the snapshot process at the time of the snapshot. | |
| 85 //! | |
| 86 //! \return A vector of ModuleSnapshot objects. The caller does not take | |
| 87 //! ownership of these objects, they are scoped to the lifetime of the | |
| 88 //! ProcessSnapshot object that they were obtained from. | |
| 89 virtual std::vector<ModuleSnapshot*> Modules() = 0; | |
| 90 | |
| 91 //! \brief Returns ThreadSnapshot objects reflecting the threads (lightweight | |
| 92 //! processes) existing in the snapshot process at the time of the | |
| 93 //! snapshot. | |
| 94 //! | |
| 95 //! \return A vector of ThreadSnapshot objects. The caller does not take | |
| 96 //! ownership of these objects, they are scoped to the lifetime of the | |
| 97 //! ProcessSnapshot object that they were obtained from. | |
| 98 virtual std::vector<ThreadSnapshot*> Threads() = 0; | |
| 99 | |
| 100 //! \brief Returns an ExceptionSnapshot reflecting the exception that the | |
| 101 //! snapshot process sustained to trigger the snapshot being taken. | |
| 102 //! | |
| 103 //! \return An ExceptionSnapshot object. The caller does not take ownership of | |
| 104 //! this object, it is scoped to the lifetime of the ProcessSnapshot | |
| 105 //! object that it was obtained from. If the snapshot is not a result of | |
| 106 //! an exception, returns `NULL`. | |
| 107 virtual ExceptionSnapshot* Exception() = 0; | |
| 108 | |
| 109 protected: | |
| 110 ~ProcessSnapshot() {} | |
| 111 }; | |
| 112 | |
| 113 } // namespace crashpad | |
| 114 | |
| 115 #endif // CRASHPAD_SNAPSHOT_PROCESS_SNAPSHOT_H_ | |
| OLD | NEW |