| 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/mac/mach_logging.h" | 28 #include "base/mac/mach_logging.h" |
| 29 #include "tools/tool_support.h" | 29 #include "tools/tool_support.h" |
| 30 #include "util/mach/exc_server_variants.h" | 30 #include "util/mach/exc_server_variants.h" |
| 31 #include "util/mach/exception_behaviors.h" | 31 #include "util/mach/exception_behaviors.h" |
| 32 #include "util/mach/mach_extensions.h" | 32 #include "util/mach/mach_extensions.h" |
| 33 #include "util/mach/mach_message_server.h" | 33 #include "util/mach/mach_message_server.h" |
| 34 #include "util/mach/symbolic_constants_mach.h" | 34 #include "util/mach/symbolic_constants_mach.h" |
| 35 #include "util/posix/symbolic_constants_posix.h" | 35 #include "util/posix/symbolic_constants_posix.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 struct Options { | 41 struct Options { |
| 43 std::string file_path; | 42 std::string file_path; |
| 44 std::string mach_service; | 43 std::string mach_service; |
| 45 FILE* file; | 44 FILE* file; |
| 46 int timeout_secs; | 45 int timeout_secs; |
| 47 MachMessageServer::Nonblocking nonblocking; | 46 MachMessageServer::Nonblocking nonblocking; |
| 48 MachMessageServer::Persistent persistent; | 47 MachMessageServer::Persistent persistent; |
| 49 }; | 48 }; |
| 50 | 49 |
| 51 class ExceptionServer : public UniversalMachExcServer { | 50 class ExceptionServer : public UniversalMachExcServer { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 " -m, --mach_service=SERVICE register SERVICE with the bootstrap server\n" | 171 " -m, --mach_service=SERVICE register SERVICE with the bootstrap server\n" |
| 173 " -n, --nonblocking don't block waiting for an exception to occur\n" | 172 " -n, --nonblocking don't block waiting for an exception to occur\n" |
| 174 " -p, --persistent continue processing exceptions after the first\n" | 173 " -p, --persistent continue processing exceptions after the first\n" |
| 175 " -t, --timeout=TIMEOUT run for a maximum of TIMEOUT seconds\n" | 174 " -t, --timeout=TIMEOUT run for a maximum of TIMEOUT seconds\n" |
| 176 " --help display this help and exit\n" | 175 " --help display this help and exit\n" |
| 177 " --version output version information and exit\n", | 176 " --version output version information and exit\n", |
| 178 me.c_str()); | 177 me.c_str()); |
| 179 ToolSupport::UsageTail(me); | 178 ToolSupport::UsageTail(me); |
| 180 } | 179 } |
| 181 | 180 |
| 182 } // namespace | 181 int CatchExceptionToolMain(int argc, char* argv[]) { |
| 183 | |
| 184 int main(int argc, char* argv[]) { | |
| 185 const std::string me(basename(argv[0])); | 182 const std::string me(basename(argv[0])); |
| 186 | 183 |
| 187 enum OptionFlags { | 184 enum OptionFlags { |
| 188 // “Short” (single-character) options. | 185 // “Short” (single-character) options. |
| 189 kOptionFile = 'f', | 186 kOptionFile = 'f', |
| 190 kOptionMachService = 'm', | 187 kOptionMachService = 'm', |
| 191 kOptionNonblocking = 'n', | 188 kOptionNonblocking = 'n', |
| 192 kOptionPersistent = 'p', | 189 kOptionPersistent = 'p', |
| 193 kOptionTimeout = 't', | 190 kOptionTimeout = 't', |
| 194 | 191 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 // This is not an error: when exiting on timeout during persistent | 290 // This is not an error: when exiting on timeout during persistent |
| 294 // processing and at least one exception was handled, it’s considered a | 291 // processing and at least one exception was handled, it’s considered a |
| 295 // success. | 292 // success. |
| 296 } else if (mr != MACH_MSG_SUCCESS) { | 293 } else if (mr != MACH_MSG_SUCCESS) { |
| 297 MACH_LOG(ERROR, mr) << "MachMessageServer::Run"; | 294 MACH_LOG(ERROR, mr) << "MachMessageServer::Run"; |
| 298 return EXIT_FAILURE; | 295 return EXIT_FAILURE; |
| 299 } | 296 } |
| 300 | 297 |
| 301 return EXIT_SUCCESS; | 298 return EXIT_SUCCESS; |
| 302 } | 299 } |
| 300 |
| 301 } // namespace |
| 302 } // namespace crashpad |
| 303 |
| 304 int main(int argc, char* argv[]) { |
| 305 return crashpad::CatchExceptionToolMain(argc, argv); |
| 306 } |
| OLD | NEW |