thread_delegate_posix.h 1.4 KB

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