| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 private: | 186 private: |
| 187 // MachMultiprocess: | 187 // MachMultiprocess: |
| 188 | 188 |
| 189 void MachMultiprocessParent() override { | 189 void MachMultiprocessParent() override { |
| 190 ProcessReader process_reader; | 190 ProcessReader process_reader; |
| 191 ASSERT_TRUE(process_reader.Initialize(ChildTask())); | 191 ASSERT_TRUE(process_reader.Initialize(ChildTask())); |
| 192 | 192 |
| 193 // Wait for the child process to indicate that it’s done setting up its | 193 // Wait for the child process to indicate that it’s done setting up its |
| 194 // annotations via the CrashpadInfo interface. | 194 // annotations via the CrashpadInfo interface. |
| 195 char c; | 195 char c; |
| 196 CheckedReadFile(ReadPipeFD(), &c, sizeof(c)); | 196 CheckedReadFile(ReadPipeHandle(), &c, sizeof(c)); |
| 197 | 197 |
| 198 // Verify the “simple map” annotations set via the CrashpadInfo interface. | 198 // Verify the “simple map” annotations set via the CrashpadInfo interface. |
| 199 const std::vector<ProcessReader::Module>& modules = | 199 const std::vector<ProcessReader::Module>& modules = |
| 200 process_reader.Modules(); | 200 process_reader.Modules(); |
| 201 std::map<std::string, std::string> all_annotations_simple_map; | 201 std::map<std::string, std::string> all_annotations_simple_map; |
| 202 for (const ProcessReader::Module& module : modules) { | 202 for (const ProcessReader::Module& module : modules) { |
| 203 MachOImageAnnotationsReader module_annotations_reader( | 203 MachOImageAnnotationsReader module_annotations_reader( |
| 204 &process_reader, module.reader, module.name); | 204 &process_reader, module.reader, module.name); |
| 205 std::map<std::string, std::string> module_annotations_simple_map = | 205 std::map<std::string, std::string> module_annotations_simple_map = |
| 206 module_annotations_reader.SimpleMap(); | 206 module_annotations_reader.SimpleMap(); |
| 207 all_annotations_simple_map.insert(module_annotations_simple_map.begin(), | 207 all_annotations_simple_map.insert(module_annotations_simple_map.begin(), |
| 208 module_annotations_simple_map.end()); | 208 module_annotations_simple_map.end()); |
| 209 } | 209 } |
| 210 | 210 |
| 211 EXPECT_GE(all_annotations_simple_map.size(), 5u); | 211 EXPECT_GE(all_annotations_simple_map.size(), 5u); |
| 212 EXPECT_EQ("crash", all_annotations_simple_map["#TEST# pad"]); | 212 EXPECT_EQ("crash", all_annotations_simple_map["#TEST# pad"]); |
| 213 EXPECT_EQ("value", all_annotations_simple_map["#TEST# key"]); | 213 EXPECT_EQ("value", all_annotations_simple_map["#TEST# key"]); |
| 214 EXPECT_EQ("y", all_annotations_simple_map["#TEST# x"]); | 214 EXPECT_EQ("y", all_annotations_simple_map["#TEST# x"]); |
| 215 EXPECT_EQ("shorter", all_annotations_simple_map["#TEST# longer"]); | 215 EXPECT_EQ("shorter", all_annotations_simple_map["#TEST# longer"]); |
| 216 EXPECT_EQ("", all_annotations_simple_map["#TEST# empty_value"]); | 216 EXPECT_EQ("", all_annotations_simple_map["#TEST# empty_value"]); |
| 217 | 217 |
| 218 // Tell the child process that it’s permitted to crash. | 218 // Tell the child process that it’s permitted to crash. |
| 219 CheckedWriteFile(WritePipeFD(), &c, sizeof(c)); | 219 CheckedWriteFile(WritePipeHandle(), &c, sizeof(c)); |
| 220 | 220 |
| 221 if (test_type_ != kDontCrash) { | 221 if (test_type_ != kDontCrash) { |
| 222 // Handle the child’s crash. Further validation will be done in | 222 // Handle the child’s crash. Further validation will be done in |
| 223 // CatchMachException(). | 223 // CatchMachException(). |
| 224 UniversalMachExcServer universal_mach_exc_server(this); | 224 UniversalMachExcServer universal_mach_exc_server(this); |
| 225 | 225 |
| 226 mach_msg_return_t mr = | 226 mach_msg_return_t mr = |
| 227 MachMessageServer::Run(&universal_mach_exc_server, | 227 MachMessageServer::Run(&universal_mach_exc_server, |
| 228 LocalPort(), | 228 LocalPort(), |
| 229 MACH_MSG_OPTION_NONE, | 229 MACH_MSG_OPTION_NONE, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 simple_annotations->SetKeyValue("#TEST# key", "value"); | 261 simple_annotations->SetKeyValue("#TEST# key", "value"); |
| 262 simple_annotations->SetKeyValue("#TEST# pad", "crash"); | 262 simple_annotations->SetKeyValue("#TEST# pad", "crash"); |
| 263 simple_annotations->SetKeyValue("#TEST# x", "y"); | 263 simple_annotations->SetKeyValue("#TEST# x", "y"); |
| 264 simple_annotations->SetKeyValue("#TEST# longer", "shorter"); | 264 simple_annotations->SetKeyValue("#TEST# longer", "shorter"); |
| 265 simple_annotations->SetKeyValue("#TEST# empty_value", ""); | 265 simple_annotations->SetKeyValue("#TEST# empty_value", ""); |
| 266 | 266 |
| 267 crashpad_info->set_simple_annotations(simple_annotations); | 267 crashpad_info->set_simple_annotations(simple_annotations); |
| 268 | 268 |
| 269 // Tell the parent that the environment has been set up. | 269 // Tell the parent that the environment has been set up. |
| 270 char c = '\0'; | 270 char c = '\0'; |
| 271 CheckedWriteFile(WritePipeFD(), &c, sizeof(c)); | 271 CheckedWriteFile(WritePipeHandle(), &c, sizeof(c)); |
| 272 | 272 |
| 273 // Wait for the parent to indicate that it’s safe to crash. | 273 // Wait for the parent to indicate that it’s safe to crash. |
| 274 CheckedReadFile(ReadPipeFD(), &c, sizeof(c)); | 274 CheckedReadFile(ReadPipeHandle(), &c, sizeof(c)); |
| 275 | 275 |
| 276 // Direct an exception message to the exception server running in the | 276 // Direct an exception message to the exception server running in the |
| 277 // parent. | 277 // parent. |
| 278 ExceptionPorts exception_ports(ExceptionPorts::kTargetTypeTask, | 278 ExceptionPorts exception_ports(ExceptionPorts::kTargetTypeTask, |
| 279 mach_task_self()); | 279 mach_task_self()); |
| 280 ASSERT_TRUE(exception_ports.SetExceptionPort( | 280 ASSERT_TRUE(exception_ports.SetExceptionPort( |
| 281 EXC_MASK_CRASH, RemotePort(), EXCEPTION_DEFAULT, THREAD_STATE_NONE)); | 281 EXC_MASK_CRASH, RemotePort(), EXCEPTION_DEFAULT, THREAD_STATE_NONE)); |
| 282 | 282 |
| 283 switch (test_type_) { | 283 switch (test_type_) { |
| 284 case kDontCrash: | 284 case kDontCrash: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 330 |
| 331 TEST(MachOImageAnnotationsReader, CrashDyld) { | 331 TEST(MachOImageAnnotationsReader, CrashDyld) { |
| 332 TestMachOImageAnnotationsReader test_mach_o_image_annotations_reader( | 332 TestMachOImageAnnotationsReader test_mach_o_image_annotations_reader( |
| 333 TestMachOImageAnnotationsReader::kCrashDyld); | 333 TestMachOImageAnnotationsReader::kCrashDyld); |
| 334 test_mach_o_image_annotations_reader.Run(); | 334 test_mach_o_image_annotations_reader.Run(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 } // namespace | 337 } // namespace |
| 338 } // namespace test | 338 } // namespace test |
| 339 } // namespace crashpad | 339 } // namespace crashpad |
| OLD | NEW |