Yavor Goulishev | 9c08e84 | 2020-04-29 14:03:33 -0700 | [diff] [blame] | 1 | <!-- |
| 2 | Copyright 2014 The Crashpad Authors. All rights reserved. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | --> |
| 16 | |
| 17 | # catch_exception_tool(1) |
| 18 | |
| 19 | ## Name |
| 20 | |
| 21 | catch_exception_tool—Catch Mach exceptions and display information about them |
| 22 | |
| 23 | ## Synopsis |
| 24 | |
| 25 | **catch_exception_tool** **-m** _SERVICE_ [_OPTION…_] |
| 26 | |
| 27 | ## Description |
| 28 | |
| 29 | Runs a Mach exception server registered with the bootstrap server under the name |
| 30 | _SERVICE_. The exception server is capable of receiving exceptions for |
| 31 | “behavior” values of `EXCEPTION_DEFAULT`, `EXCEPTION_STATE`, and |
| 32 | `EXCEPTION_STATE_IDENTITY`, with or without `MACH_EXCEPTION_CODES` set. |
| 33 | |
| 34 | ## Options |
| 35 | |
| 36 | * **-f**, **--file**=_FILE_ |
| 37 | |
| 38 | Information about the exception will be appended to _FILE_ instead of the |
| 39 | standard output stream. |
| 40 | |
| 41 | * **-m**, **--mach-service**=_SERVICE_ |
| 42 | |
| 43 | Check in with the bootstrap server under the name _SERVICE_. This service |
| 44 | name may already be reserved with the bootstrap server in cases where this |
| 45 | tool is started by launchd(8) as a result of a message being sent to a |
| 46 | service declared in a job’s `MachServices` dictionary (see launchd.plist(5)). |
| 47 | The service name may also be completely unknown to the system. |
| 48 | |
| 49 | * **-p**, **--persistent** |
| 50 | |
| 51 | Continue processing exceptions after the first one. The default mode is |
| 52 | one-shot, where this tool exits after processing the first exception. |
| 53 | |
| 54 | * **-t**, **--timeout**=_TIMEOUT_ |
| 55 | |
| 56 | Run for a maximum of _TIMEOUT_ seconds. Specify `0` to request non-blocking |
| 57 | operation, in which the tool exits immediately if no exception is received. |
| 58 | In **--persistent** mode, _TIMEOUT_ applies to the overall duration that this |
| 59 | tool will run, not to the processing of individual exceptions. When |
| 60 | **--timeout** is not specified, this tool will block indefinitely while |
| 61 | waiting for an exception. |
| 62 | |
| 63 | * **--help** |
| 64 | |
| 65 | Display help and exit. |
| 66 | |
| 67 | * **--version** |
| 68 | |
| 69 | Output version information and exit. |
| 70 | |
| 71 | ## Examples |
| 72 | |
| 73 | Run a one-shot blocking exception server registered with the bootstrap server |
| 74 | under the name `svc`: |
| 75 | |
| 76 | ``` |
| 77 | $ catch_exception_tool --mach-service=svc --file=out & |
| 78 | [1] 1233 |
| 79 | $ exception_port_tool --set-handler=handler=bootstrap:svc crasher |
| 80 | Illegal instruction: 4 |
| 81 | [1]+ Done catch_exception_tool --mach-service=svc --file=out |
| 82 | $ cat out |
| 83 | catch_exception_tool: behavior EXCEPTION_DEFAULT|MACH_EXCEPTION_CODES, pid 1234, thread 56789, exception EXC_CRASH, codes[2] 0x4200001, 0, original exception EXC_BAD_INSTRUCTION, original code[0] 1, signal SIGILL |
| 84 | ``` |
| 85 | |
| 86 | Run an on-demand exception server started by launchd(5) available via the |
| 87 | bootstrap server under the name `svc`: |
| 88 | |
| 89 | ``` |
| 90 | $ `on_demand_service_tool --load --label=catch_exception \ |
| 91 | --mach-service=svc \ |
| 92 | $(which catch_exception_tool) --mach-service=svc \ |
| 93 | --file=/tmp/out --persistent --timeout=0 |
| 94 | $ exception_port_tool --set-handler=handler=bootstrap:svc crasher |
| 95 | Illegal instruction: 4 |
| 96 | $ on_demand_service_tool --unload --label=catch_exception |
| 97 | $ cat /tmp/out |
| 98 | catch_exception_tool: behavior EXCEPTION_DEFAULT|MACH_EXCEPTION_CODES, pid 2468, thread 13579, exception EXC_CRASH, codes[2] 0x4200001, 0, original exception EXC_BAD_INSTRUCTION, original code[0] 1, signal SIGILL |
| 99 | ``` |
| 100 | |
| 101 | ## Exit Status |
| 102 | |
| 103 | * **0** |
| 104 | |
| 105 | Success. In **--persistent** mode with a **--timeout** set, it is considered |
| 106 | successful if at least one exception was caught when the timer expires. |
| 107 | |
| 108 | * **1** |
| 109 | |
| 110 | Failure, with a message printed to the standard error stream. |
| 111 | |
| 112 | ## See Also |
| 113 | |
| 114 | [exception_port_tool(1)](exception_port_tool.md), |
| 115 | [on_demand_service_tool(1)](on_demand_service_tool.md) |
| 116 | |
| 117 | ## Resources |
| 118 | |
| 119 | Crashpad home page: https://crashpad.chromium.org/. |
| 120 | |
| 121 | Report bugs at https://crashpad.chromium.org/bug/new. |
| 122 | |
| 123 | ## Copyright |
| 124 | |
| 125 | Copyright 2014 [The Crashpad |
| 126 | Authors](https://chromium.googlesource.com/crashpad/crashpad/+/master/AUTHORS). |
| 127 | |
| 128 | ## License |
| 129 | |
| 130 | Licensed under the Apache License, Version 2.0 (the “License”); |
| 131 | you may not use this file except in compliance with the License. |
| 132 | You may obtain a copy of the License at |
| 133 | |
| 134 | http://www.apache.org/licenses/LICENSE-2.0 |
| 135 | |
| 136 | Unless required by applicable law or agreed to in writing, software |
| 137 | distributed under the License is distributed on an “AS IS” BASIS, |
| 138 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 139 | See the License for the specific language governing permissions and |
| 140 | limitations under the License. |