diff --git a/Externals/Bochs_disasm/PowerPCDisasm.cpp b/Externals/Bochs_disasm/PowerPCDisasm.cpp index 99cf7f8e0f..d0c684d056 100644 --- a/Externals/Bochs_disasm/PowerPCDisasm.cpp +++ b/Externals/Bochs_disasm/PowerPCDisasm.cpp @@ -2086,7 +2086,7 @@ typedef unsigned int ppc_word; break; case 20: - fdabc(dp,in,"rsqrte",3,0); + fdabc(dp,in,"rsqrte",1,0); break; case 24: @@ -2121,15 +2121,15 @@ typedef unsigned int ppc_word; break; case 12: - fdabc(dp,in,"rsp",10,0); + fdabc(dp,in,"rsp",1,0); // 10 break; case 14: - fdabc(dp,in,"ctiw",10,0); + fdabc(dp,in,"ctiw",1,0); // 10 break; case 15: - fdabc(dp,in,"ctiwz",10,0); + fdabc(dp,in,"ctiwz",1,0); // 10 break; case 32: diff --git a/Source/Core/Core/Src/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Src/Debugger/PPCDebugInterface.cpp index c129fc9268..b959bfeaf2 100644 --- a/Source/Core/Core/Src/Debugger/PPCDebugInterface.cpp +++ b/Source/Core/Core/Src/Debugger/PPCDebugInterface.cpp @@ -29,10 +29,15 @@ void PPCDebugInterface::disasm(unsigned int address, char *dest, int max_size) { if (Core::GetState() != Core::CORE_UNINITIALIZED) { - if (Memory::IsRAMAddress(address)) + if (Memory::IsRAMAddress(address, true)) { u32 op = Memory::Read_Instruction(address); DisassembleGekko(op, address, dest, max_size); + UGeckoInstruction inst; + inst.hex = Memory::ReadUnchecked_U32(address); + if (inst.OPCD == 1) { + strcat(dest, " (hle)"); + } } else { @@ -49,7 +54,7 @@ void PPCDebugInterface::getRawMemoryString(unsigned int address, char *dest, int { if (Core::GetState() != Core::CORE_UNINITIALIZED) { - if (address < 0xE0000000) + if (Memory::IsRAMAddress(address, true)) { snprintf(dest, max_size, "%08X", readMemory(address)); } @@ -115,19 +120,20 @@ void PPCDebugInterface::insertBLR(unsigned int address) // ------------- int PPCDebugInterface::getColor(unsigned int address) { - if (!Memory::IsRAMAddress(address)) + if (!Memory::IsRAMAddress(address, true)) return 0xeeeeee; - int colors[6] = - { - 0xd0FFFF // light cyan - ,0xFFd0d0 // light red - ,0xd8d8FF // light blue - ,0xFFd0FF // light purple - ,0xd0FFd0 // light green - ,0xFFFFd0 // light yellow + static const int colors[6] = + { + 0xd0FFFF, // light cyan + 0xFFd0d0, // light red + 0xd8d8FF, // light blue + 0xFFd0FF, // light purple + 0xd0FFd0, // light green + 0xFFFFd0, // light yellow }; Symbol *symbol = g_symbolDB.GetSymbolFromAddr(address); - if (!symbol) return 0xFFFFFF; + if (!symbol) + return 0xFFFFFF; if (symbol->type != Symbol::SYMBOL_FUNCTION) return 0xEEEEFF; return colors[symbol->index % 6]; diff --git a/Source/Core/Core/Src/HW/Memmap.cpp b/Source/Core/Core/Src/HW/Memmap.cpp index 93d9edb2f9..c4bf452da5 100644 --- a/Source/Core/Core/Src/HW/Memmap.cpp +++ b/Source/Core/Core/Src/HW/Memmap.cpp @@ -31,6 +31,7 @@ may be redirected here (for example to Read_U32()). #include "../PowerPC/PowerPC.h" #include "../PowerPC/Jit64/Jit.h" #include "../PowerPC/Jit64/JitCache.h" +#include "../HLE/HLE.h" #include "CPU.h" #include "PeripheralInterface.h" #include "DSP.h" @@ -525,8 +526,15 @@ bool AreMemoryBreakpointsActivated() u32 Read_Instruction(const u32 em_address) { - return jit.GetBlockCache()->GetOriginalCode(em_address); + UGeckoInstruction inst = ReadUnchecked_U32(em_address); + if (inst.OPCD == 0) + inst.hex = jit.GetBlockCache()->GetOriginalCode(em_address); + if (inst.OPCD == 1) + return HLE::GetOrigInstruction(em_address); + else + return inst.hex; } + ////////////////////////////////////////////////////////// diff --git a/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp index 3cea7be00d..328b4f29e1 100644 --- a/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/Src/PowerPC/PPCAnalyst.cpp @@ -310,6 +310,9 @@ bool Flatten(u32 address, int *realsize, BlockStats *st, BlockRegStats *gpa, Blo memset(&code[i], 0, sizeof(CodeOp)); code[i].address = address; UGeckoInstruction inst = Memory::Read_Instruction(code[i].address); + UGeckoInstruction untouched_op = Memory::ReadUnchecked_U32(code[i].address); + if (untouched_op.OPCD == 1) // Do handle HLE instructions. + inst = untouched_op; _assert_msg_(GEKKO, inst.hex != 0, "Zero Op - Error flattening %08x op %08x", address + i*4, inst); code[i].inst = inst; code[i].branchTo = -1; diff --git a/Source/Core/Core/Src/PowerPC/PPCTables.cpp b/Source/Core/Core/Src/PowerPC/PPCTables.cpp index f55dc8af6c..3e2bd2d868 100644 --- a/Source/Core/Core/Src/PowerPC/PPCTables.cpp +++ b/Source/Core/Core/Src/PowerPC/PPCTables.cpp @@ -40,11 +40,11 @@ struct GekkoOPTemplate int runCount; }; -struct inf +struct op_inf { const char *name; int count; - bool operator < (const inf &o) const + bool operator < (const op_inf &o) const { return count > o.count; } @@ -686,7 +686,7 @@ void InitTables() } } -// #define OPLOG +#define OPLOG #ifdef OPLOG namespace { @@ -701,7 +701,7 @@ void CompileInstruction(UGeckoInstruction _inst) if (info) { #ifdef OPLOG if (!strcmp(info->opname, "mcrfs")) { - rsplocations.push_back(Jit64::js.compilerPC); + rsplocations.push_back(jit.js.compilerPC); } #endif info->compileCount++; @@ -726,11 +726,10 @@ void CountInstruction(UGeckoInstruction _inst) void PrintInstructionRunCounts() { - - std::vector temp; + std::vector temp; for (int i = 0; i < m_numInstructions; i++) { - inf x; + op_inf x; x.name = m_allInstructions[i]->opname; x.count = m_allInstructions[i]->runCount; temp.push_back(x); @@ -738,14 +737,13 @@ void PrintInstructionRunCounts() std::sort(temp.begin(), temp.end()); for (int i = 0; i < m_numInstructions; i++) { - if(temp[i].count == 0) + if (temp[i].count == 0) break; LOG(GEKKO, "%s : %i", temp[i].name,temp[i].count); //PanicAlert("%s : %i", temp[i].name,temp[i].count); } } -//TODO move to LogManager void LogCompiledInstructions() { static int time = 0; diff --git a/Source/Core/DebuggerWX/Src/JitWindow.cpp b/Source/Core/DebuggerWX/Src/JitWindow.cpp index df59ca7291..b4b54d3ffa 100644 --- a/Source/Core/DebuggerWX/Src/JitWindow.cpp +++ b/Source/Core/DebuggerWX/Src/JitWindow.cpp @@ -125,9 +125,16 @@ void CJitWindow::OnRefresh(wxCommandEvent& /*event*/) { void CJitWindow::ViewAddr(u32 em_address) { - the_jit_window->Show(true); - the_jit_window->Compare(em_address); - the_jit_window->SetFocus(); + if (the_jit_window) + { + the_jit_window->Show(true); + the_jit_window->Compare(em_address); + the_jit_window->SetFocus(); + } + else + { + PanicAlert("Jit window not available"); + } } void CJitWindow::Compare(u32 em_address) diff --git a/Source/Core/DebuggerWX/Src/MemoryView.cpp b/Source/Core/DebuggerWX/Src/MemoryView.cpp index 477370ccbe..46bce90034 100644 --- a/Source/Core/DebuggerWX/Src/MemoryView.cpp +++ b/Source/Core/DebuggerWX/Src/MemoryView.cpp @@ -159,24 +159,12 @@ void CMemoryView::OnPopupMenu(wxCommandEvent& event) switch (event.GetId()) { - case IDM_GOTOINMEMVIEW: - // CMemoryDlg::Goto(selection); - break; - #if wxUSE_CLIPBOARD case IDM_COPYADDRESS: { wxTheClipboard->SetData(new wxTextDataObject(wxString::Format(_T("%08x"), selection))); } - break; - - case IDM_COPYCODE: - { - char disasm[256]; - debugger->disasm(selection, disasm, 256); - wxTheClipboard->SetData(new wxTextDataObject(wxString::FromAscii(disasm))); //Have to manually convert from char* to wxString, don't have to in Windows? - break; - } + break; case IDM_COPYHEX: { @@ -186,22 +174,6 @@ void CMemoryView::OnPopupMenu(wxCommandEvent& event) } break; #endif - - case IDM_RUNTOHERE: - { - debugger->setBreakpoint(selection); - debugger->runToBreakpoint(); - redraw(); - } - break; - - case IDM_DYNARECRESULTS: - { -// CDynaViewDlg::ViewAddr(selection); -// CDynaViewDlg::Show(TRUE); -// MessageBox(NULL, "not impl", "CtrlDisAsmView", MB_OK); - } - break; } #if wxUSE_CLIPBOARD @@ -218,11 +190,8 @@ void CMemoryView::OnMouseUpR(wxMouseEvent& event) //menu.Append(IDM_GOTOINMEMVIEW, "&Goto in mem view"); #if wxUSE_CLIPBOARD menu.Append(IDM_COPYADDRESS, wxString::FromAscii("Copy &address")); - menu.Append(IDM_COPYCODE, wxString::FromAscii("Copy &code")); menu.Append(IDM_COPYHEX, wxString::FromAscii("Copy &hex")); #endif - menu.Append(IDM_RUNTOHERE, _T("&Run To Here")); - //menu.Append(IDM_DYNARECRESULTS, "Copy &address"); PopupMenu(&menu); event.Skip(true); } @@ -315,66 +284,11 @@ void CMemoryView::OnPaint(wxPaintEvent& event) if (debugger->isAlive()) { char dis[256] = {0}; - debugger->disasm(address, dis, 256); - char* dis2 = strchr(dis, '\t'); + u32 mem = debugger->readMemory(address); + float flt = *(float *)(&mem); + sprintf(dis, "f: %f", flt); char desc[256] = ""; - if (dis2) - { - *dis2 = 0; - dis2++; - const char* mojs = strstr(dis2, "0x8"); - - if (mojs) - { - for (int k = 0; k < 8; k++) - { - bool found = false; - - for (int j = 0; j < 22; j++) - { - if (mojs[k + 2] == "0123456789ABCDEFabcdef"[j]) - { - found = true; - } - } - - - if (!found) - { - mojs = 0; - break; - } - } - } - - if (mojs) - { - int offs; - sscanf(mojs + 2, "%08x", &offs); - branches[numBranches].src = rowY1 + rowHeight / 2; - branches[numBranches].srcAddr = address / align; - branches[numBranches++].dst = (int)(rowY1 + ((s64)offs - (s64)address) * rowHeight / align + rowHeight / 2); - sprintf(desc, "-->%s", debugger->getDescription(offs).c_str()); - dc.SetTextForeground(_T("#600060")); - } - else - { - dc.SetTextForeground(_T("#000000")); - } - - dc.DrawText(wxString::FromAscii(dis2), 17+fontSize*(8+8+8), rowY1); - } - - if (strcmp(dis, "blr")) - { - dc.SetTextForeground(_T("#007000")); - } - else - { - dc.SetTextForeground(_T("#8000FF")); - } - dc.DrawText(wxString::FromAscii(dis), 17+fontSize*(8+8), rowY1); if (desc[0] == 0)