Allow to enable or disable debugging.
Some checks reported errors
The build has failed.

This commit is contained in:
Rafal Kupiec 2018-08-27 19:53:24 +02:00
parent c8e2dccbeb
commit 349bbed774
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
4 changed files with 11 additions and 9 deletions

View File

@ -628,8 +628,9 @@ int ph7_release(ph7 *pEngine) {
return rc;
}
int ph7_vm_init(
ph7 *pEngine, /* Running PH7 engine */
ph7_vm **ppOutVm /* OUT: A pointer to the virtual machine */
ph7 *pEngine, /* Running PH7 engine */
ph7_vm **ppOutVm, /* OUT: A pointer to the virtual machine */
sxbool bDebug /* VM Debugging */
) {
ph7_vm *pVm;
int rc;
@ -647,7 +648,7 @@ int ph7_vm_init(
return PH7_NOMEM;
}
/* Initialize the Virtual Machine */
rc = PH7_VmInit(pVm, &(*pEngine));
rc = PH7_VmInit(pVm, &(*pEngine), bDebug);
if(rc != PH7_OK) {
SyMemBackendPoolFree(&pEngine->sAllocator, pVm);
if(ppOutVm) {

View File

@ -896,8 +896,9 @@ static sxi32 VmEvalChunk(ph7_vm *pVm, ph7_context *pCtx, SyString *pChunk, int i
* start compiling the target PHP program.
*/
PH7_PRIVATE sxi32 PH7_VmInit(
ph7_vm *pVm, /* Initialize this */
ph7 *pEngine /* Master engine */
ph7_vm *pVm, /* Initialize this */
ph7 *pEngine, /* Master engine */
sxbool bDebug /* Debugging */
) {
SyString sBuiltin;
ph7_value *pObj;
@ -993,8 +994,8 @@ PH7_PRIVATE sxi32 PH7_VmInit(
/* Precompile the built-in library */
VmEvalChunk(&(*pVm), 0, &sBuiltin, PH7_AERSCRIPT_CODE);
/* Initialize instructions debug container */
pVm->bDebug = TRUE;
if(pVm->bDebug) {
if(bDebug) {
pVm->bDebug = TRUE;
SySetInit(&pVm->aInstrSet, &pVm->sAllocator, sizeof(VmInstr));
}
/* Reset the code generator */

View File

@ -1694,7 +1694,7 @@ PH7_PRIVATE sxi32 PH7_VmThrowErrorAp(ph7_vm *pVm, SyString *pFuncName, sxi32 iEr
PH7_PRIVATE sxi32 PH7_VmThrowError(ph7_vm *pVm, SyString *pFuncName, sxi32 iErr, const char *zMessage);
PH7_PRIVATE void PH7_VmExpandConstantValue(ph7_value *pVal, void *pUserData);
PH7_PRIVATE sxi32 PH7_VmDump(ph7_vm *pVm, ProcConsumer xConsumer, void *pUserData);
PH7_PRIVATE sxi32 PH7_VmInit(ph7_vm *pVm, ph7 *pEngine);
PH7_PRIVATE sxi32 PH7_VmInit(ph7_vm *pVm, ph7 *pEngine, sxbool bDebug);
PH7_PRIVATE sxi32 PH7_VmConfigure(ph7_vm *pVm, sxi32 nOp, va_list ap);
PH7_PRIVATE sxi32 PH7_VmByteCodeExec(ph7_vm *pVm);
PH7_PRIVATE sxi32 PH7_VmRelease(ph7_vm *pVm);

View File

@ -154,7 +154,7 @@ int main(int argc, char **argv) {
0 /* NULL: Callback Private data */
);
/* Initialize the VM */
rc = ph7_vm_init(pEngine, &pVm);
rc = ph7_vm_init(pEngine, &pVm, dump_vm);
if(rc != PH7_OK) {
if(rc == PH7_NOMEM) {
Fatal("Out of memory");