OLD | NEW |
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/callback.h" | 10 #include "base/callback.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 void PendingProfiles::GetProfiles( | 58 void PendingProfiles::GetProfiles( |
59 std::vector<StackSamplingProfiler::Profile>* profiles) { | 59 std::vector<StackSamplingProfiler::Profile>* profiles) { |
60 profiles->clear(); | 60 profiles->clear(); |
61 | 61 |
62 AutoLock scoped_lock(profiles_lock_); | 62 AutoLock scoped_lock(profiles_lock_); |
63 profiles_.swap(*profiles); | 63 profiles_.swap(*profiles); |
64 } | 64 } |
65 } // namespace | 65 } // namespace |
66 | 66 |
67 StackSamplingProfiler::Module::Module() : base_address(nullptr) {} | 67 StackSamplingProfiler::Module::Module() : base_address(nullptr) {} |
| 68 StackSamplingProfiler::Module::Module(const void* base_address, |
| 69 const std::string& id, |
| 70 const FilePath& filename) |
| 71 : base_address(base_address), id(id), filename(filename) {} |
68 | 72 |
69 StackSamplingProfiler::Module::~Module() {} | 73 StackSamplingProfiler::Module::~Module() {} |
70 | 74 |
71 StackSamplingProfiler::Frame::Frame() | 75 StackSamplingProfiler::Frame::Frame() |
72 : instruction_pointer(nullptr), | 76 : instruction_pointer(nullptr), |
73 module_index(-1) {} | 77 module_index(-1) {} |
74 | 78 |
| 79 StackSamplingProfiler::Frame::Frame(const void* instruction_pointer, |
| 80 int module_index) |
| 81 : instruction_pointer(instruction_pointer), |
| 82 module_index(module_index) {} |
| 83 |
75 StackSamplingProfiler::Frame::~Frame() {} | 84 StackSamplingProfiler::Frame::~Frame() {} |
76 | 85 |
77 StackSamplingProfiler::Profile::Profile() : preserve_sample_ordering(false) {} | 86 StackSamplingProfiler::Profile::Profile() : preserve_sample_ordering(false) {} |
78 | 87 |
79 StackSamplingProfiler::Profile::~Profile() {} | 88 StackSamplingProfiler::Profile::~Profile() {} |
80 | 89 |
81 class StackSamplingProfiler::SamplingThread : public PlatformThread::Delegate { | 90 class StackSamplingProfiler::SamplingThread : public PlatformThread::Delegate { |
82 public: | 91 public: |
83 // Samples stacks using |native_sampler|. When complete, invokes | 92 // Samples stacks using |native_sampler|. When complete, invokes |
84 // |profiles_callback| with the collected profiles. |profiles_callback| must | 93 // |profiles_callback| with the collected profiles. |profiles_callback| must |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 261 } |
253 | 262 |
254 bool operator<(const StackSamplingProfiler::Frame &a, | 263 bool operator<(const StackSamplingProfiler::Frame &a, |
255 const StackSamplingProfiler::Frame &b) { | 264 const StackSamplingProfiler::Frame &b) { |
256 return (a.module_index < b.module_index) || | 265 return (a.module_index < b.module_index) || |
257 (a.module_index == b.module_index && | 266 (a.module_index == b.module_index && |
258 a.instruction_pointer < b.instruction_pointer); | 267 a.instruction_pointer < b.instruction_pointer); |
259 } | 268 } |
260 | 269 |
261 } // namespace base | 270 } // namespace base |
OLD | NEW |