Merge branch 'Mirrors' of git://github.com/Kingcom/pcsx2

This commit is contained in:
Gregory Hainaut 2014-05-05 09:39:35 +02:00
commit 460ee7f5de
4 changed files with 48 additions and 73 deletions

View File

@ -28,7 +28,22 @@ std::vector<MemCheck> CBreakPoints::memChecks_;
std::vector<MemCheck *> CBreakPoints::cleanupMemChecks_;
bool CBreakPoints::breakpointTriggered_ = false;
int addressMask = 0x1FFFFFFF;
// called from the dynarec
u32 __fastcall standardizeBreakpointAddress(u32 addr)
{
if (addr >= 0xFFFF8000)
return addr;
if (addr >= 0xBFC00000 && addr <= 0xBFFFFFFF)
addr &= 0x1FFFFFFF;
addr &= 0x7FFFFFFF;
if ((addr >> 28) == 2 || (addr >> 28) == 3)
addr &= ~(0xF << 28);
return addr;
}
MemCheck::MemCheck()
{
@ -100,11 +115,12 @@ void MemCheck::JitCleanup()
size_t CBreakPoints::FindBreakpoint(u32 addr, bool matchTemp, bool temp)
{
addr &= addressMask;
addr = standardizeBreakpointAddress(addr);
for (size_t i = 0; i < breakPoints_.size(); ++i)
{
if ((breakPoints_[i].addr & addressMask) == addr && (!matchTemp || breakPoints_[i].temporary == temp))
u32 cmp = standardizeBreakpointAddress(breakPoints_[i].addr);
if (cmp == addr && (!matchTemp || breakPoints_[i].temporary == temp))
return i;
}
@ -113,11 +129,14 @@ size_t CBreakPoints::FindBreakpoint(u32 addr, bool matchTemp, bool temp)
size_t CBreakPoints::FindMemCheck(u32 start, u32 end)
{
start &= addressMask;
end &= addressMask;
start = standardizeBreakpointAddress(start);
end = standardizeBreakpointAddress(end);
for (size_t i = 0; i < memChecks_.size(); ++i)
{
if ((memChecks_[i].start & addressMask) == start && (memChecks_[i].end & addressMask) == end)
u32 cmpStart = standardizeBreakpointAddress(memChecks_[i].start);
int cmpEnd = standardizeBreakpointAddress(memChecks_[i].end);
if (cmpStart == start && cmpEnd == end)
return i;
}
@ -305,70 +324,15 @@ void CBreakPoints::ClearAllMemChecks()
}
}
static inline u32 NotCached(u32 val)
{
// Remove the cached part of the address.
return val & ~0x40000000;
}
MemCheck *CBreakPoints::GetMemCheck(u32 address, int size)
{
address &= addressMask;
std::vector<MemCheck>::iterator iter;
for (iter = memChecks_.begin(); iter != memChecks_.end(); ++iter)
{
MemCheck &check = *iter;
if (check.end != 0)
{
if (NotCached(address + size) > NotCached(check.start) && NotCached(address) < NotCached(check.end))
return &check;
}
else
{
if (NotCached(check.start) == NotCached(address))
return &check;
}
}
//none found
return 0;
}
void CBreakPoints::ExecMemCheck(u32 address, bool write, int size, u32 pc)
{
auto check = GetMemCheck(address, size);
if (check)
check->Action(address, write, size, pc);
}
void CBreakPoints::ExecMemCheckJitBefore(u32 address, bool write, int size, u32 pc)
{
auto check = GetMemCheck(address, size);
if (check) {
check->JitBefore(address, write, size, pc);
cleanupMemChecks_.push_back(check);
}
}
void CBreakPoints::ExecMemCheckJitCleanup()
{
for (auto it = cleanupMemChecks_.begin(), end = cleanupMemChecks_.end(); it != end; ++it) {
auto check = *it;
check->JitCleanup();
}
cleanupMemChecks_.clear();
}
void CBreakPoints::SetSkipFirst(u32 pc)
{
breakSkipFirstAt_ = pc & addressMask;
breakSkipFirstAt_ = standardizeBreakpointAddress(pc);
breakSkipFirstTicks_ = r5900Debug.getCycles();
}
u32 CBreakPoints::CheckSkipFirst(u32 cmpPc)
{
cmpPc &= addressMask;
cmpPc = standardizeBreakpointAddress(cmpPc);
u32 pc = breakSkipFirstAt_;
if (breakSkipFirstTicks_ == r5900Debug.getCycles())
return pc;

View File

@ -132,13 +132,6 @@ public:
static void ChangeMemCheck(u32 start, u32 end, MemCheckCondition cond, MemCheckResult result);
static void ClearAllMemChecks();
static MemCheck *GetMemCheck(u32 address, int size);
static void ExecMemCheck(u32 address, bool write, int size, u32 pc);
// Executes memchecks but used by the jit. Cleanup finalizes after jit is done.
static void ExecMemCheckJitBefore(u32 address, bool write, int size, u32 pc);
static void ExecMemCheckJitCleanup();
static void SetSkipFirst(u32 pc);
static u32 CheckSkipFirst(u32 pc);
@ -168,3 +161,5 @@ private:
};
// called from the dynarec
u32 __fastcall standardizeBreakpointAddress(u32 addr);

View File

@ -483,12 +483,26 @@ std::string R5900DebugInterface::disasm(u32 address)
bool R5900DebugInterface::isValidAddress(u32 addr)
{
// ee can't access the first part of memory.
if (addr < 0x80000)
return false;
if (addr >= 0xFFFF8000)
return true;
addr &= 0x7FFFFFFF;
// get rid of ee ram mirrors
if ((addr >> 28) == 2 || (addr >> 28) == 3)
addr &= ~(0xF << 28);
// registers
if (addr >= 0x10000000 && addr < 0x10010000)
return true;
if (addr >= 0x12000000 && addr < 0x12001100)
return true;
// scratchpad
if (addr >= 0x70000000 && addr < 0x70004000)
return true;

View File

@ -1314,7 +1314,9 @@ void recMemcheck(u32 bits, bool store)
if (bits == 128)
xAND(ecx, ~0x0F);
xMOV(edx,ecx);
xCALL(standardizeBreakpointAddress);
xMOV(ecx,eax);
xMOV(edx,eax);
xADD(edx,bits/8);
// ecx = access address
@ -1332,11 +1334,11 @@ void recMemcheck(u32 bits, bool store)
// logic: memAddress < bpEnd && bpStart < memAddress+memSize
xMOV(eax,checks[i].end);
xMOV(eax,standardizeBreakpointAddress(checks[i].end));
xCMP(ecx,eax); // address < end
xForwardJGE8 next1; // if address >= end then goto next1
xMOV(eax,checks[i].start);
xMOV(eax,standardizeBreakpointAddress(checks[i].start));
xCMP(eax,edx); // start < address+size
xForwardJGE8 next2; // if start >= address+size then goto next2