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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 76 } |
77 | 77 |
78 ThreadActivityAnalyzer* GlobalActivityAnalyzer::GetAnalyzerForThread( | 78 ThreadActivityAnalyzer* GlobalActivityAnalyzer::GetAnalyzerForThread( |
79 const ThreadKey& key) { | 79 const ThreadKey& key) { |
80 auto found = analyzers_.find(key); | 80 auto found = analyzers_.find(key); |
81 if (found == analyzers_.end()) | 81 if (found == analyzers_.end()) |
82 return nullptr; | 82 return nullptr; |
83 return found->second.get(); | 83 return found->second.get(); |
84 } | 84 } |
85 | 85 |
| 86 std::vector<std::string> GlobalActivityAnalyzer::GetLogMessages() { |
| 87 std::vector<std::string> messages; |
| 88 PersistentMemoryAllocator::Reference ref; |
| 89 |
| 90 PersistentMemoryAllocator::Iterator iter(allocator_.get()); |
| 91 while ((ref = iter.GetNextOfType( |
| 92 GlobalActivityTracker::kTypeIdGlobalLogMessage)) != 0) { |
| 93 const char* message = allocator_->GetAsArray<char>( |
| 94 ref, GlobalActivityTracker::kTypeIdGlobalLogMessage, |
| 95 PersistentMemoryAllocator::kSizeAny); |
| 96 if (message) |
| 97 messages.push_back(message); |
| 98 } |
| 99 |
| 100 return messages; |
| 101 } |
| 102 |
86 GlobalActivityAnalyzer::ProgramLocation | 103 GlobalActivityAnalyzer::ProgramLocation |
87 GlobalActivityAnalyzer::GetProgramLocationFromAddress(uint64_t address) { | 104 GlobalActivityAnalyzer::GetProgramLocationFromAddress(uint64_t address) { |
88 // TODO(bcwhite): Implement this. | 105 // TODO(bcwhite): Implement this. |
89 return { 0, 0 }; | 106 return { 0, 0 }; |
90 } | 107 } |
91 | 108 |
92 void GlobalActivityAnalyzer::PrepareAllAnalyzers() { | 109 void GlobalActivityAnalyzer::PrepareAllAnalyzers() { |
93 // Fetch all the records. This will retrieve only ones created since the | 110 // Fetch all the records. This will retrieve only ones created since the |
94 // last run since the PMA iterator will continue from where it left off. | 111 // last run since the PMA iterator will continue from where it left off. |
95 uint32_t type; | 112 uint32_t type; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // Add this analyzer to the map of known ones, indexed by a unique thread | 144 // Add this analyzer to the map of known ones, indexed by a unique thread |
128 // identifier. | 145 // identifier. |
129 DCHECK(!base::ContainsKey(analyzers_, analyzer->GetThreadKey())); | 146 DCHECK(!base::ContainsKey(analyzers_, analyzer->GetThreadKey())); |
130 analyzer->allocator_reference_ = ref; | 147 analyzer->allocator_reference_ = ref; |
131 analyzers_[analyzer->GetThreadKey()] = std::move(analyzer); | 148 analyzers_[analyzer->GetThreadKey()] = std::move(analyzer); |
132 } | 149 } |
133 } | 150 } |
134 | 151 |
135 } // namespace debug | 152 } // namespace debug |
136 } // namespace base | 153 } // namespace base |
OLD | NEW |