| 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 17 matching lines...) Expand all Loading... |
| 28 #include "base/basictypes.h" | 28 #include "base/basictypes.h" |
| 29 #include "base/mac/mach_logging.h" | 29 #include "base/mac/mach_logging.h" |
| 30 #include "base/mac/scoped_mach_port.h" | 30 #include "base/mac/scoped_mach_port.h" |
| 31 #include "base/strings/stringprintf.h" | 31 #include "base/strings/stringprintf.h" |
| 32 #include "tools/tool_support.h" | 32 #include "tools/tool_support.h" |
| 33 #include "util/mach/exception_ports.h" | 33 #include "util/mach/exception_ports.h" |
| 34 #include "util/mach/mach_extensions.h" | 34 #include "util/mach/mach_extensions.h" |
| 35 #include "util/mach/symbolic_constants_mach.h" | 35 #include "util/mach/symbolic_constants_mach.h" |
| 36 #include "util/stdlib/string_number_conversion.h" | 36 #include "util/stdlib/string_number_conversion.h" |
| 37 | 37 |
| 38 namespace crashpad { |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 using namespace crashpad; | |
| 41 | |
| 42 //! \brief Manages a pool of Mach send rights, deallocating all send rights upon | 41 //! \brief Manages a pool of Mach send rights, deallocating all send rights upon |
| 43 //! destruction. | 42 //! destruction. |
| 44 //! | 43 //! |
| 45 //! This class effectively implements what a vector of | 44 //! This class effectively implements what a vector of |
| 46 //! base::mac::ScopedMachSendRight objects would be. | 45 //! base::mac::ScopedMachSendRight objects would be. |
| 47 //! | 46 //! |
| 48 //! The various “show” operations performed by this program display Mach ports | 47 //! The various “show” operations performed by this program display Mach ports |
| 49 //! by their names as they are known in this task. For this to be useful, rights | 48 //! by their names as they are known in this task. For this to be useful, rights |
| 50 //! to the same ports must have consistent names across successive calls. This | 49 //! to the same ports must have consistent names across successive calls. This |
| 51 //! cannot be guaranteed if the rights are deallocated as soon as they are used, | 50 //! cannot be guaranteed if the rights are deallocated as soon as they are used, |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 " or STATE_IDENTITY, possibly with MACH_EXCEPTION_CODES.\n" | 340 " or STATE_IDENTITY, possibly with MACH_EXCEPTION_CODES.\n" |
| 342 " flavor the thread state flavor passed to the handler: architecture-specifi
c\n" | 341 " flavor the thread state flavor passed to the handler: architecture-specifi
c\n" |
| 343 " handler the exception handler: NULL or bootstrap:SERVICE, indicating that\n
" | 342 " handler the exception handler: NULL or bootstrap:SERVICE, indicating that\n
" |
| 344 " the handler should be looked up with the bootstrap server\n" | 343 " the handler should be looked up with the bootstrap server\n" |
| 345 "The default DESCRIPTION is\n" | 344 "The default DESCRIPTION is\n" |
| 346 " target=task,mask=CRASH,behavior=DEFAULT|MACH,flavor=NONE,handler=NULL\n", | 345 " target=task,mask=CRASH,behavior=DEFAULT|MACH,flavor=NONE,handler=NULL\n", |
| 347 me.c_str()); | 346 me.c_str()); |
| 348 ToolSupport::UsageTail(me); | 347 ToolSupport::UsageTail(me); |
| 349 } | 348 } |
| 350 | 349 |
| 351 } // namespace | 350 int ExceptionPortToolMain(int argc, char* argv[]) { |
| 352 | |
| 353 int main(int argc, char* argv[]) { | |
| 354 const std::string me(basename(argv[0])); | 351 const std::string me(basename(argv[0])); |
| 355 | 352 |
| 356 enum ExitCode { | 353 enum ExitCode { |
| 357 kExitSuccess = EXIT_SUCCESS, | 354 kExitSuccess = EXIT_SUCCESS, |
| 358 | 355 |
| 359 // To differentiate this tool’s errors from errors in the programs it execs, | 356 // To differentiate this tool’s errors from errors in the programs it execs, |
| 360 // use a high exit code for ordinary failures instead of EXIT_FAILURE. This | 357 // use a high exit code for ordinary failures instead of EXIT_FAILURE. This |
| 361 // is the same rationale for using the distinct exit codes for exec | 358 // is the same rationale for using the distinct exit codes for exec |
| 362 // failures. | 359 // failures. |
| 363 kExitFailure = 125, | 360 kExitFailure = 125, |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 if (argc) { | 577 if (argc) { |
| 581 // Using the remaining arguments, start a new program with the new set of | 578 // Using the remaining arguments, start a new program with the new set of |
| 582 // exception ports in effect. | 579 // exception ports in effect. |
| 583 execvp(argv[0], argv); | 580 execvp(argv[0], argv); |
| 584 PLOG(ERROR) << "execvp " << argv[0]; | 581 PLOG(ERROR) << "execvp " << argv[0]; |
| 585 return errno == ENOENT ? kExitExecENOENT : kExitExecFailure; | 582 return errno == ENOENT ? kExitExecENOENT : kExitExecFailure; |
| 586 } | 583 } |
| 587 | 584 |
| 588 return kExitSuccess; | 585 return kExitSuccess; |
| 589 } | 586 } |
| 587 |
| 588 } // namespace |
| 589 } // namespace crashpad |
| 590 |
| 591 int main(int argc, char* argv[]) { |
| 592 return crashpad::ExceptionPortToolMain(argc, argv); |
| 593 } |
| OLD | NEW |