Beispiel #1
0
/**
 * 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 );
}
Beispiel #2
0
extern dig_fhandle FullPathOpen( char const *name, char *ext,
                                 char *result, unsigned max_res )
/***************************************************************/
{
    char        realname[ _MAX_PATH2 ];
    char *      filename;

    if( ext == NULL || *ext == '\0' ) {
        strcpy( realname, name );
    } else {
        _splitpath2( name, result, NULL, NULL, &filename, NULL );
        _makepath( realname, NULL, NULL, filename, ext );
    }
    filename = FindFile( result, realname, FilePathList );
    if( filename == NULL ) {
        filename = FindFile( result, realname, DipExePathList );
    }
    if( filename == NULL ) {
        return( -1 );
    }
    return( DIGCliOpen( filename, DIG_READ ) );
}
Beispiel #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 );
}
Beispiel #4
0
dig_fhandle PathOpen( char *name, unsigned len, char *ext ) {

    char        path[ _MAX_PATH ];
    char        *realname;
    char        *filename;

    len = len;
    if( ext == NULL || *ext == '\0' ) {
        realname = name;
    } else {
        realname = MemAlloc( _MAX_PATH );
        filename = MemAlloc( _MAX_FNAME );
        _splitpath( name, NULL, NULL, filename, NULL );
        _makepath( realname, NULL, NULL, filename, ext );
        MemFree( realname );
        MemFree( filename );
    }
    _searchenv( realname, "PATH", path );
    if( *path == '\0' ) {
        return( -1 );
    } else {
        return( DIGCliOpen( path, DIG_READ ) );
    }
}