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 |
| 38 protected: |
| 39 UnwindFunctions(); |
| 40 |
| 41 private: |
| 42 DISALLOW_COPY_AND_ASSIGN(UnwindFunctions); |
| 43 }; |
| 44 |
| 45 class BASE_EXPORT Win32UnwindFunctions : public UnwindFunctions { |
| 46 public: |
| 47 Win32UnwindFunctions(); |
| 48 |
| 49 PRUNTIME_FUNCTION LookupFunctionEntry(DWORD64 program_counter, |
| 50 PDWORD64 image_base) override; |
| 51 |
| 52 void VirtualUnwind(DWORD64 image_base, |
| 53 DWORD64 program_counter, |
| 54 PRUNTIME_FUNCTION runtime_function, |
| 55 CONTEXT* context) override; |
| 56 |
| 57 private: |
| 58 DISALLOW_COPY_AND_ASSIGN(Win32UnwindFunctions); |
| 59 }; |
| 60 |
| 61 Win32StackFrameUnwinder(); |
| 62 ~Win32StackFrameUnwinder(); |
| 63 |
| 64 bool TryUnwind(CONTEXT* context); |
| 65 |
| 66 private: |
| 67 // This function is for test purposes only. |
| 68 Win32StackFrameUnwinder(UnwindFunctions* unwind_functions); |
| 69 friend class Win32StackFrameUnwinderTest; |
| 70 |
| 71 // State associated with each stack unwinding. |
| 72 bool at_top_frame_; |
| 73 bool unwind_info_present_for_all_frames_; |
| 74 const void* pending_blacklisted_module_; |
| 75 |
| 76 Win32UnwindFunctions win32_unwind_functions_; |
| 77 UnwindFunctions* const unwind_functions_; |
| 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(Win32StackFrameUnwinder); |
| 80 }; |
| 81 |
| 82 } // namespace base |
| 83 |
| 84 #endif // BASE_PROFILER_WIN32_STACK_FRAME_UNWINDER_H_ |
OLD | NEW |