diff --git a/engine/api.c b/engine/api.c index 9c1db66..eaea4ca 100644 --- a/engine/api.c +++ b/engine/api.c @@ -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) { diff --git a/engine/vm.c b/engine/vm.c index 833a03d..62d1c22 100644 --- a/engine/vm.c +++ b/engine/vm.c @@ -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 */ diff --git a/include/ph7int.h b/include/ph7int.h index 82c8628..30ed80d 100644 --- a/include/ph7int.h +++ b/include/ph7int.h @@ -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); diff --git a/sapi/cli/main.c b/sapi/cli/main.c index 0b81dd7..dfad14d 100644 --- a/sapi/cli/main.c +++ b/sapi/cli/main.c @@ -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");