Merge pull request #140 from Kingcom/Debugger

Various debugger fixes and enhancements
This commit is contained in:
sudonim1 2014-07-15 23:59:07 +01:00
commit 80b22ca2be
7 changed files with 88 additions and 21 deletions

View File

@ -27,6 +27,10 @@
#include "../IopMem.h"
#include "SymbolMap.h"
#ifdef _WIN32
#include <Windows.h>
#endif
extern AppCoreThread CoreThread;
R5900DebugInterface r5900Debug;
@ -204,25 +208,48 @@ bool DebugInterface::parseExpression(PostfixExpression& exp, u64& dest)
// R5900DebugInterface
//
u32 R5900DebugInterface::read8(u32 address)
u32 R5900DebugInterface::readMemory(u32 address, u32 size)
{
if (!isValidAddress(address))
return -1;
return memRead8(address);
// TODO: Add linux variant of the following __try/__except
#if defined(_MSC_VER)
__try
{
#endif
switch (size)
{
case 1:
return memRead8(address);
case 2:
return memRead16(address);
case 4:
return memRead32(address);
default:
return -1;
}
#if defined(_MSC_VER)
} __except(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
{
return -1;
}
#endif
}
u32 R5900DebugInterface::read8(u32 address)
{
return readMemory(address,1);
}
u32 R5900DebugInterface::read16(u32 address)
{
if (!isValidAddress(address))
return -1;
return memRead16(address);
return readMemory(address,2);
}
u32 R5900DebugInterface::read32(u32 address)
{
if (!isValidAddress(address))
return -1;
return memRead32(address);
return readMemory(address,4);
}
u64 R5900DebugInterface::read64(u32 address)
@ -231,7 +258,19 @@ u64 R5900DebugInterface::read64(u32 address)
return -1;
u64 result;
memRead64(address,result);
// TODO: Add linux variant of the following __try/__except
#if defined(_MSC_VER)
__try {
#endif
memRead64(address,result);
#if defined(_MSC_VER)
} __except(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
{
result = -1;
}
#endif
return result;
}
@ -240,8 +279,20 @@ u128 R5900DebugInterface::read128(u32 address)
if (!isValidAddress(address))
return u128::From32(-1);
u128 result;
memRead128(address,result);
__aligned16 u128 result;
// TODO: Add linux variant of the following __try/__except
#if defined(_MSC_VER)
__try {
#endif
memRead128(address,result);
#if defined(_MSC_VER)
} __except(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
{
result.hi = result.lo = -1;
}
#endif
return result;
}

View File

@ -84,6 +84,8 @@ public:
virtual std::string disasm(u32 address);
virtual bool isValidAddress(u32 address);
virtual u32 getCycles();
private:
u32 readMemory(u32 address, u32 size);
};

View File

@ -337,6 +337,9 @@ namespace MIPSAnalyst
case 0x2C: // sdl
size = 8;
off = -7;
case 0x1E: // lq
case 0x1F: // sq
size = 16;
break;
}

View File

@ -757,14 +757,14 @@ void Pcsx2App::enterDebugMode()
{
DisassemblyDialog* dlg = GetDisassemblyPtr();
if (dlg)
dlg->setDebugMode(true);
dlg->setDebugMode(true,false);
}
void Pcsx2App::leaveDebugMode()
{
DisassemblyDialog* dlg = GetDisassemblyPtr();
if (dlg)
dlg->setDebugMode(false);
dlg->setDebugMode(false,false);
}
void Pcsx2App::resetDebugger()

View File

@ -811,7 +811,7 @@ void CtrlDisassemblyView::updateStatusBarText()
}
case 16:
{
u128 data = cpu->read128(line.info.dataAddress);
__aligned16 u128 data = cpu->read128(line.info.dataAddress);
sprintf(text,"[%08X] = %016llX%016llX",line.info.dataAddress,data._u64[1],data._u64[0]);
break;
}

View File

@ -170,7 +170,7 @@ DisassemblyDialog::DisassemblyDialog(wxWindow* parent):
SetMinSize(wxSize(1000,600));
panel->GetSizer()->Fit(this);
setDebugMode(true);
setDebugMode(true,true);
}
#ifdef WIN32
@ -212,8 +212,10 @@ void DisassemblyDialog::onBreakRunClicked(wxCommandEvent& evt)
// If the current PC is on a breakpoint, the user doesn't want to do nothing.
CBreakPoints::SetSkipFirst(r5900Debug.getPC());
r5900Debug.resumeCpu();
} else
} else {
r5900Debug.pauseCpu();
gotoPc();
}
}
void DisassemblyDialog::onStepOverClicked(wxCommandEvent& evt)
@ -352,7 +354,9 @@ void DisassemblyDialog::onDebuggerEvent(wxCommandEvent& evt)
wxEventType type = evt.GetEventType();
if (type == debEVT_SETSTATUSBARTEXT)
{
GetStatusBar()->SetLabel(evt.GetString());
CtrlDisassemblyView* view = reinterpret_cast<CtrlDisassemblyView*>(evt.GetEventObject());
if (view != NULL && view == currentCpu->getDisassembly())
GetStatusBar()->SetLabel(evt.GetString());
} else if (type == debEVT_UPDATELAYOUT)
{
if (currentCpu != NULL)
@ -420,7 +424,13 @@ void DisassemblyDialog::reset()
iopTab->getDisassembly()->clearFunctions();
};
void DisassemblyDialog::setDebugMode(bool debugMode)
void DisassemblyDialog::gotoPc()
{
eeTab->getDisassembly()->gotoPc();
iopTab->getDisassembly()->gotoPc();
}
void DisassemblyDialog::setDebugMode(bool debugMode, bool switchPC)
{
bool running = r5900Debug.isAlive();
@ -437,8 +447,8 @@ void DisassemblyDialog::setDebugMode(bool debugMode)
stepOverButton->Enable(true);
stepIntoButton->Enable(true);
eeTab->getDisassembly()->gotoPc();
iopTab->getDisassembly()->gotoPc();
if (switchPC || CBreakPoints::GetBreakpointTriggered())
gotoPc();
if (CBreakPoints::GetBreakpointTriggered())
{

View File

@ -62,7 +62,7 @@ public:
void update();
void reset();
void setDebugMode(bool debugMode);
void setDebugMode(bool debugMode, bool switchPC);
#ifdef WIN32
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
@ -79,6 +79,7 @@ protected:
void onClose(wxCloseEvent& evt);
void stepOver();
void stepInto();
void gotoPc();
private:
CpuTabPage* eeTab;
CpuTabPage* iopTab;