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

Side by Side Diff: base/profiler/stack_sampling_profiler.cc

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
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 #include "base/profiler/stack_sampling_profiler.h" 5 #include "base/profiler/stack_sampling_profiler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // StackSamplingProfiler ------------------------------------------------------ 210 // StackSamplingProfiler ------------------------------------------------------
211 211
212 StackSamplingProfiler::SamplingParams::SamplingParams() 212 StackSamplingProfiler::SamplingParams::SamplingParams()
213 : initial_delay(TimeDelta::FromMilliseconds(0)), 213 : initial_delay(TimeDelta::FromMilliseconds(0)),
214 bursts(1), 214 bursts(1),
215 burst_interval(TimeDelta::FromMilliseconds(10000)), 215 burst_interval(TimeDelta::FromMilliseconds(10000)),
216 samples_per_burst(300), 216 samples_per_burst(300),
217 sampling_interval(TimeDelta::FromMilliseconds(100)) { 217 sampling_interval(TimeDelta::FromMilliseconds(100)) {
218 } 218 }
219 219
220 StackSamplingProfiler::StackSamplingProfiler(PlatformThreadId thread_id, 220 StackSamplingProfiler::StackSamplingProfiler(
221 const SamplingParams& params, 221 PlatformThreadId thread_id,
222 const CompletedCallback& callback) 222 const SamplingParams& params,
223 : thread_id_(thread_id), params_(params), completed_callback_(callback) {} 223 const CompletedCallback& callback)
224 : StackSamplingProfiler(thread_id, params, callback, nullptr) {}
225
226 StackSamplingProfiler::StackSamplingProfiler(
227 PlatformThreadId thread_id,
228 const SamplingParams& params,
229 const CompletedCallback& callback,
230 NativeStackSamplerTestDelegate* test_delegate)
231 : thread_id_(thread_id), params_(params), completed_callback_(callback),
232 test_delegate_(test_delegate) {
233 }
224 234
225 StackSamplingProfiler::~StackSamplingProfiler() { 235 StackSamplingProfiler::~StackSamplingProfiler() {
226 Stop(); 236 Stop();
227 if (!sampling_thread_handle_.is_null()) 237 if (!sampling_thread_handle_.is_null())
228 PlatformThread::Join(sampling_thread_handle_); 238 PlatformThread::Join(sampling_thread_handle_);
229 } 239 }
230 240
231 // static 241 // static
232 void StackSamplingProfiler::StartAndRunAsync( 242 void StackSamplingProfiler::StartAndRunAsync(
233 PlatformThreadId thread_id, 243 PlatformThreadId thread_id,
234 const SamplingParams& params, 244 const SamplingParams& params,
235 const CompletedCallback& callback) { 245 const CompletedCallback& callback) {
236 CHECK(ThreadTaskRunnerHandle::Get()); 246 CHECK(ThreadTaskRunnerHandle::Get());
237 AsyncRunner::Run(thread_id, params, callback); 247 AsyncRunner::Run(thread_id, params, callback);
238 } 248 }
239 249
240 void StackSamplingProfiler::Start() { 250 void StackSamplingProfiler::Start() {
241 if (completed_callback_.is_null()) 251 if (completed_callback_.is_null())
242 return; 252 return;
243 253
244 scoped_ptr<NativeStackSampler> native_sampler = 254 scoped_ptr<NativeStackSampler> native_sampler =
245 NativeStackSampler::Create(thread_id_); 255 NativeStackSampler::Create(thread_id_, test_delegate_);
246 if (!native_sampler) 256 if (!native_sampler)
247 return; 257 return;
248 258
249 sampling_thread_.reset( 259 sampling_thread_.reset(
250 new SamplingThread(native_sampler.Pass(), params_, completed_callback_)); 260 new SamplingThread(native_sampler.Pass(), params_, completed_callback_));
251 if (!PlatformThread::Create(0, sampling_thread_.get(), 261 if (!PlatformThread::Create(0, sampling_thread_.get(),
252 &sampling_thread_handle_)) 262 &sampling_thread_handle_))
253 sampling_thread_.reset(); 263 sampling_thread_.reset();
254 } 264 }
255 265
(...skipping 11 matching lines...) Expand all
267 } 277 }
268 278
269 bool operator<(const StackSamplingProfiler::Frame &a, 279 bool operator<(const StackSamplingProfiler::Frame &a,
270 const StackSamplingProfiler::Frame &b) { 280 const StackSamplingProfiler::Frame &b) {
271 return (a.module_index < b.module_index) || 281 return (a.module_index < b.module_index) ||
272 (a.module_index == b.module_index && 282 (a.module_index == b.module_index &&
273 a.instruction_pointer < b.instruction_pointer); 283 a.instruction_pointer < b.instruction_pointer);
274 } 284 }
275 285
276 } // namespace base 286 } // namespace base
OLDNEW
« no previous file with comments | « base/profiler/stack_sampling_profiler.h ('k') | base/profiler/stack_sampling_profiler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698