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

Side by Side Diff: util/mach/exception_ports_test.cc

Issue 775943005: UniversalMachExcServer: eliminate multiple implementation inheritance (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years 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 | « util/mach/exc_server_variants_test.cc ('k') | no next file » | 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 95 }
96 } 96 }
97 97
98 if (expect_port != MACH_PORT_NULL) { 98 if (expect_port != MACH_PORT_NULL) {
99 EXPECT_TRUE(found); 99 EXPECT_TRUE(found);
100 } else { 100 } else {
101 EXPECT_FALSE(found); 101 EXPECT_FALSE(found);
102 } 102 }
103 } 103 }
104 104
105 class TestExceptionPorts : public UniversalMachExcServer, 105 class TestExceptionPorts : public MachMultiprocess,
106 public MachMultiprocess { 106 public UniversalMachExcServer::Interface {
107 public: 107 public:
108 // Where to call ExceptionPorts::SetExceptionPort() from. 108 // Where to call ExceptionPorts::SetExceptionPort() from.
109 enum SetType { 109 enum SetType {
110 // Call it from the child process on itself. 110 // Call it from the child process on itself.
111 kSetInProcess = 0, 111 kSetInProcess = 0,
112 112
113 // Call it from the parent process on the child. 113 // Call it from the parent process on the child.
114 kSetOutOfProcess, 114 kSetOutOfProcess,
115 }; 115 };
116 116
117 // Which entities to set exception ports for. 117 // Which entities to set exception ports for.
118 enum SetOn { 118 enum SetOn {
119 kSetOnTaskOnly = 0, 119 kSetOnTaskOnly = 0,
120 kSetOnTaskAndThreads, 120 kSetOnTaskAndThreads,
121 }; 121 };
122 122
123 // Which thread in the child process is expected to crash. 123 // Which thread in the child process is expected to crash.
124 enum WhoCrashes { 124 enum WhoCrashes {
125 kNobodyCrashes = 0, 125 kNobodyCrashes = 0,
126 kMainThreadCrashes, 126 kMainThreadCrashes,
127 kOtherThreadCrashes, 127 kOtherThreadCrashes,
128 }; 128 };
129 129
130 TestExceptionPorts(SetType set_type, SetOn set_on, WhoCrashes who_crashes) 130 TestExceptionPorts(SetType set_type, SetOn set_on, WhoCrashes who_crashes)
131 : UniversalMachExcServer(), 131 : MachMultiprocess(),
132 MachMultiprocess(), 132 UniversalMachExcServer::Interface(),
133 set_type_(set_type), 133 set_type_(set_type),
134 set_on_(set_on), 134 set_on_(set_on),
135 who_crashes_(who_crashes), 135 who_crashes_(who_crashes),
136 handled_(false) {} 136 handled_(false) {}
137 137
138 SetType set_type() const { return set_type_; } 138 SetType set_type() const { return set_type_; }
139 SetOn set_on() const { return set_on_; } 139 SetOn set_on() const { return set_on_; }
140 WhoCrashes who_crashes() const { return who_crashes_; } 140 WhoCrashes who_crashes() const { return who_crashes_; }
141 141
142 // UniversalMachExcServer: 142 // UniversalMachExcServer::Interface:
143 143
144 virtual kern_return_t CatchMachException( 144 virtual kern_return_t CatchMachException(
145 exception_behavior_t behavior, 145 exception_behavior_t behavior,
146 exception_handler_t exception_port, 146 exception_handler_t exception_port,
147 thread_t thread, 147 thread_t thread,
148 task_t task, 148 task_t task,
149 exception_type_t exception, 149 exception_type_t exception,
150 const mach_exception_data_type_t* code, 150 const mach_exception_data_type_t* code,
151 mach_msg_type_number_t code_count, 151 mach_msg_type_number_t code_count,
152 thread_state_flavor_t* flavor, 152 thread_state_flavor_t* flavor,
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 TestGetExceptionPorts( 436 TestGetExceptionPorts(
437 other_thread_ports, thread_handler, EXCEPTION_STATE_IDENTITY); 437 other_thread_ports, thread_handler, EXCEPTION_STATE_IDENTITY);
438 } 438 }
439 439
440 // Let the child process know that everything in the parent process is set 440 // Let the child process know that everything in the parent process is set
441 // up. 441 // up.
442 c = '\0'; 442 c = '\0';
443 CheckedWriteFD(WritePipeFD(), &c, 1); 443 CheckedWriteFD(WritePipeFD(), &c, 1);
444 444
445 if (who_crashes_ != kNobodyCrashes) { 445 if (who_crashes_ != kNobodyCrashes) {
446 UniversalMachExcServer universal_mach_exc_server(this);
447
446 kern_return_t kr = 448 kern_return_t kr =
447 MachMessageServer::Run(this, 449 MachMessageServer::Run(&universal_mach_exc_server,
448 local_port, 450 local_port,
449 MACH_MSG_OPTION_NONE, 451 MACH_MSG_OPTION_NONE,
450 MachMessageServer::kOneShot, 452 MachMessageServer::kOneShot,
451 MachMessageServer::kBlocking, 453 MachMessageServer::kBlocking,
452 MachMessageServer::kReceiveLargeError, 454 MachMessageServer::kReceiveLargeError,
453 0); 455 0);
454 EXPECT_EQ(KERN_SUCCESS, kr) 456 EXPECT_EQ(KERN_SUCCESS, kr)
455 << MachErrorMessage(kr, "MachMessageServer::Run"); 457 << MachErrorMessage(kr, "MachMessageServer::Run");
456 458
457 EXPECT_TRUE(handled_); 459 EXPECT_TRUE(handled_);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 if (geteuid() == 0) { 573 if (geteuid() == 0) {
572 EXPECT_TRUE(rv); 574 EXPECT_TRUE(rv);
573 } else { 575 } else {
574 EXPECT_FALSE(rv); 576 EXPECT_FALSE(rv);
575 } 577 }
576 } 578 }
577 579
578 } // namespace 580 } // namespace
579 } // namespace test 581 } // namespace test
580 } // namespace crashpad 582 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/mach/exc_server_variants_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698