Ejemplo n.º 1
0
void LuaDebug::accept_handler(const system::error_code& e,SocketPtr s)
{
	if( e )
	{
		return;
	}

	async_accept();
	bps.clear(); //清除以前的断点
	if( NewDebug )
		NewDebug(); //通知产生了新的调试上下文
	mSocket = s;//该操作将关闭上一次的Socket

	for( BPS::iterator i = bps.begin();i!=bps.end();++i )
	{
		std::stringstream ss(std::stringstream::out);
		ss<<"bp<"<<i->second<<">@"<<i->first<<"\n";
		
		boost::asio::write( *mSocket,boost::asio::buffer(ss.str()) );
	}

	doContinue();

	boost::asio::async_read_until( *mSocket,
		mInbuf,
		'\n',
		bind(&LuaDebug::readline_handler,this,placeholders::error,placeholders::signal_number) );
}
Ejemplo n.º 2
0
 void Service::control( DWORD code )
 {
   switch ( code )
   {
     case SERVICE_CONTROL_INTERROGATE:
       SetServiceStatus( mStatusHandle, &mStatus );
     break;
     case SERVICE_CONTROL_STOP:
     case SERVICE_CONTROL_SHUTDOWN:
       if ( mStatus.dwCurrentState == SERVICE_STOP_PENDING
         || mStatus.dwCurrentState == SERVICE_STOPPED )
         return;
       setState( SERVICE_STOP_PENDING, 0 );
       doStop();
       setState( SERVICE_STOPPED, 0 );
     break;
     case SERVICE_CONTROL_PAUSE:
       if ( mStatus.dwCurrentState != SERVICE_RUNNING )
         return;
       setState( SERVICE_PAUSE_PENDING, 0 );
       doPause();
       setState( SERVICE_PAUSED, 0 );
     break;
     case SERVICE_CONTROL_CONTINUE:
       if ( mStatus.dwCurrentState != SERVICE_PAUSED )
         return;
       setState( SERVICE_CONTINUE_PENDING, 0 );
       doContinue();
       setState( SERVICE_RUNNING, 0 );
     break;
   }
 }
