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_MAC_PROCESS_SNAPSHOT_MAC_H_ |
| 16 #define CRASHPAD_SNAPSHOT_MAC_PROCESS_SNAPSHOT_MAC_H_ |
| 17 |
| 18 #include <mach/mach.h> |
| 19 #include <sys/time.h> |
| 20 #include <unistd.h> |
| 21 |
| 22 #include <vector> |
| 23 |
| 24 #include "base/basictypes.h" |
| 25 #include "base/memory/scoped_ptr.h" |
| 26 #include "snapshot/exception_snapshot.h" |
| 27 #include "snapshot/mac/exception_snapshot_mac.h" |
| 28 #include "snapshot/mac/module_snapshot_mac.h" |
| 29 #include "snapshot/mac/process_reader.h" |
| 30 #include "snapshot/mac/system_snapshot_mac.h" |
| 31 #include "snapshot/mac/thread_snapshot_mac.h" |
| 32 #include "snapshot/module_snapshot.h" |
| 33 #include "snapshot/process_snapshot.h" |
| 34 #include "snapshot/system_snapshot.h" |
| 35 #include "snapshot/thread_snapshot.h" |
| 36 #include "util/misc/initialization_state_dcheck.h" |
| 37 #include "util/stdlib/pointer_container.h" |
| 38 |
| 39 namespace crashpad { |
| 40 |
| 41 //! \brief A ProcessSnapshot of a running (or crashed) process running on a Mac |
| 42 //! OS X system. |
| 43 class ProcessSnapshotMac final : public ProcessSnapshot { |
| 44 public: |
| 45 ProcessSnapshotMac(); |
| 46 ~ProcessSnapshotMac(); |
| 47 |
| 48 //! \brief Initializes the object. |
| 49 //! |
| 50 //! \param[in] task The task to create a snapshot from. |
| 51 //! |
| 52 //! \return `true` if the snapshot could be created, `false` otherwise with |
| 53 //! an appropriate message logged. |
| 54 bool Initialize(task_t task); |
| 55 |
| 56 //! \brief Initializes the object’s exception. |
| 57 //! |
| 58 //! This populates the data to be returned by Exception(). The parameters may |
| 59 //! be passed directly through from a Mach exception handler. |
| 60 //! |
| 61 //! This method must not be called until after a successful call to |
| 62 //! Initialize(). |
| 63 //! |
| 64 //! \return `true` if the exception information could be initialized, `false` |
| 65 //! otherwise with an appropriate message logged. When this method returns |
| 66 //! `false`, the ProcessSnapshotMac object’s validity remains unchanged. |
| 67 bool InitializeException(thread_t exception_thread, |
| 68 exception_type_t exception, |
| 69 const mach_exception_data_type_t* code, |
| 70 mach_msg_type_number_t code_count, |
| 71 thread_state_flavor_t flavor, |
| 72 const natural_t* state, |
| 73 mach_msg_type_number_t state_count); |
| 74 |
| 75 // ProcessSnapshot: |
| 76 |
| 77 pid_t ProcessID() const override; |
| 78 pid_t ParentProcessID() const override; |
| 79 void SnapshotTime(timeval* snapshot_time) const override; |
| 80 void ProcessStartTime(timeval* start_time) const override; |
| 81 void ProcessCPUTimes(timeval* user_time, timeval* system_time) const override; |
| 82 const SystemSnapshot* System() const override; |
| 83 std::vector<const ThreadSnapshot*> Threads() const override; |
| 84 std::vector<const ModuleSnapshot*> Modules() const override; |
| 85 const ExceptionSnapshot* Exception() const override; |
| 86 |
| 87 private: |
| 88 // Initializes threads_ on behalf of Initialize(). |
| 89 void InitializeThreads(); |
| 90 |
| 91 // Initializes modules_ on behalf of Initialize(). |
| 92 void InitializeModules(); |
| 93 |
| 94 internal::SystemSnapshotMac system_; |
| 95 PointerVector<internal::ThreadSnapshotMac> threads_; |
| 96 PointerVector<internal::ModuleSnapshotMac> modules_; |
| 97 scoped_ptr<internal::ExceptionSnapshotMac> exception_; |
| 98 ProcessReader process_reader_; |
| 99 timeval snapshot_time_; |
| 100 InitializationStateDcheck initialized_; |
| 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotMac); |
| 103 }; |
| 104 |
| 105 } // namespace crashpad |
| 106 |
| 107 #endif // CRASHPAD_SNAPSHOT_MAC_PROCESS_SNAPSHOT_MAC_H_ |
OLD | NEW |