mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
DebugInterface: Watches methods added
Move Watches to Common
This commit is contained in:
@ -9,6 +9,7 @@ add_library(common
|
||||
Crypto/AES.cpp
|
||||
Crypto/bn.cpp
|
||||
Crypto/ec.cpp
|
||||
Debug/Watches.cpp
|
||||
ENetUtil.cpp
|
||||
File.cpp
|
||||
FileSearch.cpp
|
||||
|
@ -60,6 +60,7 @@
|
||||
<ClInclude Include="Config\Layer.h" />
|
||||
<ClInclude Include="CPUDetect.h" />
|
||||
<ClInclude Include="DebugInterface.h" />
|
||||
<ClInclude Include="Debug\Watches.h" />
|
||||
<ClInclude Include="ENetUtil.h" />
|
||||
<ClInclude Include="Event.h" />
|
||||
<ClInclude Include="File.h" />
|
||||
@ -173,6 +174,7 @@
|
||||
<ClCompile Include="Config\Config.cpp" />
|
||||
<ClCompile Include="Config\ConfigInfo.cpp" />
|
||||
<ClCompile Include="Config\Layer.cpp" />
|
||||
<ClCompile Include="Debug\Watches.cpp" />
|
||||
<ClCompile Include="ENetUtil.cpp" />
|
||||
<ClCompile Include="File.cpp" />
|
||||
<ClCompile Include="FileSearch.cpp" />
|
||||
@ -239,4 +241,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
@ -16,6 +16,9 @@
|
||||
<Filter Include="GL\GLExtensions">
|
||||
<UniqueIdentifier>{c1d6f1fe-5ec5-406d-84f2-ed64d733d2c3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Debug">
|
||||
<UniqueIdentifier>{c6eef5b2-5e78-4f8c-8a51-8a4ffb768137}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Align.h" />
|
||||
@ -37,7 +40,6 @@
|
||||
<ClInclude Include="Config\Config.h" />
|
||||
<ClInclude Include="Config\Enums.h" />
|
||||
<ClInclude Include="Config\Layer.h" />
|
||||
<ClInclude Include="Config\Section.h" />
|
||||
<ClInclude Include="CPUDetect.h" />
|
||||
<ClInclude Include="DebugInterface.h" />
|
||||
<ClInclude Include="ENetUtil.h" />
|
||||
@ -261,6 +263,10 @@
|
||||
<ClInclude Include="GL\GLExtensions\ARB_texture_compression_bptc.h">
|
||||
<Filter>GL\GLExtensions</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Config\ConfigInfo.h" />
|
||||
<ClInclude Include="Debug\Watches.h">
|
||||
<Filter>Debug</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CDUtils.cpp" />
|
||||
@ -268,7 +274,6 @@
|
||||
<ClCompile Include="CommonFuncs.cpp" />
|
||||
<ClCompile Include="Config\Config.cpp" />
|
||||
<ClCompile Include="Config\Layer.cpp" />
|
||||
<ClCompile Include="Config\Section.cpp" />
|
||||
<ClCompile Include="ENetUtil.cpp" />
|
||||
<ClCompile Include="FileSearch.cpp" />
|
||||
<ClCompile Include="FileUtil.cpp" />
|
||||
@ -331,6 +336,10 @@
|
||||
<ClCompile Include="File.cpp" />
|
||||
<ClCompile Include="LdrWatcher.cpp" />
|
||||
<ClCompile Include="CompatPatches.cpp" />
|
||||
<ClCompile Include="Config\ConfigInfo.cpp" />
|
||||
<ClCompile Include="Debug\Watches.cpp">
|
||||
<Filter>Debug</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="CMakeLists.txt" />
|
||||
@ -338,4 +347,4 @@
|
||||
<ItemGroup>
|
||||
<Natvis Include="BitField.natvis" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
118
Source/Core/Common/Debug/Watches.cpp
Normal file
118
Source/Core/Common/Debug/Watches.cpp
Normal file
@ -0,0 +1,118 @@
|
||||
// Copyright 2018 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Common/Debug/Watches.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
namespace Common::Debug
|
||||
{
|
||||
Watch::Watch(u32 address_, const std::string& name_, Watch::State is_enabled_)
|
||||
: address(address_), name(name_), is_enabled(is_enabled_)
|
||||
{
|
||||
}
|
||||
|
||||
std::size_t Watches::SetWatch(u32 address, const std::string& name)
|
||||
{
|
||||
const std::size_t size = m_watches.size();
|
||||
for (std::size_t index = 0; index < size; index++)
|
||||
{
|
||||
if (m_watches.at(index).address == address)
|
||||
{
|
||||
UpdateWatch(index, address, name);
|
||||
return index;
|
||||
}
|
||||
}
|
||||
m_watches.emplace_back(address, name, Watch::State::Enabled);
|
||||
return size;
|
||||
}
|
||||
|
||||
const Watch& Watches::GetWatch(std::size_t index) const
|
||||
{
|
||||
return m_watches.at(index);
|
||||
}
|
||||
|
||||
const std::vector<Watch>& Watches::GetWatches() const
|
||||
{
|
||||
return m_watches;
|
||||
}
|
||||
|
||||
void Watches::UnsetWatch(u32 address)
|
||||
{
|
||||
m_watches.erase(std::remove_if(m_watches.begin(), m_watches.end(),
|
||||
[address](const auto& watch) { return watch.address == address; }),
|
||||
m_watches.end());
|
||||
}
|
||||
|
||||
void Watches::UpdateWatch(std::size_t index, u32 address, const std::string& name)
|
||||
{
|
||||
m_watches[index].address = address;
|
||||
m_watches[index].name = name;
|
||||
}
|
||||
|
||||
void Watches::UpdateWatchAddress(std::size_t index, u32 address)
|
||||
{
|
||||
m_watches[index].address = address;
|
||||
}
|
||||
|
||||
void Watches::UpdateWatchName(std::size_t index, const std::string& name)
|
||||
{
|
||||
m_watches[index].name = name;
|
||||
}
|
||||
|
||||
void Watches::EnableWatch(std::size_t index)
|
||||
{
|
||||
m_watches[index].is_enabled = Watch::State::Enabled;
|
||||
}
|
||||
|
||||
void Watches::DisableWatch(std::size_t index)
|
||||
{
|
||||
m_watches[index].is_enabled = Watch::State::Disabled;
|
||||
}
|
||||
|
||||
bool Watches::HasEnabledWatch(u32 address) const
|
||||
{
|
||||
return std::any_of(m_watches.begin(), m_watches.end(), [address](const auto& watch) {
|
||||
return watch.address == address && watch.is_enabled == Watch::State::Enabled;
|
||||
});
|
||||
}
|
||||
|
||||
void Watches::RemoveWatch(std::size_t index)
|
||||
{
|
||||
m_watches.erase(m_watches.begin() + index);
|
||||
}
|
||||
|
||||
void Watches::LoadFromStrings(const std::vector<std::string>& watches)
|
||||
{
|
||||
for (const std::string& watch : watches)
|
||||
{
|
||||
std::stringstream ss;
|
||||
u32 address;
|
||||
std::string name;
|
||||
ss << std::hex << watch;
|
||||
ss >> address;
|
||||
ss >> std::ws;
|
||||
std::getline(ss, name);
|
||||
SetWatch(address, name);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> Watches::SaveToStrings() const
|
||||
{
|
||||
std::vector<std::string> watches;
|
||||
for (const auto& watch : m_watches)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << std::hex << watch.address << " " << watch.name;
|
||||
watches.push_back(ss.str());
|
||||
}
|
||||
return watches;
|
||||
}
|
||||
|
||||
void Watches::Clear()
|
||||
{
|
||||
m_watches.clear();
|
||||
}
|
||||
} // namespace Common::Debug
|
51
Source/Core/Common/Debug/Watches.h
Normal file
51
Source/Core/Common/Debug/Watches.h
Normal file
@ -0,0 +1,51 @@
|
||||
// Copyright 2018 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
namespace Common::Debug
|
||||
{
|
||||
struct Watch
|
||||
{
|
||||
enum class State : bool
|
||||
{
|
||||
Enabled = true,
|
||||
Disabled = false
|
||||
};
|
||||
|
||||
u32 address;
|
||||
std::string name;
|
||||
State is_enabled;
|
||||
|
||||
Watch(u32 address, const std::string& name, State is_enabled);
|
||||
};
|
||||
|
||||
class Watches
|
||||
{
|
||||
public:
|
||||
std::size_t SetWatch(u32 address, const std::string& name);
|
||||
const Watch& GetWatch(std::size_t index) const;
|
||||
const std::vector<Watch>& GetWatches() const;
|
||||
void UnsetWatch(u32 address);
|
||||
void UpdateWatch(std::size_t index, u32 address, const std::string& name);
|
||||
void UpdateWatchAddress(std::size_t index, u32 address);
|
||||
void UpdateWatchName(std::size_t index, const std::string& name);
|
||||
void EnableWatch(std::size_t index);
|
||||
void DisableWatch(std::size_t index);
|
||||
bool HasEnabledWatch(u32 address) const;
|
||||
void RemoveWatch(std::size_t index);
|
||||
void LoadFromStrings(const std::vector<std::string>& watches);
|
||||
std::vector<std::string> SaveToStrings() const;
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
std::vector<Watch> m_watches;
|
||||
};
|
||||
} // namespace Common::Debug
|
@ -7,6 +7,10 @@
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Debug/Watches.h"
|
||||
|
||||
class DebugInterface
|
||||
{
|
||||
@ -14,6 +18,22 @@ protected:
|
||||
virtual ~DebugInterface() {}
|
||||
|
||||
public:
|
||||
// Watches
|
||||
virtual std::size_t SetWatch(u32 address, const std::string& name = "") = 0;
|
||||
virtual const Common::Debug::Watch& GetWatch(std::size_t index) const = 0;
|
||||
virtual const std::vector<Common::Debug::Watch>& GetWatches() const = 0;
|
||||
virtual void UnsetWatch(u32 address) = 0;
|
||||
virtual void UpdateWatch(std::size_t index, u32 address, const std::string& name) = 0;
|
||||
virtual void UpdateWatchAddress(std::size_t index, u32 address) = 0;
|
||||
virtual void UpdateWatchName(std::size_t index, const std::string& name) = 0;
|
||||
virtual void EnableWatch(std::size_t index) = 0;
|
||||
virtual void DisableWatch(std::size_t index) = 0;
|
||||
virtual bool HasEnabledWatch(u32 address) const = 0;
|
||||
virtual void RemoveWatch(std::size_t index) = 0;
|
||||
virtual void LoadWatchesFromStrings(const std::vector<std::string>& watches) = 0;
|
||||
virtual std::vector<std::string> SaveWatchesToStrings() const = 0;
|
||||
virtual void ClearWatches() = 0;
|
||||
|
||||
virtual std::string Disassemble(unsigned int /*address*/) { return "NODEBUGGER"; }
|
||||
virtual std::string GetRawMemoryString(int /*memory*/, unsigned int /*address*/)
|
||||
{
|
||||
@ -26,7 +46,6 @@ public:
|
||||
virtual void ClearBreakpoint(unsigned int /*address*/) {}
|
||||
virtual void ClearAllBreakpoints() {}
|
||||
virtual void ToggleBreakpoint(unsigned int /*address*/) {}
|
||||
virtual void AddWatch(unsigned int /*address*/) {}
|
||||
virtual void ClearAllMemChecks() {}
|
||||
virtual bool IsMemCheck(unsigned int /*address*/, size_t /*size*/) { return false; }
|
||||
virtual void ToggleMemCheck(unsigned int /*address*/, bool /*read*/, bool /*write*/, bool /*log*/)
|
||||
@ -43,4 +62,5 @@ public:
|
||||
virtual void Patch(unsigned int /*address*/, unsigned int /*value*/) {}
|
||||
virtual int GetColor(unsigned int /*address*/) { return 0xFFFFFFFF; }
|
||||
virtual std::string GetDescription(unsigned int /*address*/) = 0;
|
||||
virtual void Clear() = 0;
|
||||
};
|
||||
|
Reference in New Issue
Block a user