OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #ifndef CRASHPAD_SNAPSHOT_MAC_PROCESS_SNAPSHOT_MAC_H_ | 15 #ifndef CRASHPAD_SNAPSHOT_WIN_PROCESS_SNAPSHOT_WIN_H_ |
16 #define CRASHPAD_SNAPSHOT_MAC_PROCESS_SNAPSHOT_MAC_H_ | 16 #define CRASHPAD_SNAPSHOT_WIN_PROCESS_SNAPSHOT_WIN_H_ |
17 | 17 |
18 #include <mach/mach.h> | 18 #include <windows.h> |
19 #include <sys/time.h> | 19 #include <sys/time.h> |
20 #include <unistd.h> | |
21 | 20 |
22 #include <map> | 21 #include <map> |
23 #include <string> | 22 #include <string> |
24 #include <vector> | 23 #include <vector> |
25 | 24 |
26 #include "base/basictypes.h" | 25 #include "base/basictypes.h" |
27 #include "base/memory/scoped_ptr.h" | 26 #include "base/memory/scoped_ptr.h" |
28 #include "client/crashpad_info.h" | 27 #include "client/crashpad_info.h" |
| 28 #include "snapshot/crashpad_info_client_options.h" |
29 #include "snapshot/exception_snapshot.h" | 29 #include "snapshot/exception_snapshot.h" |
30 #include "snapshot/mac/crashpad_info_client_options.h" | |
31 #include "snapshot/mac/exception_snapshot_mac.h" | |
32 #include "snapshot/mac/module_snapshot_mac.h" | |
33 #include "snapshot/mac/process_reader.h" | |
34 #include "snapshot/mac/system_snapshot_mac.h" | |
35 #include "snapshot/mac/thread_snapshot_mac.h" | |
36 #include "snapshot/module_snapshot.h" | 30 #include "snapshot/module_snapshot.h" |
37 #include "snapshot/process_snapshot.h" | 31 #include "snapshot/process_snapshot.h" |
38 #include "snapshot/system_snapshot.h" | 32 #include "snapshot/system_snapshot.h" |
39 #include "snapshot/thread_snapshot.h" | 33 #include "snapshot/thread_snapshot.h" |
40 #include "util/mach/mach_extensions.h" | 34 #include "snapshot/win/module_snapshot_win.h" |
| 35 #include "snapshot/win/system_snapshot_win.h" |
41 #include "util/misc/initialization_state_dcheck.h" | 36 #include "util/misc/initialization_state_dcheck.h" |
42 #include "util/misc/uuid.h" | 37 #include "util/misc/uuid.h" |
43 #include "util/stdlib/pointer_container.h" | 38 #include "util/stdlib/pointer_container.h" |
44 | 39 |
45 namespace crashpad { | 40 namespace crashpad { |
46 | 41 |
47 //! \brief A ProcessSnapshot of a running (or crashed) process running on a Mac | 42 //! \brief A ProcessSnapshot of a running (or crashed) process running on a |
48 //! OS X system. | 43 //! Windows system. |
49 class ProcessSnapshotMac final : public ProcessSnapshot { | 44 class ProcessSnapshotWin final : public ProcessSnapshot { |
50 public: | 45 public: |
51 ProcessSnapshotMac(); | 46 ProcessSnapshotWin(); |
52 ~ProcessSnapshotMac() override; | 47 ~ProcessSnapshotWin() override; |
53 | 48 |
54 //! \brief Initializes the object. | 49 //! \brief Initializes the object. |
55 //! | 50 //! |
56 //! \param[in] task The task to create a snapshot from. | 51 //! \param[in] process The handle to create a snapshot from. |
57 //! | 52 //! |
58 //! \return `true` if the snapshot could be created, `false` otherwise with | 53 //! \return `true` if the snapshot could be created, `false` otherwise with |
59 //! an appropriate message logged. | 54 //! an appropriate message logged. |
60 bool Initialize(task_t task); | 55 bool Initialize(HANDLE process); |
61 | |
62 //! \brief Initializes the object’s exception. | |
63 //! | |
64 //! This populates the data to be returned by Exception(). The parameters may | |
65 //! be passed directly through from a Mach exception handler. | |
66 //! | |
67 //! This method must not be called until after a successful call to | |
68 //! Initialize(). | |
69 //! | |
70 //! \return `true` if the exception information could be initialized, `false` | |
71 //! otherwise with an appropriate message logged. When this method returns | |
72 //! `false`, the ProcessSnapshotMac object’s validity remains unchanged. | |
73 bool InitializeException(exception_behavior_t behavior, | |
74 thread_t exception_thread, | |
75 exception_type_t exception, | |
76 const mach_exception_data_type_t* code, | |
77 mach_msg_type_number_t code_count, | |
78 thread_state_flavor_t flavor, | |
79 ConstThreadState state, | |
80 mach_msg_type_number_t state_count); | |
81 | 56 |
82 //! \brief Sets the value to be returned by ReportID(). | 57 //! \brief Sets the value to be returned by ReportID(). |
83 //! | 58 //! |
84 //! On Mac OS X, the crash report ID is under the control of the snapshot | 59 //! The crash report ID is under the control of the snapshot producer, which |
85 //! producer, which may call this method to set the report ID. If this is not | 60 //! may call this method to set the report ID. If this is not done, ReportID() |
86 //! done, ReportID() will return an identifier consisting entirely of zeroes. | 61 //! will return an identifier consisting entirely of zeroes. |
87 void SetReportID(const UUID& report_id) { report_id_ = report_id; } | 62 void SetReportID(const UUID& report_id) { report_id_ = report_id; } |
88 | 63 |
89 //! \brief Sets the value to be returned by ClientID(). | 64 //! \brief Sets the value to be returned by ClientID(). |
90 //! | 65 //! |
91 //! On Mac OS X, the client ID is under the control of the snapshot producer, | 66 //! The client ID is under the control of the snapshot producer, which may |
92 //! which may call this method to set the client ID. If this is not done, | 67 //! call this method to set the client ID. If this is not done, ClientID() |
93 //! ClientID() will return an identifier consisting entirely of zeroes. | 68 //! will return an identifier consisting entirely of zeroes. |
94 void SetClientID(const UUID& client_id) { client_id_ = client_id; } | 69 void SetClientID(const UUID& client_id) { client_id_ = client_id; } |
95 | 70 |
96 //! \brief Sets the value to be returned by AnnotationsSimpleMap(). | 71 //! \brief Sets the value to be returned by AnnotationsSimpleMap(). |
97 //! | 72 //! |
98 //! On Mac OS X, all process annotations are under the control of the snapshot | 73 //! All process annotations are under the control of the snapshot producer, |
99 //! producer, which may call this method to establish these annotations. | 74 //! which may call this method to establish these annotations. Contrast this |
100 //! Contrast this with module annotations, which are under the control of the | 75 //! with module annotations, which are under the control of the process being |
101 //! process being snapshotted. | 76 //! snapshotted. |
102 void SetAnnotationsSimpleMap( | 77 void SetAnnotationsSimpleMap( |
103 const std::map<std::string, std::string>& annotations_simple_map) { | 78 const std::map<std::string, std::string>& annotations_simple_map) { |
104 annotations_simple_map_ = annotations_simple_map; | 79 annotations_simple_map_ = annotations_simple_map; |
105 } | 80 } |
106 | 81 |
107 //! \brief Returns options from CrashpadInfo structures found in modules in | 82 //! \brief Returns options from CrashpadInfo structures found in modules in |
108 //! the process. | 83 //! the process. |
109 //! | 84 //! |
110 //! \param[out] options Options set in CrashpadInfo structures in modules in | 85 //! \param[out] options Options set in CrashpadInfo structures in modules in |
111 //! the process. | 86 //! the process. |
(...skipping 10 matching lines...) Expand all Loading... |
122 void ClientID(UUID* client_id) const override; | 97 void ClientID(UUID* client_id) const override; |
123 const std::map<std::string, std::string>& AnnotationsSimpleMap() | 98 const std::map<std::string, std::string>& AnnotationsSimpleMap() |
124 const override; | 99 const override; |
125 const SystemSnapshot* System() const override; | 100 const SystemSnapshot* System() const override; |
126 std::vector<const ThreadSnapshot*> Threads() const override; | 101 std::vector<const ThreadSnapshot*> Threads() const override; |
127 std::vector<const ModuleSnapshot*> Modules() const override; | 102 std::vector<const ModuleSnapshot*> Modules() const override; |
128 const ExceptionSnapshot* Exception() const override; | 103 const ExceptionSnapshot* Exception() const override; |
129 | 104 |
130 private: | 105 private: |
131 // Initializes threads_ on behalf of Initialize(). | 106 // Initializes threads_ on behalf of Initialize(). |
132 void InitializeThreads(); | 107 // TODO(scottmg): void InitializeThreads(); |
133 | 108 |
134 // Initializes modules_ on behalf of Initialize(). | 109 // Initializes modules_ on behalf of Initialize(). |
135 void InitializeModules(); | 110 void InitializeModules(); |
136 | 111 |
137 internal::SystemSnapshotMac system_; | 112 internal::SystemSnapshotWin system_; |
138 PointerVector<internal::ThreadSnapshotMac> threads_; | 113 // TODO(scottmg): PointerVector<internal::ThreadSnapshotWin> threads_; |
139 PointerVector<internal::ModuleSnapshotMac> modules_; | 114 PointerVector<internal::ModuleSnapshotWin> modules_; |
140 scoped_ptr<internal::ExceptionSnapshotMac> exception_; | 115 // TODO(scottmg): scoped_ptr<internal::ExceptionSnapshotWin> exception_; |
141 ProcessReader process_reader_; | 116 ProcessReaderWin process_reader_; |
142 UUID report_id_; | 117 UUID report_id_; |
143 UUID client_id_; | 118 UUID client_id_; |
144 std::map<std::string, std::string> annotations_simple_map_; | 119 std::map<std::string, std::string> annotations_simple_map_; |
145 timeval snapshot_time_; | 120 timeval snapshot_time_; |
146 InitializationStateDcheck initialized_; | 121 InitializationStateDcheck initialized_; |
147 | 122 |
148 DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotMac); | 123 DISALLOW_COPY_AND_ASSIGN(ProcessSnapshotWin); |
149 }; | 124 }; |
150 | 125 |
151 } // namespace crashpad | 126 } // namespace crashpad |
152 | 127 |
153 #endif // CRASHPAD_SNAPSHOT_MAC_PROCESS_SNAPSHOT_MAC_H_ | 128 #endif // CRASHPAD_SNAPSHOT_WIN_PROCESS_SNAPSHOT_WIN_H_ |
OLD | NEW |