Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: base/profiler/native_stack_sampler.h

Issue 1423583002: Stack sampling profiler: handle unloaded and unloading modules (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: fix gcc compile Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/base.gyp ('k') | base/profiler/native_stack_sampler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_PROFILER_NATIVE_STACK_SAMPLER_H_ 5 #ifndef BASE_PROFILER_NATIVE_STACK_SAMPLER_H_
6 #define BASE_PROFILER_NATIVE_STACK_SAMPLER_H_ 6 #define BASE_PROFILER_NATIVE_STACK_SAMPLER_H_
7 7
8 #include "base/base_export.h"
9 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
9 #include "base/profiler/stack_sampling_profiler.h" 11 #include "base/profiler/stack_sampling_profiler.h"
10 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
11 13
12 namespace base { 14 namespace base {
13 15
16 class NativeStackSamplerTestDelegate;
17
14 // NativeStackSampler is an implementation detail of StackSamplingProfiler. It 18 // NativeStackSampler is an implementation detail of StackSamplingProfiler. It
15 // abstracts the native implementation required to record a stack sample for a 19 // abstracts the native implementation required to record a stack sample for a
16 // given thread. 20 // given thread.
17 class NativeStackSampler { 21 class NativeStackSampler {
18 public: 22 public:
19 virtual ~NativeStackSampler(); 23 virtual ~NativeStackSampler();
20 24
21 // Creates a stack sampler that records samples for |thread_handle|. Returns 25 // Creates a stack sampler that records samples for |thread_handle|. Returns
22 // null if this platform does not support stack sampling. 26 // null if this platform does not support stack sampling.
23 static scoped_ptr<NativeStackSampler> Create(PlatformThreadId thread_id); 27 static scoped_ptr<NativeStackSampler> Create(
28 PlatformThreadId thread_id,
29 NativeStackSamplerTestDelegate* test_delegate);
24 30
25 // The following functions are all called on the SamplingThread (not the 31 // The following functions are all called on the SamplingThread (not the
26 // thread being sampled). 32 // thread being sampled).
27 33
28 // Notifies the sampler that we're starting to record a new profile. Modules 34 // Notifies the sampler that we're starting to record a new profile. Modules
29 // shared across samples in the profile should be recorded in |modules|. 35 // shared across samples in the profile should be recorded in |modules|.
30 virtual void ProfileRecordingStarting( 36 virtual void ProfileRecordingStarting(
31 std::vector<StackSamplingProfiler::Module>* modules) = 0; 37 std::vector<StackSamplingProfiler::Module>* modules) = 0;
32 38
33 // Records a stack sample to |sample|. 39 // Records a stack sample to |sample|.
34 virtual void RecordStackSample(StackSamplingProfiler::Sample* sample) = 0; 40 virtual void RecordStackSample(StackSamplingProfiler::Sample* sample) = 0;
35 41
36 // Notifies the sampler that we've stopped recording the current 42 // Notifies the sampler that we've stopped recording the current
37 // profile. 43 // profile.
38 virtual void ProfileRecordingStopped() = 0; 44 virtual void ProfileRecordingStopped() = 0;
39 45
40 protected: 46 protected:
41 NativeStackSampler(); 47 NativeStackSampler();
42 48
43 private: 49 private:
44 DISALLOW_COPY_AND_ASSIGN(NativeStackSampler); 50 DISALLOW_COPY_AND_ASSIGN(NativeStackSampler);
45 }; 51 };
46 52
53 // NativeStackSamplerTestDelegate provides seams for test code to execute during
54 // stack collection.
55 class BASE_EXPORT NativeStackSamplerTestDelegate {
56 public:
57 virtual ~NativeStackSamplerTestDelegate();
58
59 // Called after copying the stack and resuming the target thread, but prior to
60 // walking the stack. Invoked on the SamplingThread.
61 virtual void OnPreStackWalk() = 0;
62
63 protected:
64 NativeStackSamplerTestDelegate();
65
66 private:
67 DISALLOW_COPY_AND_ASSIGN(NativeStackSamplerTestDelegate);
68 };
69
47 } // namespace base 70 } // namespace base
48 71
49 #endif // BASE_PROFILER_NATIVE_STACK_SAMPLER_H_ 72 #endif // BASE_PROFILER_NATIVE_STACK_SAMPLER_H_
50 73
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/profiler/native_stack_sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698