Skip to content

Commit

Permalink
Common: Namespace GekkoDisassembler.cpp/.h
Browse files Browse the repository at this point in the history
Moves more common code into the Common namespace where it belongs
  • Loading branch information
lioncash committed May 25, 2018
1 parent 3d44dc3 commit b60ad24
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Source/Core/Common/GekkoDisassembler.cpp
Expand Up @@ -38,6 +38,8 @@
#include "Common/GekkoDisassembler.h" #include "Common/GekkoDisassembler.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"


namespace Common
{
// version/revision // version/revision
#define PPCDISASM_VER 1 #define PPCDISASM_VER 1
#define PPCDISASM_REV 6 #define PPCDISASM_REV 6
Expand Down Expand Up @@ -2315,3 +2317,4 @@ const char* GekkoDisassembler::GetFPRName(u32 index)


return nullptr; return nullptr;
} }
} // namespace Common
3 changes: 3 additions & 0 deletions Source/Core/Common/GekkoDisassembler.h
Expand Up @@ -40,6 +40,8 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"


namespace Common
{
class GekkoDisassembler final class GekkoDisassembler final
{ {
public: public:
Expand Down Expand Up @@ -152,3 +154,4 @@ class GekkoDisassembler final
static unsigned short m_sreg; // Register in load/store instructions static unsigned short m_sreg; // Register in load/store instructions
static u32 m_displacement; // Branch- or load/store displacement static u32 m_displacement; // Branch- or load/store displacement
}; };
} // namespace Common
2 changes: 1 addition & 1 deletion Source/Core/Core/Debugger/PPCDebugInterface.cpp
Expand Up @@ -173,7 +173,7 @@ std::string PPCDebugInterface::Disassemble(unsigned int address)
} }


const u32 op = PowerPC::HostRead_Instruction(address); const u32 op = PowerPC::HostRead_Instruction(address);
std::string disasm = GekkoDisassembler::Disassemble(op, address); std::string disasm = Common::GekkoDisassembler::Disassemble(op, address);
const UGeckoInstruction inst{op}; const UGeckoInstruction inst{op};


if (inst.OPCD == 1) if (inst.OPCD == 1)
Expand Down
7 changes: 5 additions & 2 deletions Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp
Expand Up @@ -92,7 +92,7 @@ static void Trace(UGeckoInstruction& inst)
PowerPC::ppcState.ps[i][1]); PowerPC::ppcState.ps[i][1]);
} }


