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_HANDLER_MAC_EXCEPTION_HANDLER_SERVER_H_ | 15 #ifndef CRASHPAD_HANDLER_MAC_EXCEPTION_HANDLER_SERVER_H_ |
16 #define CRASHPAD_HANDLER_MAC_EXCEPTION_HANDLER_SERVER_H_ | 16 #define CRASHPAD_HANDLER_MAC_EXCEPTION_HANDLER_SERVER_H_ |
17 | 17 |
18 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
19 | 19 |
20 #include <mach/mach.h> | 20 #include <mach/mach.h> |
21 | 21 |
22 #include "base/mac/scoped_mach_port.h" | 22 #include "base/mac/scoped_mach_port.h" |
| 23 #include "util/mach/exc_server_variants.h" |
23 | 24 |
24 namespace crashpad { | 25 namespace crashpad { |
25 | 26 |
26 //! \brief Runs the main exception-handling server in Crashpad’s handler | 27 //! \brief Runs the main exception-handling server in Crashpad’s handler |
27 //! process. | 28 //! process. |
28 class ExceptionHandlerServer { | 29 class ExceptionHandlerServer { |
29 public: | 30 public: |
30 ExceptionHandlerServer(); | 31 ExceptionHandlerServer(); |
31 ~ExceptionHandlerServer(); | 32 ~ExceptionHandlerServer(); |
32 | 33 |
33 //! \brief Runs the exception-handling server. | 34 //! \brief Runs the exception-handling server. |
34 //! | 35 //! |
35 //! This method monitors \a receive_port_ for exception messages and | 36 //! \param[in] exception_interface An object to send exception messages to. |
36 //! no-senders notifications. It continues running until it has no more | 37 //! |
37 //! clients, indicated by the receipt of a no-senders notification. It is | 38 //! This method monitors receive_port() for exception messages and no-senders |
38 //! important to assure that a send right has been transferred to a client | 39 //! notifications. It continues running until it has no more clients, |
39 //! (or queued by `mach_msg()` to be sent to a client) prior to calling this | 40 //! indicated by the receipt of a no-senders notification. It is important to |
40 //! method, or it will detect that it is sender-less and return immediately. | 41 //! assure that a send right has been transferred to a client (or queued by |
| 42 //! `mach_msg()` to be sent to a client) prior to calling this method, or it |
| 43 //! will detect that it is sender-less and return immediately. |
| 44 //! |
| 45 //! All exception messages will be passed to \a exception_interface. |
41 //! | 46 //! |
42 //! This method must only be called once on an ExceptionHandlerServer object. | 47 //! This method must only be called once on an ExceptionHandlerServer object. |
43 //! | 48 //! |
44 //! If an unexpected condition that prevents this method from functioning is | 49 //! If an unexpected condition that prevents this method from functioning is |
45 //! encountered, it will log a message and terminate execution. Receipt of an | 50 //! encountered, it will log a message and terminate execution. Receipt of an |
46 //! invalid message on \a receive_port_ will cause a message to be logged, but | 51 //! invalid message on receive_port() will cause a message to be logged, but |
47 //! this method will continue running normally. | 52 //! this method will continue running normally. |
48 void Run(); | 53 void Run(UniversalMachExcServer::Interface* exception_interface); |
49 | 54 |
50 //! \brief Returns the receive right that will be monitored for exception | 55 //! \brief Returns the receive right that will be monitored for exception |
51 //! messages. | 56 //! messages. |
52 //! | 57 //! |
53 //! The caller does not take ownership of this port. The caller must not use | 58 //! The caller does not take ownership of this port. The caller must not use |
54 //! this port for any purpose other than to make send rights for clients. | 59 //! this port for any purpose other than to make send rights for clients. |
55 mach_port_t receive_port() const { return receive_port_; } | 60 mach_port_t receive_port() const { return receive_port_; } |
56 | 61 |
57 private: | 62 private: |
58 base::mac::ScopedMachReceiveRight receive_port_; | 63 base::mac::ScopedMachReceiveRight receive_port_; |
59 | 64 |
60 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServer); | 65 DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerServer); |
61 }; | 66 }; |
62 | 67 |
63 } // namespace crashpad | 68 } // namespace crashpad |
64 | 69 |
65 #endif // CRASHPAD_HANDLER_MAC_EXCEPTION_HANDLER_SERVER_H_ | 70 #endif // CRASHPAD_HANDLER_MAC_EXCEPTION_HANDLER_SERVER_H_ |
OLD | NEW |