DBG: commands for setting trace log/command
This commit is contained in:
parent
2632a95f03
commit
17cbb2bc77
|
|
@ -127,4 +127,28 @@ bool cbDebugRunToUserCode(int argc, char* argv[])
|
|||
{
|
||||
char* newargv[] = { "RunToParty", "0" };
|
||||
return cbDebugRunToParty(argc, newargv);
|
||||
}
|
||||
}
|
||||
|
||||
bool cbDebugTraceSetLog(int argc, char* argv[])
|
||||
{
|
||||
auto text = argc > 1 ? argv[1] : "";
|
||||
auto condition = argc > 2 ? argv[2] : "";
|
||||
if(!dbgsettracelog(condition, text))
|
||||
{
|
||||
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid expression \"%s\"\n"), condition);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cbDebugTraceSetCommand(int argc, char* argv[])
|
||||
{
|
||||
auto text = argc > 1 ? argv[1] : "";
|
||||
auto condition = argc > 2 ? argv[2] : "";
|
||||
if(!dbgsettracecmd(condition, text))
|
||||
{
|
||||
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid expression \"%s\"\n"), condition);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,4 +9,6 @@ bool cbDebugTraceOverBeyondTraceRecord(int argc, char* argv[]);
|
|||
bool cbDebugTraceIntoIntoTraceRecord(int argc, char* argv[]);
|
||||
bool cbDebugTraceOverIntoTraceRecord(int argc, char* argv[]);
|
||||
bool cbDebugRunToParty(int argc, char* argv[]);
|
||||
bool cbDebugRunToUserCode(int argc, char* argv[]);
|
||||
bool cbDebugRunToUserCode(int argc, char* argv[]);
|
||||
bool cbDebugTraceSetLog(int argc, char* argv[]);
|
||||
bool cbDebugTraceSetCommand(int argc, char* argv[]);
|
||||
|
|
@ -81,6 +81,11 @@ struct TraceState
|
|||
return traceCondition != nullptr;
|
||||
}
|
||||
|
||||
bool IsExtended() const
|
||||
{
|
||||
return logCondition || cmdCondition;
|
||||
}
|
||||
|
||||
bool BreakTrace() const
|
||||
{
|
||||
return !traceCondition || traceCondition->BreakTrace();
|
||||
|
|
@ -1204,12 +1209,12 @@ static void cbTraceUniversalConditionalStep(duint cip, bool bStepInto, void(*cal
|
|||
PLUG_CB_TRACEEXECUTE info;
|
||||
info.cip = cip;
|
||||
auto breakCondition = (info.stop = traceState.BreakTrace() || forceBreakTrace);
|
||||
if(traceState.IsExtended()) //only set when needed
|
||||
varset("$tracecounter", traceState.StepCount(), true);
|
||||
plugincbcall(CB_TRACEEXECUTE, &info);
|
||||
breakCondition = info.stop;
|
||||
auto logCondition = traceState.EvaluateLog(true);
|
||||
auto cmdCondition = traceState.EvaluateCmd(breakCondition);
|
||||
if(logCondition || cmdCondition)
|
||||
varset("$tracecounter", traceState.StepCount(), true);
|
||||
if(logCondition) //log
|
||||
{
|
||||
dprintf_untranslated("%s\n", stringformatinline(traceState.LogText()).c_str());
|
||||
|
|
@ -1227,6 +1232,7 @@ static void cbTraceUniversalConditionalStep(duint cip, bool bStepInto, void(*cal
|
|||
if(breakCondition) //break the debugger
|
||||
{
|
||||
auto steps = dbgcleartracestate();
|
||||
varset("$tracecounter", steps, true);
|
||||
#ifdef _WIN64
|
||||
dprintf(QT_TRANSLATE_NOOP("DBG", "Trace finished after %llu steps!\n"), steps);
|
||||
#else //x86
|
||||
|
|
|
|||
|
|
@ -223,7 +223,8 @@ static void registercommands()
|
|||
dbgcmdnew("TraceOverIntoTraceRecord\1toit", cbDebugTraceOverIntoTraceRecord, true); //Trace over into trace record
|
||||
dbgcmdnew("RunToParty", cbDebugRunToParty, true); //Run to code in a party
|
||||
dbgcmdnew("RunToUserCode\1rtu", cbDebugRunToUserCode, true); //Run to user code
|
||||
dbgcmdnew("guidfind\1findguid", cbInstrGUIDFind, true); //find GUID references TODO: undocumented
|
||||
dbgcmdnew("TraceSetLog\1SetTraceLog", cbDebugTraceSetLog, true); //Set trace log text + condition
|
||||
dbgcmdnew("TraceSetCommand\1SetTraceCommand", cbDebugTraceSetCommand, true); //Set trace command text + condition
|
||||
|
||||
//thread control
|
||||
dbgcmdnew("createthread\1threadcreate\1newthread\1threadnew", cbDebugCreatethread, true); //create thread
|
||||
|
|
@ -263,7 +264,7 @@ static void registercommands()
|
|||
dbgcmdnew("vardel", cbInstrVarDel, false); //delete a variable, arg1:variable name
|
||||
dbgcmdnew("varlist", cbInstrVarList, false); //list variables[arg1:type filter]
|
||||
|
||||
//data
|
||||
//searching
|
||||
dbgcmdnew("find", cbInstrFind, true); //find a pattern
|
||||
dbgcmdnew("findall", cbInstrFindAll, true); //find all patterns
|
||||
dbgcmdnew("findallmem\1findmemall", cbInstrFindAllMem, true); //memory map pattern find
|
||||
|
|
@ -275,6 +276,7 @@ static void registercommands()
|
|||
dbgcmdnew("yara", cbInstrYara, true); //yara test command
|
||||
dbgcmdnew("yaramod", cbInstrYaramod, true); //yara rule on module
|
||||
dbgcmdnew("setmaxfindresult\1findsetmaxresult", cbInstrSetMaxFindResult, false); //set the maximum number of occurences found
|
||||
dbgcmdnew("guidfind\1findguid", cbInstrGUIDFind, true); //find GUID references TODO: undocumented
|
||||
|
||||
//user database
|
||||
dbgcmdnew("dbsave\1savedb", cbInstrDbsave, true); //save program database
|
||||
|
|
|
|||
Loading…
Reference in New Issue