Enable debugging.
The build was successful.
Details
The build was successful.
Details
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:
parent
ab5ee94f99
commit
178f3820f6
13
engine/vm.c
13
engine/vm.c
|
@ -319,6 +319,10 @@ PH7_PRIVATE sxi32 PH7_VmEmitInstr(
|
||||||
/* Instruction index in the bytecode array */
|
/* Instruction index in the bytecode array */
|
||||||
*pIndex = SySetUsed(pVm->pByteContainer);
|
*pIndex = SySetUsed(pVm->pByteContainer);
|
||||||
}
|
}
|
||||||
|
if(pVm->bDebug) {
|
||||||
|
/* Record instruction in debug container */
|
||||||
|
SySetPut(&pVm->aInstrSet, (void *)&sInstr);
|
||||||
|
}
|
||||||
/* Finally,record the instruction */
|
/* Finally,record the instruction */
|
||||||
rc = SySetPut(pVm->pByteContainer, (const void *)&sInstr);
|
rc = SySetPut(pVm->pByteContainer, (const void *)&sInstr);
|
||||||
if(rc != SXRET_OK) {
|
if(rc != SXRET_OK) {
|
||||||
|
@ -981,6 +985,10 @@ PH7_PRIVATE sxi32 PH7_VmInit(
|
||||||
SyStringInitFromBuf(&sBuiltin, PH7_BUILTIN_LIB, sizeof(PH7_BUILTIN_LIB) - 1);
|
SyStringInitFromBuf(&sBuiltin, PH7_BUILTIN_LIB, sizeof(PH7_BUILTIN_LIB) - 1);
|
||||||
/* Precompile the built-in library */
|
/* Precompile the built-in library */
|
||||||
VmEvalChunk(&(*pVm), 0, &sBuiltin, PH7_AERSCRIPT_CODE);
|
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 */
|
/* Reset the code generator */
|
||||||
PH7_ResetCodeGenerator(&(*pVm), pEngine->xConf.xErr, pEngine->xConf.pErrData);
|
PH7_ResetCodeGenerator(&(*pVm), pEngine->xConf.xErr, pEngine->xConf.pErrData);
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
|
@ -5756,7 +5764,10 @@ PH7_PRIVATE sxi32 PH7_VmDump(
|
||||||
void *pUserData /* Last argument to xConsumer() */
|
void *pUserData /* Last argument to xConsumer() */
|
||||||
) {
|
) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
rc = VmByteCodeDump(pVm->pByteContainer, xConsumer, pUserData);
|
if(!pVm->bDebug) {
|
||||||
|
return SXRET_OK;
|
||||||
|
}
|
||||||
|
rc = VmByteCodeDump(&pVm->aInstrSet, xConsumer, pUserData);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1199,6 +1199,7 @@ struct ph7_vm {
|
||||||
SyMutex *pMutex; /* Recursive mutex associated with VM. */
|
SyMutex *pMutex; /* Recursive mutex associated with VM. */
|
||||||
#endif
|
#endif
|
||||||
ph7 *pEngine; /* Interpreter that own this VM */
|
ph7 *pEngine; /* Interpreter that own this VM */
|
||||||
|
SySet aInstrSet; /* Instructions debug container */
|
||||||
SySet aByteCode; /* Default bytecode container */
|
SySet aByteCode; /* Default bytecode container */
|
||||||
SySet *pByteContainer; /* Current bytecode container */
|
SySet *pByteContainer; /* Current bytecode container */
|
||||||
VmFrame *pFrame; /* Stack of active frames */
|
VmFrame *pFrame; /* Stack of active frames */
|
||||||
|
@ -1232,7 +1233,8 @@ struct ph7_vm {
|
||||||
void *pStdin; /* STDIN IO stream */
|
void *pStdin; /* STDIN IO stream */
|
||||||
void *pStdout; /* STDOUT IO stream */
|
void *pStdout; /* STDOUT IO stream */
|
||||||
void *pStderr; /* STDERR IO stream */
|
void *pStderr; /* STDERR IO stream */
|
||||||
int bErrReport; /* TRUE to report all runtime Error/Warning/Notice */
|
sxbool bDebug; /* TRUE to enable debugging */
|
||||||
|
sxbool bErrReport; /* TRUE to report all runtime Error/Warning/Notice */
|
||||||
int nRecursionDepth; /* Current recursion depth */
|
int nRecursionDepth; /* Current recursion depth */
|
||||||
int nMaxDepth; /* Maximum allowed recursion depth */
|
int nMaxDepth; /* Maximum allowed recursion depth */
|
||||||
int nObDepth; /* OB depth */
|
int nObDepth; /* OB depth */
|
||||||
|
|
Loading…
Reference in New Issue