| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/profiler/win32_stack_frame_unwinder.h" |
| 6 |
| 7 #include <utility> |
| 5 #include <vector> | 8 #include <vector> |
| 6 | 9 |
| 7 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 8 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/profiler/win32_stack_frame_unwinder.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 13 |
| 12 namespace base { | 14 namespace base { |
| 13 | 15 |
| 14 namespace { | 16 namespace { |
| 15 | 17 |
| 16 class TestUnwindFunctions : public Win32StackFrameUnwinder::UnwindFunctions { | 18 class TestUnwindFunctions : public Win32StackFrameUnwinder::UnwindFunctions { |
| 17 public: | 19 public: |
| 18 TestUnwindFunctions(); | 20 TestUnwindFunctions(); |
| 19 | 21 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 TestUnwindFunctions* unwind_functions_; | 192 TestUnwindFunctions* unwind_functions_; |
| 191 | 193 |
| 192 private: | 194 private: |
| 193 DISALLOW_COPY_AND_ASSIGN(Win32StackFrameUnwinderTest); | 195 DISALLOW_COPY_AND_ASSIGN(Win32StackFrameUnwinderTest); |
| 194 }; | 196 }; |
| 195 | 197 |
| 196 scoped_ptr<Win32StackFrameUnwinder> | 198 scoped_ptr<Win32StackFrameUnwinder> |
| 197 Win32StackFrameUnwinderTest::CreateUnwinder() { | 199 Win32StackFrameUnwinderTest::CreateUnwinder() { |
| 198 scoped_ptr<TestUnwindFunctions> unwind_functions(new TestUnwindFunctions); | 200 scoped_ptr<TestUnwindFunctions> unwind_functions(new TestUnwindFunctions); |
| 199 unwind_functions_ = unwind_functions.get(); | 201 unwind_functions_ = unwind_functions.get(); |
| 200 return make_scoped_ptr(new Win32StackFrameUnwinder(unwind_functions.Pass())); | 202 return make_scoped_ptr( |
| 203 new Win32StackFrameUnwinder(std::move(unwind_functions))); |
| 201 } | 204 } |
| 202 | 205 |
| 203 // Checks the case where all frames have unwind information. | 206 // Checks the case where all frames have unwind information. |
| 204 TEST_F(Win32StackFrameUnwinderTest, FramesWithUnwindInfo) { | 207 TEST_F(Win32StackFrameUnwinderTest, FramesWithUnwindInfo) { |
| 205 scoped_ptr<Win32StackFrameUnwinder> unwinder = CreateUnwinder(); | 208 scoped_ptr<Win32StackFrameUnwinder> unwinder = CreateUnwinder(); |
| 206 CONTEXT context = {0}; | 209 CONTEXT context = {0}; |
| 207 ScopedModuleHandle module; | 210 ScopedModuleHandle module; |
| 208 | 211 |
| 209 unwind_functions_->SetHasRuntimeFunction(&context); | 212 unwind_functions_->SetHasRuntimeFunction(&context); |
| 210 EXPECT_TRUE(unwinder->TryUnwind(&context, &module)); | 213 EXPECT_TRUE(unwinder->TryUnwind(&context, &module)); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 runtime_function.BeginAddress = 128; | 435 runtime_function.BeginAddress = 128; |
| 433 runtime_function.EndAddress = 512; | 436 runtime_function.EndAddress = 512; |
| 434 unwind_functions_->SetHasRuntimeFunction(image_base_for_sanity_check, | 437 unwind_functions_->SetHasRuntimeFunction(image_base_for_sanity_check, |
| 435 runtime_function, 600, | 438 runtime_function, 600, |
| 436 &context); | 439 &context); |
| 437 EXPECT_FALSE(unwinder->TryUnwind(&context, &module)); | 440 EXPECT_FALSE(unwinder->TryUnwind(&context, &module)); |
| 438 } | 441 } |
| 439 } | 442 } |
| 440 | 443 |
| 441 } // namespace base | 444 } // namespace base |
| OLD | NEW |