Beispiel #1
0
static void TestString( void )
{
    dw_loc_handle               string_length;
    dw_handle                   string_hdl;
    dw_loc_handle               a_loc;
    dw_loc_id                   id;

    /* type InputBuffer = String( 512 ); -- I forget exact Ada syntax */
    DWDeclPos( Client, 50, 1 );
    DWString( Client, NULL, 512, "InputBuffer", 0, 0 );

    /* CHARACTER*(*) A */
    /* we'll pretend the length of the string is at -4[ebp] */
    DWDeclPos( Client, 50, 8 );
    id = DWLocInit( Client );
    DWLocOp( Client, id, DW_LOC_fbreg, -4 );
    string_length = DWLocFini( Client, id );
    string_hdl = DWString( Client, string_length, sizeof( uint_32 ), NULL, 0, 0 );
    DWLocTrash( Client, string_length );
    id = DWLocInit( Client );
    DWLocOp( Client, id, DW_LOC_fbreg, -8 );
    a_loc = DWLocFini( Client, id );
    DWDeclPos( Client, 50, 16 );
    DWVariable( Client, string_hdl, a_loc, 0, NULL, "A", 0, 0 );
    DWLocTrash( Client, a_loc );
}
Beispiel #2
0
static void TestStruct1( void )
{
    dw_handle           struct_div_t;
    dw_loc_handle       field_loc;
    dw_handle           union_hdl;
    dw_handle           struct_foo;
    dw_handle           ptr_to_foo;
    dw_loc_id           id;

    /* struct div_t */
    struct_div_t = DWStruct( Client, DW_ST_STRUCT );
    DWBeginStruct( Client, struct_div_t, 8, "div_t", 0, 0 );
    id = DWLocInit( Client );
    field_loc = DWLocFini( Client, id );
    DWAddField( Client, FundamentalTypes[DW_FT_SIGNED], field_loc, "quot", 0 );
    DWLocTrash( Client, field_loc );
    id = DWLocInit( Client );
    DWLocOp( Client, id, DW_LOC_plus_uconst, 4 );
    field_loc = DWLocFini( Client, id );
    DWAddField( Client, FundamentalTypes[DW_FT_SIGNED], field_loc, "rem", 0 );
    DWLocTrash( Client, field_loc );
    DWEndStruct( Client );

    /*
        struct foo {
            struct foo *next;
            int         type;
            union {
                int     a;
                float   b;
            } x;
        };
    */
    struct_foo = DWStruct( Client, DW_ST_STRUCT );
    DWBeginStruct( Client, struct_foo, 12, "foo", 0, 0 );
    ptr_to_foo = DWPointer( Client, struct_foo, DW_PTR_TYPE_DEFAULT );
    id = DWLocInit( Client );
    field_loc = DWLocFini( Client, id );
    DWAddField( Client, ptr_to_foo, field_loc, "next", 0 );
    DWLocTrash( Client, field_loc );
    id = DWLocInit( Client );
    DWLocOp( Client, id, DW_LOC_plus_uconst, 4 );
    field_loc = DWLocFini( Client, id );
    DWAddField( Client, FundamentalTypes[DW_FT_SIGNED], field_loc, "type", 0 );
    DWLocTrash( Client, field_loc );
    union_hdl = DWStruct( Client, DW_ST_UNION );
    DWBeginStruct( Client, union_hdl, 4, "wombat", 0, 0 );
    DWAddField( Client, FundamentalTypes[DW_FT_SIGNED], NULL, "a", 0 );
    DWAddField( Client, FundamentalTypes[DW_FT_FLOAT], NULL, "b", 0 );
    DWEndStruct( Client );
    id = DWLocInit( Client );
    DWLocOp( Client, id, DW_LOC_plus_uconst, 8 );
    field_loc = DWLocFini( Client, id );
    DWAddField( Client, union_hdl, field_loc, "x", 0 );
    DWLocTrash( Client, field_loc );
    DWEndStruct( Client );
}
Beispiel #3
0
void    BIInit( void ) {
//================

    dw_init_info        init_dwl;
    dw_cu_info          cu;

    BrInitialized = TRUE;
    if( !_GenerateBrInfo() ) return;
    init_dwl.language = DWLANG_FORTRAN;
    init_dwl.compiler_options = DW_CM_BROWSER | DW_CM_UPPER;
    init_dwl.producer_name = "WATCOM FORTRAN 77";
    if ( !setjmp( init_dwl.exception_handler ) ) {
        CLIInit( &(init_dwl.funcs), MEM_SECTION );
        cBIId = DWInit( &init_dwl );
        justJunk = DWLocFini( cBIId, DWLocInit( cBIId ) );
        cu.source_filename=BIMKFullPath( CurrFile->name );
        cu.directory=".";
        cu.flags = TRUE;
        cu.offset_size = ARCHITECTURE;
        cu.segment_size = 0;
        cu.model = DW_MODEL_NONE;
        cu.inc_list = NULL;
        cu.inc_list_len = 0;
        cu.dbg_pch = NULL;
        DWBeginCompileUnit( cBIId, &cu );
        BISetSrcFile();
    } else {
        BrInitialized = FALSE;
        Error( SM_BROWSE_ERROR );
    }
    BIInitBaseTypes();
}
Beispiel #4
0
static dw_loc_handle  RetLoc( uint_32 ret_offset ){
/**** make a loc for return address *************/
    dw_loc_id       locid;
    dw_loc_handle   df_loc;

    locid = DWLocInit( Client );
    DWLocOp( Client, locid, DW_LOC_fbreg, ret_offset );
    df_loc = DWLocFini( Client, locid );
    return( df_loc );
}
Beispiel #5
0
static  dw_loc_handle   SegLoc( cg_sym_handle sym ){
/************************************************/
    dw_loc_id       locid;
    dw_loc_handle   df_loc;

    locid = DWLocInit( Client );
    DWLocSegment( Client, locid, (dw_sym_handle)sym );
    df_loc = DWLocFini( Client, locid );
    return( df_loc );
}
Beispiel #6
0
static  void GenParmLoc( dbg_local *parm, dbg_local **locals )
{
    dbg_local      *alt;
    dw_loc_handle   dw_loc;
    dw_loc_handle   dw_entry;
    dw_loc_id       df_locid;

    df_locid = DWLocInit( Client );
    if( parm->loc->class == LOC_CONST_4 ){
        df_locid = StkLoc( parm->loc->u.val, df_locid );
    }else{
Beispiel #7
0
static void TestCommonBlock( void )
{
    dw_handle                   common_block;
    dw_loc_id                   id;
    dw_loc_handle               loc;

    id = DWLocInit( Client );
    DWLocStatic( Client, id, (dw_sym_handle)5 );
    loc = DWLocFini( Client, id );
    common_block = DWBeginCommonBlock( Client, loc, NULL, "DATA", 0 );
    DWLocTrash( Client, loc );
    id = DWLocInit( Client );
    DWLocOp( Client, id, DW_LOC_plus_uconst, 4 );
    loc = DWLocFini( Client, id );
    DWVariable( Client, FundamentalTypes[DW_FT_UNSIGNED_CHAR], loc, 0, NULL, "UNCLE", 0, 0 );
    DWLocTrash( Client, loc );
    DWEndCommonBlock( Client );

    DWIncludeCommonBlock( Client, common_block );
}
Beispiel #8
0
static void TestStruct3( void )
{
    dw_handle           class_1;
    dw_handle           class_2;
    dw_handle           class_3;
    dw_loc_handle       field_hdl;
    dw_loc_id           id;

    class_1 = DWStruct( Client, DW_ST_CLASS );
    class_2 = DWStruct( Client, DW_ST_CLASS );
    DWBeginStruct( Client, class_1, 4, "bugs", 0, 0 );
    DWAddFriend( Client, class_2 );
    /* static int a; */
    DWAddField( Client, FundamentalTypes[DW_FT_SIGNED], NULL, "a", DW_FLAG_PRIVATE );  // was DW_FLAG_STATIC ??

    /* private float b; */
    field_hdl = DWLocFini( Client, DWLocInit( Client ) );
    DWAddField( Client, FundamentalTypes[DW_FT_FLOAT], field_hdl, "b", DW_FLAG_PRIVATE );
    DWLocTrash( Client, field_hdl );
    DWEndStruct( Client );

    id = DWLocInit( Client );
    SymHandles[5] = 0x666UL;
    DWLocStatic( Client, id, (dw_sym_handle)5 );
    field_hdl = DWLocFini( Client, id );
    DWVariable( Client, FundamentalTypes[DW_FT_SIGNED], field_hdl, class_1, NULL, "a", 0, 0 );
    DWLocTrash( Client, field_hdl );

    DWBeginStruct( Client, class_2, 4, "beetles", 0, 0 );
    field_hdl = DWLocFini( Client, DWLocInit( Client ) );
    DWAddField( Client, FundamentalTypes[DW_FT_FLOAT], field_hdl, "b", DW_FLAG_PRIVATE );
    DWLocTrash( Client, field_hdl );
    DWEndStruct( Client );

    class_3 = DWStruct( Client, DW_ST_CLASS );
    DWBeginStruct( Client, class_3, 16, "ants", 0, 0 );
    field_hdl = DWLocFini( Client, DWLocInit( Client ) );
    DWAddInheritance( Client, class_2, field_hdl, 0 );
    DWLocTrash( Client, field_hdl );
    DWEndStruct( Client );
}
Beispiel #9
0
static dw_loc_handle  FrameLoc( void ){
/**** make a loc for frame  address *************/
    uint            dsp;
    dw_loc_id       locid;
    dw_loc_handle   df_loc;

    locid = DWLocInit( Client );
    dsp = DFDisplayReg();
    DWLocReg( Client, locid, dsp );
    df_loc = DWLocFini( Client, locid );
    return( df_loc );
}
Beispiel #10
0
static void TestArray( void )
{
#if 0
    dw_dim_info         dim_info;
    dw_vardim_info      vdim_info;
    dw_handle           array_hdl;
    dw_loc_handle       buf_loc;
    dw_loc_handle       buf2_loc;
    dw_loc_id           id;

    /* char buf[80]; */
    DWDeclPos( Client, 55, 79 );
    array_hdl = DWBeginArray( Client, 1 );
    dim_info.index_type = FundamentalTypes[DW_FT_UNSIGNED];
    dim_info.lo_data = 0;
    dim_info.hi_data = 79;
    DWArrayDimension( Client, &dim_info );
    DWEndArray( Client );
    SymHandles[3] = 0x1234bUL;
    id = DWLocInit( Client );
    DWLocStatic( Client, id, (dw_sym_handle)3 );
    buf_loc = DWLocFini( Client, id );
    DWDeclPos( Client, 55, 80 );
    DWVariable( Client, array_hdl, buf_loc, 0, NULL, "buf", 0, DW_FLAG_GLOBAL );
    DWLocTrash( Client, buf_loc );

    /* INTEGER*4 A(1:N) */
    DWDeclPos( Client, 55, 81 );
    array_hdl = DWBeginArray( Client, 1 );
    dim_info.index_type = FundamentalTypes[DW_FT_SIGNED];
    dim_info.lo_data = 1;
    id = DWLocInit( Client );   /* assume N is at -4[ebp] */
    DWLocOp( Client, id, DW_LOC_fbreg, -4 );
    buf2_loc = DWLocFini( Client, id );
    vdim_info.count_data = (dw_handle)buf2_loc;
    DWArrayDimension( Client, &dim_info );
    DWLocTrash( Client, buf2_loc );
    DWEndArray( Client );
#endif
}
Beispiel #11
0
void main( void ) {
    /*****************/

    static const dw_funcs cli_funcs = {
        CLIReloc,
        CLIWrite,
        CLISeek,
        CLITell,
        CLIAlloc,
        CLIFree
    };
    dw_init_info        info;
    dw_loc_handle       seg;
    dw_cu_info          cuinfo;

    info.language = DW_LANG_C89;
    info.compiler_options = DW_CM_BROWSER;
    info.producer_name = "testcli";
    if( setjmp( info.exception_handler ) == 0 ) {
        info.funcs = cli_funcs;

        RelocValues[ DW_W_LOW_PC ] = 0x135;
        RelocValues[ DW_W_HIGH_PC ] = 0x34561ul;
        RelocValues[ DW_W_UNIT_SIZE ] = 0x34561ul - 0x135;
        Client = DWInit( &info );
        if( Client == NULL ) {
            fputs( "error in DWInit()\n", stderr );
            exit( 1 );
        }
        seg = DWLocFini( Client, DWLocInit( Client ) );
        memset( &cuinfo, 0, sizeof( cuinfo ));
        cuinfo.source_filename = "foo.bar";
        cuinfo.directory = "somewhere\\over\\the\\rainbow";

        DWBeginCompileUnit( Client, &cuinfo );
        Test();
        DWEndCompileUnit( Client );
        cuinfo.source_filename = "empty.unit";
        cuinfo.directory = "in\\a\\land\\far\\far\\away";
        DWBeginCompileUnit( Client, &cuinfo );
        DWEndCompileUnit( Client );
        DWLocTrash( Client, seg );
        DWFini( Client );
        DumpSections();
    } else {
        fputs( "fatal error %d in dwarf library\n", stderr );
        exit( 1 );
    }
    exit( 0 );
}
Beispiel #12
0
static void TestStruct2( void )
{
    dw_loc_handle               field_loc;
    dw_loc_id                   id;

    /*
        struct date {
            unsigned short      day     : 5;
            unsigned short      month   : 4;
            unsigned short      year    : 7;
        };
    */
    DWBeginStruct( Client, DWStruct( Client, DW_ST_STRUCT ), 2, "date", 0, 0 );
    id = DWLocInit( Client );
    field_loc = DWLocFini( Client, id );
    DWAddBitField( Client, FundamentalTypes[DW_FT_UNSIGNED], field_loc, 0, 11, 5, "day", 0 );
    DWAddBitField( Client, FundamentalTypes[DW_FT_UNSIGNED], field_loc, 0, 7, 4, "month", 0 );
    DWAddBitField( Client, FundamentalTypes[DW_FT_UNSIGNED], field_loc, 0, 0, 7, "year", 0 );
    DWLocTrash( Client, field_loc );
    DWEndStruct( Client );
}