| 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 <servers/bootstrap.h> | |
| 18 #include <stdio.h> | 17 #include <stdio.h> |
| 19 #include <string.h> | 18 #include <string.h> |
| 20 #include <unistd.h> | 19 #include <unistd.h> |
| 21 | 20 |
| 22 #include <algorithm> | 21 #include <algorithm> |
| 23 #include <string> | 22 #include <string> |
| 24 #include <vector> | 23 #include <vector> |
| 25 | 24 |
| 26 #include "base/files/scoped_file.h" | 25 #include "base/files/scoped_file.h" |
| 27 #include "base/logging.h" | 26 #include "base/logging.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 } | 255 } |
| 257 } | 256 } |
| 258 argc -= optind; | 257 argc -= optind; |
| 259 argv += optind; | 258 argv += optind; |
| 260 | 259 |
| 261 if (options.mach_service.empty()) { | 260 if (options.mach_service.empty()) { |
| 262 ToolSupport::UsageHint(me, "-m is required"); | 261 ToolSupport::UsageHint(me, "-m is required"); |
| 263 return EXIT_FAILURE; | 262 return EXIT_FAILURE; |
| 264 } | 263 } |
| 265 | 264 |
| 266 mach_port_t service_port; | 265 base::mac::ScopedMachReceiveRight |
| 267 kern_return_t kr = bootstrap_check_in( | 266 service_port(BootstrapCheckIn(options.mach_service)); |
| 268 bootstrap_port, options.mach_service.c_str(), &service_port); | 267 if (service_port == kMachPortNull) { |
| 269 if (kr != BOOTSTRAP_SUCCESS) { | |
| 270 BOOTSTRAP_LOG(ERROR, kr) << "bootstrap_check_in " << options.mach_service; | |
| 271 return EXIT_FAILURE; | 268 return EXIT_FAILURE; |
| 272 } | 269 } |
| 273 | 270 |
| 274 base::ScopedFILE file_owner; | 271 base::ScopedFILE file_owner; |
| 275 if (options.file_path.empty()) { | 272 if (options.file_path.empty()) { |
| 276 options.file = stdout; | 273 options.file = stdout; |
| 277 } else { | 274 } else { |
| 278 file_owner.reset(fopen(options.file_path.c_str(), "a")); | 275 file_owner.reset(fopen(options.file_path.c_str(), "a")); |
| 279 if (!file_owner.get()) { | 276 if (!file_owner.get()) { |
| 280 PLOG(ERROR) << "fopen " << options.file_path; | 277 PLOG(ERROR) << "fopen " << options.file_path; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 318 |
| 322 return EXIT_SUCCESS; | 319 return EXIT_SUCCESS; |
| 323 } | 320 } |
| 324 | 321 |
| 325 } // namespace | 322 } // namespace |
| 326 } // namespace crashpad | 323 } // namespace crashpad |
| 327 | 324 |
| 328 int main(int argc, char* argv[]) { | 325 int main(int argc, char* argv[]) { |
| 329 return crashpad::CatchExceptionToolMain(argc, argv); | 326 return crashpad::CatchExceptionToolMain(argc, argv); |
| 330 } | 327 } |
| OLD | NEW |