1
0
Fork 0

Fix bugs with singleshoot breakpoints

This commit is contained in:
torusrxxx 2021-01-05 23:27:13 +08:00
parent e7edb6ad34
commit 4dfeca4078
No known key found for this signature in database
GPG Key ID: A795C73A0F1CFADD
4 changed files with 38 additions and 3 deletions

View File

@ -67,10 +67,10 @@ void ExceptionDirectoryAnalysis::Analyse()
EnumerateFunctionRuntimeEntries64([&](PRUNTIME_FUNCTION Function)
{
auto funcAddr = mModuleBase + Function->BeginAddress;
auto funcEnd = mModuleBase + Function->EndAddress;
auto funcEnd = mModuleBase + Function->EndAddress - 1;
// If within limits...
if(inRange(funcAddr) && inRange(funcEnd))
if(inRange(funcAddr) && inRange(funcEnd) && funcAddr <= funcEnd)
mFunctions.push_back({ funcAddr, funcEnd });
return true;

View File

@ -507,13 +507,36 @@ bool BpSetSingleshoot(duint Address, BP_TYPE Type, bool singleshoot)
ASSERT_DEBUGGING("Command function call");
EXCLUSIVE_ACQUIRE(LockBreakpoints);
// Set breakpoint fast resume
// Set breakpoint singleshoot
BREAKPOINT* bpInfo = BpInfoFromAddr(Type, Address);
if(!bpInfo)
return false;
bpInfo->singleshoot = singleshoot;
// Update singleshoot information in TitanEngine
switch(Type)
{
case BPNORMAL:
bpInfo->titantype = (bpInfo->titantype & ~UE_SINGLESHOOT) | (singleshoot ? UE_SINGLESHOOT : 0);
if(IsBPXEnabled(Address) && bpInfo->enabled)
{
if(!DeleteBPX(Address))
dprintf(QT_TRANSLATE_NOOP("DBG", "Delete breakpoint failed (DeleteBPX): %p\n"), Address);
if(!SetBPX(Address, bpInfo->titantype, (void*)cbUserBreakpoint))
dprintf(QT_TRANSLATE_NOOP("DBG", "Error setting breakpoint at %p! (SetBPX)\n"), Address);
}
break;
case BPMEMORY:
if(bpInfo->enabled)
{
if(!RemoveMemoryBPX(Address, bpInfo->memsize))
dprintf(QT_TRANSLATE_NOOP("DBG", "Delete memory breakpoint failed (RemoveMemoryBPX): %p\n"), Address);
if(!SetMemoryBPXEx(Address, bpInfo->memsize, bpInfo->titantype, !singleshoot, (void*)cbMemoryBreakpoint))
dprintf(QT_TRANSLATE_NOOP("DBG", "Could not enable memory breakpoint %p (SetMemoryBPXEx)\n"), Address);
}
break;
}
return true;
}

View File

@ -61,6 +61,7 @@ static bool cbDisableAllBreakpoints(const BREAKPOINT* bp)
return true;
}
// Software breakpoints
bool cbDebugSetBPX(int argc, char* argv[]) //bp addr [,name [,type]]
{
if(IsArgumentsLessThan(argc, 2))
@ -325,6 +326,7 @@ bool cbDebugDisableBPX(int argc, char* argv[])
return true;
}
// Hardware breakpoints
static bool cbDeleteAllHardwareBreakpoints(const BREAKPOINT* bp)
{
if(bp->type != BPHARDWARE)
@ -627,6 +629,7 @@ bool cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
return true;
}
// Memory breakpoints
static bool cbDeleteAllMemoryBreakpoints(const BREAKPOINT* bp)
{
if(bp->type != BPMEMORY)
@ -897,6 +900,7 @@ bool cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
return true;
}
// DLL breakpoints
static bool cbDeleteAllDllBreakpoints(const BREAKPOINT* bp)
{
if(bp->type != BPDLL || !bp->enabled)
@ -1111,6 +1115,7 @@ bool cbDebugBpDllDisable(int argc, char* argv[])
return true;
}
// Exception breakpoints
static bool cbDeleteAllExceptionBreakpoints(const BREAKPOINT* bp)
{
if(bp->type != BPEXCEPTION)

View File

@ -760,7 +760,14 @@ static void handleBreakCondition(const BREAKPOINT & bp, const void* ExceptionAdd
if(doBreak)
{
if(bp.singleshoot)
{
BpDelete(bp.addr, bp.type);
if(bp.type == BPHARDWARE) // Remove this singleshoot hardware breakpoint
{
if(TITANDRXVALID(bp.titantype) && !DeleteHardwareBreakPoint(TITANGETDRX(bp.titantype)))
dprintf(QT_TRANSLATE_NOOP("DBG", "Delete hardware breakpoint failed: %p (DeleteHardwareBreakPoint)\n"), bp.addr);
}
}
if(!bp.silent)
{
switch(bp.type)