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, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 //! This method does not actually direct any crashes to the Crashpad handler, | 42 //! This method does not actually direct any crashes to the Crashpad handler, |
43 //! because there may be alternative ways to use an existing Crashpad handler | 43 //! because there may be alternative ways to use an existing Crashpad handler |
44 //! without having to start one. To begin directing crashes to the handler, | 44 //! without having to start one. To begin directing crashes to the handler, |
45 //! started by this method, call UseHandler() after this method returns | 45 //! started by this method, call UseHandler() after this method returns |
46 //! successfully. | 46 //! successfully. |
47 //! | 47 //! |
48 //! On Mac OS X, this method starts a Crashpad handler and obtains a Mach | 48 //! On Mac OS X, this method starts a Crashpad handler and obtains a Mach |
49 //! send right corresponding to a receive right held by the handler process. | 49 //! send right corresponding to a receive right held by the handler process. |
50 //! The handler process runs an exception server on this port. | 50 //! The handler process runs an exception server on this port. |
51 //! | 51 //! |
| 52 //! On Windows, SetHandler() is normally used instead since the handler is |
| 53 //! started by other means. |
| 54 //! |
52 //! \param[in] handler The path to a Crashpad handler executable. | 55 //! \param[in] handler The path to a Crashpad handler executable. |
53 //! \param[in] database The path to a Crashpad database. The handler will be | 56 //! \param[in] database The path to a Crashpad database. The handler will be |
54 //! started with this path as its `--database` argument. | 57 //! started with this path as its `--database` argument. |
55 //! \param[in] url The URL of an upload server. The handler will be started | 58 //! \param[in] url The URL of an upload server. The handler will be started |
56 //! with this URL as its `--url` argument. | 59 //! with this URL as its `--url` argument. |
57 //! \param[in] annotations Process annotations to set in each crash report. | 60 //! \param[in] annotations Process annotations to set in each crash report. |
58 //! The handler will be started with an `--annotation` argument for each | 61 //! The handler will be started with an `--annotation` argument for each |
59 //! element in this map. | 62 //! element in this map. |
60 //! \param[in] arguments Additional arguments to pass to the Crashpad handler. | 63 //! \param[in] arguments Additional arguments to pass to the Crashpad handler. |
61 //! Arguments passed in other parameters and arguments required to perform | 64 //! Arguments passed in other parameters and arguments required to perform |
62 //! the handshake are the responsibility of this method, and must not be | 65 //! the handshake are the responsibility of this method, and must not be |
63 //! specified in this parameter. | 66 //! specified in this parameter. |
64 //! | 67 //! |
65 //! \return `true` on success, `false` on failure with a message logged. | 68 //! \return `true` on success, `false` on failure with a message logged. |
66 bool StartHandler(const base::FilePath& handler, | 69 bool StartHandler(const base::FilePath& handler, |
67 const base::FilePath& database, | 70 const base::FilePath& database, |
68 const std::string& url, | 71 const std::string& url, |
69 const std::map<std::string, std::string>& annotations, | 72 const std::map<std::string, std::string>& annotations, |
70 const std::vector<std::string>& arguments); | 73 const std::vector<std::string>& arguments); |
71 | 74 |
| 75 #if defined(OS_WIN) || DOXYGEN |
| 76 //! \brief Sets the IPC port of a presumably-running Crashpad handler process |
| 77 //! which was started with StartHandler() or by other compatible means |
| 78 //! and does an IPC message exchange to register this process with the |
| 79 //! handler. However, just like StartHandler(), crashes are not serviced |
| 80 //! until UseHandler() is called. |
| 81 //! |
| 82 //! The IPC port name (somehow) encodes enough information so that |
| 83 //! registration is done with a crash handler using the appropriate database |
| 84 //! and upload server. |
| 85 //! |
| 86 //! \param[in] ipc_port The full name of the crash handler IPC port. |
| 87 //! |
| 88 //! \return `true` on success and `false` on failure. |
| 89 bool SetHandler(const std::string& ipc_port); |
| 90 #endif |
| 91 |
72 //! \brief Configures the process to direct its crashes to a Crashpad handler. | 92 //! \brief Configures the process to direct its crashes to a Crashpad handler. |
73 //! | 93 //! |
74 //! The Crashpad handler must previously have been started by StartHandler(). | 94 //! The Crashpad handler must previously have been started by StartHandler() |
| 95 //! or configured by SetHandler(). |
75 //! | 96 //! |
76 //! On Mac OS X, this method sets the task’s exception port for `EXC_CRASH`, | 97 //! On Mac OS X, this method sets the task’s exception port for `EXC_CRASH`, |
77 //! `EXC_RESOURCE`, and `EXC_GUARD` exceptions to the Mach send right obtained | 98 //! `EXC_RESOURCE`, and `EXC_GUARD` exceptions to the Mach send right obtained |
78 //! by StartHandler(). The handler will be installed with behavior | 99 //! by StartHandler(). The handler will be installed with behavior |
79 //! `EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES` and thread state flavor | 100 //! `EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES` and thread state flavor |
80 //! `MACHINE_THREAD_STATE`. Exception ports are inherited, so a Crashpad | 101 //! `MACHINE_THREAD_STATE`. Exception ports are inherited, so a Crashpad |
81 //! handler chosen by UseHandler() will remain the handler for any child | 102 //! handler chosen by UseHandler() will remain the handler for any child |
82 //! processes created after UseHandler() is called. Child processes do not | 103 //! processes created after UseHandler() is called. Child processes do not |
83 //! need to call StartHandler() or UseHandler() or be aware of Crashpad in any | 104 //! need to call StartHandler() or UseHandler() or be aware of Crashpad in any |
84 //! way. The Crashpad handler will receive crashes from child processes that | 105 //! way. The Crashpad handler will receive crashes from child processes that |
85 //! have inherited it as their exception handler even after the process that | 106 //! have inherited it as their exception handler even after the process that |
86 //! called StartHandler() exits. | 107 //! called StartHandler() exits. |
87 //! | 108 //! |
| 109 //! On Windows, this method sets the unhandled exception handler to a local |
| 110 //! function that when reached will "signal and wait" for the crash handler |
| 111 //! process to create the dump. |
| 112 //! |
88 //! \return `true` on success, `false` on failure with a message logged. | 113 //! \return `true` on success, `false` on failure with a message logged. |
89 bool UseHandler(); | 114 bool UseHandler(); |
90 | 115 |
91 private: | 116 private: |
92 #if defined(OS_MACOSX) | 117 #if defined(OS_MACOSX) |
93 base::mac::ScopedMachSendRight exception_port_; | 118 base::mac::ScopedMachSendRight exception_port_; |
94 #endif | 119 #endif |
95 | 120 |
96 DISALLOW_COPY_AND_ASSIGN(CrashpadClient); | 121 DISALLOW_COPY_AND_ASSIGN(CrashpadClient); |
97 }; | 122 }; |
98 | 123 |
99 } // namespace crashpad | 124 } // namespace crashpad |
100 | 125 |
101 #endif // CRASHPAD_CLIENT_CRASHPAD_CLIENT_H_ | 126 #endif // CRASHPAD_CLIENT_CRASHPAD_CLIENT_H_ |
OLD | NEW |