mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
DebugInterface: Watches methods added
Move Watches to Common
This commit is contained in:
@ -243,83 +243,3 @@ bool TMemCheck::Action(DebugInterface* debug_interface, u32 value, u32 addr, boo
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Watches::IsAddressWatch(u32 address) const
|
||||
{
|
||||
return std::any_of(m_watches.begin(), m_watches.end(),
|
||||
[address](const auto& watch) { return watch.address == address; });
|
||||
}
|
||||
|
||||
Watches::TWatchesStr Watches::GetStrings() const
|
||||
{
|
||||
TWatchesStr watch_strings;
|
||||
for (const TWatch& watch : m_watches)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << std::hex << watch.address << " " << watch.name;
|
||||
watch_strings.push_back(ss.str());
|
||||
}
|
||||
|
||||
return watch_strings;
|
||||
}
|
||||
|
||||
void Watches::AddFromStrings(const TWatchesStr& watch_strings)
|
||||
{
|
||||
for (const std::string& watch_string : watch_strings)
|
||||
{
|
||||
TWatch watch;
|
||||
std::stringstream ss;
|
||||
ss << std::hex << watch_string;
|
||||
ss >> watch.address;
|
||||
ss >> std::ws;
|
||||
std::getline(ss, watch.name);
|
||||
Add(watch);
|
||||
}
|
||||
}
|
||||
|
||||
void Watches::Add(const TWatch& watch)
|
||||
{
|
||||
if (IsAddressWatch(watch.address))
|
||||
return;
|
||||
|
||||
m_watches.push_back(watch);
|
||||
}
|
||||
|
||||
void Watches::Add(u32 address)
|
||||
{
|
||||
// Only add new addresses
|
||||
if (IsAddressWatch(address))
|
||||
return;
|
||||
|
||||
TWatch watch; // watch settings
|
||||
watch.is_enabled = true;
|
||||
watch.address = address;
|
||||
|
||||
m_watches.push_back(watch);
|
||||
}
|
||||
|
||||
void Watches::Update(int count, u32 address)
|
||||
{
|
||||
m_watches.at(count).address = address;
|
||||
}
|
||||
|
||||
void Watches::UpdateName(int count, const std::string name)
|
||||
{
|
||||
m_watches.at(count).name = name;
|
||||
}
|
||||
|
||||
void Watches::Remove(u32 address)
|
||||
{
|
||||
const auto iter = std::find_if(m_watches.cbegin(), m_watches.cend(),
|
||||
[address](const auto& watch) { return watch.address == address; });
|
||||
|
||||
if (iter == m_watches.cend())
|
||||
return;
|
||||
|
||||
m_watches.erase(iter);
|
||||
}
|
||||
|
||||
void Watches::Clear()
|
||||
{
|
||||
m_watches.clear();
|
||||
}
|
||||
|
Reference in New Issue
Block a user