OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 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_UTIL_MACH_MACH_EXTENSIONS_H_ | 15 #ifndef CRASHPAD_UTIL_MACH_MACH_EXTENSIONS_H_ |
16 #define CRASHPAD_UTIL_MACH_MACH_EXTENSIONS_H_ | 16 #define CRASHPAD_UTIL_MACH_MACH_EXTENSIONS_H_ |
17 | 17 |
18 #include <mach/mach.h> | 18 #include <mach/mach.h> |
19 | 19 |
| 20 #include <string> |
| 21 |
20 #include "base/mac/scoped_mach_port.h" | 22 #include "base/mac/scoped_mach_port.h" |
21 | 23 |
22 namespace crashpad { | 24 namespace crashpad { |
23 | 25 |
24 //! \brief `MACH_PORT_NULL` with the correct type for a Mach port, | 26 //! \brief `MACH_PORT_NULL` with the correct type for a Mach port, |
25 //! `mach_port_t`. | 27 //! `mach_port_t`. |
26 //! | 28 //! |
27 //! For situations where implicit conversions between signed and unsigned types | 29 //! For situations where implicit conversions between signed and unsigned types |
28 //! are not performed, use kMachPortNull instead of an explicit `implicit_cast` | 30 //! are not performed, use kMachPortNull instead of an explicit `implicit_cast` |
29 //! of `MACH_PORT_NULL` to `mach_port_t`. This is useful for logging and testing | 31 //! of `MACH_PORT_NULL` to `mach_port_t`. This is useful for logging and testing |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 //! `EXC_MASK_ALL`, and thus ExcMaskAll(), never includes the value of | 112 //! `EXC_MASK_ALL`, and thus ExcMaskAll(), never includes the value of |
111 //! `EXC_MASK_CRASH` or `EXC_MASK_CORPSE_NOTIFY`. For situations where an | 113 //! `EXC_MASK_CRASH` or `EXC_MASK_CORPSE_NOTIFY`. For situations where an |
112 //! exception mask corresponding to every possible exception understood by the | 114 //! exception mask corresponding to every possible exception understood by the |
113 //! running kernel is desired, use this function instead. | 115 //! running kernel is desired, use this function instead. |
114 //! | 116 //! |
115 //! Should new exception types be introduced in the future, this function will | 117 //! Should new exception types be introduced in the future, this function will |
116 //! be updated to include their bits in the returned mask value when run time | 118 //! be updated to include their bits in the returned mask value when run time |
117 //! support is present. | 119 //! support is present. |
118 exception_mask_t ExcMaskValid(); | 120 exception_mask_t ExcMaskValid(); |
119 | 121 |
| 122 //! \brief Makes a `boostrap_check_in()` call to the process’ bootstrap server. |
| 123 //! |
| 124 //! This function is provided to make it easier to call `bootstrap_check_in()` |
| 125 //! while avoiding accidental leaks of the returned receive right. |
| 126 //! |
| 127 //! \param[in] service_name The service name to check in. |
| 128 //! |
| 129 //! \return On success, a receive right to the service port. On failure, |
| 130 //! `MACH_PORT_NULL` with a message logged. |
| 131 base::mac::ScopedMachReceiveRight BootstrapCheckIn( |
| 132 const std::string& service_name); |
| 133 |
| 134 //! \brief Makes a `boostrap_look_up()` call to the process’ bootstrap server. |
| 135 //! |
| 136 //! This function is provided to make it easier to call `bootstrap_look_up()` |
| 137 //! while avoiding accidental leaks of the returned send right. |
| 138 //! |
| 139 //! \param[in] service_name The service name to look up. |
| 140 //! |
| 141 //! \return On success, a send right to the service port. On failure, |
| 142 //! `MACH_PORT_NULL` with a message logged. |
| 143 base::mac::ScopedMachSendRight BootstrapLookUp(const std::string& service_name); |
| 144 |
120 //! \brief Obtains the system’s default Mach exception handler for crash-type | 145 //! \brief Obtains the system’s default Mach exception handler for crash-type |
121 //! exceptions. | 146 //! exceptions. |
122 //! | 147 //! |
123 //! This is obtained by looking up `"com.apple.ReportCrash"` with the bootstrap | 148 //! This is obtained by looking up `"com.apple.ReportCrash"` with the bootstrap |
124 //! server. The service name comes from the first launch agent loaded by | 149 //! server. The service name comes from the first launch agent loaded by |
125 //! `launchd` with a `MachServices` entry having `ExceptionServer` set. This | 150 //! `launchd` with a `MachServices` entry having `ExceptionServer` set. This |
126 //! launch agent is normally loaded from | 151 //! launch agent is normally loaded from |
127 //! `/System/Library/LaunchAgents/com.apple.ReportCrash.plist`. | 152 //! `/System/Library/LaunchAgents/com.apple.ReportCrash.plist`. |
128 //! | 153 //! |
129 //! \return On success, a send right to an `exception_handler_t` corresponding | 154 //! \return On success, a send right to an `exception_handler_t` corresponding |
130 //! to the system’s default crash reporter. On failure, `MACH_PORT_NULL`, | 155 //! to the system’s default crash reporter. On failure, `MACH_PORT_NULL`, |
131 //! with a message logged. | 156 //! with a message logged. |
132 base::mac::ScopedMachSendRight SystemCrashReporterHandler(); | 157 base::mac::ScopedMachSendRight SystemCrashReporterHandler(); |
133 | 158 |
134 } // namespace crashpad | 159 } // namespace crashpad |
135 | 160 |
136 #endif // CRASHPAD_UTIL_MACH_MACH_EXTENSIONS_H_ | 161 #endif // CRASHPAD_UTIL_MACH_MACH_EXTENSIONS_H_ |
OLD | NEW |