| 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, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 #include "client/simulate_crash.h" | 15 #include "client/simulate_crash.h" |
| 16 | 16 |
| 17 #include <mach/mach.h> | 17 #include <mach/mach.h> |
| 18 #include <string.h> | 18 #include <string.h> |
| 19 | 19 |
| 20 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
| 21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "gtest/gtest.h" | 23 #include "gtest/gtest.h" |
| 24 #include "util/mach/exc_server_variants.h" | 24 #include "util/mach/exc_server_variants.h" |
| 25 #include "util/mach/exception_behaviors.h" | 25 #include "util/mach/exception_behaviors.h" |
| 26 #include "util/mach/exception_ports.h" | 26 #include "util/mach/exception_ports.h" |
| 27 #include "util/mach/mach_extensions.h" | 27 #include "util/mach/mach_extensions.h" |
| 28 #include "util/mach/mach_message.h" |
| 28 #include "util/mach/mach_message_server.h" | 29 #include "util/mach/mach_message_server.h" |
| 29 #include "util/mach/symbolic_constants_mach.h" | 30 #include "util/mach/symbolic_constants_mach.h" |
| 30 #include "util/test/mac/mach_errors.h" | 31 #include "util/test/mac/mach_errors.h" |
| 31 #include "util/test/mac/mach_multiprocess.h" | 32 #include "util/test/mac/mach_multiprocess.h" |
| 32 | 33 |
| 33 namespace crashpad { | 34 namespace crashpad { |
| 34 namespace test { | 35 namespace test { |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 class TestSimulateCrashMac final : public MachMultiprocess, | 38 class TestSimulateCrashMac final : public MachMultiprocess, |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 if (target_ == kExceptionPortsTargetBoth) { | 245 if (target_ == kExceptionPortsTargetBoth) { |
| 245 // The client has registered EXC_CRASH handlers for both its thread and | 246 // The client has registered EXC_CRASH handlers for both its thread and |
| 246 // task targets. Run a server that will return a failure code when the | 247 // task targets. Run a server that will return a failure code when the |
| 247 // exception message is sent to the thread target, which will cause the | 248 // exception message is sent to the thread target, which will cause the |
| 248 // client to fall back to the task target and send another message. | 249 // client to fall back to the task target and send another message. |
| 249 succeed_ = false; | 250 succeed_ = false; |
| 250 mr = MachMessageServer::Run(&universal_mach_exc_server, | 251 mr = MachMessageServer::Run(&universal_mach_exc_server, |
| 251 LocalPort(), | 252 LocalPort(), |
| 252 MACH_MSG_OPTION_NONE, | 253 MACH_MSG_OPTION_NONE, |
| 253 MachMessageServer::kOneShot, | 254 MachMessageServer::kOneShot, |
| 254 MachMessageServer::kBlocking, | |
| 255 MachMessageServer::kReceiveLargeError, | 255 MachMessageServer::kReceiveLargeError, |
| 256 MACH_MSG_TIMEOUT_NONE); | 256 kMachMessageTimeoutWaitIndefinitely); |
| 257 EXPECT_EQ(MACH_MSG_SUCCESS, mr) | 257 EXPECT_EQ(MACH_MSG_SUCCESS, mr) |
| 258 << MachErrorMessage(mr, "MachMessageServer::Run"); | 258 << MachErrorMessage(mr, "MachMessageServer::Run"); |
| 259 } | 259 } |
| 260 | 260 |
| 261 succeed_ = true; | 261 succeed_ = true; |
| 262 mr = MachMessageServer::Run(&universal_mach_exc_server, | 262 mr = MachMessageServer::Run(&universal_mach_exc_server, |
| 263 LocalPort(), | 263 LocalPort(), |
| 264 MACH_MSG_OPTION_NONE, | 264 MACH_MSG_OPTION_NONE, |
| 265 MachMessageServer::kOneShot, | 265 MachMessageServer::kOneShot, |
| 266 MachMessageServer::kBlocking, | |
| 267 MachMessageServer::kReceiveLargeError, | 266 MachMessageServer::kReceiveLargeError, |
| 268 MACH_MSG_TIMEOUT_NONE); | 267 kMachMessageTimeoutWaitIndefinitely); |
| 269 EXPECT_EQ(MACH_MSG_SUCCESS, mr) | 268 EXPECT_EQ(MACH_MSG_SUCCESS, mr) |
| 270 << MachErrorMessage(mr, "MachMessageServer::Run"); | 269 << MachErrorMessage(mr, "MachMessageServer::Run"); |
| 271 } | 270 } |
| 272 | 271 |
| 273 void MachMultiprocessChild() override { | 272 void MachMultiprocessChild() override { |
| 274 bool task_valid = target_ == kExceptionPortsTargetTask || | 273 bool task_valid = target_ == kExceptionPortsTargetTask || |
| 275 target_ == kExceptionPortsTargetBoth; | 274 target_ == kExceptionPortsTargetBoth; |
| 276 ExceptionPorts task_exception_ports(ExceptionPorts::kTargetTypeTask, | 275 ExceptionPorts task_exception_ports(ExceptionPorts::kTargetTypeTask, |
| 277 TASK_NULL); | 276 TASK_NULL); |
| 278 ASSERT_TRUE(task_exception_ports.SetExceptionPort( | 277 ASSERT_TRUE(task_exception_ports.SetExceptionPort( |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 test_simulate_crash_mac.Run(); | 374 test_simulate_crash_mac.Run(); |
| 376 } | 375 } |
| 377 } | 376 } |
| 378 } | 377 } |
| 379 } | 378 } |
| 380 } | 379 } |
| 381 | 380 |
| 382 } // namespace | 381 } // namespace |
| 383 } // namespace test | 382 } // namespace test |
| 384 } // namespace crashpad | 383 } // namespace crashpad |
| OLD | NEW |