Ejemplo n.º 1
0
static image_entry *CreateImage( const char *exe, const char *symfile )
{
    image_entry         *image;
    bool                local;
    const char          *curr_name;
    unsigned            curr_len;
    const char          *this_name;
    unsigned            this_len;
    char_ring           *curr;
    open_access         ind;

    if( exe != NULL && symfile == NULL ) {
        local = false;
        this_name = SkipPathInfo( exe, OP_REMOTE );
        this_len = ExtPointer( exe, OP_REMOTE ) - exe;
        for( curr = LocalDebugInfo; curr != NULL; curr = curr->next ) {
            curr_name = SkipPathInfo( curr->name, OP_LOCAL );
            curr_name = RealFName( curr_name, &ind );
            if( curr_name[0] == '@' && curr_name[1] == 'l' )
                curr_name += 2;
            curr_len = ExtPointer( curr_name, OP_LOCAL ) - curr_name;
            local = ( this_len == curr_len && strnicmp( this_name, curr_name, this_len ) == 0 );
            if( local ) {
                symfile = curr->name;
                break;
            }
        }
    }

    _SwitchOn( SW_ERROR_RETURNS );
    image = DoCreateImage( exe, symfile );
    _SwitchOff( SW_ERROR_RETURNS );
    return( image );
}
Ejemplo n.º 2
0
static image_entry *CreateImage( const char *exe, const char *symfile )
{
    image_entry         *image;
    bool                local;
    const char          *curr_name;
    unsigned            curr_len;
    const char          *this_name;
    unsigned            this_len;
    char_ring           *curr;
    obj_attrs           oattrs;

    if( exe != NULL && symfile == NULL ) {
        local = false;
        this_name = SkipPathInfo( exe, OP_REMOTE );
        this_len = ExtPointer( exe, OP_REMOTE ) - exe;
        for( curr = LocalDebugInfo; curr != NULL; curr = curr->next ) {
            oattrs = 0;
            curr_name = SkipPathInfo( curr->name, OP_LOCAL );
            curr_name = RealFName( curr_name, &oattrs );
            if( curr_name[0] == '@' && curr_name[1] == 'l' )
                curr_name += 2;
            curr_len = ExtPointer( curr_name, OP_LOCAL ) - curr_name;
            local = ( this_len == curr_len && strnicmp( this_name, curr_name, this_len ) == 0 );
            if( local ) {
                symfile = curr->name;
                break;
            }
        }
    }
    image = DoCreateImage( exe, symfile );
    if( image == NULL ) {
        ErrorRet( ERR_NONE, LIT_ENG( ERR_NO_MEMORY_FOR_DEBUG ) );
    }
    return( image );
}
Ejemplo n.º 3
0
static void FileSetTitle( a_window *wnd, mod_handle mod )
{
    char        *p;
    const char  *image_name;
    file_window *file = WndFile( wnd );

    if( file->track ) {
        p = StrCopy( ": ", StrCopy( LIT_DUI( WindowSource ), TxtBuff ) );
    } else {
        p = TxtBuff;
    }
    if( file->viewhndl != NULL ) {
        p = StrCopy( SkipPathInfo( FGetName( file->viewhndl ), 0 ), p );
    } else if( file->mod != NO_MOD ) {
        p += ModName( file->mod, p, TXT_LEN );
    }
    image_name = ModImageName( mod );
    if( image_name[0] != NULLCHAR ) {
        p = StrCopy( "(", StrCopy( " ", p ) );
        p = StrCopy( ")", StrCopy( SkipPathInfo( image_name, OP_REMOTE ), p ) );
    }
    WndSetTitle( wnd, TxtBuff );
}
Ejemplo n.º 4
0
static void DoDownLoadCode( void )
/********************************/
{
    file_handle     fh;

    if( !DownLoadTask )
        return;
    fh = FullPathOpen( TaskCmd, strlen( TaskCmd ), "exe", TxtBuff, TXT_LEN );
    if( fh == NIL_HANDLE ) {
        Error( ERR_NONE, LIT_ENG( ERR_FILE_NOT_OPEN ), TaskCmd );
    }
    FileClose( fh );
    FindLocalDebugInfo( TxtBuff );
    CopyToRemote( TxtBuff, SkipPathInfo( TxtBuff, OP_LOCAL ), true, NULL );
}
Ejemplo n.º 5
0
static void AsmSetTitle( a_window *wnd )
{
    char        *p;
    char        *image_name;
    asm_window  *asw = WndAsm( wnd );

    p = StrCopy( ": ", StrCopy( LIT( WindowAssembly ), TxtBuff ) );
    p += ModName( asw->mod, p, TXT_LEN );
    image_name = ModImageName( asw->mod );
    if( image_name[0] != '\0' ) {
        p = StrCopy( "(", StrCopy( " ", p ) );
        p = StrCopy( ")", StrCopy( SkipPathInfo( image_name, OP_REMOTE ), p ) );
    }
    WndSetTitle( wnd, TxtBuff );
}
Ejemplo n.º 6
0
static walk_result FindTheMad( mad_handle mh, void *d )
{
    struct find_mad     *fd = d;
    char                buff[80];
//    char                *p;

    MADNameFile( mh, buff, sizeof( buff ) );
//    p = SkipPathInfo( buff, 0 );
    SkipPathInfo( buff, 0 );
    if( memicmp( buff, fd->name, fd->len ) == 0 ) {
        fd->mad = mh;
        return( WR_STOP );
    }
    MADNameDescription( mh, buff, sizeof( buff ) );
    NormalizeString( buff );
    if( memicmp( buff, fd->name, fd->len ) == 0 ) {
        fd->mad = mh;
        return( WR_STOP );
    }
    return( WR_CONTINUE );
}
Ejemplo n.º 7
0
/*
 * ProcImgSymInfo -- initialize symbolic information
 *
 * Note: This function should try to open files locally first, for two
 * reasons:
 * 1) If a local file is open as remote, then local caching may interfere with
 *    file operations (notably seeks with DIO_SEEK_CUR)
 * 2) Remote access goes through extra layer of indirection; this overhead
 *    is completely unnecessary for local debugging.
 */
