1
0
Fork 0

DBG: huge performance improvement in script runtime

This commit is contained in:
mrexodia 2016-09-06 12:03:40 +02:00
parent a9a8c04218
commit 9f17d0aa3b
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
4 changed files with 14 additions and 31 deletions

View File

@ -649,7 +649,7 @@ static bool handleAssignment(const char* variable, duint resultv, bool silent, b
bool destIsVar = false;
duint temp;
//TODO: implement destIsVar without retrieving the value
valfromstring_noexpr(variable, &temp, true, false, nullptr, &destIsVar, nullptr); //there is no return check on this because the destination might not exist yet
valfromstring_noexpr(variable, &temp, true, true, nullptr, &destIsVar, nullptr); //there is no return check on this because the destination might not exist yet
if(!destIsVar)
destIsVar = vargettype(variable, nullptr);
if(!destIsVar || !valtostring(variable, resultv, true))

View File

@ -259,7 +259,7 @@ CMDRESULT cbInstrMov(int argc, char* argv[])
}
bool isvar = false;
duint temp = 0;
valfromstring(argv[1], &temp, true, false, 0, &isvar, 0); //there is no return check on this because the destination might not exist yet
valfromstring(argv[1], &temp, true, true, 0, &isvar, 0); //there is no return check on this because the destination might not exist yet
if(!isvar)
isvar = vargettype(argv[1], 0);
if(!isvar || !valtostring(argv[1], set_value, true))
@ -627,7 +627,7 @@ static CMDRESULT ReadWriteVariable(const char* varname, std::function<CMDRESULT(
duint set_value = 0;
bool isvar;
int varsize;
if(!valfromstring(varname, &set_value, true, false, &varsize, &isvar))
if(!valfromstring(varname, &set_value, true, true, &varsize, &isvar))
{
dprintf(QT_TRANSLATE_NOOP("DBG", "invalid variable \"%s\"\n"), varname);
return STATUS_ERROR;
@ -636,7 +636,7 @@ static CMDRESULT ReadWriteVariable(const char* varname, std::function<CMDRESULT(
if(retVal != STATUS_CONTINUE)
return retVal;
duint temp = 0;
valfromstring(varname, &temp, true, false, 0, nullptr, 0); //there is no return check on this because the destination might not exist yet
valfromstring(varname, &temp, true, true, 0, nullptr, 0); //there is no return check on this because the destination might not exist yet
if(!isvar)
isvar = vargettype(varname, 0);
if(!isvar || !valtostring(varname, set_value, true))

View File

@ -320,26 +320,9 @@ static CMDRESULT scriptinternalcmdexec(const char* cmd)
return STATUS_PAUSE;
else if(scriptisinternalcommand(cmd, "nop")) //do nothing
return STATUS_CONTINUE;
char command[deflen] = "";
strcpy_s(command, StringUtils::Trim(cmd).c_str());
COMMAND* found = cmdget(command);
if(!found) //invalid command
{
ExpressionParser parser(command);
duint result;
if(!parser.Calculate(result, valuesignedcalc(), true, false))
return STATUS_ERROR;
varset("$ans", result, true);
return STATUS_CONTINUE;
}
if(arraycontains(found->name, "var")) //var
{
cmddirectexec(command);
return STATUS_CONTINUE;
}
CMDRESULT res = cmddirectexec(command);
while(DbgIsDebugging() && dbgisrunning()) //while not locked (NOTE: possible deadlock)
Sleep(10);
CMDRESULT res = cmddirectexec(cmd);
while(DbgIsDebugging() && dbgisrunning()) //while not locked (NOTE: possible deadlock)
Sleep(1);
return res;
}

View File

@ -1534,7 +1534,7 @@ static bool isdigitduint(char digit)
\param string The string to parse.
\param [out] value The value of the expression. This value cannot be null.
\param silent true to not output anything to the console.
\param baseonly true to skip parsing API names, labels, symbols and variables (basic expressions only).
\param baseonly true to skip parsing API names, labels and symbols (basic expressions only).
\param [out] value_size This function can output the value size parsed (for example memory location size or register size). Can be null.
\param [out] isvar This function can output if the expression is variable (for example memory locations, registers or variables are variable). Can be null.
\param [out] hexonly This function can output if the output value should only be printed as hexadecimal (for example addresses). Can be null.
@ -1694,6 +1694,12 @@ bool valfromstring_noexpr(const char* string, duint* value, bool silent, bool ba
inc = 1;
return convertNumber(string + inc, *value, 16);
}
else if(varget(string, value, value_size, 0)) //then come variables
{
if(isvar)
*isvar = true;
return true;
}
if(baseonly)
return false;
else if(valapifromstring(string, value, value_size, true, silent, hexonly)) //then come APIs
@ -1702,12 +1708,6 @@ bool valfromstring_noexpr(const char* string, duint* value, bool silent, bool ba
return true;
else if(SymAddrFromName(string, value)) //then come symbols
return true;
else if(varget(string, value, value_size, 0)) //then come variables
{
if(isvar)
*isvar = true;
return true;
}
else if(strstr(string, "sub_") == string) //then come sub_ functions
{
#ifdef _WIN64