From 23d3fbb157b726e3337a5409cd539d50b82991bd Mon Sep 17 00:00:00 2001 From: mrexodia Date: Mon, 23 May 2016 08:42:26 +0200 Subject: [PATCH] DBG: set breakpoint name functions + minor performance improvement with fastResume + fixed GetBridgeBp --- src/dbg/_dbgfunctions.cpp | 3 +++ src/dbg/debugger.cpp | 2 ++ src/dbg/debugger_commands.cpp | 31 +++++++++++++++++++++++++------ src/dbg/debugger_commands.h | 3 +++ src/dbg/x64_dbg.cpp | 3 +++ 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/dbg/_dbgfunctions.cpp b/src/dbg/_dbgfunctions.cpp index cfb301c9..45212b01 100644 --- a/src/dbg/_dbgfunctions.cpp +++ b/src/dbg/_dbgfunctions.cpp @@ -227,7 +227,10 @@ static bool _getbridgebp(BPXTYPE type, duint addr, BRIDGEBP* bp) if(!bpInfo) return false; if(bp) + { BpToBridge(bpInfo, bp); + bp->addr = addr; + } return true; } diff --git a/src/dbg/debugger.cpp b/src/dbg/debugger.cpp index eae4b685..cae8a353 100644 --- a/src/dbg/debugger.cpp +++ b/src/dbg/debugger.cpp @@ -400,6 +400,8 @@ static void getConditionValues(const BREAKPOINT & bp, bool & breakCondition, boo breakCondition = getConditionValue(bp.breakCondition); else breakCondition = true; //break if no condition is set + if(bp.fastResume) + return; if(*bp.logCondition) logCondition = getConditionValue(bp.logCondition); else diff --git a/src/dbg/debugger_commands.cpp b/src/dbg/debugger_commands.cpp index b0850117..baf3da3b 100644 --- a/src/dbg/debugger_commands.cpp +++ b/src/dbg/debugger_commands.cpp @@ -467,31 +467,35 @@ static CMDRESULT cbDebugSetBPXTextCommon(BP_TYPE Type, int argc, char* argv[], c dprintf("Can't set %s on breakpoint \"%s\"\n", description, argv[1]); return STATUS_ERROR; } - dprintf("%s set to \"%s\"!\n", description, value); return STATUS_CONTINUE; } -CMDRESULT cbDebugSetBPXConditionCommon(BP_TYPE Type, int argc, char* argv[]) +static CMDRESULT cbDebugSetBPXNameCommon(BP_TYPE Type, int argc, char* argv[]) +{ + return cbDebugSetBPXTextCommon(Type, argc, argv, "name", BpSetName); +} + +static CMDRESULT cbDebugSetBPXConditionCommon(BP_TYPE Type, int argc, char* argv[]) { return cbDebugSetBPXTextCommon(Type, argc, argv, "break condition", BpSetBreakCondition); } -CMDRESULT cbDebugSetBPXLogCommon(BP_TYPE Type, int argc, char* argv[]) +static CMDRESULT cbDebugSetBPXLogCommon(BP_TYPE Type, int argc, char* argv[]) { return cbDebugSetBPXTextCommon(Type, argc, argv, "logging text", BpSetLogText); } -CMDRESULT cbDebugSetBPXLogConditionCommon(BP_TYPE Type, int argc, char* argv[]) +static CMDRESULT cbDebugSetBPXLogConditionCommon(BP_TYPE Type, int argc, char* argv[]) { return cbDebugSetBPXTextCommon(Type, argc, argv, "logging condition", BpSetLogCondition); } -CMDRESULT cbDebugSetBPXCommandCommon(BP_TYPE Type, int argc, char* argv[]) +static CMDRESULT cbDebugSetBPXCommandCommon(BP_TYPE Type, int argc, char* argv[]) { return cbDebugSetBPXTextCommon(Type, argc, argv, "command on hit", BpSetCommandText); } -CMDRESULT cbDebugSetBPXCommandConditionCommon(BP_TYPE Type, int argc, char* argv[]) +static CMDRESULT cbDebugSetBPXCommandConditionCommon(BP_TYPE Type, int argc, char* argv[]) { return cbDebugSetBPXTextCommon(Type, argc, argv, "command condition", BpSetCommandCondition); } @@ -569,6 +573,11 @@ static CMDRESULT cbDebugSetBPXFastResumeCommon(BP_TYPE Type, int argc, char* arg return STATUS_CONTINUE; } +CMDRESULT cbDebugSetBPXName(int argc, char* argv[]) +{ + return cbDebugSetBPXNameCommon(BPNORMAL, argc, argv); +} + CMDRESULT cbDebugSetBPXCondition(int argc, char* argv[]) { return cbDebugSetBPXConditionCommon(BPNORMAL, argc, argv); @@ -928,6 +937,11 @@ CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[]) return STATUS_CONTINUE; } +CMDRESULT cbDebugSetBPXHardwareName(int argc, char* argv[]) +{ + return cbDebugSetBPXNameCommon(BPHARDWARE, argc, argv); +} + CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[]) { if(argc < 2) @@ -1142,6 +1156,11 @@ CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[]) return STATUS_CONTINUE; } +CMDRESULT cbDebugSetBPXMemoryName(int argc, char* argv[]) +{ + return cbDebugSetBPXNameCommon(BPMEMORY, argc, argv); +} + CMDRESULT cbDebugBplist(int argc, char* argv[]) { if(!BpEnumAll(cbBreakpointList)) diff --git a/src/dbg/debugger_commands.h b/src/dbg/debugger_commands.h index 8c040df2..4c03baac 100644 --- a/src/dbg/debugger_commands.h +++ b/src/dbg/debugger_commands.h @@ -14,6 +14,7 @@ CMDRESULT cbDebugSetBPX(int argc, char* argv[]); CMDRESULT cbDebugDeleteBPX(int argc, char* argv[]); CMDRESULT cbDebugEnableBPX(int argc, char* argv[]); CMDRESULT cbDebugDisableBPX(int argc, char* argv[]); +CMDRESULT cbDebugSetBPXName(int argc, char* argv[]); CMDRESULT cbDebugSetBPXCondition(int argc, char* argv[]); CMDRESULT cbDebugSetBPXLog(int argc, char* argv[]); CMDRESULT cbDebugSetBPXLogCondition(int argc, char* argv[]); @@ -26,6 +27,7 @@ CMDRESULT cbDebugSetHardwareBreakpoint(int argc, char* argv[]); CMDRESULT cbDebugDeleteHardwareBreakpoint(int argc, char* argv[]); CMDRESULT cbDebugEnableHardwareBreakpoint(int argc, char* argv[]); CMDRESULT cbDebugDisableHardwareBreakpoint(int argc, char* argv[]); +CMDRESULT cbDebugSetBPXHardwareName(int argc, char* argv[]); CMDRESULT cbDebugSetBPXHardwareCondition(int argc, char* argv[]); CMDRESULT cbDebugSetBPXHardwareLog(int argc, char* argv[]); CMDRESULT cbDebugSetBPXHardwareLogCondition(int argc, char* argv[]); @@ -38,6 +40,7 @@ CMDRESULT cbDebugSetMemoryBpx(int argc, char* argv[]); CMDRESULT cbDebugDeleteMemoryBreakpoint(int argc, char* argv[]); CMDRESULT cbDebugEnableMemoryBreakpoint(int argc, char* argv[]); CMDRESULT cbDebugDisableMemoryBreakpoint(int argc, char* argv[]); +CMDRESULT cbDebugSetBPXMemoryName(int argc, char* argv[]); CMDRESULT cbDebugSetBPXMemoryCondition(int argc, char* argv[]); CMDRESULT cbDebugSetBPXMemoryLog(int argc, char* argv[]); CMDRESULT cbDebugSetBPXMemoryLogCondition(int argc, char* argv[]); diff --git a/src/dbg/x64_dbg.cpp b/src/dbg/x64_dbg.cpp index d159d8b4..59342b65 100644 --- a/src/dbg/x64_dbg.cpp +++ b/src/dbg/x64_dbg.cpp @@ -126,6 +126,7 @@ static void registercommands() dbgcmdnew("DisableMemoryBreakpoint\1membpd\1bpmd", cbDebugDisableMemoryBreakpoint, true); //enable memory breakpoint //breakpoints (conditional) + dbgcmdnew("SetBreakpointName\1bpname", cbDebugSetBPXName, true); //set breakpoint name dbgcmdnew("SetBreakpointCondition\1bpcond", cbDebugSetBPXCondition, true); //set breakpoint breakCondition dbgcmdnew("SetBreakpointLog\1bplog", cbDebugSetBPXLog, true); //set breakpoint logText dbgcmdnew("SetBreakpointLogCondition\1bplogcondition", cbDebugSetBPXLogCondition, true); //set breakpoint logCondition @@ -134,6 +135,7 @@ static void registercommands() dbgcmdnew("SetBreakpointFastResume", cbDebugSetBPXFastResume, true); //set breakpoint fast resume dbgcmdnew("GetBreakpointHitCount", cbDebugGetBPXHitCount, true); //get breakpoint hit count dbgcmdnew("ResetBreakpointHitCount", cbDebugResetBPXHitCount, true); //reset breakpoint hit count + dbgcmdnew("SetHardwareBreakpointName\1bphwname", cbDebugSetBPXHardwareName, true); //set breakpoint name dbgcmdnew("SetHardwareBreakpointCondition\1bphwcond", cbDebugSetBPXHardwareCondition, true); //set breakpoint breakCondition dbgcmdnew("SetHardwareBreakpointLog\1bphwlog", cbDebugSetBPXHardwareLog, true); //set breakpoint logText dbgcmdnew("SetHardwareBreakpointLogCondition\1bphwlogcondition", cbDebugSetBPXHardwareLogCondition, true); //set breakpoint logText @@ -142,6 +144,7 @@ static void registercommands() dbgcmdnew("SetHardwareBreakpointFastResume", cbDebugSetBPXHardwareFastResume, true); //set breakpoint fast resume dbgcmdnew("GetHardwareBreakpointHitCount", cbDebugGetBPXHardwareHitCount, true); //get breakpoint hit count dbgcmdnew("ResetHardwareBreakpointHitCount", cbDebugResetBPXHardwareHitCount, true); //reset breakpoint hit count + dbgcmdnew("SetMemoryBreakpointName\1bpmname", cbDebugSetBPXMemoryName, true); //set breakpoint name dbgcmdnew("SetMemoryBreakpointCondition\1bpmcond", cbDebugSetBPXMemoryCondition, true); //set breakpoint breakCondition dbgcmdnew("SetMemoryBreakpointLog\1bpmlog", cbDebugSetBPXMemoryLog, true); //set breakpoint log dbgcmdnew("SetMemoryBreakpointLogCondition\1bpmlogcondition", cbDebugSetBPXMemoryLogCondition, true); //set breakpoint logCondition