mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-11 18:50:30 +00:00
DebugInterface: MemoryPatches methods added
CodeView: Restore instruction added
This commit is contained in:
parent
7eaba154a4
commit
8fa898fe9a
15 changed files with 365 additions and 81 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/GekkoDisassembler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
|
@ -16,6 +17,33 @@
|
|||
#include "Core/PowerPC/PPCSymbolDB.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
|
||||
void PPCPatches::Patch(std::size_t index)
|
||||
{
|
||||
auto& patch = m_patches[index];
|
||||
if (patch.value.empty())
|
||||
return;
|
||||
|
||||
const u32 address = patch.address;
|
||||
const std::size_t size = patch.value.size();
|
||||
if (!PowerPC::HostIsRAMAddress(address))
|
||||
return;
|
||||
|
||||
for (u32 offset = 0; offset < size; ++offset)
|
||||
{
|
||||
const u8 value = PowerPC::HostRead_U8(address + offset);
|
||||
PowerPC::HostWrite_U8(patch.value[offset], address + offset);
|
||||
patch.value[offset] = value;
|
||||
|
||||
if (((address + offset) % 4) == 3)
|
||||
PowerPC::ScheduleInvalidateCacheThreadSafe(Common::AlignDown(address + offset, 4));
|
||||
}
|
||||
if (((address + size) % 4) != 0)
|
||||
{
|
||||
PowerPC::ScheduleInvalidateCacheThreadSafe(
|
||||
Common::AlignDown(address + static_cast<u32>(size), 4));
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t PPCDebugInterface::SetWatch(u32 address, const std::string& name)
|
||||
{
|
||||
return m_watches.SetWatch(address, name);
|
||||
|
@ -86,6 +114,51 @@ void PPCDebugInterface::ClearWatches()
|
|||
m_watches.Clear();
|
||||
}
|
||||
|
||||
void PPCDebugInterface::SetPatch(u32 address, u32 value)
|
||||
{
|
||||
m_patches.SetPatch(address, value);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::SetPatch(u32 address, std::vector<u8> value)
|
||||
{
|
||||
m_patches.SetPatch(address, value);
|
||||
}
|
||||
|
||||
const std::vector<Common::Debug::MemoryPatch>& PPCDebugInterface::GetPatches() const
|
||||
{
|
||||
return m_patches.GetPatches();
|
||||
}
|
||||
|
||||
void PPCDebugInterface::UnsetPatch(u32 address)
|
||||
{
|
||||
m_patches.UnsetPatch(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::EnablePatch(std::size_t index)
|
||||
{
|
||||
m_patches.EnablePatch(index);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::DisablePatch(std::size_t index)
|
||||
{
|
||||
m_patches.DisablePatch(index);
|
||||
}
|
||||
|
||||
bool PPCDebugInterface::HasEnabledPatch(u32 address) const
|
||||
{
|
||||
return m_patches.HasEnabledPatch(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::RemovePatch(std::size_t index)
|
||||
{
|
||||
m_patches.RemovePatch(index);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::ClearPatches()
|
||||
{
|
||||
m_patches.ClearPatches();
|
||||
}
|
||||
|
||||
std::string PPCDebugInterface::Disassemble(unsigned int address)
|
||||
{
|
||||
// PowerPC::HostRead_U32 seemed to crash on shutdown
|
||||
|
@ -220,12 +293,6 @@ void PPCDebugInterface::ToggleMemCheck(unsigned int address, bool read, bool wri
|
|||
}
|
||||
}
|
||||
|
||||
void PPCDebugInterface::Patch(unsigned int address, unsigned int value)
|
||||
{
|
||||
PowerPC::HostWrite_U32(value, address);
|
||||
PowerPC::ScheduleInvalidateCacheThreadSafe(address);
|
||||
}
|
||||
|
||||
// =======================================================
|
||||
// Separate the blocks with colors.
|
||||
// -------------
|
||||
|
@ -275,5 +342,6 @@ void PPCDebugInterface::Clear()
|
|||
{
|
||||
ClearAllBreakpoints();
|
||||
ClearAllMemChecks();
|
||||
ClearPatches();
|
||||
ClearWatches();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
|
||||
#include "Common/DebugInterface.h"
|
||||
|
||||
class PPCPatches : public Common::Debug::MemoryPatches
|
||||
{
|
||||
private:
|
||||
void Patch(std::size_t index) override;
|
||||
};
|
||||
|
||||
// wrapper between disasm control and Dolphin debugger
|
||||
|
||||
class PPCDebugInterface final : public DebugInterface
|
||||
|
@ -31,6 +37,17 @@ public:
|
|||
std::vector<std::string> SaveWatchesToStrings() const override;
|
||||
void ClearWatches() override;
|
||||
|
||||
// Memory Patches
|
||||
void SetPatch(u32 address, u32 value);
|
||||
void SetPatch(u32 address, std::vector<u8> value);
|
||||
const std::vector<Common::Debug::MemoryPatch>& GetPatches() const;
|
||||
void UnsetPatch(u32 address);
|
||||
void EnablePatch(std::size_t index);
|
||||
void DisablePatch(std::size_t index);
|
||||
bool HasEnabledPatch(u32 address) const;
|
||||
void RemovePatch(std::size_t index);
|
||||
void ClearPatches();
|
||||
|
||||
std::string Disassemble(unsigned int address) override;
|
||||
std::string GetRawMemoryString(int memory, unsigned int address) override;
|
||||
int GetInstructionSize(int /*instruction*/) override { return 4; }
|
||||
|
@ -57,7 +74,6 @@ public:
|
|||
void SetPC(unsigned int address) override;
|
||||
void Step() override {}
|
||||
void RunToBreakpoint() override;
|
||||
void Patch(unsigned int address, unsigned int value) override;
|
||||
int GetColor(unsigned int address) override;
|
||||
std::string GetDescription(unsigned int address) override;
|
||||
|
||||
|
@ -65,4 +81,5 @@ public:
|
|||
|
||||
private:
|
||||
Common::Debug::Watches m_watches;
|
||||
PPCPatches m_patches;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue