| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 explicit Child(TestExceptionPorts* test_exception_ports) | 205 explicit Child(TestExceptionPorts* test_exception_ports) |
| 206 : test_exception_ports_(test_exception_ports), | 206 : test_exception_ports_(test_exception_ports), |
| 207 thread_(), | 207 thread_(), |
| 208 init_semaphore_(0), | 208 init_semaphore_(0), |
| 209 crash_semaphore_(0) {} | 209 crash_semaphore_(0) {} |
| 210 | 210 |
| 211 ~Child() {} | 211 ~Child() {} |
| 212 | 212 |
| 213 void Run() { | 213 void Run() { |
| 214 ExceptionPorts self_task_ports(ExceptionPorts::kTargetTypeTask, | 214 ExceptionPorts self_task_ports(ExceptionPorts::kTargetTypeTask, |
| 215 MACH_PORT_NULL); | 215 TASK_NULL); |
| 216 ExceptionPorts self_thread_ports(ExceptionPorts::kTargetTypeThread, | 216 ExceptionPorts self_thread_ports(ExceptionPorts::kTargetTypeThread, |
| 217 MACH_PORT_NULL); | 217 THREAD_NULL); |
| 218 | 218 |
| 219 mach_port_t remote_port = test_exception_ports_->RemotePort(); | 219 mach_port_t remote_port = test_exception_ports_->RemotePort(); |
| 220 | 220 |
| 221 // Set the task’s and this thread’s exception ports, if appropriate. | 221 // Set the task’s and this thread’s exception ports, if appropriate. |
| 222 if (test_exception_ports_->set_type() == kSetInProcess) { | 222 if (test_exception_ports_->set_type() == kSetInProcess) { |
| 223 ASSERT_TRUE(self_task_ports.SetExceptionPort( | 223 ASSERT_TRUE(self_task_ports.SetExceptionPort( |
| 224 EXC_MASK_CRASH, remote_port, EXCEPTION_DEFAULT, THREAD_STATE_NONE)); | 224 EXC_MASK_CRASH, remote_port, EXCEPTION_DEFAULT, THREAD_STATE_NONE)); |
| 225 | 225 |
| 226 if (test_exception_ports_->set_on() == kSetOnTaskAndThreads) { | 226 if (test_exception_ports_->set_on() == kSetOnTaskAndThreads) { |
| 227 ASSERT_TRUE(self_thread_ports.SetExceptionPort(EXC_MASK_CRASH, | 227 ASSERT_TRUE(self_thread_ports.SetExceptionPort(EXC_MASK_CRASH, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 private: | 278 private: |
| 279 // Calls ThreadMain(). | 279 // Calls ThreadMain(). |
| 280 static void* ThreadMainThunk(void* argument) { | 280 static void* ThreadMainThunk(void* argument) { |
| 281 Child* self = reinterpret_cast<Child*>(argument); | 281 Child* self = reinterpret_cast<Child*>(argument); |
| 282 return self->ThreadMain(); | 282 return self->ThreadMain(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 // Runs the “other” thread. | 285 // Runs the “other” thread. |
| 286 void* ThreadMain() { | 286 void* ThreadMain() { |
| 287 ExceptionPorts self_thread_ports(ExceptionPorts::kTargetTypeThread, | 287 ExceptionPorts self_thread_ports(ExceptionPorts::kTargetTypeThread, |
| 288 MACH_PORT_NULL); | 288 THREAD_NULL); |
| 289 mach_port_t remote_port = test_exception_ports_->RemotePort(); | 289 mach_port_t remote_port = test_exception_ports_->RemotePort(); |
| 290 | 290 |
| 291 // Set this thread’s exception handler, if appropriate. | 291 // Set this thread’s exception handler, if appropriate. |
| 292 if (test_exception_ports_->set_type() == kSetInProcess && | 292 if (test_exception_ports_->set_type() == kSetInProcess && |
| 293 test_exception_ports_->set_on() == kSetOnTaskAndThreads) { | 293 test_exception_ports_->set_on() == kSetOnTaskAndThreads) { |
| 294 CHECK(self_thread_ports.SetExceptionPort(EXC_MASK_CRASH, | 294 CHECK(self_thread_ports.SetExceptionPort(EXC_MASK_CRASH, |
| 295 remote_port, | 295 remote_port, |
| 296 EXCEPTION_STATE_IDENTITY, | 296 EXCEPTION_STATE_IDENTITY, |
| 297 MACHINE_THREAD_STATE)); | 297 MACHINE_THREAD_STATE)); |
| 298 } | 298 } |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 std::vector<ExceptionPorts::ExceptionHandler> handlers; | 553 std::vector<ExceptionPorts::ExceptionHandler> handlers; |
| 554 bool rv = explicit_host_ports.GetExceptionPorts( | 554 bool rv = explicit_host_ports.GetExceptionPorts( |
| 555 ExcMaskAll() | EXC_MASK_CRASH, &handlers); | 555 ExcMaskAll() | EXC_MASK_CRASH, &handlers); |
| 556 if (geteuid() == 0) { | 556 if (geteuid() == 0) { |
| 557 EXPECT_TRUE(rv); | 557 EXPECT_TRUE(rv); |
| 558 } else { | 558 } else { |
| 559 EXPECT_FALSE(rv); | 559 EXPECT_FALSE(rv); |
| 560 } | 560 } |
| 561 | 561 |
| 562 ExceptionPorts implicit_host_ports(ExceptionPorts::kTargetTypeHost, | 562 ExceptionPorts implicit_host_ports(ExceptionPorts::kTargetTypeHost, |
| 563 MACH_PORT_NULL); | 563 HOST_NULL); |
| 564 EXPECT_EQ("host", implicit_host_ports.TargetTypeName()); | 564 EXPECT_EQ("host", implicit_host_ports.TargetTypeName()); |
| 565 | 565 |
| 566 rv = implicit_host_ports.GetExceptionPorts( | 566 rv = implicit_host_ports.GetExceptionPorts( |
| 567 ExcMaskAll() | EXC_MASK_CRASH, &handlers); | 567 ExcMaskAll() | EXC_MASK_CRASH, &handlers); |
| 568 if (geteuid() == 0) { | 568 if (geteuid() == 0) { |
| 569 EXPECT_TRUE(rv); | 569 EXPECT_TRUE(rv); |
| 570 } else { | 570 } else { |
| 571 EXPECT_FALSE(rv); | 571 EXPECT_FALSE(rv); |
| 572 } | 572 } |
| 573 } | 573 } |
| 574 | 574 |
| 575 } // namespace | 575 } // namespace |
| 576 } // namespace test | 576 } // namespace test |
| 577 } // namespace crashpad | 577 } // namespace crashpad |
| OLD | NEW |