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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 "Usage: %" PRFilePath " [OPTION]...\n" | 53 "Usage: %" PRFilePath " [OPTION]...\n" |
54 "Crashpad's exception handler server.\n" | 54 "Crashpad's exception handler server.\n" |
55 "\n" | 55 "\n" |
56 " --annotation=KEY=VALUE set a process annotation in each crash report\n" | 56 " --annotation=KEY=VALUE set a process annotation in each crash report\n" |
57 " --database=PATH store the crash report database at PATH\n" | 57 " --database=PATH store the crash report database at PATH\n" |
58 #if defined(OS_MACOSX) | 58 #if defined(OS_MACOSX) |
59 " --handshake-fd=FD establish communication with the client over FD\n
" | 59 " --handshake-fd=FD establish communication with the client over FD\n
" |
60 " --reset-own-crash-exception-port-to-system-default\n" | 60 " --reset-own-crash-exception-port-to-system-default\n" |
61 " reset the server's exception handler to default\n
" | 61 " reset the server's exception handler to default\n
" |
62 #elif defined(OS_WIN) | 62 #elif defined(OS_WIN) |
| 63 " --persistent continue running after all clients exit\n" |
63 " --pipe-name=PIPE communicate with the client over PIPE\n" | 64 " --pipe-name=PIPE communicate with the client over PIPE\n" |
64 #endif // OS_MACOSX | 65 #endif // OS_MACOSX |
65 " --url=URL send crash reports to this Breakpad server URL,\n
" | 66 " --url=URL send crash reports to this Breakpad server URL,\n
" |
66 " only if uploads are enabled for the database\n" | 67 " only if uploads are enabled for the database\n" |
67 " --help display this help and exit\n" | 68 " --help display this help and exit\n" |
68 " --version output version information and exit\n", | 69 " --version output version information and exit\n", |
69 me.value().c_str()); | 70 me.value().c_str()); |
70 ToolSupport::UsageTail(me); | 71 ToolSupport::UsageTail(me); |
71 } | 72 } |
72 | 73 |
73 int HandlerMain(int argc, char* argv[]) { | 74 int HandlerMain(int argc, char* argv[]) { |
74 const base::FilePath argv0( | 75 const base::FilePath argv0( |
75 ToolSupport::CommandLineArgumentToFilePathStringType(argv[0])); | 76 ToolSupport::CommandLineArgumentToFilePathStringType(argv[0])); |
76 const base::FilePath me(argv0.BaseName()); | 77 const base::FilePath me(argv0.BaseName()); |
77 | 78 |
78 enum OptionFlags { | 79 enum OptionFlags { |
79 // Long options without short equivalents. | 80 // Long options without short equivalents. |
80 kOptionLastChar = 255, | 81 kOptionLastChar = 255, |
81 kOptionAnnotation, | 82 kOptionAnnotation, |
82 kOptionDatabase, | 83 kOptionDatabase, |
83 #if defined(OS_MACOSX) | 84 #if defined(OS_MACOSX) |
84 kOptionHandshakeFD, | 85 kOptionHandshakeFD, |
85 kOptionResetOwnCrashExceptionPortToSystemDefault, | 86 kOptionResetOwnCrashExceptionPortToSystemDefault, |
86 #elif defined(OS_WIN) | 87 #elif defined(OS_WIN) |
| 88 kOptionPersistent, |
87 kOptionPipeName, | 89 kOptionPipeName, |
88 #endif // OS_MACOSX | 90 #endif // OS_MACOSX |
89 kOptionURL, | 91 kOptionURL, |
90 | 92 |
91 // Standard options. | 93 // Standard options. |
92 kOptionHelp = -2, | 94 kOptionHelp = -2, |
93 kOptionVersion = -3, | 95 kOptionVersion = -3, |
94 }; | 96 }; |
95 | 97 |
96 struct { | 98 struct { |
97 std::map<std::string, std::string> annotations; | 99 std::map<std::string, std::string> annotations; |
98 std::string url; | 100 std::string url; |
99 const char* database; | 101 const char* database; |
100 #if defined(OS_MACOSX) | 102 #if defined(OS_MACOSX) |
101 int handshake_fd; | 103 int handshake_fd; |
102 bool reset_own_crash_exception_port_to_system_default; | 104 bool reset_own_crash_exception_port_to_system_default; |
103 #elif defined(OS_WIN) | 105 #elif defined(OS_WIN) |
| 106 bool persistent; |
104 std::string pipe_name; | 107 std::string pipe_name; |
105 #endif | 108 #endif // OS_MACOSX |
106 } options = {}; | 109 } options = {}; |
107 #if defined(OS_MACOSX) | 110 #if defined(OS_MACOSX) |
108 options.handshake_fd = -1; | 111 options.handshake_fd = -1; |
109 options.reset_own_crash_exception_port_to_system_default = false; | 112 options.reset_own_crash_exception_port_to_system_default = false; |
110 #endif | 113 #endif |
111 | 114 |
112 const option long_options[] = { | 115 const option long_options[] = { |
113 {"annotation", required_argument, nullptr, kOptionAnnotation}, | 116 {"annotation", required_argument, nullptr, kOptionAnnotation}, |
114 {"database", required_argument, nullptr, kOptionDatabase}, | 117 {"database", required_argument, nullptr, kOptionDatabase}, |
115 #if defined(OS_MACOSX) | 118 #if defined(OS_MACOSX) |
116 {"handshake-fd", required_argument, nullptr, kOptionHandshakeFD}, | 119 {"handshake-fd", required_argument, nullptr, kOptionHandshakeFD}, |
117 {"reset-own-crash-exception-port-to-system-default", | 120 {"reset-own-crash-exception-port-to-system-default", |
118 no_argument, | 121 no_argument, |
119 nullptr, | 122 nullptr, |
120 kOptionResetOwnCrashExceptionPortToSystemDefault}, | 123 kOptionResetOwnCrashExceptionPortToSystemDefault}, |
121 #elif defined(OS_WIN) | 124 #elif defined(OS_WIN) |
| 125 {"persistent", no_argument, nullptr, kOptionPersistent}, |
122 {"pipe-name", required_argument, nullptr, kOptionPipeName}, | 126 {"pipe-name", required_argument, nullptr, kOptionPipeName}, |
123 #endif | 127 #endif // OS_MACOSX |
124 {"url", required_argument, nullptr, kOptionURL}, | 128 {"url", required_argument, nullptr, kOptionURL}, |
125 {"help", no_argument, nullptr, kOptionHelp}, | 129 {"help", no_argument, nullptr, kOptionHelp}, |
126 {"version", no_argument, nullptr, kOptionVersion}, | 130 {"version", no_argument, nullptr, kOptionVersion}, |
127 {nullptr, 0, nullptr, 0}, | 131 {nullptr, 0, nullptr, 0}, |
128 }; | 132 }; |
129 | 133 |
130 int opt; | 134 int opt; |
131 while ((opt = getopt_long(argc, argv, "", long_options, nullptr)) != -1) { | 135 while ((opt = getopt_long(argc, argv, "", long_options, nullptr)) != -1) { |
132 switch (opt) { | 136 switch (opt) { |
133 case kOptionAnnotation: { | 137 case kOptionAnnotation: { |
(...skipping 22 matching lines...) Expand all Loading... |
156 "--handshake-fd requires a file descriptor"); | 160 "--handshake-fd requires a file descriptor"); |
157 return EXIT_FAILURE; | 161 return EXIT_FAILURE; |
158 } | 162 } |
159 break; | 163 break; |
160 } | 164 } |
161 case kOptionResetOwnCrashExceptionPortToSystemDefault: { | 165 case kOptionResetOwnCrashExceptionPortToSystemDefault: { |
162 options.reset_own_crash_exception_port_to_system_default = true; | 166 options.reset_own_crash_exception_port_to_system_default = true; |
163 break; | 167 break; |
164 } | 168 } |
165 #elif defined(OS_WIN) | 169 #elif defined(OS_WIN) |
| 170 case kOptionPersistent: { |
| 171 options.persistent = true; |
| 172 break; |
| 173 } |
166 case kOptionPipeName: { | 174 case kOptionPipeName: { |
167 options.pipe_name = optarg; | 175 options.pipe_name = optarg; |
168 break; | 176 break; |
169 } | 177 } |
170 #endif // OS_MACOSX | 178 #endif // OS_MACOSX |
171 case kOptionURL: { | 179 case kOptionURL: { |
172 options.url = optarg; | 180 options.url = optarg; |
173 break; | 181 break; |
174 } | 182 } |
175 case kOptionHelp: { | 183 case kOptionHelp: { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 base::mac::ScopedMachReceiveRight receive_right( | 229 base::mac::ScopedMachReceiveRight receive_right( |
222 ChildPortHandshake::RunServerForFD( | 230 ChildPortHandshake::RunServerForFD( |
223 base::ScopedFD(options.handshake_fd), | 231 base::ScopedFD(options.handshake_fd), |
224 ChildPortHandshake::PortRightType::kReceiveRight)); | 232 ChildPortHandshake::PortRightType::kReceiveRight)); |
225 if (!receive_right.is_valid()) { | 233 if (!receive_right.is_valid()) { |
226 return EXIT_FAILURE; | 234 return EXIT_FAILURE; |
227 } | 235 } |
228 | 236 |
229 ExceptionHandlerServer exception_handler_server(receive_right.Pass()); | 237 ExceptionHandlerServer exception_handler_server(receive_right.Pass()); |
230 #elif defined(OS_WIN) | 238 #elif defined(OS_WIN) |
231 ExceptionHandlerServer exception_handler_server(options.pipe_name); | 239 ExceptionHandlerServer exception_handler_server(options.pipe_name, |
| 240 options.persistent); |
232 #endif // OS_MACOSX | 241 #endif // OS_MACOSX |
233 | 242 |
234 scoped_ptr<CrashReportDatabase> database(CrashReportDatabase::Initialize( | 243 scoped_ptr<CrashReportDatabase> database(CrashReportDatabase::Initialize( |
235 base::FilePath(ToolSupport::CommandLineArgumentToFilePathStringType( | 244 base::FilePath(ToolSupport::CommandLineArgumentToFilePathStringType( |
236 options.database)))); | 245 options.database)))); |
237 if (!database) { | 246 if (!database) { |
238 return EXIT_FAILURE; | 247 return EXIT_FAILURE; |
239 } | 248 } |
240 | 249 |
241 CrashReportUploadThread upload_thread(database.get(), options.url); | 250 CrashReportUploadThread upload_thread(database.get(), options.url); |
(...skipping 14 matching lines...) Expand all Loading... |
256 | 265 |
257 #if defined(OS_MACOSX) | 266 #if defined(OS_MACOSX) |
258 int main(int argc, char* argv[]) { | 267 int main(int argc, char* argv[]) { |
259 return crashpad::HandlerMain(argc, argv); | 268 return crashpad::HandlerMain(argc, argv); |
260 } | 269 } |
261 #elif defined(OS_WIN) | 270 #elif defined(OS_WIN) |
262 int wmain(int argc, wchar_t* argv[]) { | 271 int wmain(int argc, wchar_t* argv[]) { |
263 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::HandlerMain); | 272 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::HandlerMain); |
264 } | 273 } |
265 #endif // OS_MACOSX | 274 #endif // OS_MACOSX |
OLD | NEW |