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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 const char kTargetEquals[] = "target="; | 114 const char kTargetEquals[] = "target="; |
115 const char kMaskEquals[] = "mask="; | 115 const char kMaskEquals[] = "mask="; |
116 const char kBehaviorEquals[] = "behavior="; | 116 const char kBehaviorEquals[] = "behavior="; |
117 const char kFlavorEquals[] = "flavor="; | 117 const char kFlavorEquals[] = "flavor="; |
118 const char kHandlerEquals[] = "handler="; | 118 const char kHandlerEquals[] = "handler="; |
119 | 119 |
120 std::string handler_string(handler_string_ro); | 120 std::string handler_string(handler_string_ro); |
121 char* handler_string_c = &handler_string[0]; | 121 char* handler_string_c = &handler_string[0]; |
122 | 122 |
123 char* token; | 123 char* token; |
124 while ((token = strsep(&handler_string_c, ",")) != NULL) { | 124 while ((token = strsep(&handler_string_c, ",")) != nullptr) { |
125 if (strncmp(token, kTargetEquals, strlen(kTargetEquals)) == 0) { | 125 if (strncmp(token, kTargetEquals, strlen(kTargetEquals)) == 0) { |
126 const char* value = token + strlen(kTargetEquals); | 126 const char* value = token + strlen(kTargetEquals); |
127 if (strcmp(value, "host") == 0) { | 127 if (strcmp(value, "host") == 0) { |
128 description->target_type = ExceptionPorts::kTargetTypeHost; | 128 description->target_type = ExceptionPorts::kTargetTypeHost; |
129 } else if (strcmp(value, "task") == 0) { | 129 } else if (strcmp(value, "task") == 0) { |
130 description->target_type = ExceptionPorts::kTargetTypeTask; | 130 description->target_type = ExceptionPorts::kTargetTypeTask; |
131 } else if (strcmp(value, "thread") == 0) { | 131 } else if (strcmp(value, "thread") == 0) { |
132 description->target_type = ExceptionPorts::kTargetTypeThread; | 132 description->target_type = ExceptionPorts::kTargetTypeThread; |
133 } else { | 133 } else { |
134 return false; | 134 return false; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 bool show_host; | 395 bool show_host; |
396 bool show_task; | 396 bool show_task; |
397 bool show_thread; | 397 bool show_thread; |
398 bool show_new_host; | 398 bool show_new_host; |
399 bool show_new_task; | 399 bool show_new_task; |
400 bool show_new_thread; | 400 bool show_new_thread; |
401 bool numeric; | 401 bool numeric; |
402 } options = {}; | 402 } options = {}; |
403 | 403 |
404 const struct option long_options[] = { | 404 const struct option long_options[] = { |
405 {"set_handler", required_argument, NULL, kOptionSetPort}, | 405 {"set_handler", required_argument, nullptr, kOptionSetPort}, |
406 {"show_bootstrap", required_argument, NULL, kOptionShowBootstrap}, | 406 {"show_bootstrap", required_argument, nullptr, kOptionShowBootstrap}, |
407 {"pid", required_argument, NULL, kOptionPid}, | 407 {"pid", required_argument, nullptr, kOptionPid}, |
408 {"show_host", no_argument, NULL, kOptionShowHost}, | 408 {"show_host", no_argument, nullptr, kOptionShowHost}, |
409 {"show_task", no_argument, NULL, kOptionShowTask}, | 409 {"show_task", no_argument, nullptr, kOptionShowTask}, |
410 {"show_thread", no_argument, NULL, kOptionShowThread}, | 410 {"show_thread", no_argument, nullptr, kOptionShowThread}, |
411 {"show_new_host", no_argument, NULL, kOptionShowNewHost}, | 411 {"show_new_host", no_argument, nullptr, kOptionShowNewHost}, |
412 {"show_new_task", no_argument, NULL, kOptionShowNewTask}, | 412 {"show_new_task", no_argument, nullptr, kOptionShowNewTask}, |
413 {"show_new_thread", no_argument, NULL, kOptionShowNewThread}, | 413 {"show_new_thread", no_argument, nullptr, kOptionShowNewThread}, |
414 {"numeric", no_argument, NULL, kOptionNumeric}, | 414 {"numeric", no_argument, nullptr, kOptionNumeric}, |
415 {"help", no_argument, NULL, kOptionHelp}, | 415 {"help", no_argument, nullptr, kOptionHelp}, |
416 {"version", no_argument, NULL, kOptionVersion}, | 416 {"version", no_argument, nullptr, kOptionVersion}, |
417 {NULL, 0, NULL, 0}, | 417 {nullptr, 0, nullptr, 0}, |
418 }; | 418 }; |
419 | 419 |
420 int opt; | 420 int opt; |
421 while ((opt = getopt_long(argc, argv, "+s:p:htHTn", long_options, NULL)) != | 421 while ((opt = getopt_long(argc, argv, "+s:p:htHTn", long_options, nullptr)) != |
422 -1) { | 422 -1) { |
423 switch (opt) { | 423 switch (opt) { |
424 case kOptionSetPort: { | 424 case kOptionSetPort: { |
425 options.set_handler.push_back({}); | 425 options.set_handler.push_back({}); |
426 ExceptionHandlerDescription* description = &options.set_handler.back(); | 426 ExceptionHandlerDescription* description = &options.set_handler.back(); |
427 description->target_type = ExceptionPorts::kTargetTypeTask; | 427 description->target_type = ExceptionPorts::kTargetTypeTask; |
428 description->mask = EXC_MASK_CRASH; | 428 description->mask = EXC_MASK_CRASH; |
429 description->behavior = EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES; | 429 description->behavior = EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES; |
430 description->flavor = THREAD_STATE_NONE; | 430 description->flavor = THREAD_STATE_NONE; |
431 description->handler = "NULL"; | 431 description->handler = "NULL"; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 case kOptionNumeric: | 468 case kOptionNumeric: |
469 options.numeric = true; | 469 options.numeric = true; |
470 break; | 470 break; |
471 case kOptionHelp: | 471 case kOptionHelp: |
472 Usage(me); | 472 Usage(me); |
473 return kExitSuccess; | 473 return kExitSuccess; |
474 case kOptionVersion: | 474 case kOptionVersion: |
475 ToolSupport::Version(me); | 475 ToolSupport::Version(me); |
476 return kExitSuccess; | 476 return kExitSuccess; |
477 default: | 477 default: |
478 ToolSupport::UsageHint(me, NULL); | 478 ToolSupport::UsageHint(me, nullptr); |
479 return kExitFailure; | 479 return kExitFailure; |
480 } | 480 } |
481 } | 481 } |
482 argc -= optind; | 482 argc -= optind; |
483 argv += optind; | 483 argv += optind; |
484 | 484 |
485 if (options.show_bootstrap.empty() && !options.show_host && | 485 if (options.show_bootstrap.empty() && !options.show_host && |
486 !options.show_task && !options.show_thread && | 486 !options.show_task && !options.show_thread && |
487 options.set_handler.empty() && argc == 0) { | 487 options.set_handler.empty() && argc == 0) { |
488 ToolSupport::UsageHint(me, "nothing to do"); | 488 ToolSupport::UsageHint(me, "nothing to do"); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 | 584 |
585 return kExitSuccess; | 585 return kExitSuccess; |
586 } | 586 } |
587 | 587 |
588 } // namespace | 588 } // namespace |
589 } // namespace crashpad | 589 } // namespace crashpad |
590 | 590 |
591 int main(int argc, char* argv[]) { | 591 int main(int argc, char* argv[]) { |
592 return crashpad::ExceptionPortToolMain(argc, argv); | 592 return crashpad::ExceptionPortToolMain(argc, argv); |
593 } | 593 } |
OLD | NEW |