Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: tools/exception_port_tool.cc

Issue 649713002: Use the correct null constants for Mach threads, tasks, and hosts (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | util/mac/process_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 return true; 174 return true;
175 } 175 }
176 176
177 // ShowExceptionPorts() shows handlers as numeric mach_port_t values, which are 177 // ShowExceptionPorts() shows handlers as numeric mach_port_t values, which are
178 // opaque and meaningless on their own. ShowBootstrapService() can be used to 178 // opaque and meaningless on their own. ShowBootstrapService() can be used to
179 // look up a service with the bootstrap server by name and show its mach_port_t 179 // look up a service with the bootstrap server by name and show its mach_port_t
180 // value, which can then be associated with handlers shown by 180 // value, which can then be associated with handlers shown by
181 // ShowExceptionPorts(). Any send rights obtained by this function are added to 181 // ShowExceptionPorts(). Any send rights obtained by this function are added to
182 // |mach_send_right_pool|. 182 // |mach_send_right_pool|.
183 void ShowBootstrapService( 183 void ShowBootstrapService(const std::string& service_name,
184 const std::string& service_name, MachSendRightPool* mach_send_right_pool) { 184 MachSendRightPool* mach_send_right_pool) {
185 mach_port_t service_port; 185 mach_port_t service_port;
186 kern_return_t kr = bootstrap_look_up( 186 kern_return_t kr = bootstrap_look_up(
187 bootstrap_port, const_cast<char*>(service_name.c_str()), &service_port); 187 bootstrap_port, const_cast<char*>(service_name.c_str()), &service_port);
188 if (kr != BOOTSTRAP_SUCCESS) { 188 if (kr != BOOTSTRAP_SUCCESS) {
189 BOOTSTRAP_LOG(ERROR, kr) << "bootstrap_look_up " << service_name; 189 BOOTSTRAP_LOG(ERROR, kr) << "bootstrap_look_up " << service_name;
190 return; 190 return;
191 } 191 }
192 192
193 mach_send_right_pool->AddSendRight(service_port); 193 mach_send_right_pool->AddSendRight(service_port);
194 194
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 MachSendRightPool mach_send_right_pool; 510 MachSendRightPool mach_send_right_pool;
511 511
512 // Show bootstrap services requested. 512 // Show bootstrap services requested.
513 for (const char* service : options.show_bootstrap) { 513 for (const char* service : options.show_bootstrap) {
514 ShowBootstrapService(service, &mach_send_right_pool); 514 ShowBootstrapService(service, &mach_send_right_pool);
515 } 515 }
516 516
517 // Show the original exception ports. 517 // Show the original exception ports.
518 if (options.show_host) { 518 if (options.show_host) {
519 ShowExceptionPorts( 519 ShowExceptionPorts(
520 ExceptionPorts(ExceptionPorts::kTargetTypeHost, MACH_PORT_NULL), 520 ExceptionPorts(ExceptionPorts::kTargetTypeHost, HOST_NULL),
521 options.numeric, 521 options.numeric,
522 false, 522 false,
523 &mach_send_right_pool); 523 &mach_send_right_pool);
524 } 524 }
525 if (options.show_task) { 525 if (options.show_task) {
526 ShowExceptionPorts( 526 ShowExceptionPorts(
527 ExceptionPorts(ExceptionPorts::kTargetTypeTask, options.alternate_task), 527 ExceptionPorts(ExceptionPorts::kTargetTypeTask, options.alternate_task),
528 options.numeric, 528 options.numeric,
529 false, 529 false,
530 &mach_send_right_pool); 530 &mach_send_right_pool);
531 } 531 }
532 if (options.show_thread) { 532 if (options.show_thread) {
533 ShowExceptionPorts( 533 ShowExceptionPorts(
534 ExceptionPorts(ExceptionPorts::kTargetTypeThread, MACH_PORT_NULL), 534 ExceptionPorts(ExceptionPorts::kTargetTypeThread, THREAD_NULL),
535 options.numeric, 535 options.numeric,
536 false, 536 false,
537 &mach_send_right_pool); 537 &mach_send_right_pool);
538 } 538 }
539 539
540 if (!options.set_handler.empty()) { 540 if (!options.set_handler.empty()) {
541 // Set new exception handlers. 541 // Set new exception handlers.
542 for (ExceptionHandlerDescription description : options.set_handler) { 542 for (ExceptionHandlerDescription description : options.set_handler) {
543 if (!SetExceptionPort( 543 if (!SetExceptionPort(
544 &description, 544 &description,
545 description.target_type == ExceptionPorts::kTargetTypeTask 545 description.target_type == ExceptionPorts::kTargetTypeTask
546 ? options.alternate_task 546 ? options.alternate_task
547 : MACH_PORT_NULL)) { 547 : TASK_NULL)) {
548 return kExitFailure; 548 return kExitFailure;
549 } 549 }
550 } 550 }
551 551
552 // Show changed exception ports. 552 // Show changed exception ports.
553 if (options.show_new_host) { 553 if (options.show_new_host) {
554 ShowExceptionPorts( 554 ShowExceptionPorts(
555 ExceptionPorts(ExceptionPorts::kTargetTypeHost, MACH_PORT_NULL), 555 ExceptionPorts(ExceptionPorts::kTargetTypeHost, HOST_NULL),
556 options.numeric, 556 options.numeric,
557 true, 557 true,
558 &mach_send_right_pool); 558 &mach_send_right_pool);
559 } 559 }
560 if (options.show_new_task) { 560 if (options.show_new_task) {
561 ShowExceptionPorts( 561 ShowExceptionPorts(
562 ExceptionPorts(ExceptionPorts::kTargetTypeTask, 562 ExceptionPorts(ExceptionPorts::kTargetTypeTask,
563 options.alternate_task), 563 options.alternate_task),
564 options.numeric, 564 options.numeric,
565 true, 565 true,
566 &mach_send_right_pool); 566 &mach_send_right_pool);
567 } 567 }
568 if (options.show_new_thread) { 568 if (options.show_new_thread) {
569 ShowExceptionPorts( 569 ShowExceptionPorts(
570 ExceptionPorts(ExceptionPorts::kTargetTypeThread, MACH_PORT_NULL), 570 ExceptionPorts(ExceptionPorts::kTargetTypeThread, THREAD_NULL),
571 options.numeric, 571 options.numeric,
572 true, 572 true,
573 &mach_send_right_pool); 573 &mach_send_right_pool);
574 } 574 }
575 } 575 }
576 576
577 if (argc) { 577 if (argc) {
578 // 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
579 // exception ports in effect. 579 // exception ports in effect.
580 execvp(argv[0], argv); 580 execvp(argv[0], argv);
581 PLOG(ERROR) << "execvp " << argv[0]; 581 PLOG(ERROR) << "execvp " << argv[0];
582 return errno == ENOENT ? kExitExecENOENT : kExitExecFailure; 582 return errno == ENOENT ? kExitExecENOENT : kExitExecFailure;
583 } 583 }
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 }
OLDNEW
« no previous file with comments | « no previous file | util/mac/process_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698