예제 #1
0
    HRESULT PendingBreakpoint::UnbindFromModule( Module* mod, Program* prog )
    {
        GuardedArea     guard( mBoundBPGuard );

        if ( mDeleted )
            return E_BP_DELETED;

        HRESULT         hr = S_OK;
        ModuleBinding*  binding = NULL;
        DWORD           boundBPCount = 0;
        RefPtr<ErrorBreakpoint> lastErrorBP;

        binding = GetBinding( mod->GetId() );
        if ( binding == NULL )
            return E_FAIL;

        for ( ModuleBinding::BPList::iterator it = binding->BoundBPs.begin();
            it != binding->BoundBPs.end();
            it++ )
        {
            BoundBreakpoint*    bp = it->Get();

            bp->Dispose();
            SendUnboundEvent( bp, prog );
        }

        mBindings.erase( mod->GetId() );

        for ( BindingMap::iterator it = mBindings.begin();
            it != mBindings.end();
            it++ )
        {
            ModuleBinding&  bind = it->second;
            boundBPCount += bind.BoundBPs.size();
            if ( bind.ErrorBP.Get() != NULL )
                lastErrorBP = bind.ErrorBP;
        }

        // if there're no more bound BPs, then send an error BP event
        // there should always be at least one error BP, because there should 
        // always be at least one module - the EXE

        if ( (boundBPCount == 0) && (lastErrorBP.Get() != NULL) )
        {
            SendErrorEvent( lastErrorBP.Get() );
        }

        return hr;
    }
예제 #2
0
    HRESULT PendingBreakpoint::BindToAllModules()
    {
        GuardedArea             guard( mBoundBPGuard );

        if ( mDeleted )
            return E_BP_DELETED;

        HRESULT                 hr = S_OK;
        BpRequestInfo           reqInfo;
        auto_ptr<BPBinder>      binder;

        hr = MakeBinder( mBPRequest, binder );
        if ( FAILED( hr ) )
            return hr;

        // generate bound and error breakpoints
        BPBinderCallback        callback( binder.get(), this, mDocContext.Get(), mDebugger );
        mEngine->ForeachProgram( &callback );

        if ( mDocContext.Get() == NULL )
        {
            // set up our document context, since we didn't have one
            callback.GetDocumentContext( mDocContext );
        }

        // enable all bound BPs if we're enabled
        if ( mState.state == PBPS_ENABLED )
        {
            for ( BindingMap::iterator it = mBindings.begin();
                it != mBindings.end();
                it++ )
            {
                ModuleBinding&  bind = it->second;

                for ( ModuleBinding::BPList::iterator itBind = bind.BoundBPs.begin();
                    itBind != bind.BoundBPs.end();
                    itBind++ )
                {
                    (*itBind)->Enable( TRUE );
                }
            }
        }

        if ( callback.GetBoundBPCount() > 0 )
        {
            // send a bound event

            CComPtr<IEnumDebugBoundBreakpoints2>    enumBPs;

            hr = EnumBoundBreakpoints( &enumBPs );
            if ( FAILED( hr ) )
                return hr;

            hr = SendBoundEvent( enumBPs );
        }
        else if ( callback.GetErrorBPCount() > 0 )
        {
            // send an error event

            RefPtr<ErrorBreakpoint> errorBP;

            callback.GetLastErrorBP( errorBP );

            hr = SendErrorEvent( errorBP.Get() );
        }
        else
            hr = E_FAIL;

        if ( SUCCEEDED( hr ) )
        {
            hr = mEngine->AddPendingBP( this );
        }

        return hr;
    }
void DeviceMotionService::RegisterForSensor()
{
    if (!RegisterForAccelerometerSensor()) {
        SendErrorEvent();
    }
}