diff --git a/Source/Core/Common/Src/LogManager.cpp b/Source/Core/Common/Src/LogManager.cpp index d57f51600c..da2898c9b2 100644 --- a/Source/Core/Common/Src/LogManager.cpp +++ b/Source/Core/Common/Src/LogManager.cpp @@ -99,7 +99,7 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, va_end(args); static const char level_to_char[7] = "-NEWID"; - sprintf(msg, "%s %c: %s %s\n", + sprintf(msg, "%s %c[%s]: %s\n", Common::Timer::GetTimeFormatted().c_str(), level_to_char[(int)level], log->getShortName(), diff --git a/Source/Core/Common/Src/MsgHandler.cpp b/Source/Core/Common/Src/MsgHandler.cpp index 93ae6f6284..868d0a8bcc 100644 --- a/Source/Core/Common/Src/MsgHandler.cpp +++ b/Source/Core/Common/Src/MsgHandler.cpp @@ -53,7 +53,7 @@ bool MsgAlert(const char* caption, bool yes_no, int Style, const char* format, . ERROR_LOG(MASTER_LOG, "%s: %s", caption, buffer); // Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored - if (msg_handler && (AlertEnabled || yes_no)) { + if (msg_handler && (AlertEnabled || Style == QUESTION)) { ret = msg_handler(caption, buffer, yes_no, Style); } return ret; diff --git a/Source/Core/Core/Src/Debugger/DebugInterface.h b/Source/Core/Core/Src/Debugger/DebugInterface.h index 7df1405e8e..0cf8ca746e 100644 --- a/Source/Core/Core/Src/Debugger/DebugInterface.h +++ b/Source/Core/Core/Src/Debugger/DebugInterface.h @@ -25,7 +25,7 @@ public: virtual void setPC(unsigned int /*address*/) {} virtual void step() {} virtual void runToBreakpoint() {} - virtual void insertBLR(unsigned int /*address*/) {} + virtual void insertBLR(unsigned int /*address*/, unsigned int) {} virtual int getColor(unsigned int /*address*/){return 0xFFFFFFFF;} virtual std::string getDescription(unsigned int /*address*/) = 0; }; diff --git a/Source/Core/Core/Src/Debugger/PPCDebugInterface.cpp b/Source/Core/Core/Src/Debugger/PPCDebugInterface.cpp index ce6fde3633..934da93158 100644 --- a/Source/Core/Core/Src/Debugger/PPCDebugInterface.cpp +++ b/Source/Core/Core/Src/Debugger/PPCDebugInterface.cpp @@ -112,9 +112,9 @@ void PPCDebugInterface::toggleBreakpoint(unsigned int address) BreakPoints::Add(address); } -void PPCDebugInterface::insertBLR(unsigned int address) +void PPCDebugInterface::insertBLR(unsigned int address, unsigned int value) { - Memory::Write_U32(0x4e800020, address); + Memory::Write_U32(value, address); } diff --git a/Source/Core/Core/Src/Debugger/PPCDebugInterface.h b/Source/Core/Core/Src/Debugger/PPCDebugInterface.h index f7e0da0bb1..70da7a703e 100644 --- a/Source/Core/Core/Src/Debugger/PPCDebugInterface.h +++ b/Source/Core/Core/Src/Debugger/PPCDebugInterface.h @@ -26,7 +26,7 @@ public: virtual void setPC(unsigned int address); virtual void step() {} virtual void runToBreakpoint(); - virtual void insertBLR(unsigned int address); + virtual void insertBLR(unsigned int address, unsigned int); virtual int getColor(unsigned int address); virtual std::string getDescription(unsigned int address); }; diff --git a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter.cpp index 7cf5b445a8..bd762f6346 100644 --- a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter.cpp +++ b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter.cpp @@ -129,6 +129,14 @@ void SingleStep() } } +//#define SHOW_HISTORY +#ifdef SHOW_HISTORY +std::vector PCVec; +std::vector PCBlockVec; +int ShowBlocks = 30; +int ShowSteps = 300; +#endif + // FastRun - inspired by GCemu (to imitate the JIT so that they can be compared). void Run() { @@ -137,6 +145,12 @@ void Run() //we have to check exceptions at branches apparently (or maybe just rfi?) if (Core::GetStartupParameter().bEnableDebugging) { + #ifdef SHOW_HISTORY + PCBlockVec.push_back(PC); + if (PCBlockVec.size() > ShowBlocks) + PCBlockVec.erase(PCBlockVec.begin()); + #endif + // Debugging friendly version of inner loop. Tries to do the timing as similarly to the // JIT as possible. Does not take into account that some instructions take multiple cycles. while (CoreTiming::downcount > 0) @@ -145,9 +159,32 @@ void Run() int i; for (i = 0; !m_EndBlock; i++) { + #ifdef SHOW_HISTORY + PCVec.push_back(PC); + if (PCVec.size() > ShowSteps) + PCVec.erase(PCVec.begin()); + #endif + //2: check for breakpoint if (BreakPoints::IsAddressBreakPoint(PC)) { + #ifdef SHOW_HISTORY + NOTICE_LOG(POWERPC, "----------------------------"); + NOTICE_LOG(POWERPC, "Blocks:"); + for (int j = 0; j < PCBlockVec.size(); j++) + NOTICE_LOG(POWERPC, "PC: 0x%08x", PCBlockVec.at(j)); + NOTICE_LOG(POWERPC, "----------------------------"); + NOTICE_LOG(POWERPC, "Steps:"); + for (int j = 0; j < PCVec.size(); j++) + { + // Write space + if (j > 0) + if (PCVec.at(j) != PCVec.at(j-1) + 4) + NOTICE_LOG(POWERPC, ""); + + NOTICE_LOG(POWERPC, "PC: 0x%08x", PCVec.at(j)); + } + #endif INFO_LOG(POWERPC, "Hit Breakpoint - %08x", PC); CCPU::Break(); if (BreakPoints::IsTempBreakPoint(PC)) @@ -156,7 +193,6 @@ void Run() Host_UpdateDisasmDialog(); return; } - SingleStepInner(); } CoreTiming::downcount -= i; diff --git a/Source/Core/DebuggerWX/Src/CodeView.cpp b/Source/Core/DebuggerWX/Src/CodeView.cpp index 3625ffde53..c958e30f56 100644 --- a/Source/Core/DebuggerWX/Src/CodeView.cpp +++ b/Source/Core/DebuggerWX/Src/CodeView.cpp @@ -38,7 +38,7 @@ enum IDM_COPYADDRESS, IDM_COPYHEX, IDM_COPYCODE, - IDM_INSERTBLR, + IDM_INSERTBLR, IDM_INSERTNOP, IDM_RUNTOHERE, IDM_JITRESULTS, IDM_FOLLOWBRANCH, @@ -190,6 +190,36 @@ u32 CCodeView::AddrToBranch(u32 addr) return 0; } +void CCodeView::InsertBlrNop(int Blr) +{ + // Check if this address has been modified + int find = -1; + for(u32 i = 0; i < BlrList.size(); i++) + { + if(BlrList.at(i).Address == selection) + { find = i; break; } + } + + // Save the old value + if(find >= 0) + { + Memory::Write_U32(BlrList.at(find).OldValue, selection); + BlrList.erase(BlrList.begin() + find); + } + else + { + BlrStruct Temp; + Temp.Address = selection; + Temp.OldValue = debugger->readMemory(selection); + BlrList.push_back(Temp); + if (Blr == 0) + debugger->insertBLR(selection, 0x4e800020); + else + debugger->insertBLR(selection, 0x60000000); + } + redraw(); +} + void CCodeView::OnPopupMenu(wxCommandEvent& event) { #if wxUSE_CLIPBOARD @@ -252,31 +282,10 @@ void CCodeView::OnPopupMenu(wxCommandEvent& event) // Insert blr or restore old value case IDM_INSERTBLR: - { - // Check if this address has been modified - int find = -1; - for(u32 i = 0; i < BlrList.size(); i++) - { - if(BlrList.at(i).Address == selection) - { find = i; break; } - } - - // Save the old value - if(find >= 0) - { - Memory::Write_U32(BlrList.at(find).OldValue, selection); - BlrList.erase(BlrList.begin() + find); - } - else - { - BlrStruct Temp; - Temp.Address = selection; - Temp.OldValue = debugger->readMemory(selection); - BlrList.push_back(Temp); - debugger->insertBLR(selection); - } - redraw(); - } + InsertBlrNop(0); + break; + case IDM_INSERTNOP: + InsertBlrNop(1); break; case IDM_JITRESULTS: @@ -349,6 +358,7 @@ void CCodeView::OnMouseUpR(wxMouseEvent& event) menu.Append(IDM_ADDFUNCTION, _T("&Add function")); menu.Append(IDM_JITRESULTS, wxString::FromAscii("PPC vs X86")); menu.Append(IDM_INSERTBLR, wxString::FromAscii("Insert &blr")); + menu.Append(IDM_INSERTNOP, wxString::FromAscii("Insert &nop")); menu.Append(IDM_PATCHALERT, wxString::FromAscii("Patch alert")); PopupMenu(&menu); event.Skip(true); diff --git a/Source/Core/DebuggerWX/Src/CodeView.h b/Source/Core/DebuggerWX/Src/CodeView.h index a139941de1..dc0b563fc1 100644 --- a/Source/Core/DebuggerWX/Src/CodeView.h +++ b/Source/Core/DebuggerWX/Src/CodeView.h @@ -39,6 +39,7 @@ class CCodeView void OnMouseUpL(wxMouseEvent& event); void OnMouseUpR(wxMouseEvent& event); void OnPopupMenu(wxCommandEvent& event); + void InsertBlrNop(int); u32 GetSelection() {return(selection);} diff --git a/Source/Core/VideoCommon/Src/AVIDump.cpp b/Source/Core/VideoCommon/Src/AVIDump.cpp index 3e00821ea1..3447efbacf 100644 --- a/Source/Core/VideoCommon/Src/AVIDump.cpp +++ b/Source/Core/VideoCommon/Src/AVIDump.cpp @@ -138,8 +138,8 @@ void AVIDump::AddFrame(char *data) { AVIStreamWrite(m_streamCompressed, ++m_frameCount, 1, (LPVOID) data, m_bitmap.biSizeImage, AVIIF_KEYFRAME, NULL, &m_byteBuffer); m_totalBytes += m_byteBuffer; - // Fun fact: VfW can't property save files over 2gb in size, but can keep - // writing to them up to 4gb. + // Close the recording if the file is more than 2gb + // VfW can't properly save files over 2gb in size, but can keep writing to them up to 4gb. if (m_totalBytes >= 2000000000) { CloseFile(); m_fileCount++;