OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BASE_PROFILER_WIN32_STACK_FRAME_UNWINDER_H_ |
| 6 #define BASE_PROFILER_WIN32_STACK_FRAME_UNWINDER_H_ |
| 7 |
| 8 #include <windows.h> |
| 9 |
| 10 #include "base/base_export.h" |
| 11 #include "base/macros.h" |
| 12 |
| 13 namespace base { |
| 14 |
| 15 #if !defined(_WIN64) |
| 16 // Allows code to compile for x86. Actual support for x86 will require either |
| 17 // refactoring these interfaces or separate architecture-specific interfaces. |
| 18 using PRUNTIME_FUNCTION = void*; |
| 19 #endif // !defined(_WIN64) |
| 20 |
| 21 // Instances of this class are expected to be created and destroyed for each |
| 22 // stack unwinding, outside of SuspendThread/ResumeThread. |
| 23 class BASE_EXPORT Win32StackFrameUnwinder { |
| 24 public: |
| 25 // Interface for Win32 unwind-related functionality this class depends |
| 26 // on. Provides a seam for testing. |
| 27 class BASE_EXPORT UnwindFunctions { |
| 28 public: |
| 29 virtual ~UnwindFunctions(); |
| 30 |
| 31 virtual PRUNTIME_FUNCTION LookupFunctionEntry(DWORD64 program_counter, |
| 32 PDWORD64 image_base) = 0; |
| 33 virtual void VirtualUnwind(DWORD64 image_base, |
| 34 DWORD64 program_counter, |
| 35 PRUNTIME_FUNCTION runtime_function, |
| 36 CONTEXT* context) = 0; |
| 37 protected: |
| 38 UnwindFunctions(); |
| 39 |
| 40 private: |
| 41 DISALLOW_COPY_AND_ASSIGN(UnwindFunctions); |
| 42 }; |
| 43 |
| 44 class BASE_EXPORT Win32UnwindFunctions : public UnwindFunctions { |
| 45 public: |
| 46 Win32UnwindFunctions(); |
| 47 |
| 48 virtual PRUNTIME_FUNCTION LookupFunctionEntry(DWORD64 program_counter, |
| 49 PDWORD64 image_base) override; |
| 50 |
| 51 virtual void VirtualUnwind(DWORD64 image_base, DWORD64 program_counter, |
| 52 PRUNTIME_FUNCTION runtime_function, |
| 53 CONTEXT* context) override; |
| 54 |
| 55 private: |
| 56 DISALLOW_COPY_AND_ASSIGN(Win32UnwindFunctions); |
| 57 }; |
| 58 |
| 59 Win32StackFrameUnwinder(); |
| 60 ~Win32StackFrameUnwinder(); |
| 61 |
| 62 bool TryUnwind(CONTEXT* context); |
| 63 |
| 64 private: |
| 65 // This function is for test purposes only. |
| 66 Win32StackFrameUnwinder(UnwindFunctions* unwind_functions); |
| 67 friend class Win32StackFrameUnwinderTest; |
| 68 |
| 69 // State associated with each stack unwinding. |
| 70 bool at_top_frame_; |
| 71 bool unwind_info_present_for_all_frames_; |
| 72 const void* pending_blacklisted_module_; |
| 73 |
| 74 Win32UnwindFunctions win32_unwind_functions_; |
| 75 UnwindFunctions* const unwind_functions_; |
| 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(Win32StackFrameUnwinder); |
| 78 }; |
| 79 |
| 80 } // namespace base |
| 81 |
| 82 #endif // BASE_PROFILER_WIN32_STACK_FRAME_UNWINDER_H_ |
OLD | NEW |