thread_delegate_posix.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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_POSIX_H_
  5. #define BASE_PROFILER_THREAD_DELEGATE_POSIX_H_
  6. #include "base/base_export.h"
  7. #include "base/profiler/sampling_profiler_thread_token.h"
  8. #include "base/profiler/thread_delegate.h"
  9. #include "base/threading/platform_thread.h"
  10. namespace base {
  11. // Platform- and thread-specific implementation in support of stack sampling on
  12. // POSIX.
  13. class BASE_EXPORT ThreadDelegatePosix : public ThreadDelegate {
  14. public:
  15. static std::unique_ptr<ThreadDelegatePosix> Create(
  16. SamplingProfilerThreadToken thread_token);
  17. ~ThreadDelegatePosix() override;
  18. ThreadDelegatePosix(const ThreadDelegatePosix&) = delete;
  19. ThreadDelegatePosix& operator=(const ThreadDelegatePosix&) = delete;
  20. // ThreadDelegate
  21. PlatformThreadId GetThreadId() const override;
  22. uintptr_t GetStackBaseAddress() const override;
  23. std::vector<uintptr_t*> GetRegistersToRewrite(
  24. RegisterContext* thread_context) override;
  25. private:
  26. ThreadDelegatePosix(PlatformThreadId id, uintptr_t base_address);
  27. const PlatformThreadId thread_id_;
  28. const uintptr_t thread_stack_base_address_;
  29. };
  30. } // namespace base
  31. #endif // BASE_PROFILER_THREAD_DELEGATE_POSIX_H_