static bool ProcImgSymInfo( image_entry *image )
{
    file_handle fh;
    unsigned    last;
    char        buff[TXT_LEN];
    char        *symfile_name;
    const char  *nopath;
    size_t      len;

    image->deferred_symbols = false;
    if( _IsOff( SW_LOAD_SYMS ) )
        return( NO_MOD );
    if( image->symfile_name != NULL ) {
        last = DIP_PRIOR_MAX;
        fh = PathOpen( image->symfile_name, strlen( image->symfile_name ), "sym" );
        if( fh == NIL_HANDLE ) {
            nopath = SkipPathInfo( image->symfile_name, OP_REMOTE );
            fh = PathOpen( nopath, strlen( nopath ), "sym" );
            if( fh == NIL_HANDLE ) {
                /* try the sym file without an added extension */
                fh = FileOpen( image->symfile_name, OP_READ );
            }
        }
    } else {
        last = DIP_PRIOR_EXPORTS - 1;
        fh = FileOpen( image->image_name, OP_READ );
        if( fh == NIL_HANDLE ) {
            fh = FileOpen( image->image_name, OP_READ | OP_REMOTE );
        }
    }
    if( fh != NIL_HANDLE ) {
        if( CheckLoadDebugInfo( image, fh, DIP_PRIOR_MIN, last ) ) {
            return( true );
        }
        FileClose( fh );
    }
    if( image->symfile_name != NULL )
        return( false );
    _AllocA( symfile_name, strlen( image->image_name ) + 1 );
    strcpy( symfile_name, image->image_name );
    symfile_name[ExtPointer( symfile_name, OP_REMOTE ) - symfile_name] = NULLCHAR;
    len = MakeFileName( buff, symfile_name, "sym", OP_REMOTE );
    _Alloc( image->symfile_name, len + 1 );
    if( image->symfile_name != NULL ) {
        memcpy( image->symfile_name, buff, len + 1 );
        fh = FileOpen( image->symfile_name, OP_READ );
        if( fh == NIL_HANDLE ) {
            fh = FileOpen( image->symfile_name, OP_READ | OP_REMOTE );
        }
        if( fh == NIL_HANDLE ) {
            fh = PathOpen( image->symfile_name, strlen( image->symfile_name ), "" );
        }
        if( fh != NIL_HANDLE ) {
            if( CheckLoadDebugInfo( image, fh, DIP_PRIOR_MIN, DIP_PRIOR_MAX ) ) {
                return( true );
            }
            FileClose( fh );
        }
        _Free( image->symfile_name );
    }
    image->symfile_name = NULL;
    if( _IsOff( SW_NO_EXPORT_SYMS ) ) {
        if( _IsOn( SW_DEFER_SYM_LOAD ) ) {
            image->deferred_symbols = true;
        } else {
            fh = FileOpen( image->image_name, OP_READ | OP_REMOTE );
            if( fh != NIL_HANDLE ) {
                if( CheckLoadDebugInfo( image, fh, DIP_PRIOR_EXPORTS - 1, DIP_PRIOR_MAX ) ) {
                    return( true );
                }
                FileClose( fh );
            }
        }
    }
    return( false );
}
Ejemplo n.º 8
0
void *OpenSrcFile( cue_handle *ch )
{
    void        *hndl;
    char_ring   *path;
    char        *p;
    char        *d;
    char        *rem_name;
    bool        used_star;
    unsigned    len;
    char        *buff;

    len = CueFile( ch, NULL, 0 ) + 1;
    _AllocA( buff, len );
    CueFile( ch, buff, len );
    hndl = FOpenSource( buff, CueMod( ch ), CueFileId( ch ) );
    if( hndl != NULL ) return( hndl );
    for( path = SrcSpec; path != NULL; path = path->next ) {
        used_star = FALSE;
        d = TxtBuff;
        for( p = path->name; *p != '\0'; ++p ) {
            if( *p == '*' ) {
                used_star = TRUE;
                d += ModName( CueMod( ch ), d, TXT_LEN );
            } else {
                *d++ = *p;
            }
        }
        *d = NULLCHAR;
        if( !used_star ) {
            #if 0
                /*
                    John can't remember why he put this code in, and it
                    screws up when the user sets a source path of ".".
                    If we find some case where it's required, we'll have to
                    think harder about things.
                */
            if( *ExtPointer( TxtBuff, 0 ) != '\0' ) {
                *SkipPathInfo( TxtBuff, 0 ) = '\0';
            }
            #endif
            d = AppendPathDelim( TxtBuff, 0 );
            if( !IsAbsolutePath( buff ) ) {
                StrCopy( buff, d );
                hndl = FOpenSource( TxtBuff, CueMod( ch ), CueFileId( ch ) );
                if( hndl != NULL ) return( hndl );
            }
            /*
                We have a small problem here. We want to strip off the
                path information for the source file name, but we don't
                know if the file was compiled on the local system or the
                remote one. We'll kludge things by doing a local skip
                and then a remote one and seeing who takes off the most stuff.
                Don't even think about the case where the file has been
                compiled on a third, different type of file system.
            */
            p = SkipPathInfo( buff, OP_LOCAL );
            rem_name = SkipPathInfo( buff, OP_REMOTE );
            if( rem_name > p ) p = rem_name;
            d = StrCopy( p, d );
            *d = NULLCHAR;
        }
        hndl = FOpenSource( TxtBuff, CueMod( ch ), CueFileId( ch ) );
        if( hndl != NULL ) return( hndl );
    }
    return( NULL );
}
Ejemplo n.º 9
0
void SetPointAddr( brkp *bp, address addr )
{
    DIPHDL( cue, ch );
    image_entry *image;
    mod_handle  mod;
    char  const *start;
    bool        ok;

    if( bp->status.b.unmapped )
        return;
    _Free( bp->source_line );
    bp->source_line = NULL;
    bp->loc.addr = addr;
    _Free( bp->mod_name );
    bp->mod_name = NULL;
    _Free( bp->image_name );
    bp->image_name = NULL;
    _Free( bp->sym_name );
    bp->sym_name = NULL;
    bp->cue_diff = 0;
    bp->addr_diff = 0;
    if( !IS_BP_EXECUTE( bp->th ) ) {
        GetWPVal( bp );
    } else if( DeAliasAddrMod( addr, &mod ) != SR_NONE ) {
        image = ImageEntry( mod );
        if( image == NULL )
            return;
        ModName( mod, TxtBuff, TXT_LEN );
        bp->mod_name = DupStr( TxtBuff );
        if( image->image_name != NULL ) {
            start = SkipPathInfo( image->image_name, OP_REMOTE );
            bp->image_name = DupStrLen( start, ExtPointer( start, OP_REMOTE ) - start );
        } else {
            bp->image_name = NULL;
        }
        switch( DeAliasAddrCue( NO_MOD, addr, ch ) ) {
        case SR_EXACT:
            bp->source_line = CopySourceLine( ch );
            Format( TxtBuff, "%d", CueLine( ch ) );
            bp->sym_name = DupStr( TxtBuff );
            ok = GetBPSymAddr( bp, &addr );
            break;
        case SR_CLOSEST:
            Format( TxtBuff, "%d", CueLine( ch ) );
            bp->sym_name = DupStr( TxtBuff );
            bp->addr_diff = addr.mach.offset - CueAddr( ch ).mach.offset;
            ok = GetBPSymAddr( bp, &addr );
            break;
        default:
            ok = false;
        }
        if( !ok ) {
            _Free( bp->image_name );
            _Free( bp->mod_name );
            _Free( bp->sym_name );
            bp->image_name = NULL;
            bp->mod_name = NULL;
            bp->sym_name = NULL;
        }
    }
}