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/macros.h" | |
6 #include "base/profiler/win32_stack_frame_unwinder.h" | 5 #include "base/profiler/win32_stack_frame_unwinder.h" |
7 | 6 |
8 #include <windows.h> | 7 #include <windows.h> |
| 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" |
| 13 |
11 namespace base { | 14 namespace base { |
12 | 15 |
13 // Win32UnwindFunctions ------------------------------------------------------- | 16 // Win32UnwindFunctions ------------------------------------------------------- |
14 | 17 |
15 const HMODULE ModuleHandleTraits::kNonNullModuleForTesting = | 18 const HMODULE ModuleHandleTraits::kNonNullModuleForTesting = |
16 reinterpret_cast<HMODULE>(static_cast<uintptr_t>(-1)); | 19 reinterpret_cast<HMODULE>(static_cast<uintptr_t>(-1)); |
17 | 20 |
18 // static | 21 // static |
19 bool ModuleHandleTraits::CloseHandle(HMODULE handle) { | 22 bool ModuleHandleTraits::CloseHandle(HMODULE handle) { |
20 if (handle == kNonNullModuleForTesting) | 23 if (handle == kNonNullModuleForTesting) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 105 } |
103 | 106 |
104 } // namespace | 107 } // namespace |
105 | 108 |
106 // Win32StackFrameUnwinder ---------------------------------------------------- | 109 // Win32StackFrameUnwinder ---------------------------------------------------- |
107 | 110 |
108 Win32StackFrameUnwinder::UnwindFunctions::~UnwindFunctions() {} | 111 Win32StackFrameUnwinder::UnwindFunctions::~UnwindFunctions() {} |
109 Win32StackFrameUnwinder::UnwindFunctions::UnwindFunctions() {} | 112 Win32StackFrameUnwinder::UnwindFunctions::UnwindFunctions() {} |
110 | 113 |
111 Win32StackFrameUnwinder::Win32StackFrameUnwinder() | 114 Win32StackFrameUnwinder::Win32StackFrameUnwinder() |
112 : Win32StackFrameUnwinder(make_scoped_ptr(new Win32UnwindFunctions)) { | 115 : Win32StackFrameUnwinder(WrapUnique(new Win32UnwindFunctions)) {} |
113 } | |
114 | 116 |
115 Win32StackFrameUnwinder::~Win32StackFrameUnwinder() {} | 117 Win32StackFrameUnwinder::~Win32StackFrameUnwinder() {} |
116 | 118 |
117 bool Win32StackFrameUnwinder::TryUnwind(CONTEXT* context, | 119 bool Win32StackFrameUnwinder::TryUnwind(CONTEXT* context, |
118 ScopedModuleHandle* module) { | 120 ScopedModuleHandle* module) { |
119 #ifdef _WIN64 | 121 #ifdef _WIN64 |
120 ScopedModuleHandle frame_module = | 122 ScopedModuleHandle frame_module = |
121 unwind_functions_->GetModuleForProgramCounter(context->Rip); | 123 unwind_functions_->GetModuleForProgramCounter(context->Rip); |
122 if (!frame_module.IsValid()) { | 124 if (!frame_module.IsValid()) { |
123 // There's no loaded module containing the instruction pointer. This can be | 125 // There's no loaded module containing the instruction pointer. This can be |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 173 |
172 module->Set(frame_module.Take()); | 174 module->Set(frame_module.Take()); |
173 return true; | 175 return true; |
174 #else | 176 #else |
175 NOTREACHED(); | 177 NOTREACHED(); |
176 return false; | 178 return false; |
177 #endif | 179 #endif |
178 } | 180 } |
179 | 181 |
180 Win32StackFrameUnwinder::Win32StackFrameUnwinder( | 182 Win32StackFrameUnwinder::Win32StackFrameUnwinder( |
181 scoped_ptr<UnwindFunctions> unwind_functions) | 183 std::unique_ptr<UnwindFunctions> unwind_functions) |
182 : at_top_frame_(true), | 184 : at_top_frame_(true), unwind_functions_(std::move(unwind_functions)) {} |
183 unwind_functions_(std::move(unwind_functions)) {} | |
184 | 185 |
185 } // namespace base | 186 } // namespace base |
OLD | NEW |