thread_delegate.h 1.4 KB

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