Exemple #1
0
static bool CheckLoadDebugInfo( image_entry *image, file_handle fh,
                        unsigned start, unsigned end )
{
    char        buff[TXT_LEN];
    char        *symfile;
    unsigned    prio;
    char        *endstr;

    prio = start;
    for( ;; ) {
        prio = DIPPriority( prio );
        if( prio == 0 || prio > end )
            return( false );
        DIPStatus = DS_OK;
        image->dip_handle = DIPLoadInfo( fh, sizeof( image_entry * ), prio );
        if( image->dip_handle != NO_MOD )
            break;
        if( DIPStatus & DS_ERR ) {
            symfile = image->symfile_name;
            if( symfile == NULL )
                symfile = image->image_name;
            endstr = Format( buff, LIT_ENG( Sym_Info_Load_Failed ), symfile );
            *endstr++ = ' ';
            StrCopy( DIPMsgText( DIPStatus ), endstr );
            Warn( buff );
            return( false );
        }
    }
    *(image_entry **)ImageExtra( image->dip_handle ) = image;
    return( true );
}
Exemple #2
0
static bool CheckLoadDebugInfo( image_entry *image, file_handle fh, dip_priority start, dip_priority end )
{
    char            buff[TXT_LEN];
    char            *symfile;
    dip_priority    priority;
    char            *endstr;

    image->dip_handle = NO_MOD;
    for( priority = start - 1; (priority = DIPPriority( priority )) != 0; ) {
        if( priority > end )
            return( false );
        DIPStatus = DS_OK;
        image->dip_handle = DIPLoadInfo( FH2FP( fh ), sizeof( image_entry * ), priority );
        if( image->dip_handle != NO_MOD )
            break;
        if( DIPStatus & DS_ERR ) {
            symfile = image->symfile_name;
            if( symfile == NULL )
                symfile = image->image_name;
            endstr = Format( buff, LIT_ENG( Sym_Info_Load_Failed ), symfile );
            *endstr++ = ' ';
            StrCopy( DIPMsgText( DIPStatus ), endstr );
            Warn( buff );
            return( false );
        }
    }
    *(image_entry **)DIPImageExtra( image->dip_handle ) = image;
    return( true );
}
Exemple #3
0
mod_handle WPDipLoadInfo( dig_fhandle fid, const char *f_name, void *image,
                   unsigned image_size, unsigned dip_start, unsigned dip_end )
/****************************************************************************/
{
    unsigned    prio;
    mod_handle  dip_module;

    dip_module = NO_MOD;
    prio = dip_start;
    for( ;; ) {
        prio = DIPPriority( prio );
        if( prio == 0 || prio > dip_end )
            break;
        DIPStatus = DS_OK;
        dip_module = DIPLoadInfo( fid, image_size, prio );
        if( dip_module != NO_MOD ) {
            *(void **)DIPImageExtra( dip_module ) = image;
            DIPMapInfo( dip_module, image );
            break;
        }
        if( DIPStatus & DS_ERR ) {
            ErrorMsg( LIT( Dip_Info_Failed ), f_name, errMsgText( DIPStatus ) );
        }
    }
    return( dip_module );
}
Exemple #4
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 );
}
Exemple #5
0
/*
 * LoadDbgInfo
 */
bool LoadDbgInfo( ModuleNode *mod )
{
    dip_priority    priority;

    if( !GetSegmentList( mod ) )
        return( false );
    mod->syminfo->procinfo = DIPCreateProcess();
    for( priority = 0; (priority = DIPPriority( priority )) != 0; ) {
        mod->syminfo->hdl = DIPLoadInfo( mod->fp, 0, priority );
        if( mod->syminfo->hdl != NO_MOD ) {
            break;
        }
    }
    if( mod->syminfo->hdl == NO_MOD )
        return( false );
    return( true );
}
Exemple #6
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 );
}