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 ); }
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(); }
dw_client DwarfInit( void ) /*************************/ { dw_client client; dw_init_info info; dw_cu_info cu; size_t incsize; char *inclist; char *fname; dw_sectnum sect; static const dw_funcs cli_funcs = { dw_reloc, dw_write, dw_seek, dw_tell, dw_alloc, dw_free }; for( sect = 0; sect < DW_DEBUG_MAX; ++sect ) { dw_sections[sect].bufcount = 0; dw_sections[sect].bufptrs = NULL; dw_sections[sect].offset = 0; dw_sections[sect].length = 0; } info.language = DWLANG_C; info.compiler_options = DW_CM_BROWSER; info.producer_name = DWARF_PRODUCER_ID " V1"; memcpy( &info.exception_handler, Environment, sizeof( jmp_buf ) ); info.funcs = cli_funcs; info.abbrev_sym = NULL; relocValues[DW_W_LOW_PC] = 0x0; relocValues[DW_W_HIGH_PC] = 0x1; relocValues[DW_W_UNIT_SIZE] = 0x1; client = DWInit( &info ); if( client == NULL ) { CFatal( "dwarf: error in DWInit()" ); } fname = FNameFullPath( FNames ); incsize = 0; inclist = NULL; #if 0 if( HFileList != NULL ) { char *p; incsize = strlen( HFileList ) + 1; inclist = CMemAlloc( incsize ); memcpy( inclist, HFileList, incsize ); // need to handle the case where there are multiple ';' in a row for( p = inclist; *p != '\0'; p++ ) { if( *p == ';' ) { *p = '\0'; } } if( inclist[incsize - 2] == '\0' ) { --incsize; } } #endif cu.source_filename = fname; cu.directory = ""; cu.flags = 1; cu.offset_size = TARGET_NEAR_POINTER; cu.segment_size = 0; cu.model = DW_MODEL_NONE; cu.inc_list = inclist; cu.inc_list_len = incsize; cu.dbg_pch = NULL; DWBeginCompileUnit( client, &cu ); CMemFree( inclist ); DWDeclFile( client, fname ); return( client ); }
extern void DFBegCCU( segment_id code, dw_sym_handle dbg_pch ) /****************************************************************/ // Call when codeseg hase been defined { dw_cu_info cu; back_handle bck; segment_id old; type_def *tipe_addr; if( _IsntModel( DBG_LOCALS | DBG_TYPES ) ) { return; } if( CcuDef ) { cu.source_filename = FEAuxInfo( NULL, SOURCE_NAME ); cu.directory = ""; cu.dbg_pch = dbg_pch; cu.inc_list = NULL; cu.inc_list_len = 0; old = SetOP( code ); #if _TARGET & ( _TARG_IAPX86 | _TARG_80386 ) if( _IsTargetModel( FLAT_MODEL ) ) { bck = MakeLabel(); OutLabel( bck->lbl ); Pc_Low = bck; Pc_High = MakeLabel(); // Emitting DW_AT_low_pc and DW_AT_high_pc is valid *only* if the // compilation unit's code is in a single contiguous block (see // DWARF 2, section 3.1). // I don't know how to find out at the time of this call if there's // only one code segment or not, hence these attributes are always // disabled. The low/high pc attribs should probably be handled by // the linker. cu.flags = false; cu.segment_size = 0; } else { bck = NULL; cu.flags = false; Pc_Low = NULL; Pc_High = NULL; cu.segment_size = 2; } #else bck = MakeLabel(); OutLabel( bck->lbl ); Pc_Low = bck; Pc_High = MakeLabel(); cu.flags = true; cu.segment_size = 0; #endif SetOP( old ); Comp_High = Pc_High; tipe_addr = TypeAddress( TY_NEAR_POINTER ); cu.offset_size = tipe_addr->length; switch( GetMemModel() ) { case 'h': cu.model = DW_MODEL_HUGE; break; case 'l': cu.model = DW_MODEL_LARGE; break; case 'f': cu.model = DW_MODEL_FLAT; break; case 's': cu.model = DW_MODEL_SMALL; break; default: cu.model = DW_MODEL_NONE; break; } DWBeginCompileUnit( Client, &cu ); if( cu.flags ) { BEFreeBack( bck ); } } else { CcuDef = true; } }
dw_client DwarfInit( void ) /********************/ { dw_client client; dw_init_info info; dw_cu_info cu; unsigned incsize; char *inclist; char *fname; static const dw_funcs cli_funcs = { dw_reloc, dw_write, dw_seek, dw_tell, dw_alloc, dw_free }; DWSectInit(); info.language = DWLANG_C; info.compiler_options = DW_CM_BROWSER; info.producer_name = "WATCOM C V10"; memcpy( &info.exception_handler, Environment, sizeof( jmp_buf ) ); info.funcs = cli_funcs; relocValues[ DW_W_LOW_PC ] = 0x0; relocValues[ DW_W_HIGH_PC ] = 0x1; relocValues[ DW_W_UNIT_SIZE ] = 0x1; client = DWInit( &info ); if( client == NULL ) { CFatal( "dwarf: error in DWInit()" ); } fname = FNameFullPath( FNames ); incsize = 0; inclist = NULL; #if 0 if( HFileList != NULL ) { char *p; incsize = strlen( HFileList ) + 1; inclist = CMemAlloc( incsize ); strcpy( inclist, HFileList ); // need to handle the case where there are multiple ';' in a row for( p = inclist; *p; p++ ) { if( *p == ';' ) *p = '\0'; } if( inclist[ incsize - 2 ] == '\0' ) --incsize; /* 27-may-94 */ } #endif cu.source_filename = fname; cu.directory = ""; cu.flags = 1; cu.offset_size = TARGET_NEAR_POINTER; cu.segment_size = 0; cu.model = DW_MODEL_NONE; cu.inc_list = inclist; cu.inc_list_len = incsize; cu.dbg_pch = NULL; DWBeginCompileUnit( client, &cu ); CMemFree( inclist ); DWDeclFile( client, fname ); return( client ); }
extern dw_client DwarfInit( void ) /********************************/ { dw_init_info info; dw_cu_info cu; char dir[_MAX_PATH2]; char fname[_MAX_PATH]; char * full_fname; int i; char * incbuf; char * inccurr; unsigned incsize; dw_client client; DwioInit(); for( i = 0 ; i < DW_DEBUG_MAX ; i++ ) { dw_sections[i].file = DwioCreateFile(); dw_sections[i].offset = 0; dw_sections[i].length = 0; } HFileListStart(); incsize = HFileListSize(); if( incsize != 0 ) { incbuf = CMemAlloc( incsize ); inccurr = incbuf; for(;;) { HFileListNext( inccurr ); if( *inccurr == '\0' ) break; inccurr = strend( inccurr ) + 1; } incsize = inccurr - incbuf; } info.language = DWLANG_CPP; info.compiler_options = DW_CM_BROWSER; info.producer_name = "WATCOM C++ V1"; memcpy( info.exception_handler, Environment, sizeof( jmp_buf ) ); info.funcs.reloc = &dw_reloc; info.funcs.write = &dw_write; info.funcs.seek = &dw_seek; info.funcs.tell = &dw_tell; info.funcs.alloc = &dw_alloc; info.funcs.free = &dw_free; client = DWInit( &info ); if( client == NULL ) { CFatal( "dwarf: error in DWInit()" ); } getcwd( dir, sizeof( dir ) ), full_fname = IoSuppFullPath( WholeFName, fname, sizeof( fname ) ); cu.source_filename = full_fname; cu.directory = dir; cu.flags = 1; cu.offset_size = TARGET_NEAR_POINTER; cu.segment_size = 0; cu.model = DW_MODEL_NONE; cu.inc_list = incbuf; cu.inc_list_len = incsize; cu.dbg_pch = 0; DWBeginCompileUnit( client, &cu ); if( incsize != 0 ) { CMemFree( incbuf ); } return( client ); }