Ejemplo n.º 3
0
//=============================================================================
// METHOD    : SPELLcontroller::doFinish
//=============================================================================
void SPELLcontroller::doFinish()
{
    switch(getStatus())
    {
    case STATUS_RUNNING: // Allowed status
    case STATUS_PAUSED: // Allowed status
    case STATUS_WAITING: // Allowed status
    case STATUS_PROMPT: // Allowed status
        break;
    default:
        return;
    }
    if (m_error) return; // Do not continue on error

    DEBUG("[C] Do finish");

    m_finished = true;
    m_recover = false;
    m_reload = false;
    m_recoverEvent.set();

    SPELLexecutor::instance().getScheduler().abortWait( false );
    setStatus(STATUS_FINISHED);
    doContinue();
}
Ejemplo n.º 4
0
//=============================================================================
// METHOD    : SPELLcontroller::doAbort
//=============================================================================
void SPELLcontroller::doAbort()
{
    switch(getStatus())
    {
    case STATUS_ERROR: // Disallowed status
    case STATUS_ABORTED: // Disallowed status
    case STATUS_FINISHED: // Disallowed status
    case STATUS_RELOADING: // Disallowed status
        return;
    default:
        break;
    }
    if (m_error) return; // Do not continue on error

    DEBUG("[C] Do abort");

    // Setting this flags like this will provoke the execution abort thanks to the
    // checkAborted() call in the dispatching mechanism. We shall not do more
    // here (like setting the status) since the status ABORTED shall be set AFTER
    // doing some extra operations in the executor, like unloading the SPELL driver.
    // See SPELLexecutorImpl::executionAborted() method.
    m_abort = true;
    m_recover = false;
    m_reload = false;
    m_recoverEvent.set();

    SPELLexecutor::instance().getScheduler().abortWait( false );
    doContinue();
}
Ejemplo n.º 5
0
//=============================================================================
// METHOD    : SPELLcontroller::doStep
//=============================================================================
void SPELLcontroller::doStep( bool stepOver )
{
	switch(getStatus())
	{
	case STATUS_PAUSED: // Allowed status
	case STATUS_INTERRUPTED: // Allowed status
		break;
	default:
		return;
	}
    if (m_error) return; // Do not continue on error

    DEBUG("[C] Do step ( stepping over: " + BSTR(stepOver) + ")" );

    SPELLexecutor::instance().getScheduler().restartWait();

    // A step will disable the step over
    if (stepOver)
    {
        SPELLexecutor::instance().getCallstack().stepOver( SO_ONCE_OVER );
    }
    else
    {
        SPELLexecutor::instance().getCallstack().stepOver( SO_ONCE_INTO );
    }

    setMode( MODE_STEP );

    doContinue();
}
Ejemplo n.º 6
0
//=============================================================================
// METHOD    : SPELLcontroller::setAutoRun
//=============================================================================
void SPELLcontroller::setAutoRun()
{
    DEBUG("[C] Set autorun");
    setMode( MODE_PLAY );
    setStatus(STATUS_RUNNING);
    doContinue();
}
Ejemplo n.º 7
0
//=============================================================================
// METHOD    : SPELLcontroller::doGoto
//=============================================================================
void SPELLcontroller::doGoto( const int line )
{
    if (getStatus() != STATUS_PAUSED || m_error ) return;

    DEBUG("[C] Do goto line " + ISTR(line));

    if (SPELLexecutor::instance().goLine(line))
    {
        m_skipping = true;
        doContinue();
    }
}
Ejemplo n.º 8
0
//=============================================================================
// METHOD    : SPELLcontroller::doGoto
//=============================================================================
void SPELLcontroller::doGoto( const std::string& label )
{
    if (getStatus() != STATUS_PAUSED || m_error ) return;

    DEBUG("[C] Do goto label " + label);

    if (SPELLexecutor::instance().goLabel(label,false))
    {
        m_skipping = true;
        doContinue();
    }
}
Ejemplo n.º 9
0
//=============================================================================
// METHOD    : SPELLcontroller::doClose
//=============================================================================
void SPELLcontroller::doClose()
{
    DEBUG("[C] Do close");
    m_finished = true;
    SPELLexecutorStatus st = getStatus();
    if ( st != STATUS_FINISHED && st != STATUS_ABORTED && st != STATUS_ERROR )
    {
        doContinue();
    }
    m_recoverEvent.set();
    DEBUG("[C] Finalize executor");
    SPELLexecutor::instance().finalize();
}
Ejemplo n.º 10
0
int NonLinearLSQ::curvefit() {

  size_t n(nSize());
  size_t p(nParms());

  //  Initialize the solver function information
  _nlsqPointer d = { this };
  gsl_multifit_function_fdf mf;
  mf.f      = &f;
  mf.df     = &df;
  mf.fdf    = &fdf;
  mf.n      =  n;
  mf.p      = p;
  mf.params =  &d;

  const gsl_multifit_fdfsolver_type *T = gsl_multifit_fdfsolver_lmsder;
  gsl_multifit_fdfsolver *s = gsl_multifit_fdfsolver_alloc(T, n, p);

  _fitParms = guess();
  gsl_vector *x = NlsqTogsl(_fitParms);
  gsl_matrix *covar = gsl_matrix_alloc(p, p);
  gsl_multifit_fdfsolver_set(s, &mf, x);

  _nIters = 0;
  checkIteration(_nIters, gslToNlsq(s->x), NLVector(p,999.0),
                  gsl_blas_dnrm2(s->f), GSL_CONTINUE);


  do {
    _nIters++;

    _status = gsl_multifit_fdfsolver_iterate(s);
    _fitParms = gslToNlsq(s->x);

    gsl_multifit_covar(s->J, 0.0, covar);
    _uncert = getUncertainty(covar);

    _status = checkIteration(_nIters, _fitParms, _uncert, gsl_blas_dnrm2(s->f),
                             _status);
    if ( _status  ) { break; }
    if(!doContinue()) { break; }

    _status = gsl_multifit_test_delta(s->dx, s->x, absErr(), relErr());
  } while ((_status == GSL_CONTINUE) && (_nIters < _maxIters));

  // Clean up
  gsl_multifit_fdfsolver_free(s);
  gsl_matrix_free(covar);

  return (_status);
}
Ejemplo n.º 11
0
//=============================================================================
// METHOD    : SPELLcontroller::doSkip
//=============================================================================
void SPELLcontroller::doSkip()
{
    switch(getStatus())
    {
    case STATUS_PAUSED: // Allowed status
    case STATUS_INTERRUPTED: // Allowed status
        break;
    default:
        return;
    }
    if (m_error) return; // Do not continue on error

    if (!SPELLexecutor::instance().canSkip())
    {
        LOG_WARN("[C] Cannot skip current line");
        return;
    }

    DEBUG("[C] Do skip");

    bool waitAborted = SPELLexecutor::instance().getScheduler().abortWait( false );

    // Either we skip a proc line, or we abort a wait condition (then we dont want to actually skip a line)
    if (waitAborted)
    {
    	SPELLexecutor::instance().getCIF().warning("Wait condition aborted", LanguageConstants::SCOPE_SYS );
    	setStatus(STATUS_PAUSED);
    }
    else
    {
        if (SPELLexecutor::instance().goNextLine())
        {
            m_skipping = not waitAborted;
            doContinue();
        }
        else
        {
        	/** \todo Should try to go to upper frame instead of stepping.
            // This is the issue that obligues us to put a return statement
            // at the end of each function. */
            doStep(false);
        }
    }
}
Ejemplo n.º 12
0
//=============================================================================
// METHOD    : SPELLcontroller::doPlay
//=============================================================================
void SPELLcontroller::doPlay()
{
    DEBUG("[C] Do play (current status " + SPELLexecutorUtils::statusToString(getStatus()) + ")");
	switch(getStatus())
	{
	case STATUS_PAUSED: // Allowed status
	case STATUS_INTERRUPTED: // Allowed status
		break;
	default:
		return;
	}
    if (m_error) return; // Do not continue on error

    DEBUG("[C] Restart wait in scheduler" );
    SPELLexecutor::instance().getScheduler().restartWait();
    DEBUG("[C] Set status running and mode play" );
    setStatus(STATUS_RUNNING);
    setMode(MODE_PLAY);
    DEBUG("[C] Continue" );
    doContinue();
}