예제 #1
0
char *CnvAddr( address addr, cnvaddr_option cao, bool uniq,
                        char *p, size_t max )
{
    char                off_buff[40];
    size_t              str_width, name_width, off_width;
    addr_off            sym_offset;
    search_result       sr;
    location_list       ll;
    DIPHDL( sym, sym );

    off_width = 0;
    AddrFloat( &addr );
    sr = DeAliasAddrSym( NO_MOD, addr, sym );
    switch( sr ) {
    case SR_NONE:
        return( NULL );
    case SR_CLOSEST:
        if( cao == CAO_NO_PLUS )
            return( NULL );
        DIPSymLocation( sym, NULL, &ll );
        sym_offset = addr.mach.offset - ll.e[0].u.addr.mach.offset;
        if( cao == CAO_NORMAL_PLUS ) {
            char    *prfx;
            prfx = AddHexSpec( off_buff );
            off_width = CnvULongHex( sym_offset, prfx, sizeof( off_buff ) - ( prfx - off_buff ) ) - off_buff + 1;
        }
        break;
    case SR_EXACT:
        break;
    }
    name_width = QualifiedSymName( sym, NULL, 0, uniq );
    str_width = name_width + off_width;
    if( max == 0 )
        max = str_width;
    if( str_width > max ) { /* won't fit */
        if( off_width != 0 )
            return( NULL );
        QualifiedSymName( sym, p, max - 1, uniq );
        p += max - 1;
        *p++ = '>';
        *p = NULLCHAR;
        return( p );
    }
    QualifiedSymName( sym, p, name_width + 1, uniq );
    p += name_width;
    if( off_width != 0 ) {
        --off_width;
        *p++ = '+';
        memcpy( p, off_buff, off_width );
        p += off_width;
        *p = NULLCHAR;
    }
    return( p );
}
예제 #2
0
void SymResolve( stack_entry *entry )
{
    item_mach   tmp;
    sym_handle  *sh;

    if( entry->flags & SF_SYM ) {
        sh = entry->v.sh;
        entry->flags &= ~SF_FORM_MASK;
        if( DIPSymLocation( sh, entry->lc, &entry->v.loc ) == DS_OK ) {
            entry->flags |= SF_LOCATION;
            if( entry->v.loc.e[0].type == LT_ADDR ) {
                entry->flags |= SF_IMP_ADDR;
            }
            GetTrueEntry( entry );
        } else {
            if( entry->info.kind == TK_STRING ) {
                _ChkAlloc( entry->v.string.allocated, entry->info.size,
                            LIT_ENG( ERR_NO_MEMORY_FOR_EXPR ) );
                LocationCreate( &entry->v.string.loc, LT_INTERNAL,
                            entry->v.string.allocated );
                if( DIPSymValue( sh, entry->lc, entry->v.string.allocated ) != DS_OK ) {
                    Error( ERR_NONE, LIT_ENG( ERR_NO_ACCESS ) );
                }
            } else {
                if( DIPSymValue( sh, entry->lc, &tmp ) != DS_OK ) {
                    Error( ERR_NONE, LIT_ENG( ERR_NO_ACCESS ) );
                }
                FromItem( &tmp, entry );
            }
        }
        switch( entry->info.kind ) {
        case TK_CODE:
        case TK_ADDRESS:
            if( !(entry->flags & SF_LOCATION) ) {
                ExprSetAddrInfo( entry, false );
/*
        This was here before, but that messes up things like 'do x=0:0'
        where 'x' is a newly created debugger variable. I can't think
        of any reason why you'd want to do this. If it turns out that there
        is a reason, talk to me.
                        Brian.
            } else {
                LocationToAddr( entry );
*/
            }
            entry->th = NULL;
            break;
        }
    }
}
예제 #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( DIPSymLocation( sym, NULL, &ll ) != DS_OK ) {
        return( curr_mod->mod_file[0] );
    }
    ch = alloca( DIPHandleSize( HK_CUE, false ) );
    switch( DIPAddrCue( curr_mod->mh, ll.e[0].u.addr, ch ) ) {
    case SR_NONE:
    case SR_FAIL:
        return( curr_mod->mod_file[0] );
    }
    fid = DIPCueFileId( ch );
    file_count = curr_mod->file_count;
    for( count = 0; count < file_count; ++count ) {
        sym_file = curr_mod->mod_file[count];
        if( sym_file->fid == fid ) {
            return( sym_file );
        }
    }
    curr_mod->file_count++;
    curr_mod->mod_file = ProfRealloc( curr_mod->mod_file, curr_mod->file_count * sizeof( pointer ) );
    count = DIPCueFile( ch, NULL, 0 ) + 1;
    sym_file = ProfCAlloc( sizeof( file_info ) + count );
    sym_file->fid = fid;
    DIPCueFile( ch, sym_file->name, count );
    initRoutineInfo( sym_file );
    curr_mod->mod_file[file_count] = sym_file;
    return( sym_file );
}
예제 #4
0
/*
 * GetSymbolName
 */
bool GetSymbolName( address *addr, char *name, DWORD *symoff )
{
    sym_handle          *symhdl;
    search_result       sr;
    location_list       ll;

    symhdl = MemAlloc( DIPHandleSize( HK_SYM ) );
    sr = DIPAddrSym( NO_MOD, *addr, symhdl );
    switch( sr ) {
    case SR_CLOSEST:
        DIPSymLocation( symhdl, NULL, &ll );
        *symoff = MADAddrDiff( addr,&(ll.e[0].u.addr), MAF_FULL );
        break;
    case SR_EXACT:
        *symoff = 0;
        break;
    case SR_NONE:
        MemFree( symhdl );
        return( false );
    }
    DIPSymName( symhdl, NULL, SNT_OBJECT, name, MAX_SYM_NAME );
    MemFree( symhdl );
    return( true );
}