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

Unified Diff: base/profiler/native_stack_sampler_win.cc

Issue 2444143002: Add process lifetime annotations to stack samples. (Closed)
Patch Set: abandon generator for on-the-fly Profiles creation Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/profiler/native_stack_sampler_posix.cc ('k') | base/profiler/stack_sampling_profiler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/profiler/native_stack_sampler_win.cc
diff --git a/base/profiler/native_stack_sampler_win.cc b/base/profiler/native_stack_sampler_win.cc
index 9dbfcc92f969448988719cf84822b27a59684c4a..e1605109fe960d769523733b2a1190700b250d28 100644
--- a/base/profiler/native_stack_sampler_win.cc
+++ b/base/profiler/native_stack_sampler_win.cc
@@ -332,6 +332,8 @@ void SuspendThreadAndRecordStack(
void* stack_copy_buffer,
size_t stack_copy_buffer_size,
std::vector<RecordedFrame>* stack,
+ NativeStackSampler::AnnotateCallback annotator,
+ StackSamplingProfiler::Sample* sample,
NativeStackSamplerTestDelegate* test_delegate) {
DCHECK(stack->empty());
@@ -366,6 +368,8 @@ void SuspendThreadAndRecordStack(
if (PointsToGuardPage(bottom))
return;
+ (*annotator)(sample);
+
CopyMemoryFromStack(stack_copy_buffer,
reinterpret_cast<const void*>(bottom), top - bottom);
}
@@ -383,6 +387,7 @@ void SuspendThreadAndRecordStack(
class NativeStackSamplerWin : public NativeStackSampler {
public:
NativeStackSamplerWin(win::ScopedHandle thread_handle,
+ AnnotateCallback annotator,
NativeStackSamplerTestDelegate* test_delegate);
~NativeStackSamplerWin() override;
@@ -421,6 +426,8 @@ class NativeStackSamplerWin : public NativeStackSampler {
win::ScopedHandle thread_handle_;
+ const AnnotateCallback annotator_;
+
NativeStackSamplerTestDelegate* const test_delegate_;
// The stack base address corresponding to |thread_handle_|.
@@ -443,11 +450,15 @@ class NativeStackSamplerWin : public NativeStackSampler {
NativeStackSamplerWin::NativeStackSamplerWin(
win::ScopedHandle thread_handle,
+ AnnotateCallback annotator,
NativeStackSamplerTestDelegate* test_delegate)
- : thread_handle_(thread_handle.Take()), test_delegate_(test_delegate),
+ : thread_handle_(thread_handle.Take()),
+ annotator_(annotator),
+ test_delegate_(test_delegate),
thread_stack_base_address_(
GetThreadEnvironmentBlock(thread_handle_.Get())->Tib.StackBase),
stack_copy_buffer_(new unsigned char[kStackCopyBufferSize]) {
+ DCHECK(annotator_);
}
NativeStackSamplerWin::~NativeStackSamplerWin() {
@@ -469,7 +480,7 @@ void NativeStackSamplerWin::RecordStackSample(
std::vector<RecordedFrame> stack;
SuspendThreadAndRecordStack(thread_handle_.Get(), thread_stack_base_address_,
stack_copy_buffer_.get(), kStackCopyBufferSize,
- &stack, test_delegate_);
+ &stack, annotator_, sample, test_delegate_);
CopyToSample(stack, sample, current_modules_);
}
@@ -521,11 +532,11 @@ void NativeStackSamplerWin::CopyToSample(
const std::vector<RecordedFrame>& stack,
StackSamplingProfiler::Sample* sample,
std::vector<StackSamplingProfiler::Module>* modules) {
- sample->clear();
- sample->reserve(stack.size());
+ sample->frames.clear();
+ sample->frames.reserve(stack.size());
for (const RecordedFrame& frame : stack) {
- sample->push_back(StackSamplingProfiler::Frame(
+ sample->frames.push_back(StackSamplingProfiler::Frame(
reinterpret_cast<uintptr_t>(frame.instruction_pointer),
GetModuleIndex(frame.module.Get(), modules)));
}
@@ -535,6 +546,7 @@ void NativeStackSamplerWin::CopyToSample(
std::unique_ptr<NativeStackSampler> NativeStackSampler::Create(
PlatformThreadId thread_id,
+ AnnotateCallback annotator,
NativeStackSamplerTestDelegate* test_delegate) {
#if _WIN64
// Get the thread's handle.
@@ -545,7 +557,7 @@ std::unique_ptr<NativeStackSampler> NativeStackSampler::Create(
if (thread_handle) {
return std::unique_ptr<NativeStackSampler>(new NativeStackSamplerWin(
- win::ScopedHandle(thread_handle), test_delegate));
+ win::ScopedHandle(thread_handle), annotator, test_delegate));
}
#endif
return std::unique_ptr<NativeStackSampler>();
« no previous file with comments | « base/profiler/native_stack_sampler_posix.cc ('k') | base/profiler/stack_sampling_profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698