Esempio n. 1
0
static walk_result CheckFirstFile( cue_handle *ch, void *_d )
{
    cue_mod     *d = _d;
    char        *buff;
    unsigned    len;

    len = CueFile( ch, NULL, 0 ) + 1;
    _AllocA( buff, len );
    CueFile( ch, buff, len );
    if( stricmp( buff, d->file ) == 0 ) {
        d->found = true;
    }
    return( WR_STOP );
}
Esempio n. 2
0
static walk_result FindCue( cue_handle *ch, void *d )
{
    cue_find    *cd = d;
    char        file[FILENAME_MAX];
    unsigned    len;
    unsigned    match;


    len = CueFile( ch, file, sizeof( file ) );
    if( len < cd->len ) return( WR_CONTINUE );
    if( memcmp( &file[len - cd->len], cd->name, cd->len ) == 0 ) {
        match = CMP_SENSITIVE;
    } else if( memicmp( &file[len - cd->len], cd->name, cd->len ) == 0 ) {
        match = CMP_INSENSITIVE;
    } else {
        return( WR_CONTINUE );
    }
    if( match > cd->match ) {
        cd->match = match;
        cd->id = CueFileId( ch );
        cd->ambig = FALSE;
    } else if( match == cd->match ) {
        cd->ambig = TRUE;
    }
    return( WR_CONTINUE );
}
Esempio n. 3
0
STATIC file_info  *loadFileInfo( mod_info *curr_mod, sym_handle *sym )
/********************************************************************/
{
    file_info       *sym_file;
    cue_handle      *ch;
    cue_fileid      fid;
    int             file_count;
    int             count;
    location_list   ll;

    if( SymLocation( sym, NULL, &ll ) != DS_OK ) {
        return( curr_mod->mod_file[0] );
    }
    ch = alloca( DIPHandleSize( HK_CUE ) );
    switch( AddrCue( curr_mod->mh, ll.e[0].u.addr, ch ) ) {
    case    SR_NONE:
    case    SR_FAIL:
        return( curr_mod->mod_file[0] );
    }
    fid = CueFileId( ch );
    file_count = curr_mod->file_count;
    count = 0;
    while( count < file_count ) {
        sym_file = curr_mod->mod_file[count];
        if( sym_file->fid == fid ) {
            return( sym_file );
        }
        count++;
    }
    curr_mod->file_count++;
    curr_mod->mod_file = ProfRealloc( curr_mod->mod_file,
                             curr_mod->file_count * sizeof( pointer ) );
    count = CueFile( ch, NULL, 0 ) + 1;
    sym_file = ProfCAlloc( sizeof( file_info ) + count );
    sym_file->fid = fid;
    CueFile( ch, sym_file->name, count );
    initRoutineInfo( sym_file );
    curr_mod->mod_file[file_count] = sym_file;
    return( sym_file );
}
Esempio n. 4
0
/*
 * doFindSymbol
 */
BOOL doFindSymbol( ADDRESS *addr, syminfo *si, int getsrcinfo ) {

    sym_handle          *symhdl;
    cue_handle          *cue;
    search_result       sr;
    location_list       ll;
    address             dipaddr;
    BOOL                ret;

    si->segnum = -1;
    si->name[0] = 0;
    if( !StatShowSymbols || curProcess == NULL ) {
        return( FALSE );
    }
    symhdl = MemAlloc( DIPHandleSize( HK_SYM ) );
    dipaddr.sect_id = 0;
    dipaddr.indirect = FALSE;
    dipaddr.mach.offset = addr->offset;
    dipaddr.mach.segment = addr->seg;
    sr = AddrSym( NO_MOD, dipaddr, symhdl );
    switch( sr ) {
    case SR_CLOSEST:
        SymLocation( symhdl, NULL, &ll );
        si->symoff = addr->offset - ll.e[0].u.addr.mach.offset;
        break;
    case SR_EXACT:
        si->symoff = 0;
        break;
    case SR_NONE:
        ret = FALSE;
        break;
    }
    if( sr != SR_NONE ) {
        SymName( symhdl, NULL, SN_OBJECT, si->name, MAX_SYM_NAME );
//      SymName( symhdl, NULL, SN_SOURCE, si->name, MAX_SYM_NAME );
        if( getsrcinfo ) {
            cue = MemAlloc( DIPHandleSize( HK_CUE ) );
            if( AddrCue( NO_MOD, dipaddr, cue ) == SR_NONE ) {
                MemFree( cue );
                ret = FALSE;
            } else {
                CueFile( cue, si->filename, MAX_FILE_NAME );
                si->linenum = CueLine( cue );
                MemFree( cue );
                ret = TRUE;
            }
        }
    }
    MemFree( symhdl );
    return( ret );
}
Esempio n. 5
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 );
}
Esempio n. 6
0
/**
 * WalkFileList callback, the module pass.
 *
 * @returns WR_CONTINUE
 * @param   cue     The file.
 * @param   ignored Unused user argument.
 */
