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 <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // The global GetUserDataSnapshot will return an empty snapshot if the ref | 76 // The global GetUserDataSnapshot will return an empty snapshot if the ref |
77 // or id is not valid. | 77 // or id is not valid. |
78 activity_snapshot_.user_data_stack.push_back(global->GetUserDataSnapshot( | 78 activity_snapshot_.user_data_stack.push_back(global->GetUserDataSnapshot( |
79 activity_snapshot_.process_id, activity.user_data_ref, | 79 activity_snapshot_.process_id, activity.user_data_ref, |
80 activity.user_data_id)); | 80 activity.user_data_id)); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 GlobalActivityAnalyzer::GlobalActivityAnalyzer( | 84 GlobalActivityAnalyzer::GlobalActivityAnalyzer( |
85 std::unique_ptr<PersistentMemoryAllocator> allocator) | 85 std::unique_ptr<PersistentMemoryAllocator> allocator) |
86 : allocator_(std::move(allocator)), allocator_iterator_(allocator_.get()) { | 86 : allocator_(std::move(allocator)), |
| 87 analysis_stamp_(0LL), |
| 88 allocator_iterator_(allocator_.get()) { |
87 DCHECK(allocator_); | 89 DCHECK(allocator_); |
88 } | 90 } |
89 | 91 |
90 GlobalActivityAnalyzer::~GlobalActivityAnalyzer() {} | 92 GlobalActivityAnalyzer::~GlobalActivityAnalyzer() {} |
91 | 93 |
92 #if !defined(OS_NACL) | 94 #if !defined(OS_NACL) |
93 // static | 95 // static |
94 std::unique_ptr<GlobalActivityAnalyzer> GlobalActivityAnalyzer::CreateWithFile( | 96 std::unique_ptr<GlobalActivityAnalyzer> GlobalActivityAnalyzer::CreateWithFile( |
95 const FilePath& file_path) { | 97 const FilePath& file_path) { |
96 // Map the file read-write so it can guarantee consistency between | 98 // Map the file read-write so it can guarantee consistency between |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 ref, GlobalActivityTracker::kTypeIdGlobalLogMessage, | 227 ref, GlobalActivityTracker::kTypeIdGlobalLogMessage, |
226 PersistentMemoryAllocator::kSizeAny); | 228 PersistentMemoryAllocator::kSizeAny); |
227 if (message) | 229 if (message) |
228 messages.push_back(message); | 230 messages.push_back(message); |
229 } | 231 } |
230 | 232 |
231 return messages; | 233 return messages; |
232 } | 234 } |
233 | 235 |
234 std::vector<GlobalActivityTracker::ModuleInfo> | 236 std::vector<GlobalActivityTracker::ModuleInfo> |
235 GlobalActivityAnalyzer::GetModules() { | 237 GlobalActivityAnalyzer::GetModules(int64_t pid) { |
236 std::vector<GlobalActivityTracker::ModuleInfo> modules; | 238 std::vector<GlobalActivityTracker::ModuleInfo> modules; |
237 | 239 |
238 PersistentMemoryAllocator::Iterator iter(allocator_.get()); | 240 PersistentMemoryAllocator::Iterator iter(allocator_.get()); |
239 const GlobalActivityTracker::ModuleInfoRecord* record; | 241 const GlobalActivityTracker::ModuleInfoRecord* record; |
240 while ( | 242 while ( |
241 (record = | 243 (record = |
242 iter.GetNextOfObject<GlobalActivityTracker::ModuleInfoRecord>()) != | 244 iter.GetNextOfObject<GlobalActivityTracker::ModuleInfoRecord>()) != |
243 nullptr) { | 245 nullptr) { |
| 246 int64_t process_id; |
| 247 int64_t create_stamp; |
| 248 if (!OwningProcess::GetOwningProcessId(&record->owner, &process_id, |
| 249 &create_stamp) || |
| 250 pid != process_id || create_stamp > analysis_stamp_) { |
| 251 continue; |
| 252 } |
244 GlobalActivityTracker::ModuleInfo info; | 253 GlobalActivityTracker::ModuleInfo info; |
245 if (record->DecodeTo(&info, allocator_->GetAllocSize( | 254 if (record->DecodeTo(&info, allocator_->GetAllocSize( |
246 allocator_->GetAsReference(record)))) { | 255 allocator_->GetAsReference(record)))) { |
247 modules.push_back(std::move(info)); | 256 modules.push_back(std::move(info)); |
248 } | 257 } |
249 } | 258 } |
250 | 259 |
251 return modules; | 260 return modules; |
252 } | 261 } |
253 | 262 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 } break; | 376 } break; |
368 } | 377 } |
369 } | 378 } |
370 | 379 |
371 // Reverse the list of PIDs so that they get popped in the order found. | 380 // Reverse the list of PIDs so that they get popped in the order found. |
372 std::reverse(process_ids_.begin(), process_ids_.end()); | 381 std::reverse(process_ids_.begin(), process_ids_.end()); |
373 } | 382 } |
374 | 383 |
375 } // namespace debug | 384 } // namespace debug |
376 } // namespace base | 385 } // namespace base |
OLD | NEW |