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, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #include <getopt.h> | 15 #include <getopt.h> |
16 #include <libgen.h> | 16 #include <libgen.h> |
17 #include <stdlib.h> | 17 #include <stdlib.h> |
18 | 18 |
19 #include <string> | 19 #include <string> |
20 | 20 |
21 #include "base/files/file_path.h" | 21 #include "base/files/file_path.h" |
| 22 #include "base/logging.h" |
22 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
23 #include "client/crash_report_database.h" | 24 #include "client/crash_report_database.h" |
24 #include "tools/tool_support.h" | 25 #include "tools/tool_support.h" |
25 #include "handler/mac/crash_report_exception_handler.h" | 26 #include "handler/mac/crash_report_exception_handler.h" |
| 27 #include "handler/mac/crash_report_upload_thread.h" |
26 #include "handler/mac/exception_handler_server.h" | 28 #include "handler/mac/exception_handler_server.h" |
27 #include "util/mach/child_port_handshake.h" | 29 #include "util/mach/child_port_handshake.h" |
28 #include "util/posix/close_stdio.h" | 30 #include "util/posix/close_stdio.h" |
29 #include "util/stdlib/string_number_conversion.h" | 31 #include "util/stdlib/string_number_conversion.h" |
| 32 #include "util/synchronization/semaphore.h" |
30 | 33 |
31 namespace crashpad { | 34 namespace crashpad { |
32 namespace { | 35 namespace { |
33 | 36 |
34 void Usage(const std::string& me) { | 37 void Usage(const std::string& me) { |
35 fprintf(stderr, | 38 fprintf(stderr, |
36 "Usage: %s [OPTION]...\n" | 39 "Usage: %s [OPTION]...\n" |
37 "Crashpad's exception handler server.\n" | 40 "Crashpad's exception handler server.\n" |
38 "\n" | 41 "\n" |
39 " --database=PATH store the crash report database at PATH\n" | 42 " --database=PATH store the crash report database at PATH\n" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 ChildPortHandshake::RunClient(options.handshake_fd, | 125 ChildPortHandshake::RunClient(options.handshake_fd, |
123 exception_handler_server.receive_port(), | 126 exception_handler_server.receive_port(), |
124 MACH_MSG_TYPE_MAKE_SEND); | 127 MACH_MSG_TYPE_MAKE_SEND); |
125 | 128 |
126 scoped_ptr<CrashReportDatabase> database( | 129 scoped_ptr<CrashReportDatabase> database( |
127 CrashReportDatabase::Initialize(base::FilePath(options.database))); | 130 CrashReportDatabase::Initialize(base::FilePath(options.database))); |
128 if (!database) { | 131 if (!database) { |
129 return EXIT_FAILURE; | 132 return EXIT_FAILURE; |
130 } | 133 } |
131 | 134 |
132 CrashReportExceptionHandler exception_handler(database.get()); | 135 CrashReportUploadThread upload_thread(database.get()); |
| 136 upload_thread.Start(); |
| 137 |
| 138 CrashReportExceptionHandler exception_handler(database.get(), &upload_thread); |
133 | 139 |
134 exception_handler_server.Run(&exception_handler); | 140 exception_handler_server.Run(&exception_handler); |
135 | 141 |
| 142 upload_thread.Stop(); |
| 143 |
136 return EXIT_SUCCESS; | 144 return EXIT_SUCCESS; |
137 } | 145 } |
138 | 146 |
139 } // namespace | 147 } // namespace |
140 } // namespace crashpad | 148 } // namespace crashpad |
141 | 149 |
142 int main(int argc, char* argv[]) { | 150 int main(int argc, char* argv[]) { |
143 return crashpad::HandlerMain(argc, argv); | 151 return crashpad::HandlerMain(argc, argv); |
144 } | 152 } |
OLD | NEW |