Debugging: Added 'insert nop' to menu, added 'show history' code for interpreter mode

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3388 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2009-06-09 05:26:39 +00:00
parent bb412e5641
commit 33a0f0838b
9 changed files with 82 additions and 35 deletions

View File

@ -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(),

View File

@ -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;

View File

@ -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;
};

View File

@ -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);
}

View File

@ -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);
};

View File

@ -129,6 +129,14 @@ void SingleStep()
}
}
//#define SHOW_HISTORY
#ifdef SHOW_HISTORY
std::vector <int> PCVec;
std::vector <int> 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;

View File

@ -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);

View File

@ -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);}

View File

@ -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++;