Beispiel #1
0
extern  void    BEFiniBack( b *bk ) {
//===================================

    Action( "BEFiniBack" );
    if( !IS_REAL_BACK( bk ) ) {
        Action( "( %s )%n", FEName( TO_REAL_BACK( bk )->s ) );
        return;
    }
    VerBack(bk);
    Action( "( %s [ %s ] )%n", FEName( bk->s ), Label( bk->lp ) );
}
Beispiel #2
0
static  void    DumpScList( score_list *curr )
/********************************************/
{
    DumpLiteral( "    " );
    switch( curr->info.class ) {
    case SC_N_CONSTANT:
        DumpChar( '&' );
        DumpLong( curr->info.offset );
        break;
    case SC_N_TEMP:
        DumpChar( 't' );
        DumpInt( curr->info.symbol.t->v.id );
        DumpLiteral( " offset " );
        DumpLong( curr->info.offset );
        break;
    case SC_N_MEMORY:
        DumpXString( FEName( curr->info.symbol.p ) );
        DumpLiteral( " offset " );
        DumpLong( curr->info.offset );
        break;
    case SC_N_INDEXED:
        if( curr->info.base == NULL ) {
            ;
        } else if( curr->info.base->n.class == N_TEMP ) {
            DumpChar( 't' );
            DumpInt( curr->info.base->t.v.id );
            DumpChar( '+' );
        } else {
            DumpXString( FEName( curr->info.base->v.symbol ) );
            DumpChar( '+' );
        }
        DumpLong( curr->info.offset );
        DumpChar( '[' );
        DumpRegName( ScoreList[curr->info.index_reg]->reg );
        DumpChar( ']' );
        break;
    case SC_N_INITIAL:
        DumpLiteral( "INITIAL(" );
        DumpLong( curr->info.offset );
        DumpChar( ')' );
        break;
    case SC_N_VOLATILE:
        DumpLiteral( "VOLATILE - Oh No!" );
        break;
    case SC_N_ADDRESS:
        DumpLiteral( "ADDRESS(" );
        DumpOperand(curr->info.symbol.p);
        DumpChar( ')' );
        break;
    }
Beispiel #3
0
static  bool    LblName( label_handle lbl, bool no_prefix )
/*********************************************************/
{
    if( !ValidLbl( lbl ) )
        return( false );
    if( no_prefix ) {
        if( lbl->lbl.sym == NULL ) {
            return( false );
        }
    } else {
        DumpChar( 'L' );
        DumpPtr( lbl );
        if( lbl->lbl.sym == NULL ) {
            return( true );
        }
    }
    DumpChar( '(' );
    if( AskIfRTLabel( lbl ) ) {
        DumpXString( AskRTName( SYM2RTIDX( lbl->lbl.sym ) ) );
    } else if( AskIfCommonLabel( lbl ) ) {
        DumpLiteral( "Common import => [" );
        DumpUInt( (unsigned)(pointer_int)lbl->lbl.sym );
        DumpLiteral( "] " );
    } else {
        DumpXString( FEName( lbl->lbl.sym ) );
    }
    DumpChar( ')' );
    return( true );
}
Beispiel #4
0
void    CVOutSym( cv_out *out, cg_sym_handle sym )
/*** Put a sym in out ***************************/
{
    dbg_type    tipe;
    fe_attr     attr;
    const char  *nm;

    attr = FEAttr( sym );
    tipe = FEDbgType( sym );
    nm = FEName( sym );
    if( attr & FE_STATIC ) {
        cs_gdata     *ptr;
        sg_index    kind;

        if( attr & FE_GLOBAL ) {
            kind = SG_GDATA;
        } else {
            kind = SG_LDATA;
        }
        ptr = StartSym(  out, kind );
        ptr->offset = 0;
        ptr->segment = 0;
        ptr->type = tipe;
        CVPutStr( out, nm );
        EndSym( out );
    } else {
        FrameVar( out, nm, tipe, 0 );
    }
}
Beispiel #5
0
extern  b       *BENewBack(sym s) {
//=================================

    b   *bk;

    Action( "BENewBack" );
    if( NewBackReturn == FAKE_NULL ) {
        bk = NULL;
    } else if( NewBackReturn != NULL ) {
        bk = NewBackReturn;
    } else {
        bk = CGAlloc( sizeof( b  ));
        bk->n = BackList;
        bk->s = s;
        bk->loc = -1;
        bk->i = ++BackId;
        bk->lp = NewLabel();
        BackList = bk;
        if( !IS_REAL_BACK( bk ) ) {
            CGError( "Internal error - odd memory" );
        }
    }
    Action( "( %s ) -> %p%n", FEName( s ), bk );
    return(bk);
}
Beispiel #6
0
extern  void    DFGenStatic( cg_sym_handle sym, dbg_loc loc ) {
/*******************************************************************/
    uint            flags;
    fe_attr         attr;
    const char      *name;
    dw_loc_handle   dw_loc;
    dw_loc_handle   dw_segloc;
    dw_handle       obj;
    dbg_type        dbtype;

    attr = FEAttr( sym );
    if( attr & FE_GLOBAL ){
        flags = DW_FLAG_GLOBAL;
    }else{
        flags = 0;
    }
    name = FEName( sym );
    if( attr & FE_STATIC ){
#if _TARGET & ( _TARG_IAPX86 | _TARG_80386 )
        if( _IsTargetModel( FLAT_MODEL ) ) {
            dw_segloc = NULL;
        }else{
            dw_segloc = SegLoc( sym );
        }
#else
        dw_segloc = NULL;
#endif
    }else{
        dw_segloc = NULL;
    }
    dbtype = FEDbgType( sym ); /* causes name side effects */
    dw_loc = DBGLoc2DF( loc );
    obj = DWVariable( Client, dbtype, dw_loc,
                0, dw_segloc, name, 0, flags );
    if( attr &  FE_GLOBAL ){
        name = FEName( sym );
        DWPubname( Client, obj, name );
    }
    if( dw_loc != NULL ){
        DWLocTrash( Client, dw_loc );
    }
    if( dw_segloc != NULL ){
        DWLocTrash( Client, dw_segloc );
    }
}
Beispiel #7
0
extern  void    BEFreeBack( b *bk ) {
//===================================

    b   **o;
    Action( "BEFreeBack" );
    if( !IS_REAL_BACK( bk ) ) {
        Action( "( %s )%n", FEName( TO_REAL_BACK( bk )->s ) );
        return;
    }
    VerBack(bk);
    o = &BackList;
    while( *o != bk ) {
        o = (b**)*o;
    }
    *o = bk->n;
    Action( "( %s [ %s ] )%n", FEName( bk->s ), Label( bk->lp ) );
    CGFree( bk );
}
Beispiel #8
0
void    CVProEnd( dbg_rtn *rtn, offset lc )
/*****************************************/
{
    cg_sym_handle       sym;
    dbg_type            tipe;
    fe_attr             attr;
    const char          *name;
    cs_gproc            *ptr;
    sg_index            kind;
    cv_out              out[1];

    /* unused parameters */ (void)lc;

    sym = AskForLblSym( CurrProc->label );
    attr = FEAttr( sym );
    if( attr & FE_GLOBAL ){
        kind = SG_GPROC;
    }else{
        kind = SG_LPROC;
    }
    NewBuff( out, CVSyms );
    ptr = StartSym(  out, kind );
    ptr->pParent = 0;
    ptr->pEnd = 0;
    ptr->pNext = 0;
    ptr->proc_length = 0;
    ptr->debug_start = rtn->pro_size;
    ptr->debug_end = 0;
    ptr->offset = 0;
    ptr->segment = 0;
    tipe = FEDbgType( sym );
    ptr->proctype = tipe;
    ptr->flags.s = 0;
#if _TARGET & ( _TARG_IAPX86 | _TARG_80386 )
    if( *(call_class *)FindAuxInfoSym( sym, CALL_CLASS ) & FAR_CALL ) {
        ptr->flags.f.far_ret = true;
    }
#endif
    if( rtn->obj_type != DBG_NIL_TYPE ) {
        name = FEAuxInfo( sym, CLASS_APPENDED_NAME );
    } else {
        name = FEName( sym );
    }
    CVPutStr( out, name );
    EndSym( out );
    BuffPatchSet( CVSyms, RtnPatch );
    BuffWrite( out, &ptr->offset );
    SymReloc( CVSyms, sym, 0 );
    BuffSkip( out, &ptr->proctype );
    buffEnd( out );
    DBLocFini( rtn->reeturn );
    DBLocFini( rtn->obj_loc );
    if( rtn->parms != NULL ){
        DumpParms( rtn->parms, &rtn->rtn_blk->locals );
    }
    DumpLocals( rtn->rtn_blk->locals );
}
Beispiel #9
0
static void    SymParm( cg_sym_handle sym, dw_loc_handle loc,
                                        dw_loc_handle entry ) {
/*******************************************************************/
//    fe_attr         attr;
    const char      *name;
//    dw_handle       obj;
    dbg_type        dbtype;

//    attr = FEAttr( sym );
    dbtype = FEDbgType( sym ); /* causes FEName side effects */
    name = FEName( sym );
//    obj = DWFormalParameter( Client, dbtype, loc, entry,  name, DW_DEFAULT_NONE );
    DWFormalParameter( Client, dbtype, loc, entry,  name, DW_DEFAULT_NONE );
}
Beispiel #10
0
extern  void    BEFini() {
//========================

    b   *bk;
    l   *lb;

    for( bk = BackList; bk != NULL; bk = bk->n ) {
        Action("UnFreed back handle for %s%n", FEName( bk->s ) );
    }
    if( BackList != NULL ) {
        CGError("UnFreed back handles!" );
    }
    for( lb = LblList; lb != NULL; lb = lb->n ) {
        VDefLabel( lb );
    }
    Action( "BEFini%n" );
    FiniDbgInfo();
    TypeFini();
    BECloseFiles();
}
Beispiel #11
0
static  bool    LblName( code_lbl *lbl ) {
/*****************************************/


    if( ValidLbl( lbl ) == FALSE ) return( FALSE );
    DumpLiteral( "L" );
    DumpPtr( lbl );
    if( lbl->lbl.sym == NULL ) return( TRUE );
    DumpLiteral( "(" );
    if( AskIfRTLabel( lbl ) ) {
        DumpXString( AskRTName( (rt_class)(pointer_int)lbl->lbl.sym ) );
    } else if( AskIfCommonLabel( lbl ) ) {
        DumpLiteral( "Common import => [" );
        DumpInt( (int)(pointer_int)lbl->lbl.sym );
        DumpLiteral( "] " );
    } else {
        DumpXString( FEName( lbl->lbl.sym ) );
    }
    DumpLiteral( ")" );
    return( TRUE );
}
Beispiel #12
0
static  bool    LblName( label_handle lbl ) {
/*****************************************/


    if( ValidLbl( lbl ) == false ) return( false );
    DumpChar( 'L' );
    DumpPtr( lbl );
    if( lbl->lbl.sym == NULL ) return( true );
    DumpChar( '(' );
    if( AskIfRTLabel( lbl ) ) {
        DumpXString( AskRTName( (rt_class)(pointer_int)lbl->lbl.sym ) );
    } else if( AskIfCommonLabel( lbl ) ) {
        DumpLiteral( "Common import => [" );
        DumpInt( (int)(pointer_int)lbl->lbl.sym );
        DumpLiteral( "] " );
    } else {
        DumpXString( FEName( lbl->lbl.sym ) );
    }
    DumpChar( ')' );
    return( true );
}
Beispiel #13
0
static  void DumpParms( dbg_local *parm, dbg_local **locals )
{
    dbg_local   *alt;
    cv_out      out[1];
    dbg_local   *next;

    for( ; parm != NULL; parm = next ) {    /* find and unlink from locals */
        next = parm->link;
        alt = UnLinkLoc( locals, parm->sym );
        if( alt != NULL ){
            dbg_type    tipe;
            type_length offset;
            name       *t;

            if( alt->kind == DBG_SYM_VAR ){
                tipe = FEDbgType( alt->sym );
                t = LocSymBP( alt->loc );
                if( t != NULL ){
                    offset = NewBase( t );
                    NewBuff( out, CVSyms );
                    FrameVar( out, FEName( alt->sym ), tipe, offset );
                    buffEnd( out );
                }else{
                    CVGenStatic( alt->sym, alt->loc, false );
                }
            }
            DBLocFini( alt->loc );
            CGFree( alt );
        }
        DBLocFini( parm->loc );
        CGFree( parm );
    }
//#if _TARGET & _TARG_AXP
#if 0 // seems like it screws CVPACK on intel
    NewBuff( out, CVSyms );
    StartSym(  out, SG_ENDARG );
    EndSym( out );
    buffEnd( out );
#endif
}
Beispiel #14
0
void    CVGenStatic( cg_sym_handle sym, dbg_loc loc, bool mem )
/*************************************************************/
{
    dbg_type    tipe;
    cv_out      out[1];
    fe_attr     attr;
    cs_gdata    *ptr;
    sg_index    kind;
    const char  *name;

    attr = FEAttr( sym );
    tipe = FEDbgType( sym );
    NewBuff( out, CVSyms );
    attr = FEAttr( sym );
    if( attr & FE_GLOBAL ) {
        kind = SG_GDATA;
    } else {
        kind = SG_LDATA;
    }
    ptr = StartSym(  out, kind );
    ptr->offset = 0;
    ptr->segment = 0;
    ptr->type = tipe;
    if( mem ){
        name = FEAuxInfo( sym, CLASS_APPENDED_NAME );
    } else {
        name = FEName( sym );
    }
    CVPutStr( out, name );
    EndSym( out );
    if( LocSimpStatic( loc ) == sym ) {
        BuffWrite( out, &ptr->offset );
        SymReloc( CVSyms, sym, 0 );
        BuffSkip( out, &ptr->type );
    } else {
        /*TODO:can't handle locs */
    }
    buffEnd( out );
}
Beispiel #15
0
char *DbgSymNameShort(          // GET Short SYMBOL NAME
    SYMBOL sym )                // - symbol
{
    return FEName( sym );
}
Beispiel #16
0
extern  void    DumpOperand( name *operand ) {
/********************************************/

    char        buffer[20];
    hw_reg_set  reg;
    name        *base;

    if( operand->n.class == N_INDEXED ) {
        if( operand->i.base != NULL ) {
            if( !( operand->i.index_flags & X_FAKE_BASE ) ) {
                if( operand->i.index_flags & X_LOW_ADDR_BASE ) {
                    DumpLiteral( "l^" );
                }
                DumpOperand( operand->i.base );
                if( operand->i.constant > 0 ) {
                    DumpChar( '+' );
                }
            }
        }
        if( operand->i.constant != 0 ) {
            DumpLong( operand->i.constant );
        }
        DumpChar( '[' );
        if( operand->i.index_flags & X_BASE ) {
            reg = operand->i.index->r.reg;
#if _TARGET & ( _TARG_IAPX86 | _TARG_80386 )
            if( HW_COvlap( reg, HW_SEGS ) ) {

                hw_reg_set tmp;

                tmp = reg;
                HW_COnlyOn( tmp, HW_SEGS );
                DumpRegName( tmp );
                DumpChar( ':' );
                HW_CTurnOff( reg, HW_SEGS );
            }
#endif
            if( operand->i.index_flags & X_HIGH_BASE ) {
                DumpRegName( HighReg( reg ) );
                DumpChar( '+' );
                DumpRegName( LowReg( reg ) );
            } else {
                DumpRegName( LowReg( reg ) );
                DumpChar( '+' );
                DumpRegName( HighReg( reg ) );
            }
        } else {
            DumpOperand( operand->i.index );
        }
        if( operand->i.scale != 0 ) {
            DumpChar( '*' );
            DumpInt( 1 << operand->i.scale );
        }
        if( operand->i.index_flags & ( X_ALIGNED_1 | X_ALIGNED_2 | X_ALIGNED_4 | X_ALIGNED_8 ) ) {
            DumpChar( '$' );
            DumpInt( FlagsToAlignment( operand->i.index_flags ) );
        }
        DumpChar( ']' );
        base = operand->i.base;
        if( base != NULL ) {
            if( operand->i.index_flags & X_FAKE_BASE ) {
                DumpChar( '{' );
                if( base->n.class == N_MEMORY ) {
                    DumpXString( AskName(base->v.symbol, base->m.memory_type) );
                } else if( base->n.class == N_TEMP ) {
                    if( _FrontEndTmp( base ) ) {
                        DumpXString( FEName( base->v.symbol ) );
                    } else {
                        DumpOperand( base );
                    }
                }
                DumpChar( '}' );
            }
        }