• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef BASE_PROFILER_STACK_COPIER_SIGNAL_H_
6 #define BASE_PROFILER_STACK_COPIER_SIGNAL_H_
7 
8 #include <memory>
9 
10 #include "base/base_export.h"
11 #include "base/profiler/stack_copier.h"
12 
13 namespace base {
14 
15 class ThreadDelegate;
16 
17 // Supports stack copying on platforms where a signal must be delivered to the
18 // profiled thread and the stack is copied from the signal handler.
19 class BASE_EXPORT StackCopierSignal : public StackCopier {
20  public:
21   StackCopierSignal(std::unique_ptr<ThreadDelegate> thread_delegate);
22   ~StackCopierSignal() override;
23 
24   // StackCopier:
25   bool CopyStack(StackBuffer* stack_buffer,
26                  uintptr_t* stack_top,
27                  TimeTicks* timestamp,
28                  RegisterContext* thread_context,
29                  Delegate* delegate) override;
30 
31   using StackCopier::CopyStackContentsAndRewritePointers;
32 
33  protected:
34   std::vector<uintptr_t*> GetRegistersToRewrite(
35       RegisterContext* thread_context) override;
36 
37  private:
38   std::unique_ptr<ThreadDelegate> thread_delegate_;
39 };
40 
41 }  // namespace base
42 
43 #endif  // BASE_PROFILER_STACK_COPIER_SIGNAL_H_
44