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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 " --mach-service=SERVICE register SERVICE with the bootstrap server\n" | 75 " --mach-service=SERVICE register SERVICE with the bootstrap server\n" |
76 " --reset-own-crash-exception-port-to-system-default\n" | 76 " --reset-own-crash-exception-port-to-system-default\n" |
77 " reset the server's exception handler to default\n " | 77 " reset the server's exception handler to default\n " |
78 #elif defined(OS_WIN) | 78 #elif defined(OS_WIN) |
79 " --handshake-handle=HANDLE\n" | 79 " --handshake-handle=HANDLE\n" |
80 " create a new pipe and send its name via HANDLE\n" | 80 " create a new pipe and send its name via HANDLE\n" |
81 " --pipe-name=PIPE communicate with the client over PIPE\n" | 81 " --pipe-name=PIPE communicate with the client over PIPE\n" |
82 #endif // OS_MACOSX | 82 #endif // OS_MACOSX |
83 " --url=URL send crash reports to this Breakpad server URL,\n " | 83 " --url=URL send crash reports to this Breakpad server URL,\n " |
84 " only if uploads are enabled for the database\n" | 84 " only if uploads are enabled for the database\n" |
85 " --no-rate-limit don't rate limit crash uploads\n" | |
Mark Mentovai
2016/01/06 15:52:41
Same here (although it means more stupid #ifdefs).
scottmg
2016/01/06 17:48:11
Done.
| |
85 " --help display this help and exit\n" | 86 " --help display this help and exit\n" |
86 " --version output version information and exit\n", | 87 " --version output version information and exit\n", |
87 me.value().c_str()); | 88 me.value().c_str()); |
88 ToolSupport::UsageTail(me); | 89 ToolSupport::UsageTail(me); |
89 } | 90 } |
90 | 91 |
91 #if defined(OS_MACOSX) | 92 #if defined(OS_MACOSX) |
92 | 93 |
93 struct ResetSIGTERMTraits { | 94 struct ResetSIGTERMTraits { |
94 static struct sigaction* InvalidValue() { | 95 static struct sigaction* InvalidValue() { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 kOptionDatabase, | 128 kOptionDatabase, |
128 #if defined(OS_MACOSX) | 129 #if defined(OS_MACOSX) |
129 kOptionHandshakeFD, | 130 kOptionHandshakeFD, |
130 kOptionMachService, | 131 kOptionMachService, |
131 kOptionResetOwnCrashExceptionPortToSystemDefault, | 132 kOptionResetOwnCrashExceptionPortToSystemDefault, |
132 #elif defined(OS_WIN) | 133 #elif defined(OS_WIN) |
133 kOptionHandshakeHandle, | 134 kOptionHandshakeHandle, |
134 kOptionPipeName, | 135 kOptionPipeName, |
135 #endif // OS_MACOSX | 136 #endif // OS_MACOSX |
136 kOptionURL, | 137 kOptionURL, |
138 kOptionNoRateLimit, | |
Mark Mentovai
2016/01/06 15:52:41
and this and the option struct and the switch bloc
scottmg
2016/01/06 17:48:11
Done. Yuck.
| |
137 | 139 |
138 // Standard options. | 140 // Standard options. |
139 kOptionHelp = -2, | 141 kOptionHelp = -2, |
140 kOptionVersion = -3, | 142 kOptionVersion = -3, |
141 }; | 143 }; |
142 | 144 |
143 struct { | 145 struct { |
144 std::map<std::string, std::string> annotations; | 146 std::map<std::string, std::string> annotations; |
145 std::string url; | 147 std::string url; |
146 const char* database; | 148 const char* database; |
147 #if defined(OS_MACOSX) | 149 #if defined(OS_MACOSX) |
148 int handshake_fd; | 150 int handshake_fd; |
149 std::string mach_service; | 151 std::string mach_service; |
150 bool reset_own_crash_exception_port_to_system_default; | 152 bool reset_own_crash_exception_port_to_system_default; |
151 #elif defined(OS_WIN) | 153 #elif defined(OS_WIN) |
152 HANDLE handshake_handle; | 154 HANDLE handshake_handle; |
153 std::string pipe_name; | 155 std::string pipe_name; |
154 #endif // OS_MACOSX | 156 #endif // OS_MACOSX |
157 bool rate_limit; | |
155 } options = {}; | 158 } options = {}; |
156 #if defined(OS_MACOSX) | 159 #if defined(OS_MACOSX) |
157 options.handshake_fd = -1; | 160 options.handshake_fd = -1; |
158 #elif defined(OS_WIN) | 161 #elif defined(OS_WIN) |
159 options.handshake_handle = INVALID_HANDLE_VALUE; | 162 options.handshake_handle = INVALID_HANDLE_VALUE; |
160 #endif | 163 #endif |
164 options.rate_limit = true; | |
161 | 165 |
162 const option long_options[] = { | 166 const option long_options[] = { |
163 {"annotation", required_argument, nullptr, kOptionAnnotation}, | 167 {"annotation", required_argument, nullptr, kOptionAnnotation}, |
164 {"database", required_argument, nullptr, kOptionDatabase}, | 168 {"database", required_argument, nullptr, kOptionDatabase}, |
165 #if defined(OS_MACOSX) | 169 #if defined(OS_MACOSX) |
166 {"handshake-fd", required_argument, nullptr, kOptionHandshakeFD}, | 170 {"handshake-fd", required_argument, nullptr, kOptionHandshakeFD}, |
167 {"mach-service", required_argument, nullptr, kOptionMachService}, | 171 {"mach-service", required_argument, nullptr, kOptionMachService}, |
168 {"reset-own-crash-exception-port-to-system-default", | 172 {"reset-own-crash-exception-port-to-system-default", |
169 no_argument, | 173 no_argument, |
170 nullptr, | 174 nullptr, |
171 kOptionResetOwnCrashExceptionPortToSystemDefault}, | 175 kOptionResetOwnCrashExceptionPortToSystemDefault}, |
172 #elif defined(OS_WIN) | 176 #elif defined(OS_WIN) |
173 {"handshake-handle", required_argument, nullptr, kOptionHandshakeHandle}, | 177 {"handshake-handle", required_argument, nullptr, kOptionHandshakeHandle}, |
174 {"pipe-name", required_argument, nullptr, kOptionPipeName}, | 178 {"pipe-name", required_argument, nullptr, kOptionPipeName}, |
175 #endif // OS_MACOSX | 179 #endif // OS_MACOSX |
176 {"url", required_argument, nullptr, kOptionURL}, | 180 {"url", required_argument, nullptr, kOptionURL}, |
181 {"no-rate-limit", no_argument, nullptr, kOptionNoRateLimit}, | |
177 {"help", no_argument, nullptr, kOptionHelp}, | 182 {"help", no_argument, nullptr, kOptionHelp}, |
178 {"version", no_argument, nullptr, kOptionVersion}, | 183 {"version", no_argument, nullptr, kOptionVersion}, |
179 {nullptr, 0, nullptr, 0}, | 184 {nullptr, 0, nullptr, 0}, |
180 }; | 185 }; |
181 | 186 |
182 int opt; | 187 int opt; |
183 while ((opt = getopt_long(argc, argv, "", long_options, nullptr)) != -1) { | 188 while ((opt = getopt_long(argc, argv, "", long_options, nullptr)) != -1) { |
184 switch (opt) { | 189 switch (opt) { |
185 case kOptionAnnotation: { | 190 case kOptionAnnotation: { |
186 std::string key; | 191 std::string key; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 } | 238 } |
234 case kOptionPipeName: { | 239 case kOptionPipeName: { |
235 options.pipe_name = optarg; | 240 options.pipe_name = optarg; |
236 break; | 241 break; |
237 } | 242 } |
238 #endif // OS_MACOSX | 243 #endif // OS_MACOSX |
239 case kOptionURL: { | 244 case kOptionURL: { |
240 options.url = optarg; | 245 options.url = optarg; |
241 break; | 246 break; |
242 } | 247 } |
248 case kOptionNoRateLimit: { | |
249 options.rate_limit = false; | |
250 break; | |
251 } | |
243 case kOptionHelp: { | 252 case kOptionHelp: { |
244 Usage(me); | 253 Usage(me); |
245 return EXIT_SUCCESS; | 254 return EXIT_SUCCESS; |
246 } | 255 } |
247 case kOptionVersion: { | 256 case kOptionVersion: { |
248 ToolSupport::Version(me); | 257 ToolSupport::Version(me); |
249 return EXIT_SUCCESS; | 258 return EXIT_SUCCESS; |
250 } | 259 } |
251 default: { | 260 default: { |
252 ToolSupport::UsageHint(me, nullptr); | 261 ToolSupport::UsageHint(me, nullptr); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 } | 373 } |
365 #endif // OS_MACOSX | 374 #endif // OS_MACOSX |
366 | 375 |
367 scoped_ptr<CrashReportDatabase> database(CrashReportDatabase::Initialize( | 376 scoped_ptr<CrashReportDatabase> database(CrashReportDatabase::Initialize( |
368 base::FilePath(ToolSupport::CommandLineArgumentToFilePathStringType( | 377 base::FilePath(ToolSupport::CommandLineArgumentToFilePathStringType( |
369 options.database)))); | 378 options.database)))); |
370 if (!database) { | 379 if (!database) { |
371 return EXIT_FAILURE; | 380 return EXIT_FAILURE; |
372 } | 381 } |
373 | 382 |
374 CrashReportUploadThread upload_thread(database.get(), options.url); | 383 CrashReportUploadThread upload_thread( |
384 database.get(), options.url, options.rate_limit); | |
375 upload_thread.Start(); | 385 upload_thread.Start(); |
376 | 386 |
377 PruneCrashReportThread prune_thread(database.get(), | 387 PruneCrashReportThread prune_thread(database.get(), |
378 PruneCondition::GetDefault()); | 388 PruneCondition::GetDefault()); |
379 prune_thread.Start(); | 389 prune_thread.Start(); |
380 | 390 |
381 CrashReportExceptionHandler exception_handler( | 391 CrashReportExceptionHandler exception_handler( |
382 database.get(), &upload_thread, &options.annotations); | 392 database.get(), &upload_thread, &options.annotations); |
383 | 393 |
384 exception_handler_server.Run(&exception_handler); | 394 exception_handler_server.Run(&exception_handler); |
385 | 395 |
386 upload_thread.Stop(); | 396 upload_thread.Stop(); |
387 prune_thread.Stop(); | 397 prune_thread.Stop(); |
388 | 398 |
389 return EXIT_SUCCESS; | 399 return EXIT_SUCCESS; |
390 } | 400 } |
391 | 401 |
392 } // namespace crashpad | 402 } // namespace crashpad |
OLD | NEW |