summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/tools/freezer.cpp26
-rw-r--r--src/core/tools/freezer.h7
2 files changed, 21 insertions, 12 deletions
diff --git a/src/core/tools/freezer.cpp b/src/core/tools/freezer.cpp
index 4ca1870f2..5c674a099 100644
--- a/src/core/tools/freezer.cpp
+++ b/src/core/tools/freezer.cpp
@@ -113,19 +113,15 @@ void Freezer::Unfreeze(VAddr address) {
113bool Freezer::IsFrozen(VAddr address) const { 113bool Freezer::IsFrozen(VAddr address) const {
114 std::lock_guard lock{entries_mutex}; 114 std::lock_guard lock{entries_mutex};
115 115
116 return std::find_if(entries.begin(), entries.end(), [address](const Entry& entry) { 116 return FindEntry(address) != entries.cend();
117 return entry.address == address;
118 }) != entries.end();
119} 117}
120 118
121void Freezer::SetFrozenValue(VAddr address, u64 value) { 119void Freezer::SetFrozenValue(VAddr address, u64 value) {
122 std::lock_guard lock{entries_mutex}; 120 std::lock_guard lock{entries_mutex};
123 121
124 const auto iter = std::find_if(entries.begin(), entries.end(), [address](const Entry& entry) { 122 const auto iter = FindEntry(address);
125 return entry.address == address;
126 });
127 123
128 if (iter == entries.end()) { 124 if (iter == entries.cend()) {
129 LOG_ERROR(Common_Memory, 125 LOG_ERROR(Common_Memory,
130 "Tried to set freeze value for address={:016X} that is not frozen!", address); 126 "Tried to set freeze value for address={:016X} that is not frozen!", address);
131 return; 127 return;
@@ -140,11 +136,9 @@ void Freezer::SetFrozenValue(VAddr address, u64 value) {
140std::optional<Freezer::Entry> Freezer::GetEntry(VAddr address) const { 136std::optional<Freezer::Entry> Freezer::GetEntry(VAddr address) const {
141 std::lock_guard lock{entries_mutex}; 137 std::lock_guard lock{entries_mutex};
142 138
143 const auto iter = std::find_if(entries.begin(), entries.end(), [address](const Entry& entry) { 139 const auto iter = FindEntry(address);
144 return entry.address == address;
145 });
146 140
147 if (iter == entries.end()) { 141 if (iter == entries.cend()) {
148 return std::nullopt; 142 return std::nullopt;
149 } 143 }
150 144
@@ -157,6 +151,16 @@ std::vector<Freezer::Entry> Freezer::GetEntries() const {
157 return entries; 151 return entries;
158} 152}
159 153
154Freezer::Entries::iterator Freezer::FindEntry(VAddr address) {
155 return std::find_if(entries.begin(), entries.end(),
156 [address](const Entry& entry) { return entry.address == address; });
157}
158
159Freezer::Entries::const_iterator Freezer::FindEntry(VAddr address) const {
160 return std::find_if(entries.begin(), entries.end(),
161 [address](const Entry& entry) { return entry.address == address; });
162}
163
160void Freezer::FrameCallback(std::uintptr_t, std::chrono::nanoseconds ns_late) { 164void Freezer::FrameCallback(std::uintptr_t, std::chrono::nanoseconds ns_late) {
161 if (!IsActive()) { 165 if (!IsActive()) {
162 LOG_DEBUG(Common_Memory, "Memory freezer has been deactivated, ending callback events."); 166 LOG_DEBUG(Common_Memory, "Memory freezer has been deactivated, ending callback events.");
diff --git a/src/core/tools/freezer.h b/src/core/tools/freezer.h
index 2b2326bc4..0fdb701a7 100644
--- a/src/core/tools/freezer.h
+++ b/src/core/tools/freezer.h
@@ -73,13 +73,18 @@ public:
73 std::vector<Entry> GetEntries() const; 73 std::vector<Entry> GetEntries() const;
74 74
75private: 75private:
76 using Entries = std::vector<Entry>;
77
78 Entries::iterator FindEntry(VAddr address);
79 Entries::const_iterator FindEntry(VAddr address) const;
80
76 void FrameCallback(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); 81 void FrameCallback(std::uintptr_t user_data, std::chrono::nanoseconds ns_late);
77 void FillEntryReads(); 82 void FillEntryReads();
78 83
79 std::atomic_bool active{false}; 84 std::atomic_bool active{false};
80 85
81 mutable std::mutex entries_mutex; 86 mutable std::mutex entries_mutex;
82 std::vector<Entry> entries; 87 Entries entries;
83 88
84 std::shared_ptr<Core::Timing::EventType> event; 89 std::shared_ptr<Core::Timing::EventType> event;
85 Core::Timing::CoreTiming& core_timing; 90 Core::Timing::CoreTiming& core_timing;