static walk_result File2Callback( cue_handle *cue, void *ignored )
{
    address         prev_addr = {0};
    long            prev_line = -1;
    cue_handle      *next_cue = alloca( DIPHandleSize( HK_CUE, false ) );
    cue_handle      *prev_cue = NULL;
    cue_handle      *cue2     = alloca( DIPHandleSize( HK_CUE, false ) );
    mod_handle      mod       = CueMod( cue );
    cue_fileid      file_id   = CueFileId( cue );
    search_result   search_rc;
    char            buff[1024];
    size_t          len;
    dip_status      rc;

    /* filename */
    buff[0] = '\0';
    len = CueFile( cue, buff, sizeof( buff ) );
    if( len > 0 ) {
        printf( " %lx %s\n", file_id, buff );
    } else {
        printf( " %lx (len=%u)\n", file_id, len );
    }

    /* check the LineCue function */
    if( Opts.do_cue_tests ) {
        search_rc = LineCue( mod, file_id, 0, 0, cue2 );
        CompareCues( cue, cue2, SR_EXACT, search_rc, true, false, true, false,
                     "LineCue(,,0,)" );
    }

    /* lines */
    do {
        long        line   = CueLine( cue );
        unsigned    column = CueColumn( cue );
        address     addr   = CueAddr( cue );


        printf( "  Line %5ld ", line );
        if( column ) {
            printf( "Col %2d ", column );
        }
        printf( "at %04x:%08lx%s\n", addr.mach.segment, (long)addr.mach.offset,
                prev_line >= 0 && addr.mach.offset < prev_addr.mach.offset
                ? "^"
                : prev_line >= 0 && line < prev_line ? "!" : "" );

        /* do tests */
        if( Opts.do_cue_tests ) {
            if( CueFileId( cue ) !=  file_id ) {
                printf( "ERROR: file id changed! new:%#lx old:%#lx\n",
                        (long)CueFileId( cue ), (long)file_id );
            }
            if( CueMod( cue ) !=  mod ) {
                printf( "ERROR: module changed! new:%#lx old:%#lx\n",
                        (long)CueMod( cue ), (long)file_id );
            }

            /* line searches */
            search_rc = LineCue( mod, file_id, line, 0, cue2 );
            CompareCues( cue, cue2, SR_EXACT, search_rc, true, false, false, false,
                         "LineCue(,,n,)" );
            if( line > prev_line + 1 && prev_line >= 0 ) {
                search_rc = LineCue( mod, file_id, line - 1, 0, cue2 );
                CompareCues( prev_cue, cue2,
                             prev_line == line - 1 ? SR_EXACT : SR_CLOSEST,
                             search_rc, true, false, false, false,
                             "LineCue(,,n-1,)" );
            }

            /* address searches */
            search_rc = AddrCue( mod, addr, cue2 );
            CompareCues( cue, cue2, SR_EXACT, search_rc, false, false, true, false,
                         "AddrCue(,,n,)" );
        }


        /* next */
        rc = CueAdjust( cue, 1, next_cue );
        prev_cue  = cue;
        cue       = next_cue;
        next_cue  = prev_cue;
        prev_addr = addr;
        prev_line = line;
    } while( rc == DS_OK );

    return( WR_CONTINUE );
}