mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 00:59:44 -06:00
DebugInterface: Watches methods added
Move Watches to Common
This commit is contained in:
@ -15,6 +15,76 @@
|
||||
#include "Core/PowerPC/PPCSymbolDB.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
|
||||
std::size_t PPCDebugInterface::SetWatch(u32 address, const std::string& name)
|
||||
{
|
||||
return m_watches.SetWatch(address, name);
|
||||
}
|
||||
|
||||
const Common::Debug::Watch& PPCDebugInterface::GetWatch(std::size_t index) const
|
||||
{
|
||||
return m_watches.GetWatch(index);
|
||||
}
|
||||
|
||||
const std::vector<Common::Debug::Watch>& PPCDebugInterface::GetWatches() const
|
||||
{
|
||||
return m_watches.GetWatches();
|
||||
}
|
||||
|
||||
void PPCDebugInterface::UnsetWatch(u32 address)
|
||||
{
|
||||
m_watches.UnsetWatch(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::UpdateWatch(std::size_t index, u32 address, const std::string& name)
|
||||
{
|
||||
return m_watches.UpdateWatch(index, address, name);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::UpdateWatchAddress(std::size_t index, u32 address)
|
||||
{
|
||||
return m_watches.UpdateWatchAddress(index, address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::UpdateWatchName(std::size_t index, const std::string& name)
|
||||
{
|
||||
return m_watches.UpdateWatchName(index, name);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::EnableWatch(std::size_t index)
|
||||
{
|
||||
m_watches.EnableWatch(index);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::DisableWatch(std::size_t index)
|
||||
{
|
||||
m_watches.DisableWatch(index);
|
||||
}
|
||||
|
||||
bool PPCDebugInterface::HasEnabledWatch(u32 address) const
|
||||
{
|
||||
return m_watches.HasEnabledWatch(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::RemoveWatch(std::size_t index)
|
||||
{
|
||||
return m_watches.RemoveWatch(index);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::LoadWatchesFromStrings(const std::vector<std::string>& watches)
|
||||
{
|
||||
m_watches.LoadFromStrings(watches);
|
||||
}
|
||||
|
||||
std::vector<std::string> PPCDebugInterface::SaveWatchesToStrings() const
|
||||
{
|
||||
return m_watches.SaveToStrings();
|
||||
}
|
||||
|
||||
void PPCDebugInterface::ClearWatches()
|
||||
{
|
||||
m_watches.Clear();
|
||||
}
|
||||
|
||||
std::string PPCDebugInterface::Disassemble(unsigned int address)
|
||||
{
|
||||
// PowerPC::HostRead_U32 seemed to crash on shutdown
|
||||
@ -117,11 +187,6 @@ void PPCDebugInterface::ToggleBreakpoint(unsigned int address)
|
||||
PowerPC::breakpoints.Add(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::AddWatch(unsigned int address)
|
||||
{
|
||||
PowerPC::watches.Add(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::ClearAllMemChecks()
|
||||
{
|
||||
PowerPC::memchecks.Clear();
|
||||
@ -204,3 +269,10 @@ void PPCDebugInterface::SetPC(unsigned int address)
|
||||
void PPCDebugInterface::RunToBreakpoint()
|
||||
{
|
||||
}
|
||||
|
||||
void PPCDebugInterface::Clear()
|
||||
{
|
||||
ClearAllBreakpoints();
|
||||
ClearAllMemChecks();
|
||||
ClearWatches();
|
||||
}
|
||||
|
@ -15,6 +15,22 @@ class PPCDebugInterface final : public DebugInterface
|
||||
{
|
||||
public:
|
||||
PPCDebugInterface() {}
|
||||
// Watches
|
||||
std::size_t SetWatch(u32 address, const std::string& name = "") override;
|
||||
const Common::Debug::Watch& GetWatch(std::size_t index) const override;
|
||||
const std::vector<Common::Debug::Watch>& GetWatches() const override;
|
||||
void UnsetWatch(u32 address) override;
|
||||
void UpdateWatch(std::size_t index, u32 address, const std::string& name) override;
|
||||
void UpdateWatchAddress(std::size_t index, u32 address) override;
|
||||
void UpdateWatchName(std::size_t index, const std::string& name) override;
|
||||
void EnableWatch(std::size_t index) override;
|
||||
void DisableWatch(std::size_t index) override;
|
||||
bool HasEnabledWatch(u32 address) const override;
|
||||
void RemoveWatch(std::size_t index) override;
|
||||
void LoadWatchesFromStrings(const std::vector<std::string>& watches) override;
|
||||
std::vector<std::string> SaveWatchesToStrings() const override;
|
||||
void ClearWatches() override;
|
||||
|
||||
std::string Disassemble(unsigned int address) override;
|
||||
std::string GetRawMemoryString(int memory, unsigned int address) override;
|
||||
int GetInstructionSize(int /*instruction*/) override { return 4; }
|
||||
@ -23,7 +39,6 @@ public:
|
||||
void SetBreakpoint(unsigned int address) override;
|
||||
void ClearBreakpoint(unsigned int address) override;
|
||||
void ClearAllBreakpoints() override;
|
||||
void AddWatch(unsigned int address) override;
|
||||
void ToggleBreakpoint(unsigned int address) override;
|
||||
void ClearAllMemChecks() override;
|
||||
bool IsMemCheck(unsigned int address, size_t size = 1) override;
|
||||
@ -45,4 +60,9 @@ public:
|
||||
void Patch(unsigned int address, unsigned int value) override;
|
||||
int GetColor(unsigned int address) override;
|
||||
std::string GetDescription(unsigned int address) override;
|
||||
|
||||
void Clear() override;
|
||||
|
||||
private:
|
||||
Common::Debug::Watches m_watches;
|
||||
};
|
||||
|
@ -17,6 +17,76 @@ namespace DSP
|
||||
{
|
||||
namespace LLE
|
||||
{
|
||||
std::size_t DSPDebugInterface::SetWatch(u32 address, const std::string& name)
|
||||
{
|
||||
return m_watches.SetWatch(address, name);
|
||||
}
|
||||
|
||||
const Common::Debug::Watch& DSPDebugInterface::GetWatch(std::size_t index) const
|
||||
{
|
||||
return m_watches.GetWatch(index);
|
||||
}
|
||||
|
||||
const std::vector<Common::Debug::Watch>& DSPDebugInterface::GetWatches() const
|
||||
{
|
||||
return m_watches.GetWatches();
|
||||
}
|
||||
|
||||
void DSPDebugInterface::UnsetWatch(u32 address)
|
||||
{
|
||||
m_watches.UnsetWatch(address);
|
||||
}
|
||||
|
||||
void DSPDebugInterface::UpdateWatch(std::size_t index, u32 address, const std::string& name)
|
||||
{
|
||||
return m_watches.UpdateWatch(index, address, name);
|
||||
}
|
||||
|
||||
void DSPDebugInterface::UpdateWatchAddress(std::size_t index, u32 address)
|
||||
{
|
||||
return m_watches.UpdateWatchAddress(index, address);
|
||||
}
|
||||
|
||||
void DSPDebugInterface::UpdateWatchName(std::size_t index, const std::string& name)
|
||||
{
|
||||
return m_watches.UpdateWatchName(index, name);
|
||||
}
|
||||
|
||||
void DSPDebugInterface::EnableWatch(std::size_t index)
|
||||
{
|
||||
m_watches.EnableWatch(index);
|
||||
}
|
||||
|
||||
void DSPDebugInterface::DisableWatch(std::size_t index)
|
||||
{
|
||||
m_watches.DisableWatch(index);
|
||||
}
|
||||
|
||||
bool DSPDebugInterface::HasEnabledWatch(u32 address) const
|
||||
{
|
||||
return m_watches.HasEnabledWatch(address);
|
||||
}
|
||||
|
||||
void DSPDebugInterface::RemoveWatch(std::size_t index)
|
||||
{
|
||||
return m_watches.RemoveWatch(index);
|
||||
}
|
||||
|
||||
void DSPDebugInterface::LoadWatchesFromStrings(const std::vector<std::string>& watches)
|
||||
{
|
||||
m_watches.LoadFromStrings(watches);
|
||||
}
|
||||
|
||||
std::vector<std::string> DSPDebugInterface::SaveWatchesToStrings() const
|
||||
{
|
||||
return m_watches.SaveToStrings();
|
||||
}
|
||||
|
||||
void DSPDebugInterface::ClearWatches()
|
||||
{
|
||||
m_watches.Clear();
|
||||
}
|
||||
|
||||
std::string DSPDebugInterface::Disassemble(unsigned int address)
|
||||
{
|
||||
// we'll treat addresses as line numbers.
|
||||
@ -191,5 +261,10 @@ void DSPDebugInterface::SetPC(unsigned int address)
|
||||
void DSPDebugInterface::RunToBreakpoint()
|
||||
{
|
||||
}
|
||||
|
||||
void DSPDebugInterface::Clear()
|
||||
{
|
||||
ClearWatches();
|
||||
}
|
||||
} // namespace LLE
|
||||
} // namespace DSP
|
||||
|
@ -18,6 +18,22 @@ class DSPDebugInterface final : public DebugInterface
|
||||
{
|
||||
public:
|
||||
DSPDebugInterface() {}
|
||||
// Watches
|
||||
std::size_t SetWatch(u32 address, const std::string& name = "") override;
|
||||
const Common::Debug::Watch& GetWatch(std::size_t index) const override;
|
||||
const std::vector<Common::Debug::Watch>& GetWatches() const override;
|
||||
void UnsetWatch(u32 address) override;
|
||||
void UpdateWatch(std::size_t index, u32 address, const std::string& name) override;
|
||||
void UpdateWatchAddress(std::size_t index, u32 address) override;
|
||||
void UpdateWatchName(std::size_t index, const std::string& name) override;
|
||||
void EnableWatch(std::size_t index) override;
|
||||
void DisableWatch(std::size_t index) override;
|
||||
bool HasEnabledWatch(u32 address) const override;
|
||||
void RemoveWatch(std::size_t index) override;
|
||||
void LoadWatchesFromStrings(const std::vector<std::string>& watches) override;
|
||||
std::vector<std::string> SaveWatchesToStrings() const override;
|
||||
void ClearWatches() override;
|
||||
|
||||
std::string Disassemble(unsigned int address) override;
|
||||
std::string GetRawMemoryString(int memory, unsigned int address) override;
|
||||
int GetInstructionSize(int instruction) override { return 1; }
|
||||
@ -40,6 +56,11 @@ public:
|
||||
void Patch(unsigned int address, unsigned int value) override;
|
||||
int GetColor(unsigned int address) override;
|
||||
std::string GetDescription(unsigned int address) override;
|
||||
|
||||
void Clear() override;
|
||||
|
||||
private:
|
||||
Common::Debug::Watches m_watches;
|
||||
};
|
||||
} // namespace LLE
|
||||
} // namespace DSP
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -38,13 +38,6 @@ struct TMemCheck
|
||||
bool Action(DebugInterface* dbg_interface, u32 value, u32 addr, bool write, size_t size, u32 pc);
|
||||
};
|
||||
|
||||
struct TWatch
|
||||
{
|
||||
std::string name;
|
||||
u32 address = 0;
|
||||
bool is_enabled = false;
|
||||
};
|
||||
|
||||
// Code breakpoints.
|
||||
class BreakPoints
|
||||
{
|
||||
@ -97,30 +90,3 @@ public:
|
||||
private:
|
||||
TMemChecks m_mem_checks;
|
||||
};
|
||||
|
||||
class Watches
|
||||
{
|
||||
public:
|
||||
using TWatches = std::vector<TWatch>;
|
||||
using TWatchesStr = std::vector<std::string>;
|
||||
|
||||
const TWatches& GetWatches() const { return m_watches; }
|
||||
TWatchesStr GetStrings() const;
|
||||
void AddFromStrings(const TWatchesStr& watch_strings);
|
||||
|
||||
bool IsAddressWatch(u32 address) const;
|
||||
|
||||
// Add watch
|
||||
void Add(u32 address);
|
||||
void Add(const TWatch& watch);
|
||||
|
||||
void Update(int count, u32 address);
|
||||
void UpdateName(int count, const std::string name);
|
||||
|
||||
// Remove watch
|
||||
void Remove(u32 address);
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
TWatches m_watches;
|
||||
};
|
||||
|
@ -34,7 +34,6 @@ static bool s_cpu_core_base_is_injected = false;
|
||||
Interpreter* const s_interpreter = Interpreter::getInstance();
|
||||
static CoreMode s_mode = CoreMode::Interpreter;
|
||||
|
||||
Watches watches;
|
||||
BreakPoints breakpoints;
|
||||
MemChecks memchecks;
|
||||
PPCDebugInterface debug_interface;
|
||||
|
@ -135,7 +135,6 @@ static_assert(offsetof(PowerPC::PowerPCState, above_fits_in_first_0x100) <= 0x10
|
||||
|
||||
extern PowerPCState ppcState;
|
||||
|
||||
extern Watches watches;
|
||||
extern BreakPoints breakpoints;
|
||||
extern MemChecks memchecks;
|
||||
extern PPCDebugInterface debug_interface;
|
||||
|
Reference in New Issue
Block a user