| 6 | #define BASE_PROFILER_THREAD_DELEGATE_H_ |
| 7 |
| 8 | #include <vector> |
| 9 |
| 10 | #include "base/base_export.h" |
| 11 | #include "base/profiler/register_context.h" |
| 12 | #include "base/threading/platform_thread.h" |
| 13 |
| 14 | namespace base { |
| 15 |
| 16 | // Platform-specific thread and stack manipulation delegate, for use by the |
| 17 | // platform-independent stack copying/walking implementation in |
| 18 | // StackSamplerImpl. Provides the common interface across signal- and |
| 19 | // suspend-based stack copy implementations. |
| 20 | class BASE_EXPORT ThreadDelegate { |
| 21 | public: |
| 22 | ThreadDelegate() = default; |
| 23 | virtual ~ThreadDelegate() = default; |
| 24 |
| 25 | ThreadDelegate(const ThreadDelegate&) = delete; |
| 26 | ThreadDelegate& operator=(const ThreadDelegate&) = delete; |
| 27 |
| 28 | // Gets the platform-specific id for the thread. |
| 29 | virtual PlatformThreadId GetThreadId() const = 0; |
| 30 |
| 31 | // Gets the base address of the thread's stack. |
| 32 | virtual uintptr_t GetStackBaseAddress() const = 0; |
| 33 |
| 34 | // Returns a list of registers that should be rewritten to point into the |
| 35 | // stack copy, if they originally pointed into the original stack. |
| 36 | // May heap allocate. |
| 37 | virtual std::vector<uintptr_t*> GetRegistersToRewrite( |
| 38 | RegisterContext* thread_context) = 0; |
| 39 | }; |
| 40 |
| 41 | } // namespace base |
| 42 |
| 43 | #endif // BASE_PROFILER_THREAD_DELEGATE_H_ |
| 44 |