| 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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 kMemoryValue2, | 474 kMemoryValue2, |
| 475 true)); | 475 true)); |
| 476 ASSERT_NO_FATAL_FAILURE( | 476 ASSERT_NO_FATAL_FAILURE( |
| 477 ExpectMinidumpContextX86(kSeed2, observed_context, false)); | 477 ExpectMinidumpContextX86(kSeed2, observed_context, false)); |
| 478 ASSERT_NO_FATAL_FAILURE(ExpectMinidumpMemoryDescriptor( | 478 ASSERT_NO_FATAL_FAILURE(ExpectMinidumpMemoryDescriptor( |
| 479 observed_stack, &memory_list->MemoryRanges[2])); | 479 observed_stack, &memory_list->MemoryRanges[2])); |
| 480 } | 480 } |
| 481 } | 481 } |
| 482 | 482 |
| 483 struct InitializeFromSnapshotX86Traits { | 483 struct InitializeFromSnapshotX86Traits { |
| 484 typedef MinidumpContextX86 MinidumpContextType; | 484 using MinidumpContextType = MinidumpContextX86; |
| 485 static void InitializeCPUContext(CPUContext* context, uint32_t seed) { | 485 static void InitializeCPUContext(CPUContext* context, uint32_t seed) { |
| 486 return InitializeCPUContextX86(context, seed); | 486 return InitializeCPUContextX86(context, seed); |
| 487 } | 487 } |
| 488 static void ExpectMinidumpContext( | 488 static void ExpectMinidumpContext( |
| 489 uint32_t expect_seed, const MinidumpContextX86* observed, bool snapshot) { | 489 uint32_t expect_seed, const MinidumpContextX86* observed, bool snapshot) { |
| 490 return ExpectMinidumpContextX86(expect_seed, observed, snapshot); | 490 return ExpectMinidumpContextX86(expect_seed, observed, snapshot); |
| 491 } | 491 } |
| 492 }; | 492 }; |
| 493 | 493 |
| 494 struct InitializeFromSnapshotAMD64Traits { | 494 struct InitializeFromSnapshotAMD64Traits { |
| 495 typedef MinidumpContextAMD64 MinidumpContextType; | 495 using MinidumpContextType = MinidumpContextAMD64; |
| 496 static void InitializeCPUContext(CPUContext* context, uint32_t seed) { | 496 static void InitializeCPUContext(CPUContext* context, uint32_t seed) { |
| 497 return InitializeCPUContextX86_64(context, seed); | 497 return InitializeCPUContextX86_64(context, seed); |
| 498 } | 498 } |
| 499 static void ExpectMinidumpContext(uint32_t expect_seed, | 499 static void ExpectMinidumpContext(uint32_t expect_seed, |
| 500 const MinidumpContextAMD64* observed, | 500 const MinidumpContextAMD64* observed, |
| 501 bool snapshot) { | 501 bool snapshot) { |
| 502 return ExpectMinidumpContextAMD64(expect_seed, observed, snapshot); | 502 return ExpectMinidumpContextAMD64(expect_seed, observed, snapshot); |
| 503 } | 503 } |
| 504 }; | 504 }; |
| 505 | 505 |
| 506 struct InitializeFromSnapshotNoContextTraits { | 506 struct InitializeFromSnapshotNoContextTraits { |
| 507 typedef MinidumpContextX86 MinidumpContextType; | 507 using MinidumpContextType = MinidumpContextX86; |
| 508 static void InitializeCPUContext(CPUContext* context, uint32_t seed) { | 508 static void InitializeCPUContext(CPUContext* context, uint32_t seed) { |
| 509 context->architecture = kCPUArchitectureUnknown; | 509 context->architecture = kCPUArchitectureUnknown; |
| 510 } | 510 } |
| 511 static void ExpectMinidumpContext(uint32_t expect_seed, | 511 static void ExpectMinidumpContext(uint32_t expect_seed, |
| 512 const MinidumpContextX86* observed, | 512 const MinidumpContextX86* observed, |
| 513 bool snapshot) { | 513 bool snapshot) { |
| 514 FAIL(); | 514 FAIL(); |
| 515 } | 515 } |
| 516 }; | 516 }; |
| 517 | 517 |
| 518 template <typename Traits> | 518 template <typename Traits> |
| 519 void RunInitializeFromSnapshotTest(bool thread_id_collision) { | 519 void RunInitializeFromSnapshotTest(bool thread_id_collision) { |
| 520 typedef typename Traits::MinidumpContextType MinidumpContextType; | 520 using MinidumpContextType = typename Traits::MinidumpContextType; |
| 521 MINIDUMP_THREAD expect_threads[3] = {}; | 521 MINIDUMP_THREAD expect_threads[3] = {}; |
| 522 uint64_t thread_ids[arraysize(expect_threads)] = {}; | 522 uint64_t thread_ids[arraysize(expect_threads)] = {}; |
| 523 uint8_t memory_values[arraysize(expect_threads)] = {}; | 523 uint8_t memory_values[arraysize(expect_threads)] = {}; |
| 524 uint32_t context_seeds[arraysize(expect_threads)] = {}; | 524 uint32_t context_seeds[arraysize(expect_threads)] = {}; |
| 525 | 525 |
| 526 expect_threads[0].ThreadId = 1; | 526 expect_threads[0].ThreadId = 1; |
| 527 expect_threads[0].SuspendCount = 2; | 527 expect_threads[0].SuspendCount = 2; |
| 528 expect_threads[0].Priority = 3; | 528 expect_threads[0].Priority = 3; |
| 529 expect_threads[0].Teb = 0x0123456789abcdef; | 529 expect_threads[0].Teb = 0x0123456789abcdef; |
| 530 expect_threads[0].Stack.StartOfMemoryRange = 0x1000; | 530 expect_threads[0].Stack.StartOfMemoryRange = 0x1000; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 | 675 |
| 676 TEST(MinidumpThreadWriterDeathTest, InitializeFromSnapshot_NoContext) { | 676 TEST(MinidumpThreadWriterDeathTest, InitializeFromSnapshot_NoContext) { |
| 677 ASSERT_DEATH( | 677 ASSERT_DEATH( |
| 678 RunInitializeFromSnapshotTest<InitializeFromSnapshotNoContextTraits>( | 678 RunInitializeFromSnapshotTest<InitializeFromSnapshotNoContextTraits>( |
| 679 false), "context_"); | 679 false), "context_"); |
| 680 } | 680 } |
| 681 | 681 |
| 682 } // namespace | 682 } // namespace |
| 683 } // namespace test | 683 } // namespace test |
| 684 } // namespace crashpad | 684 } // namespace crashpad |
| OLD | NEW |