1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_PROFILER_THREAD_DELEGATE_H_
6 #define BASE_PROFILER_THREAD_DELEGATE_H_
10 #include "base/base_export.h"
11 #include "base/profiler/register_context.h"
12 #include "base/threading/platform_thread.h"
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 {
22 ThreadDelegate() = default;
23 virtual ~ThreadDelegate() = default;
25 ThreadDelegate(const ThreadDelegate&) = delete;
26 ThreadDelegate& operator=(const ThreadDelegate&) = delete;
28 // Gets the platform-specific id for the thread.
29 virtual PlatformThreadId GetThreadId() const = 0;
31 // Gets the base address of the thread's stack.
32 virtual uintptr_t GetStackBaseAddress() const = 0;
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.
37 virtual std::vector<uintptr_t*> GetRegistersToRewrite(
38 RegisterContext* thread_context) = 0;
43 #endif // BASE_PROFILER_THREAD_DELEGATE_H_