static search_result FindACue( cue_handle *ch ) { cue_find data; data.found_a_file = FALSE; data.best_line = 0; data.best_ch = ch; data.name = CurrGet.li.source.start; data.len = CurrGet.li.source.len; if( CurrGet.multi_module ) { if( data.len == 0 ) { Error( ERR_NONE, LIT( ERR_WANT_MODULE ) ); } if( WalkModList( CurrGet.li.mod, FindModCue, &data ) == WR_FAIL ) { return( SR_FAIL ); } } else { if( CurrGet.li.mod == NO_MOD ) CurrGet.li.mod = CodeAddrMod; if( FindModCue( CurrGet.li.mod, &data ) == WR_FAIL ) { return( SR_FAIL ); } } if( !data.found_a_file ) { Error( ERR_NONE, LIT( ERR_NO_SRC_FILE ), data.name, data.len ); } if( data.best_line == 0 ) return( SR_NONE ); if( data.best_line == CurrGet.li.name.len ) return( SR_EXACT ); return( SR_CLOSEST ); }
static mod_handle FindFileMod( const char *file ) { cue_mod d; d.found = false; d.file = file; WalkModList( NO_MOD, CheckOneMod, &d ); return( d.found ? d.mod : NO_MOD ); }
static void BasicType( unsigned basic_type ) { struct internal_mod mod_srch; struct imp_type_handle *internal; dip_type_info info; DIPHDL( type, th ); WalkModList( NO_MOD, FindInternalMod, &mod_srch ); internal = TypeCreate( th, mod_srch.mh ); info.kind = TI_KIND_EXTRACT( basic_type ); info.modifier = TI_MOD_EXTRACT( basic_type ); info.size = TI_SIZE_EXTRACT( basic_type ); FillInDefaults( &info ); internal->t.k = info.kind; internal->t.m = info.modifier; internal->t.s = info.size; internal->ri = NULL; PushType( th ); }
STATIC void loadImageInfo( image_info * curr_image ) /**************************************************/ { int name_len; int object_file; int sym_file; struct stat file_status; sym_file = -1; object_file = -1; curr_image->dip_handle = NO_MOD; if( curr_image->sym_deleted ) { } else if( curr_image->sym_name != NULL ) { sym_file = open( curr_image->sym_name, O_RDONLY|O_BINARY ); if( sym_file != -1 ) { curr_image->dip_handle = WPDipLoadInfo( sym_file, curr_image->sym_name, curr_image, sizeof(image_info), DIP_PRIOR_MIN, DIP_PRIOR_MAX ); } } else { name_len = strlen( curr_image->name ) + 1; memcpy( FNameBuff, curr_image->name, name_len ); ReplaceExt( FNameBuff, ".sym" ); name_len = strlen( FNameBuff ) + 1; curr_image->sym_name = ProfAlloc( name_len ); memcpy( curr_image->sym_name, FNameBuff, name_len ); sym_file = open( curr_image->sym_name, O_RDONLY|O_BINARY ); if( sym_file != -1 ) { curr_image->dip_handle = WPDipLoadInfo( sym_file, curr_image->sym_name, curr_image, sizeof(image_info), DIP_PRIOR_MIN, DIP_PRIOR_MAX ); } if( curr_image->dip_handle == NO_MOD ) { ProfFree( curr_image->sym_name ); curr_image->sym_name = NULL; } } object_file = open( curr_image->name, O_RDONLY|O_BINARY ); if( object_file == -1 ) { curr_image->exe_not_found = true; if( curr_image->main_load ) { ErrorMsg( LIT( Exe_Not_Found ), curr_image->name ); } } else if( curr_image->time_stamp == 0 ) { /* If sample timestamp is 0, the sampler couldn't figure out the right value. Assume it's OK. */ } else if( fstat( object_file, &file_status ) == 0 ) { /* QNX creation dates and time stamps tend to be 1 */ /* unit different, so do not test for equality */ if( file_status.st_mtime - curr_image->time_stamp > 1 ) { curr_image->exe_changed = true; if( curr_image->main_load ) { ErrorMsg( LIT( Exe_Has_Changed ), curr_image->name ); } } } if( curr_image->dip_handle == NO_MOD && !curr_image->sym_deleted && object_file != -1 ) { curr_image->dip_handle = WPDipLoadInfo( object_file, curr_image->name, curr_image, sizeof(image_info), DIP_PRIOR_MIN, DIP_PRIOR_MAX ); } if( curr_image->dip_handle == NO_MOD ) { if( sym_file != -1 ) { close( sym_file ); } if( object_file != -1 ) { close( object_file ); } } initModuleInfo( curr_image ); if( curr_image->dip_handle != NO_MOD ) { WalkModList( curr_image->dip_handle, &loadModuleInfo, curr_image ); } }
/** * Dumps the loaded debug info. * * @returns 0 on success, exit code on failure. * @param file The filename. * @param mh The DIP/DIG module handle. * @param proc The process which the module is loaded into. */ static int DumpIt( const char *file, mod_handle mh, process_info *proc ) { walk_result walkres; struct stat s; char buff[1024]; unsigned len; int i; /* * Module. */ printf( " Module\n" "========\n" "\n" "name = %s\n", file); if( !stat( file, &s ) ) { struct tm *ts; char buff[80]; ts = gmtime( &s.st_mtime ); strftime( buff, sizeof( buff ), "%Y-%m-%d %H:%M:%S UCT", ts ); printf( "timestamp = %s\n", buff ); } printf( "DIP = %s\n", ImageDIP( mh ) ); #if 0 /* crashes codeview, nothing on dwarf. */ buff[0] = '\0'; len = ModName( mh, buff, sizeof( buff ) ); if( len ) { printf( "module name = %s\n", buff ); } #else len = len; (void)buff; #endif printf( "\n" "\n" ); /* * Compiled units? */ if( 1 ) { printf( " Compiled Units\n" "================\n" "\n" "index seg:offset info lang name\n" "---------------------------------------\n"); i = 0; walkres = WalkModList( mh, ModCallback, &i ); printf( "\n" "\n" ); } #if 0 /* * Types. * This crashes DWARF, and with codeview it'll only work on one special module. */ if( 1 ) { printf( " Types\n" "=======\n" "\n" "index seg:offset info lang name\n" "---------------------------------------\n"); i = 0; walkres = WalkTypeList( /*mh*/ IMH_GBL, TypeCallback, &i ); printf( "\n" "\n" ); } #endif /* * Global (?) Symbols. */ if( 1 ) { printf( " Global Symbols\n" "================\n" "\n" "index kind seg:offset info lng name\n" "------------------------------------------\n"); i = 0; walkres = WalkSymList( SS_MODULE, &mh, SymCallback, &i ); printf( "\n" "\n" ); } /* * Iterate compiled modules and dump their line numbers and symbols. */ if( 1 ) { i = 0; walkres = WalkModList( mh, Mod2Callback, &i ); } printf("\n"); return( 0 ); }