Ejemplo n.º 1
0
static void begin_thread_helper( void *param )
/********************************************************/
{
    thread_args         *td = (thread_args *)param;
    thread_fn           *rtn;
    void                *arg;
    thread_data         *tdata;
    int                 thread_handle;
    REGISTRATION_RECORD rr;

    td->tid = RdosGetThreadHandle();    
    rtn = td->rtn;
    arg = td->argument;
    thread_handle = td->thread_handle;
    RdosSetSignal( td->signal );

    tdata = (thread_data *)RdosAllocateMem( __ThreadDataSize );

    if( tdata != NULL ) {
        memset( tdata, 0, __ThreadDataSize );
        tdata->__data_size = __ThreadDataSize;

        if( !__RdosAddThread( tdata ) ) {
                // print runtime error message now ?
            return;
        }
    }

    // now get the thread_data ptr the 'standard' way -- this may cause
    // a new thread_data structure to be allocated on heap:
    tdata = __THREADDATAPTR;
    if( tdata == NULL ) {
        // this is a library runtime error, should we print an error message ?
        return;
    }

    __NewExceptionFilter( &rr );
    __sig_init_rtn(); // fills in a thread-specific copy of signal table
    (*rtn)( arg );
    _endthread();
    RdosFreeMem(tdata);
    return;
}
Ejemplo n.º 2
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 );
}