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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "util/mach/mach_extensions.h" | 43 #include "util/mach/mach_extensions.h" |
44 #include "util/posix/close_stdio.h" | 44 #include "util/posix/close_stdio.h" |
45 #elif defined(OS_WIN) | 45 #elif defined(OS_WIN) |
46 #include <windows.h> | 46 #include <windows.h> |
47 #include "handler/win/crash_report_exception_handler.h" | 47 #include "handler/win/crash_report_exception_handler.h" |
48 #include "util/win/exception_handler_server.h" | 48 #include "util/win/exception_handler_server.h" |
49 #include "util/win/handle.h" | 49 #include "util/win/handle.h" |
50 #endif // OS_MACOSX | 50 #endif // OS_MACOSX |
51 | 51 |
52 namespace crashpad { | 52 namespace crashpad { |
| 53 |
53 namespace { | 54 namespace { |
54 | 55 |
55 void Usage(const base::FilePath& me) { | 56 void Usage(const base::FilePath& me) { |
56 fprintf(stderr, | 57 fprintf(stderr, |
57 "Usage: %" PRFilePath " [OPTION]...\n" | 58 "Usage: %" PRFilePath " [OPTION]...\n" |
58 "Crashpad's exception handler server.\n" | 59 "Crashpad's exception handler server.\n" |
59 "\n" | 60 "\n" |
60 " --annotation=KEY=VALUE set a process annotation in each crash report\n" | 61 " --annotation=KEY=VALUE set a process annotation in each crash report\n" |
61 " --database=PATH store the crash report database at PATH\n" | 62 " --database=PATH store the crash report database at PATH\n" |
62 #if defined(OS_MACOSX) | 63 #if defined(OS_MACOSX) |
63 " --handshake-fd=FD establish communication with the client over FD\n
" | 64 " --handshake-fd=FD establish communication with the client over FD\n
" |
64 " --mach-service=SERVICE register SERVICE with the bootstrap server\n" | 65 " --mach-service=SERVICE register SERVICE with the bootstrap server\n" |
65 " --reset-own-crash-exception-port-to-system-default\n" | 66 " --reset-own-crash-exception-port-to-system-default\n" |
66 " reset the server's exception handler to default\n
" | 67 " reset the server's exception handler to default\n
" |
67 #elif defined(OS_WIN) | 68 #elif defined(OS_WIN) |
68 " --handshake-handle=HANDLE\n" | 69 " --handshake-handle=HANDLE\n" |
69 " create a new pipe and send its name via HANDLE\n" | 70 " create a new pipe and send its name via HANDLE\n" |
70 " --pipe-name=PIPE communicate with the client over PIPE\n" | 71 " --pipe-name=PIPE communicate with the client over PIPE\n" |
71 #endif // OS_MACOSX | 72 #endif // OS_MACOSX |
72 " --url=URL send crash reports to this Breakpad server URL,\n
" | 73 " --url=URL send crash reports to this Breakpad server URL,\n
" |
73 " only if uploads are enabled for the database\n" | 74 " only if uploads are enabled for the database\n" |
74 " --help display this help and exit\n" | 75 " --help display this help and exit\n" |
75 " --version output version information and exit\n", | 76 " --version output version information and exit\n", |
76 me.value().c_str()); | 77 me.value().c_str()); |
77 ToolSupport::UsageTail(me); | 78 ToolSupport::UsageTail(me); |
78 } | 79 } |
79 | 80 |
| 81 } // namespace |
| 82 |
80 int HandlerMain(int argc, char* argv[]) { | 83 int HandlerMain(int argc, char* argv[]) { |
81 const base::FilePath argv0( | 84 const base::FilePath argv0( |
82 ToolSupport::CommandLineArgumentToFilePathStringType(argv[0])); | 85 ToolSupport::CommandLineArgumentToFilePathStringType(argv[0])); |
83 const base::FilePath me(argv0.BaseName()); | 86 const base::FilePath me(argv0.BaseName()); |
84 | 87 |
85 enum OptionFlags { | 88 enum OptionFlags { |
86 // Long options without short equivalents. | 89 // Long options without short equivalents. |
87 kOptionLastChar = 255, | 90 kOptionLastChar = 255, |
88 kOptionAnnotation, | 91 kOptionAnnotation, |
89 kOptionDatabase, | 92 kOptionDatabase, |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 CrashReportExceptionHandler exception_handler( | 319 CrashReportExceptionHandler exception_handler( |
317 database.get(), &upload_thread, &options.annotations); | 320 database.get(), &upload_thread, &options.annotations); |
318 | 321 |
319 exception_handler_server.Run(&exception_handler); | 322 exception_handler_server.Run(&exception_handler); |
320 | 323 |
321 upload_thread.Stop(); | 324 upload_thread.Stop(); |
322 | 325 |
323 return EXIT_SUCCESS; | 326 return EXIT_SUCCESS; |
324 } | 327 } |
325 | 328 |
326 } // namespace | |
327 } // namespace crashpad | 329 } // namespace crashpad |
328 | |
329 #if defined(OS_MACOSX) | |
330 int main(int argc, char* argv[]) { | |
331 return crashpad::HandlerMain(argc, argv); | |
332 } | |
333 #elif defined(OS_WIN) | |
334 int wmain(int argc, wchar_t* argv[]) { | |
335 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::HandlerMain); | |
336 } | |
337 #endif // OS_MACOSX | |
OLD | NEW |