std::string ppc_inst = GekkoDisassembler::Disassemble(inst.hex, PC); const std::string ppc_inst = Common::GekkoDisassembler::Disassemble(inst.hex, PC);
DEBUG_LOG(POWERPC, DEBUG_LOG(POWERPC,
"INTER PC: %08x SRR0: %08x SRR1: %08x CRval: %016lx FPSCR: %08x MSR: %08x LR: " "INTER PC: %08x SRR0: %08x SRR1: %08x CRval: %016lx FPSCR: %08x MSR: %08x LR: "
"%08x %s %08x %s", "%08x %s %08x %s",
Expand Down Expand Up @@ -295,15 +295,18 @@ void Interpreter::Run()


void Interpreter::unknown_instruction(UGeckoInstruction inst) void Interpreter::unknown_instruction(UGeckoInstruction inst)
{ {
std::string disasm = GekkoDisassembler::Disassemble(PowerPC::HostRead_U32(last_pc), last_pc); const u32 opcode = PowerPC::HostRead_U32(last_pc);
const std::string disasm = Common::GekkoDisassembler::Disassemble(opcode, last_pc);
NOTICE_LOG(POWERPC, "Last PC = %08x : %s", last_pc, disasm.c_str()); NOTICE_LOG(POWERPC, "Last PC = %08x : %s", last_pc, disasm.c_str());
Dolphin_Debugger::PrintCallstack(); Dolphin_Debugger::PrintCallstack();
NOTICE_LOG(POWERPC, NOTICE_LOG(POWERPC,
"\nIntCPU: Unknown instruction %08x at PC = %08x last_PC = %08x LR = %08x\n", "\nIntCPU: Unknown instruction %08x at PC = %08x last_PC = %08x LR = %08x\n",
inst.hex, PC, last_pc, LR); inst.hex, PC, last_pc, LR);
for (int i = 0; i < 32; i += 4) for (int i = 0; i < 32; i += 4)
{
NOTICE_LOG(POWERPC, "r%d: 0x%08x r%d: 0x%08x r%d:0x%08x r%d: 0x%08x", i, rGPR[i], i + 1, NOTICE_LOG(POWERPC, "r%d: 0x%08x r%d: 0x%08x r%d:0x%08x r%d: 0x%08x", i, rGPR[i], i + 1,
rGPR[i + 1], i + 2, rGPR[i + 2], i + 3, rGPR[i + 3]); rGPR[i + 1], i + 2, rGPR[i + 2], i + 3, rGPR[i + 3]);
}
ASSERT_MSG(POWERPC, 0, ASSERT_MSG(POWERPC, 0,
"\nIntCPU: Unknown instruction %08x at PC = %08x last_PC = %08x LR = %08x\n", "\nIntCPU: Unknown instruction %08x at PC = %08x last_PC = %08x LR = %08x\n",
inst.hex, PC, last_pc, LR); inst.hex, PC, last_pc, LR);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/Jit64/Jit.cpp
Expand Up @@ -931,7 +931,7 @@ const u8* Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
#if defined(_DEBUG) || defined(DEBUGFAST) #if defined(_DEBUG) || defined(DEBUGFAST)
if (gpr.SanityCheck() || fpr.SanityCheck()) if (gpr.SanityCheck() || fpr.SanityCheck())
{ {
std::string ppc_inst = GekkoDisassembler::Disassemble(op.inst.hex, em_address); std::string ppc_inst = Common::GekkoDisassembler::Disassemble(op.inst.hex, em_address);
// NOTICE_LOG(DYNA_REC, "Unflushed register: %s", ppc_inst.c_str()); // NOTICE_LOG(DYNA_REC, "Unflushed register: %s", ppc_inst.c_str());
} }
#endif #endif
Expand Down
5 changes: 2 additions & 3 deletions Source/Core/Core/PowerPC/Jit64Common/Jit64Base.cpp
Expand Up @@ -133,9 +133,8 @@ void LogGeneratedX86(size_t size, const PPCAnalyst::CodeBuffer& code_buffer, con
for (size_t i = 0; i < size; i++) for (size_t i = 0; i < size; i++)
{ {
const PPCAnalyst::CodeOp& op = code_buffer[i]; const PPCAnalyst::CodeOp& op = code_buffer[i];
std::string temp = StringFromFormat( const std::string disasm = Common::GekkoDisassembler::Disassemble(op.inst.hex, op.address);
"%08x %s", op.address, GekkoDisassembler::Disassemble(op.inst.hex, op.address).c_str()); DEBUG_LOG(DYNA_REC, "IR_X86 PPC: %08x %s\n", op.address, disasm.c_str());
DEBUG_LOG(DYNA_REC, "IR_X86 PPC: %s\n", temp.c_str());
} }


disassembler x64disasm; disassembler x64disasm;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt2/Debugger/JITWidget.cpp
Expand Up @@ -163,7 +163,7 @@ void JITWidget::Update()
for (u32 i = 0; i < code_block.m_num_instructions; i++) for (u32 i = 0; i < code_block.m_num_instructions; i++)
{ {
const PPCAnalyst::CodeOp& op = code_buffer[i]; const PPCAnalyst::CodeOp& op = code_buffer[i];
std::string opcode = GekkoDisassembler::Disassemble(op.inst.hex, op.address); const std::string opcode = Common::GekkoDisassembler::Disassemble(op.inst.hex, op.address);
ppc_disasm << std::setfill('0') << std::setw(8) << std::hex << op.address; ppc_disasm << std::setfill('0') << std::setw(8) << std::hex << op.address;
ppc_disasm << " " << opcode << std::endl; ppc_disasm << " " << opcode << std::endl;
} }
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/Debugger/AssemblerEntryDialog.cpp
Expand Up @@ -85,6 +85,6 @@ void AssemblerEntryDialog::OnTextChanged(wxCommandEvent& evt)
unsigned long code; unsigned long code;
std::string result = "Input text is invalid"; std::string result = "Input text is invalid";
if (evt.GetString().ToULong(&code, 0) && code <= std::numeric_limits<u32>::max()) if (evt.GetString().ToULong(&code, 0) && code <= std::numeric_limits<u32>::max())
result = TabsToSpaces(1, GekkoDisassembler::Disassemble(code, m_address)); result = TabsToSpaces(1, Common::GekkoDisassembler::Disassemble(code, m_address));
m_preview->SetLabel(wxString::Format(_("Preview: %s"), result.c_str())); m_preview->SetLabel(wxString::Format(_("Preview: %s"), result.c_str()));
} }
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/Debugger/JitWindow.cpp
Expand Up @@ -99,7 +99,7 @@ void CJitWindow::Compare(u32 em_address)
for (u32 i = 0; i < code_block.m_num_instructions; i++) for (u32 i = 0; i < code_block.m_num_instructions; i++)
{ {
const PPCAnalyst::CodeOp& op = code_buffer[i]; const PPCAnalyst::CodeOp& op = code_buffer[i];
std::string opcode = GekkoDisassembler::Disassemble(op.inst.hex, op.address); const std::string opcode = Common::GekkoDisassembler::Disassemble(op.inst.hex, op.address);
ppc_disasm << std::setfill('0') << std::setw(8) << std::hex << op.address; ppc_disasm << std::setfill('0') << std::setw(8) << std::hex << op.address;
ppc_disasm << " " << opcode << std::endl; ppc_disasm << " " << opcode << std::endl;
} }
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/DolphinWX/Debugger/RegisterView.cpp
Expand Up @@ -284,11 +284,11 @@ wxString CRegTable::GetValue(int row, int col)
switch (col) switch (col)
{ {
case 0: case 0:
return StrToWxStr(GekkoDisassembler::GetGPRName(row)); return StrToWxStr(Common::GekkoDisassembler::GetGPRName(row));
case 1: case 1:
return FormatGPR(row); return FormatGPR(row);
case 2: case 2:
return StrToWxStr(GekkoDisassembler::GetFPRName(row)); return StrToWxStr(Common::GekkoDisassembler::GetFPRName(row));
case 3: case 3:
return FormatFPR(row, 0); return FormatFPR(row, 0);
case 4: case 4:
Expand Down

0 comments on commit b60ad24

Please sign in to comment.