Common: Introduce the new Gekko disassembler to Common.

This moves the Gekko disassembler to Common where it should be. Having it in the Bochs disassembly Externals is incorrect.

Unlike the PowerPC disassembler prior however, this one is updated to have an API that is more fitting for C++. e.g. Not needing to specify a string buffer and size. It does all of this under the hood.

This modifies all the DebuggingInterfaces as necessary to handle this.
This commit is contained in:
Lioncash 2014-07-17 21:33:51 -04:00
commit 0718937237
21 changed files with 2553 additions and 2434 deletions

View file

@ -2,7 +2,9 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include "PowerPCDisasm.h"
#include <string>
#include "Common/GekkoDisassembler.h"
#include "Core/Core.h"
#include "Core/Host.h"
@ -15,31 +17,37 @@
#include "Core/PowerPC/PPCSymbolDB.h"
#include "Core/PowerPC/JitCommon/JitBase.h"
void PPCDebugInterface::Disassemble(unsigned int address, char *dest, int max_size)
std::string PPCDebugInterface::Disassemble(unsigned int address)
{
// Memory::ReadUnchecked_U32 seemed to crash on shutdown
if (PowerPC::GetState() == PowerPC::CPU_POWERDOWN) return;
if (PowerPC::GetState() == PowerPC::CPU_POWERDOWN)
return "";
if (Core::GetState() != Core::CORE_UNINITIALIZED)
{
if (Memory::IsRAMAddress(address, true, true))
{
u32 op = Memory::Read_Instruction(address);
DisassembleGekko(op, address, dest, max_size);
std::string disasm = GekkoDisassembler::Disassemble(op, address);
UGeckoInstruction inst;
inst.hex = Memory::ReadUnchecked_U32(address);
if (inst.OPCD == 1) {
strcat(dest, " (hle)");
if (inst.OPCD == 1)
{
disasm += " (hle)";
}
return disasm;
}
else
{
strcpy(dest, "(No RAM here)");
return "(No RAM here)";
}
}
else
{
strcpy(dest, "<unknown>");
return "<unknown>";
}
}

View file

@ -14,7 +14,7 @@ class PPCDebugInterface final : public DebugInterface
{
public:
PPCDebugInterface(){}
virtual void Disassemble(unsigned int address, char *dest, int max_size) override;
virtual std::string Disassemble(unsigned int address) override;
virtual void GetRawMemoryString(int memory, unsigned int address, char *dest, int max_size) override;
virtual int GetInstructionSize(int /*instruction*/) override {return 4;}
virtual bool IsAlive() override;