DBG+GUI: enable/disable memory breakpoints
This commit is contained in:
parent
6b6fc7634f
commit
e85b474b13
|
@ -526,10 +526,7 @@ static bool cbSetModuleBreakpoints(const BREAKPOINT* bp)
|
|||
{
|
||||
uint size=0;
|
||||
memfindbaseaddr(bp->addr, &size);
|
||||
bool restore=false;
|
||||
if(!bp->singleshoot)
|
||||
restore=true;
|
||||
if(!SetMemoryBPXEx(bp->addr, size, bp->titantype, restore, (void*)cbMemoryBreakpoint))
|
||||
if(!SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint))
|
||||
dprintf("could not set memory breakpoint "fhex"!\n", bp->addr);
|
||||
}
|
||||
break;
|
||||
|
@ -1297,6 +1294,32 @@ bool cbDisableAllHardwareBreakpoints(const BREAKPOINT* bp)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool cbEnableAllMemoryBreakpoints(const BREAKPOINT* bp)
|
||||
{
|
||||
if(bp->type!=BPMEMORY or bp->enabled)
|
||||
return true;
|
||||
uint size=0;
|
||||
memfindbaseaddr(bp->addr, &size);
|
||||
if(!bpenable(bp->addr, BPMEMORY, true) or !SetMemoryBPXEx(bp->addr, size, bp->titantype, !bp->singleshoot, (void*)cbMemoryBreakpoint))
|
||||
{
|
||||
dprintf("could not enable memory breakpoint "fhex"\n", bp->addr);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cbDisableAllMemoryBreakpoints(const BREAKPOINT* bp)
|
||||
{
|
||||
if(bp->type!=BPMEMORY or !bp->enabled)
|
||||
return true;
|
||||
if(!bpenable(bp->addr, BPMEMORY, false) or !DeleteHardwareBreakPoint((bp->titantype>>8)&0xF))
|
||||
{
|
||||
dprintf("could not disable memory breakpoint "fhex"\n", bp->addr);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cbBreakpointList(const BREAKPOINT* bp)
|
||||
{
|
||||
const char* type=0;
|
||||
|
|
|
@ -62,6 +62,8 @@ bool cbEnableAllBreakpoints(const BREAKPOINT* bp);
|
|||
bool cbDisableAllBreakpoints(const BREAKPOINT* bp);
|
||||
bool cbEnableAllHardwareBreakpoints(const BREAKPOINT* bp);
|
||||
bool cbDisableAllHardwareBreakpoints(const BREAKPOINT* bp);
|
||||
bool cbEnableAllMemoryBreakpoints(const BREAKPOINT* bp);
|
||||
bool cbDisableAllMemoryBreakpoints(const BREAKPOINT* bp);
|
||||
bool cbBreakpointList(const BREAKPOINT* bp);
|
||||
bool cbDeleteAllMemoryBreakpoints(const BREAKPOINT* bp);
|
||||
bool cbDeleteAllHardwareBreakpoints(const BREAKPOINT* bp);
|
||||
|
|
|
@ -298,7 +298,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
|
|||
{
|
||||
if(!bpenable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint))
|
||||
{
|
||||
dprintf("could not enable "fhex"\n", found.addr);
|
||||
dprintf("could not enable breakpoint "fhex"\n", found.addr);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
GuiUpdateAllViews();
|
||||
|
@ -318,7 +318,7 @@ CMDRESULT cbDebugEnableBPX(int argc, char* argv[])
|
|||
}
|
||||
if(!bpenable(found.addr, BPNORMAL, true) or !SetBPX(found.addr, found.titantype, (void*)cbUserBreakpoint))
|
||||
{
|
||||
dprintf("could not enable "fhex"\n", found.addr);
|
||||
dprintf("could not enable breakpoint "fhex"\n", found.addr);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
dputs("breakpoint enabled!");
|
||||
|
@ -347,7 +347,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
|
|||
{
|
||||
if(!bpenable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr))
|
||||
{
|
||||
dprintf("could not disable "fhex"\n", found.addr);
|
||||
dprintf("could not disable breakpoint "fhex"\n", found.addr);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
GuiUpdateAllViews();
|
||||
|
@ -366,7 +366,7 @@ CMDRESULT cbDebugDisableBPX(int argc, char* argv[])
|
|||
}
|
||||
if(!bpenable(found.addr, BPNORMAL, false) or !DeleteBPX(found.addr))
|
||||
{
|
||||
dprintf("could not disable "fhex"\n", found.addr);
|
||||
dprintf("could not disable breakpoint "fhex"\n", found.addr);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
dputs("breakpoint disabled!");
|
||||
|
@ -1174,7 +1174,7 @@ CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[])
|
|||
}
|
||||
if(!bpenable(found.addr, BPHARDWARE, true) or !SetHardwareBreakPoint(found.addr, 0, (found.titantype>>4)&0xF, found.titantype&0xF, (void*)cbHardwareBreakpoint))
|
||||
{
|
||||
dprintf("could not enable "fhex"\n", found.addr);
|
||||
dprintf("could not enable hardware breakpoint "fhex"\n", found.addr);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
dputs("hardware breakpoint enabled!");
|
||||
|
@ -1187,7 +1187,7 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
|
|||
char arg1[deflen]="";
|
||||
if(!argget(*argv, arg1, 0, true)) //delete all hardware breakpoints
|
||||
{
|
||||
if(!bpgetcount(BPNORMAL))
|
||||
if(!bpgetcount(BPHARDWARE))
|
||||
{
|
||||
dputs("no hardware breakpoints to disable!");
|
||||
return STATUS_CONTINUE;
|
||||
|
@ -1212,10 +1212,97 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[])
|
|||
}
|
||||
if(!bpenable(found.addr, BPHARDWARE, false) or !DeleteHardwareBreakPoint((found.titantype>>8)&0xF))
|
||||
{
|
||||
dprintf("could not disable "fhex"\n", found.addr);
|
||||
dprintf("could not disable hardware breakpoint "fhex"\n", found.addr);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
dputs("hardware breakpoint disabled!");
|
||||
GuiUpdateAllViews();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]="";
|
||||
DWORD drx=0;
|
||||
if(!GetUnusedHardwareBreakPointRegister(0))
|
||||
{
|
||||
dputs("you can only set 4 hardware breakpoints");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
if(!argget(*argv, arg1, 0, true)) //enable all memory breakpoints
|
||||
{
|
||||
if(!bpgetcount(BPMEMORY))
|
||||
{
|
||||
dputs("no hardware breakpoints to enable!");
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
if(!bpenumall(cbEnableAllHardwareBreakpoints)) //at least one enable failed
|
||||
return STATUS_ERROR;
|
||||
dputs("all memory breakpoints enabled!");
|
||||
GuiUpdateAllViews();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
BREAKPOINT found;
|
||||
uint addr=0;
|
||||
if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint
|
||||
{
|
||||
dprintf("no such memory breakpoint \"%s\"\n", arg1);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
if(found.enabled)
|
||||
{
|
||||
dputs("hardware memory already enabled!");
|
||||
GuiUpdateAllViews();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
uint size=0;
|
||||
memfindbaseaddr(found.addr, &size);
|
||||
if(!bpenable(found.addr, BPMEMORY, true) or !SetMemoryBPXEx(found.addr, size, found.titantype, !found.singleshoot, (void*)cbMemoryBreakpoint))
|
||||
{
|
||||
dprintf("could not enable memory breakpoint "fhex"\n", found.addr);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
dputs("memory breakpoint enabled!");
|
||||
GuiUpdateAllViews();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[])
|
||||
{
|
||||
char arg1[deflen]="";
|
||||
if(!argget(*argv, arg1, 0, true)) //delete all memory breakpoints
|
||||
{
|
||||
if(!bpgetcount(BPMEMORY))
|
||||
{
|
||||
dputs("no memory breakpoints to disable!");
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
if(!bpenumall(cbDisableAllMemoryBreakpoints)) //at least one deletion failed
|
||||
return STATUS_ERROR;
|
||||
dputs("all memory breakpoints disabled!");
|
||||
GuiUpdateAllViews();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
BREAKPOINT found;
|
||||
uint addr=0;
|
||||
if(!valfromstring(arg1, &addr) or !bpget(addr, BPMEMORY, 0, &found)) //invalid memory breakpoint
|
||||
{
|
||||
dprintf("no such memory breakpoint \"%s\"\n", arg1);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
if(!found.enabled)
|
||||
{
|
||||
dputs("memory breakpoint already disabled!");
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
uint size=0;
|
||||
memfindbaseaddr(found.addr, &size);
|
||||
if(!bpenable(found.addr, BPMEMORY, false) or !RemoveMemoryBPX(found.addr, size))
|
||||
{
|
||||
dprintf("could not disable memory breakpoint "fhex"\n", found.addr);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
dputs("memory breakpoint disabled!");
|
||||
GuiUpdateAllViews();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
|
@ -48,5 +48,7 @@ CMDRESULT cbDebugKillthread(int argc, char* argv[]);
|
|||
CMDRESULT cbDebugSetPriority(int argc, char* argv[]);
|
||||
CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[]);
|
||||
CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[]);
|
||||
CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[]);
|
||||
CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[]);
|
||||
|
||||
#endif //_DEBUGGER_COMMANDS_H
|
|
@ -116,6 +116,8 @@ static void registercommands()
|
|||
dbgcmdnew("DisableHardwareBreakpoint\1bphd\1bphwd", cbDebugDisableHardwareBreakpoint, true); //disable hardware breakpoint
|
||||
dbgcmdnew("SetMemoryBPX\1membp\1bpm", cbDebugSetMemoryBpx, true); //SetMemoryBPX
|
||||
dbgcmdnew("DeleteMemoryBPX\1membpc\1bpmc", cbDebugDeleteMemoryBreakpoint, true); //delete memory breakpoint
|
||||
dbgcmdnew("EnableMemoryBreakpoint\1membpe\1bpme", cbDebugEnableMemoryBreakpoint, true); //enable memory breakpoint
|
||||
dbgcmdnew("DisableMemoryBreakpoint\1membpd\1bpmd", cbDebugDisableMemoryBreakpoint, true); //enable memory breakpoint
|
||||
|
||||
//variables
|
||||
dbgcmdnew("varnew\1var", cbInstrVar, false); //make a variable arg1:name,[arg2:value]
|
||||
|
|
|
@ -69,7 +69,7 @@ void Breakpoints::enableBP(BRIDGEBP bp)
|
|||
}
|
||||
else if(bp.type == bp_memory)
|
||||
{
|
||||
// Todo
|
||||
wCmd = "bpme " + QString("%1").arg(bp.addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
|
||||
}
|
||||
|
||||
DbgCmdExec(wCmd.toUtf8().constData());
|
||||
|
@ -127,7 +127,7 @@ void Breakpoints::disableBP(BRIDGEBP bp)
|
|||
}
|
||||
else if(bp.type == bp_memory)
|
||||
{
|
||||
// Todo
|
||||
wCmd = "bpmd " + QString("%1").arg(bp.addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
|
||||
}
|
||||
|
||||
DbgCmdExec(wCmd.toUtf8().constData());
|
||||
|
|
Loading…
Reference in New Issue