From b60ad2425d05dc5134de76d0848a5079ad197500 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 25 May 2018 16:29:56 -0400 Subject: [PATCH] Common: Namespace GekkoDisassembler.cpp/.h Moves more common code into the Common namespace where it belongs --- Source/Core/Common/GekkoDisassembler.cpp | 3 +++ Source/Core/Common/GekkoDisassembler.h | 3 +++ Source/Core/Core/Debugger/PPCDebugInterface.cpp | 2 +- Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp | 7 +++++-- Source/Core/Core/PowerPC/Jit64/Jit.cpp | 2 +- Source/Core/Core/PowerPC/Jit64Common/Jit64Base.cpp | 5 ++--- Source/Core/DolphinQt2/Debugger/JITWidget.cpp | 2 +- Source/Core/DolphinWX/Debugger/AssemblerEntryDialog.cpp | 2 +- Source/Core/DolphinWX/Debugger/JitWindow.cpp | 2 +- Source/Core/DolphinWX/Debugger/RegisterView.cpp | 4 ++-- 10 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Source/Core/Common/GekkoDisassembler.cpp b/Source/Core/Common/GekkoDisassembler.cpp index ac77957991..7571ffff7c 100644 --- a/Source/Core/Common/GekkoDisassembler.cpp +++ b/Source/Core/Common/GekkoDisassembler.cpp @@ -38,6 +38,8 @@ #include "Common/GekkoDisassembler.h" #include "Common/StringUtil.h" +namespace Common +{ // version/revision #define PPCDISASM_VER 1 #define PPCDISASM_REV 6 @@ -2315,3 +2317,4 @@ const char* GekkoDisassembler::GetFPRName(u32 index) return nullptr; } +} // namespace Common diff --git a/Source/Core/Common/GekkoDisassembler.h b/Source/Core/Common/GekkoDisassembler.h index 684ae92052..f3e3ef0859 100644 --- a/Source/Core/Common/GekkoDisassembler.h +++ b/Source/Core/Common/GekkoDisassembler.h @@ -40,6 +40,8 @@ #include "Common/CommonTypes.h" #include "Common/StringUtil.h" +namespace Common +{ class GekkoDisassembler final { public: @@ -152,3 +154,4 @@ private: static unsigned short m_sreg; // Register in load/store instructions static u32 m_displacement; // Branch- or load/store displacement }; +} // namespace Common diff --git a/Source/Core/Core/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Debugger/PPCDebugInterface.cpp index 6222a94c34..6ca9401778 100644 --- a/Source/Core/Core/Debugger/PPCDebugInterface.cpp +++ b/Source/Core/Core/Debugger/PPCDebugInterface.cpp @@ -173,7 +173,7 @@ std::string PPCDebugInterface::Disassemble(unsigned int 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}; if (inst.OPCD == 1) diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp index 4436d46fc2..3e6ec2aa9e 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp @@ -92,7 +92,7 @@ static void Trace(UGeckoInstruction& inst) 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, "INTER PC: %08x SRR0: %08x SRR1: %08x CRval: %016lx FPSCR: %08x MSR: %08x LR: " "%08x %s %08x %s", @@ -295,15 +295,18 @@ void Interpreter::Run() 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()); Dolphin_Debugger::PrintCallstack(); NOTICE_LOG(POWERPC, "\nIntCPU: Unknown instruction %08x at PC = %08x last_PC = %08x LR = %08x\n", inst.hex, PC, last_pc, LR); 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, rGPR[i + 1], i + 2, rGPR[i + 2], i + 3, rGPR[i + 3]); + } ASSERT_MSG(POWERPC, 0, "\nIntCPU: Unknown instruction %08x at PC = %08x last_PC = %08x LR = %08x\n", inst.hex, PC, last_pc, LR); diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index e6c3baf9cf..0bbd499400 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -931,7 +931,7 @@ const u8* Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC) #if defined(_DEBUG) || defined(DEBUGFAST) 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()); } #endif diff --git a/Source/Core/Core/PowerPC/Jit64Common/Jit64Base.cpp b/Source/Core/Core/PowerPC/Jit64Common/Jit64Base.cpp index d5f59732be..4525d8c23c 100644 --- a/Source/Core/Core/PowerPC/Jit64Common/Jit64Base.cpp +++ b/Source/Core/Core/PowerPC/Jit64Common/Jit64Base.cpp @@ -133,9 +133,8 @@ void LogGeneratedX86(size_t size, const PPCAnalyst::CodeBuffer& code_buffer, con for (size_t i = 0; i < size; i++) { const PPCAnalyst::CodeOp& op = code_buffer[i]; - std::string temp = StringFromFormat( - "%08x %s", op.address, GekkoDisassembler::Disassemble(op.inst.hex, op.address).c_str()); - DEBUG_LOG(DYNA_REC, "IR_X86 PPC: %s\n", temp.c_str()); + const std::string disasm = Common::GekkoDisassembler::Disassemble(op.inst.hex, op.address); + DEBUG_LOG(DYNA_REC, "IR_X86 PPC: %08x %s\n", op.address, disasm.c_str()); } disassembler x64disasm; diff --git a/Source/Core/DolphinQt2/Debugger/JITWidget.cpp b/Source/Core/DolphinQt2/Debugger/JITWidget.cpp index 81cc85fb4d..2cf73ddbca 100644 --- a/Source/Core/DolphinQt2/Debugger/JITWidget.cpp +++ b/Source/Core/DolphinQt2/Debugger/JITWidget.cpp @@ -163,7 +163,7 @@ void JITWidget::Update() for (u32 i = 0; i < code_block.m_num_instructions; 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 << " " << opcode << std::endl; } diff --git a/Source/Core/DolphinWX/Debugger/AssemblerEntryDialog.cpp b/Source/Core/DolphinWX/Debugger/AssemblerEntryDialog.cpp index 079a3ab222..f6939801fb 100644 --- a/Source/Core/DolphinWX/Debugger/AssemblerEntryDialog.cpp +++ b/Source/Core/DolphinWX/Debugger/AssemblerEntryDialog.cpp @@ -85,6 +85,6 @@ void AssemblerEntryDialog::OnTextChanged(wxCommandEvent& evt) unsigned long code; std::string result = "Input text is invalid"; if (evt.GetString().ToULong(&code, 0) && code <= std::numeric_limits::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())); } diff --git a/Source/Core/DolphinWX/Debugger/JitWindow.cpp b/Source/Core/DolphinWX/Debugger/JitWindow.cpp index 47a70e3697..a84d859c7a 100644 --- a/Source/Core/DolphinWX/Debugger/JitWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/JitWindow.cpp @@ -99,7 +99,7 @@ void CJitWindow::Compare(u32 em_address) for (u32 i = 0; i < code_block.m_num_instructions; 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 << " " << opcode << std::endl; } diff --git a/Source/Core/DolphinWX/Debugger/RegisterView.cpp b/Source/Core/DolphinWX/Debugger/RegisterView.cpp index f027224da6..6d62ca6b5e 100644 --- a/Source/Core/DolphinWX/Debugger/RegisterView.cpp +++ b/Source/Core/DolphinWX/Debugger/RegisterView.cpp @@ -284,11 +284,11 @@ wxString CRegTable::GetValue(int row, int col) switch (col) { case 0: - return StrToWxStr(GekkoDisassembler::GetGPRName(row)); + return StrToWxStr(Common::GekkoDisassembler::GetGPRName(row)); case 1: return FormatGPR(row); case 2: - return StrToWxStr(GekkoDisassembler::GetFPRName(row)); + return StrToWxStr(Common::GekkoDisassembler::GetFPRName(row)); case 3: return FormatFPR(row, 0); case 4: