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

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

Issue 2444143002: Add process lifetime annotations to stack samples. (Closed)
Patch Set: 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 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/native_stack_sampler.h" 5 #include "base/profiler/native_stack_sampler.h"
6 6
7 #include <objbase.h> 7 #include <objbase.h>
8 #include <windows.h> 8 #include <windows.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <winternl.h> 10 #include <winternl.h>
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 module_handle, modules->size() - 1)).first; 501 module_handle, modules->size() - 1)).first;
502 } 502 }
503 503
504 return loc->second; 504 return loc->second;
505 } 505 }
506 506
507 void NativeStackSamplerWin::CopyToSample( 507 void NativeStackSamplerWin::CopyToSample(
508 const std::vector<RecordedFrame>& stack, 508 const std::vector<RecordedFrame>& stack,
509 StackSamplingProfiler::Sample* sample, 509 StackSamplingProfiler::Sample* sample,
510 std::vector<StackSamplingProfiler::Module>* modules) { 510 std::vector<StackSamplingProfiler::Module>* modules) {
511 sample->clear(); 511 sample->frames.clear();
512 sample->reserve(stack.size()); 512 sample->frames.reserve(stack.size());
513 513
514 for (const RecordedFrame& frame : stack) { 514 for (const RecordedFrame& frame : stack) {
515 sample->push_back(StackSamplingProfiler::Frame( 515 sample->frames.push_back(StackSamplingProfiler::Frame(
516 reinterpret_cast<uintptr_t>(frame.instruction_pointer), 516 reinterpret_cast<uintptr_t>(frame.instruction_pointer),
517 GetModuleIndex(frame.module.Get(), modules))); 517 GetModuleIndex(frame.module.Get(), modules)));
518 } 518 }
519 } 519 }
520 520
521 } // namespace 521 } // namespace
522 522
523 std::unique_ptr<NativeStackSampler> NativeStackSampler::Create( 523 std::unique_ptr<NativeStackSampler> NativeStackSampler::Create(
524 PlatformThreadId thread_id, 524 PlatformThreadId thread_id,
525 NativeStackSamplerTestDelegate* test_delegate) { 525 NativeStackSamplerTestDelegate* test_delegate) {
526 #if _WIN64 526 #if _WIN64
527 // Get the thread's handle. 527 // Get the thread's handle.
528 HANDLE thread_handle = ::OpenThread( 528 HANDLE thread_handle = ::OpenThread(
529 THREAD_GET_CONTEXT | THREAD_SUSPEND_RESUME | THREAD_QUERY_INFORMATION, 529 THREAD_GET_CONTEXT | THREAD_SUSPEND_RESUME | THREAD_QUERY_INFORMATION,
530 FALSE, 530 FALSE,
531 thread_id); 531 thread_id);
532 532
533 if (thread_handle) { 533 if (thread_handle) {
534 return std::unique_ptr<NativeStackSampler>(new NativeStackSamplerWin( 534 return std::unique_ptr<NativeStackSampler>(new NativeStackSamplerWin(
535 win::ScopedHandle(thread_handle), test_delegate)); 535 win::ScopedHandle(thread_handle), test_delegate));
536 } 536 }
537 #endif 537 #endif
538 return std::unique_ptr<NativeStackSampler>(); 538 return std::unique_ptr<NativeStackSampler>();
539 } 539 }
540 540
541 } // namespace base 541 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/profiler/stack_sampling_profiler.h » ('j') | base/profiler/stack_sampling_profiler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698