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 ); }
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 ); }
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 ); } }
static void GenRetSym( dbg_loc loc, dbg_type tipe ) { /*******************************************************************/ dw_loc_handle dw_loc; dw_loc = DBGLoc2DF( loc ); if( dw_loc != NULL ){ DWVariable( Client, tipe, dw_loc, 0, NULL, ".return", 0, DW_FLAG_ARTIFICIAL ); DWLocTrash( Client, dw_loc ); } }
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 ); }
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 ); }
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 }
void BIEnd( void ) { //=============== char fn[_MAX_PATH]; if( !_GenerateBrInfo() ) return; MakeName( SDFName( SrcName ), BrowseExtn, fn ); DWEndCompileUnit( cBIId ); DWLocTrash( cBIId, justJunk ); DWFini( cBIId ); CLIDump( fn ); CLIClear(); }
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 ); }
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 ); }