コード例 #1
0
ファイル: dipdump.c プロジェクト: bhanug/open-watcom-v2
/**
 * Dumps the debug information in a file.
 *
 * @returns 0 on success, exit code on failure.
 * @param   file    The filename.
 * @param   dips    The dips to load and use.
 */
static int DumpFile( const char *file, char **dips )
{
    int             rc = 1;
    dig_fhandle     fh;

    /*
     * Open the file
     */
    fh = DIGCliOpen( file, DIG_READ );
    if( fh == DIG_NIL_HANDLE ) {
        return( ErrorMsg( "Failed to open '%s'\n", file ) );
    }

    /*
     * Init DIP, create a process and load the file into the process.
     */
    if( InitDIP( dips ) ) {
        process_info    *proc = DIPCreateProcess();

        if( proc != NULL ) {
            int         prty;
            mod_handle  mh = 0;

            for( prty = DIPPriority( 0 ); prty != 0; prty = DIPPriority( prty ) ) {
                DIGCliSeek( fh, 0, DIG_ORG );
                mh = DIPLoadInfo( fh, 0, prty );
                if( mh != NO_MOD ) {
                    break;
                }
            }
            if( mh != NO_MOD ) {
                DIPMapInfo( mh, NULL );
                InfoMsg( "DIP opened '%s' at prty=%d, mh=%lx\n", file, prty, (long)mh );

                /*
                 * Enumerate the debug info.
                 */
                rc = DumpIt( file, mh, proc );

                /*
                 * Cleanup.
                 */
                DIPUnloadInfo( mh );
            } else {
                ErrorMsg( "DIP failed to open '%s'.\n", file);
            }
            DIPDestroyProcess( proc );
        }
        TermDIP();
    }
    DIGCliClose( fh );
    return( rc );
}
コード例 #2
0
/*
 * SymFileClose - close the current symfile
 */
void SymFileClose( void ) {

    if( curModHdl != NO_MOD ) {
        DIPUnloadInfo( curModHdl );
    }
    if( curProcess != NULL ) {
        DIPDestroyProcess( curProcess );
    }
    if( curFileHdl != -1 ) {
        DIGCliClose( curFileHdl );
    }
    curProcess = NULL;
    curModHdl = NO_MOD;
    curFileHdl = -1;
}
コード例 #3
0
/*
 * LoadDbgInfo
 */
BOOL LoadDbgInfo( void ) {

    BOOL                err;
    unsigned            priority;

    DEBUGOUT( "Enter LoadDbgInfo" );
    err = TRUE;
    curProcess = DIPCreateProcess();
    curFileHdl = DIGCliOpen( DTModuleEntry.szExePath , DIG_READ );
    if( curFileHdl != -1 ) {
        DEBUGOUT( "File open OK" );
        priority = 0;
        for( ;; ) {
            priority = DIPPriority( priority );
            if( priority == 0 ) break;
            curModHdl = DIPLoadInfo( curFileHdl, 0, priority );
            if( curModHdl != NO_MOD ) break;
        }
        if( curModHdl != NO_MOD ) {
                DEBUGOUT( "debug info load OK" );
                DIPMapInfo( curModHdl, NULL );
                err = FALSE;
        } else {
            DEBUGOUT( "curModHdl == NO_MOD" );
        }
    }
    if( err ) {
        DEBUGOUT( "LoadDbgInfo Failed" );
        if( (int)curFileHdl != -1 ) {
            DIGCliClose( curFileHdl );
        }
        DIPDestroyProcess( curProcess );
        curProcess = NULL;
        curModHdl = NO_MOD;
        curFileHdl = -1;
        return( FALSE );
    }
    return( TRUE );
}