OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/debug/activity_analyzer.h" | 5 #include "base/debug/activity_analyzer.h" |
6 | 6 |
7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/memory_mapped_file.h" | 9 #include "base/files/memory_mapped_file.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 const char* message = allocator_->GetAsArray<char>( | 152 const char* message = allocator_->GetAsArray<char>( |
153 ref, GlobalActivityTracker::kTypeIdGlobalLogMessage, | 153 ref, GlobalActivityTracker::kTypeIdGlobalLogMessage, |
154 PersistentMemoryAllocator::kSizeAny); | 154 PersistentMemoryAllocator::kSizeAny); |
155 if (message) | 155 if (message) |
156 messages.push_back(message); | 156 messages.push_back(message); |
157 } | 157 } |
158 | 158 |
159 return messages; | 159 return messages; |
160 } | 160 } |
161 | 161 |
| 162 std::vector<GlobalActivityTracker::ModuleInfo> |
| 163 GlobalActivityAnalyzer::GetModules() { |
| 164 std::vector<GlobalActivityTracker::ModuleInfo> modules; |
| 165 PersistentMemoryAllocator::Reference ref; |
| 166 |
| 167 PersistentMemoryAllocator::Iterator iter(allocator_.get()); |
| 168 while ((ref = iter.GetNextOfType( |
| 169 GlobalActivityTracker::kTypeIdModuleInfoRecord)) != 0) { |
| 170 const GlobalActivityTracker::ModuleInfoRecord* record = |
| 171 allocator_->GetAsObject<GlobalActivityTracker::ModuleInfoRecord>( |
| 172 ref, GlobalActivityTracker::kTypeIdModuleInfoRecord); |
| 173 if (record) { |
| 174 GlobalActivityTracker::ModuleInfo info; |
| 175 record->DecodeTo(&info, allocator_->GetAllocSize(ref)); |
| 176 modules.push_back(std::move(info)); |
| 177 } |
| 178 } |
| 179 |
| 180 return modules; |
| 181 } |
| 182 |
162 GlobalActivityAnalyzer::ProgramLocation | 183 GlobalActivityAnalyzer::ProgramLocation |
163 GlobalActivityAnalyzer::GetProgramLocationFromAddress(uint64_t address) { | 184 GlobalActivityAnalyzer::GetProgramLocationFromAddress(uint64_t address) { |
164 // TODO(bcwhite): Implement this. | 185 // TODO(bcwhite): Implement this. |
165 return { 0, 0 }; | 186 return { 0, 0 }; |
166 } | 187 } |
167 | 188 |
168 void GlobalActivityAnalyzer::PrepareAllAnalyzers() { | 189 void GlobalActivityAnalyzer::PrepareAllAnalyzers() { |
169 // Fetch all the records. This will retrieve only ones created since the | 190 // Fetch all the records. This will retrieve only ones created since the |
170 // last run since the PMA iterator will continue from where it left off. | 191 // last run since the PMA iterator will continue from where it left off. |
171 uint32_t type; | 192 uint32_t type; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // Add this analyzer to the map of known ones, indexed by a unique thread | 225 // Add this analyzer to the map of known ones, indexed by a unique thread |
205 // identifier. | 226 // identifier. |
206 DCHECK(!base::ContainsKey(analyzers_, analyzer->GetThreadKey())); | 227 DCHECK(!base::ContainsKey(analyzers_, analyzer->GetThreadKey())); |
207 analyzer->allocator_reference_ = ref; | 228 analyzer->allocator_reference_ = ref; |
208 analyzers_[analyzer->GetThreadKey()] = std::move(analyzer); | 229 analyzers_[analyzer->GetThreadKey()] = std::move(analyzer); |
209 } | 230 } |
210 } | 231 } |
211 | 232 |
212 } // namespace debug | 233 } // namespace debug |
213 } // namespace base | 234 } // namespace base |
OLD | NEW |