Exemple #1
0
static void DebugThread( void *Param )
{
    int CurrModuleHandle;
    int WaitHandle;
    int thread;
    struct TDebug *obj = (struct TDebug *)Param;

    obj->FInstalled = TRUE;

    CurrModuleHandle = RdosGetModuleHandle();
    SelfKey = RdosGetModuleFocusKey( CurrModuleHandle );    
    if ( SelfKey != RdosGetFocus() )
        SelfKey = 0;
        
    RdosWaitMilli( 250 );

    obj->FHandle = RdosSpawnDebug( obj->FProgram, obj->FParam, obj->FStartDir, 0, 0, &thread);
        
    RdosWaitMilli( 250 );

    if( obj->FHandle ) {
        WaitHandle = RdosCreateWait();
        RdosAddWaitForDebugEvent( WaitHandle, obj->FHandle, obj );
        
        while( obj->FInstalled )
            if( RdosWaitForever( WaitHandle ) )
                SignalDebugData( obj );

        RdosCloseWait( WaitHandle );
    } else
        obj->FInstalled = FALSE;
}
Exemple #2
0
static void RemoveThread( struct TDebug *obj, int thread )
{
    struct TDebugThread *p;
    struct TDebugThread *t;

    RdosEnterSection( obj->FSection );

    p = 0;
    t = obj->ThreadList;

    while( t ) {
        if( t->ThreadID == thread ) {
            if( p )
                p->Next = t->Next;
            else
                obj->ThreadList = t->Next;
            break;            
        }
        else {
            p = t;
            t = t->Next;
        }
    }

    if( t ) {
        if( t == obj->CurrentThread ) {
            obj->CurrentThread = 0;
            RdosLeaveSection( obj->FSection );

            RdosWaitMilli( 25 );

            RdosEnterSection( obj->FSection );
        }
        free( t );
    }

    RdosLeaveSection( obj->FSection );
}
Exemple #3
0
static void SignalDebugData( struct TDebug *obj )
{
    int thread;
    char debtype;
    struct TCreateProcessEvent cpe;
    struct TCreateThreadEvent cte;
    struct TLoadDllEvent lde;
    struct TExceptionEvent ee;
    int ExitCode;
    int handle;
    struct TDebugThread *newt;

    RdosWaitMilli( 5 );

    debtype = RdosGetDebugEvent( obj->FHandle, &thread );

    switch (debtype) {
        case EVENT_EXCEPTION:
            RdosGetDebugEventData( obj->FHandle, &ee );
            HandleException( obj, &ee, thread );
            break;

        case EVENT_CREATE_THREAD:
            RdosGetDebugEventData( obj->FHandle, &cte );
            HandleCreateThread( obj, &cte );
            obj->FThreadChanged = TRUE;
            break;

        case EVENT_CREATE_PROCESS:
            RdosGetDebugEventData( obj->FHandle, &cpe );
            HandleCreateProcess( obj, &cpe );
            break;

        case EVENT_TERMINATE_THREAD:
            HandleTerminateThread( obj, thread );
            obj->FThreadChanged = TRUE;
            if( !obj->CurrentThread ) {
                obj->CurrentThread = obj->ThreadList;
                while( obj->CurrentThread && !IsDebug( obj->CurrentThread ) )
                    obj->CurrentThread = obj->CurrentThread->Next;

                if (!obj->CurrentThread)
                    obj->CurrentThread = obj->ThreadList;
            }
            break;

        case EVENT_TERMINATE_PROCESS:
            RdosGetDebugEventData( obj->FHandle, &ExitCode );
            HandleTerminateProcess( obj, ExitCode);
            obj->FInstalled = FALSE;
            RdosSetSignal( obj->UserSignal );
            break;

        case EVENT_LOAD_DLL:
            RdosGetDebugEventData( obj->FHandle, &lde );
            HandleLoadDll( obj, &lde );
            obj->FModuleChanged = TRUE;
            break;

        case EVENT_FREE_DLL:
            RdosGetDebugEventData( obj->FHandle, &handle );
            HandleFreeDll( obj, handle );
            obj->FModuleChanged = TRUE;
            break;
    }

    RdosClearDebugEvent( obj->FHandle );

    if( debtype == EVENT_EXCEPTION ) {
        if( obj->CurrentThread ) {
            DeactivateBreaks( obj->CurrentThread, obj->BreakList);

            if( thread != obj->CurrentThread->ThreadID ) {
                newt = LockThread( obj, thread );
                if( newt ) {
                    obj->CurrentThread = newt;
                    obj->FThreadChanged = TRUE;
                }
                UnlockThread( obj );
            }
        }

        RdosSetSignal( obj->UserSignal );
    }
    else
        RdosContinueDebugEvent( obj->FHandle, thread );
}
Exemple #4
0
_WCRTLINK void delay( unsigned ms )
{
    RdosWaitMilli( ms );
}