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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 private: | 238 private: |
239 // MachMultiprocess: | 239 // MachMultiprocess: |
240 | 240 |
241 void MachMultiprocessParent() override { | 241 void MachMultiprocessParent() override { |
242 ProcessReader process_reader; | 242 ProcessReader process_reader; |
243 ASSERT_TRUE(process_reader.Initialize(ChildTask())); | 243 ASSERT_TRUE(process_reader.Initialize(ChildTask())); |
244 | 244 |
245 // Wait for the child process to indicate that it’s done setting up its | 245 // Wait for the child process to indicate that it’s done setting up its |
246 // annotations via the CrashpadInfo interface. | 246 // annotations via the CrashpadInfo interface. |
247 char c; | 247 char c; |
248 CheckedReadFile(ReadPipeHandle(), &c, sizeof(c)); | 248 CheckedReadFileExactly(ReadPipeHandle(), &c, sizeof(c)); |
249 | 249 |
250 // Verify the “simple map” annotations set via the CrashpadInfo interface. | 250 // Verify the “simple map” annotations set via the CrashpadInfo interface. |
251 const std::vector<ProcessReader::Module>& modules = | 251 const std::vector<ProcessReader::Module>& modules = |
252 process_reader.Modules(); | 252 process_reader.Modules(); |
253 std::map<std::string, std::string> all_annotations_simple_map; | 253 std::map<std::string, std::string> all_annotations_simple_map; |
254 for (const ProcessReader::Module& module : modules) { | 254 for (const ProcessReader::Module& module : modules) { |
255 MachOImageAnnotationsReader module_annotations_reader( | 255 MachOImageAnnotationsReader module_annotations_reader( |
256 &process_reader, module.reader, module.name); | 256 &process_reader, module.reader, module.name); |
257 std::map<std::string, std::string> module_annotations_simple_map = | 257 std::map<std::string, std::string> module_annotations_simple_map = |
258 module_annotations_reader.SimpleMap(); | 258 module_annotations_reader.SimpleMap(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 simple_annotations->SetKeyValue("#TEST# longer", "shorter"); | 326 simple_annotations->SetKeyValue("#TEST# longer", "shorter"); |
327 simple_annotations->SetKeyValue("#TEST# empty_value", ""); | 327 simple_annotations->SetKeyValue("#TEST# empty_value", ""); |
328 | 328 |
329 crashpad_info->set_simple_annotations(simple_annotations); | 329 crashpad_info->set_simple_annotations(simple_annotations); |
330 | 330 |
331 // Tell the parent that the environment has been set up. | 331 // Tell the parent that the environment has been set up. |
332 char c = '\0'; | 332 char c = '\0'; |
333 CheckedWriteFile(WritePipeHandle(), &c, sizeof(c)); | 333 CheckedWriteFile(WritePipeHandle(), &c, sizeof(c)); |
334 | 334 |
335 // Wait for the parent to indicate that it’s safe to crash. | 335 // Wait for the parent to indicate that it’s safe to crash. |
336 CheckedReadFile(ReadPipeHandle(), &c, sizeof(c)); | 336 CheckedReadFileExactly(ReadPipeHandle(), &c, sizeof(c)); |
337 | 337 |
338 // Direct an exception message to the exception server running in the | 338 // Direct an exception message to the exception server running in the |
339 // parent. | 339 // parent. |
340 ExceptionPorts exception_ports(ExceptionPorts::kTargetTypeTask, | 340 ExceptionPorts exception_ports(ExceptionPorts::kTargetTypeTask, |
341 mach_task_self()); | 341 mach_task_self()); |
342 ASSERT_TRUE(exception_ports.SetExceptionPort( | 342 ASSERT_TRUE(exception_ports.SetExceptionPort( |
343 EXC_MASK_CRASH, RemotePort(), EXCEPTION_DEFAULT, THREAD_STATE_NONE)); | 343 EXC_MASK_CRASH, RemotePort(), EXCEPTION_DEFAULT, THREAD_STATE_NONE)); |
344 | 344 |
345 switch (test_type_) { | 345 switch (test_type_) { |
346 case kDontCrash: { | 346 case kDontCrash: { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 | 418 |
419 TEST(MachOImageAnnotationsReader, CrashDyld) { | 419 TEST(MachOImageAnnotationsReader, CrashDyld) { |
420 TestMachOImageAnnotationsReader test_mach_o_image_annotations_reader( | 420 TestMachOImageAnnotationsReader test_mach_o_image_annotations_reader( |
421 TestMachOImageAnnotationsReader::kCrashDyld); | 421 TestMachOImageAnnotationsReader::kCrashDyld); |
422 test_mach_o_image_annotations_reader.Run(); | 422 test_mach_o_image_annotations_reader.Run(); |
423 } | 423 } |
424 | 424 |
425 } // namespace | 425 } // namespace |
426 } // namespace test | 426 } // namespace test |
427 } // namespace crashpad | 427 } // namespace crashpad |
OLD | NEW |