private void ExecuteCore(int coreNumber) { try { if (InDebugMode) { MyExecutionBlock currentBlock = CurrentDebuggedBlocks[coreNumber]; if (SimulationStep == 0 && currentBlock == null) { ExecutionPlan[coreNumber].InitStepPlan.Reset(); currentBlock = ExecutionPlan[coreNumber].InitStepPlan; m_debugStepComplete = false; } MyExecutionBlock lastBlock = null; do { lastBlock = currentBlock; currentBlock.SimulationStep = SimulationStep; currentBlock = currentBlock.ExecuteStep(); }while (currentBlock != null && currentBlock.CurrentChild == null); if (currentBlock == null) { ExecutionPlan[coreNumber].StandardStepPlan.Reset(); currentBlock = ExecutionPlan[coreNumber].StandardStepPlan; } else { m_debugStepComplete = false; } CurrentDebuggedBlocks[coreNumber] = currentBlock; } else //not in debug mode { if (SimulationStep == 0) { ExecutionPlan[coreNumber].InitStepPlan.SimulationStep = 0; ExecutionPlan[coreNumber].InitStepPlan.Execute(); } //TODO: here should be else! (but some module are not prepared for this) ExecutionPlan[coreNumber].StandardStepPlan.SimulationStep = SimulationStep; ExecutionPlan[coreNumber].StandardStepPlan.Execute(); } } catch (Exception e) { m_errorOccured = true; m_lastException = new MySimulationException(coreNumber, e.Message, e); MyKernelFactory.Instance.MarkContextDead(coreNumber); } }
private void ExecuteDebugStep() { MyExecutionBlock currentBlock = CurrentDebuggedBlock; if (currentBlock == null) { if (m_executionPhase == ExecutionPhase.Initialization) { // The next step should be the beginning of the initialization plan. if (ExecutionPlan.InitStepPlan != null) { // There is an initialization plan, take the first step. ExecutionPlan.InitStepPlan.Reset(); currentBlock = ExecutionPlan.InitStepPlan; } else { // There is no initialization plan, go to PreStandard and stop because the loading of // block data might be needed. m_executionPhase = ExecutionPhase.PreStandard; return; } } else if (m_executionPhase == ExecutionPhase.Standard) { ExecutionPlan.StandardStepPlan.Reset(); currentBlock = ExecutionPlan.StandardStepPlan; } } // This checks if breakpoint was encountered, also used for "stepping". bool leavingTargetBlock = false; do { currentBlock.SimulationStep = SimulationStep; currentBlock = currentBlock.ExecuteStep(); if (StopWhenTouchedBlock != null && currentBlock == StopWhenTouchedBlock) { leavingTargetBlock = true; } } while (currentBlock != null && currentBlock.CurrentChild == null); if (currentBlock == null) { // The current plan finished. if (m_executionPhase == ExecutionPhase.Initialization) { // This means the init plan got finished, not the standard plan. m_stepComplete = false; } else { // This means the standard plan finished, remove the init plan (debug window will reset). ExecutionPlan.InitStepPlan = null; } // If rescheduling happens, this will be set to "Initialization" again, if not, we need to // perform just the standard plan again. m_executionPhase = ExecutionPhase.PreStandard; leavingTargetBlock = true; } else { m_stepComplete = false; } CurrentDebuggedBlock = currentBlock; if (DebugStepMode != DebugStepMode.None) { // A step into/over/out is performed. if (leavingTargetBlock) { // The target block is being left or the sim step is over - step over/out is finished. EmitDebugTargetReached(); } if (DebugStepMode == DebugStepMode.StepInto) { // Step into == one step of the simulation. EmitDebugTargetReached(); } } if (currentBlock != null && Breakpoints.Contains(currentBlock.CurrentChild)) { // A breakpoint has been reached. EmitDebugTargetReached(); } }