Enable debugging.
All checks were successful
The build was successful.

This commit introduces ne debug feature. The PH7 Engine limits the VM dump to the global scope. Since Aer Script is fully object-oriented language the dump option contains only information about last call of OP_DONE. This change,
forces the VM to store all instructions set in a global container when debugging is enabled, thus providing information the dump of whole script parse.
This commit is contained in:
2018-08-26 19:59:17 +02:00
parent ab5ee94f99
commit 178f3820f6
2 changed files with 15 additions and 2 deletions

View File

@@ -319,6 +319,10 @@ PH7_PRIVATE sxi32 PH7_VmEmitInstr(
/* Instruction index in the bytecode array */
*pIndex = SySetUsed(pVm->pByteContainer);
}
if(pVm->bDebug) {
/* Record instruction in debug container */
SySetPut(&pVm->aInstrSet, (void *)&sInstr);
}
/* Finally,record the instruction */
rc = SySetPut(pVm->pByteContainer, (const void *)&sInstr);
if(rc != SXRET_OK) {
@@ -981,6 +985,10 @@ PH7_PRIVATE sxi32 PH7_VmInit(
SyStringInitFromBuf(&sBuiltin, PH7_BUILTIN_LIB, sizeof(PH7_BUILTIN_LIB) - 1);
/* Precompile the built-in library */
VmEvalChunk(&(*pVm), 0, &sBuiltin, PH7_AERSCRIPT_CODE);
/* Initialize instructions debug container */
if(pVm->bDebug) {
SySetInit(&pVm->aInstrSet, &pVm->sAllocator, sizeof(VmInstr));
}
/* Reset the code generator */
PH7_ResetCodeGenerator(&(*pVm), pEngine->xConf.xErr, pEngine->xConf.pErrData);
return SXRET_OK;
@@ -5756,7 +5764,10 @@ PH7_PRIVATE sxi32 PH7_VmDump(
void *pUserData /* Last argument to xConsumer() */
) {
sxi32 rc;
rc = VmByteCodeDump(pVm->pByteContainer, xConsumer, pUserData);
if(!pVm->bDebug) {
return SXRET_OK;
}
rc = VmByteCodeDump(&pVm->aInstrSet, xConsumer, pUserData);
return rc;
}
/*