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

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

Issue 2444143002: Add process lifetime annotations to stack samples. (Closed)
Patch Set: abandon generator for on-the-fly Profiles creation Created 4 years 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 | « no previous file | base/profiler/native_stack_sampler_posix.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 <memory> 8 #include <memory>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/profiler/stack_sampling_profiler.h" 12 #include "base/profiler/stack_sampling_profiler.h"
13 #include "base/threading/platform_thread.h" 13 #include "base/threading/platform_thread.h"
14 14
15 namespace base { 15 namespace base {
16 16
17 class NativeStackSamplerTestDelegate; 17 class NativeStackSamplerTestDelegate;
18 18
19 // NativeStackSampler is an implementation detail of StackSamplingProfiler. It 19 // NativeStackSampler is an implementation detail of StackSamplingProfiler. It
20 // abstracts the native implementation required to record a stack sample for a 20 // abstracts the native implementation required to record a stack sample for a
21 // given thread. 21 // given thread.
22 class NativeStackSampler { 22 class NativeStackSampler {
23 public: 23 public:
24 // The callback type used to add annotations to a sample during collection.
25 // This is passed to the native sampler to be applied at the most appropriate
26 // time. It is a simple function-pointer because the generated code must be
27 // completely predictable and do nothing that could acquire a mutex; a
28 // Callback object is code outside the control of this object and could,
29 // for example, acquire a mutex as part of allocating memory for a LOG
30 // message.
31 using AnnotateCallback = void (*)(StackSamplingProfiler::Sample*);
32
24 virtual ~NativeStackSampler(); 33 virtual ~NativeStackSampler();
25 34
26 // Creates a stack sampler that records samples for |thread_handle|. Returns 35 // Creates a stack sampler that records samples for |thread_handle|. Returns
27 // null if this platform does not support stack sampling. 36 // null if this platform does not support stack sampling.
28 static std::unique_ptr<NativeStackSampler> Create( 37 static std::unique_ptr<NativeStackSampler> Create(
29 PlatformThreadId thread_id, 38 PlatformThreadId thread_id,
39 AnnotateCallback annotator,
30 NativeStackSamplerTestDelegate* test_delegate); 40 NativeStackSamplerTestDelegate* test_delegate);
31 41
32 // The following functions are all called on the SamplingThread (not the 42 // The following functions are all called on the SamplingThread (not the
33 // thread being sampled). 43 // thread being sampled).
34 44
35 // Notifies the sampler that we're starting to record a new profile. Modules 45 // Notifies the sampler that we're starting to record a new profile. Modules
36 // shared across samples in the profile should be recorded in |modules|. 46 // shared across samples in the profile should be recorded in |modules|.
37 virtual void ProfileRecordingStarting( 47 virtual void ProfileRecordingStarting(
38 std::vector<StackSamplingProfiler::Module>* modules) = 0; 48 std::vector<StackSamplingProfiler::Module>* modules) = 0;
39 49
(...skipping 25 matching lines...) Expand all
65 NativeStackSamplerTestDelegate(); 75 NativeStackSamplerTestDelegate();
66 76
67 private: 77 private:
68 DISALLOW_COPY_AND_ASSIGN(NativeStackSamplerTestDelegate); 78 DISALLOW_COPY_AND_ASSIGN(NativeStackSamplerTestDelegate);
69 }; 79 };
70 80
71 } // namespace base 81 } // namespace base
72 82
73 #endif // BASE_PROFILER_NATIVE_STACK_SAMPLER_H_ 83 #endif // BASE_PROFILER_NATIVE_STACK_SAMPLER_H_
74 84
OLDNEW
« no previous file with comments | « no previous file | base/profiler/native_stack_sampler_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698