STATIC walk_result loadModuleInfo( mod_handle mh, void *_curr_image ) /*******************************************************************/ { image_info *curr_image = _curr_image; mod_info *new_mod; int mod_count; int name_len; name_len = ModName( mh, NULL, 0 ); new_mod = ProfCAlloc( sizeof( mod_info ) + name_len ); ModName( mh, new_mod->name, name_len + 1 ); new_mod->mh = mh; mod_count = curr_image->mod_count; curr_image->mod_count++; curr_image->module = ProfRealloc( curr_image->module, curr_image->mod_count * sizeof( pointer ) ); curr_image->module[mod_count] = new_mod; initFileInfo( new_mod ); WalkSymList( SS_MODULE, &mh, &loadRoutineInfo, new_mod ); return( WR_CONTINUE ); }
/** * 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 ); }
/** * WalkModList callback, pass 2. * * @returns WR_CONTINUE * @param mh The module. * @param ignored Pointer to the current module index. */ static walk_result Mod2Callback( mod_handle mh, void *_idx ) { walk_result walkres; int i; int need_trailing_newline = 0; int *idx = (int *)_idx; ++*idx; /* * Linenumbers. */ if( 1 && ModHasInfo( mh, HK_CUE ) == DS_OK ) { printf( "%03d Line Numbers\n" "-----------------\n" "\n", *idx ); i = 0; walkres = WalkFileList( mh, File2Callback, &i ); printf( "\n" "\n" ); need_trailing_newline = 1; } /* * Types */ if( 1 && ModHasInfo( mh, HK_TYPE ) == DS_OK ) { printf( " %03d Types\n" "-----------\n" "\n" "index seg:offset info lang name\n" "---------------------------------------\n", *idx); i = 0; walkres = WalkTypeList( mh, Type2Callback, &i ); printf( "\n" "\n" ); need_trailing_newline = 1; } /* * Symbols. */ if( 1 && ModHasInfo( mh, HK_SYM ) == DS_OK ) { printf( "%03d Symbols\n" "------------\n" "\n", *idx ); i = 0; walkres = WalkSymList( SS_MODULE, &mh, Sym2Callback, &i ); printf( "\n" "\n" ); need_trailing_newline = 1; } if( need_trailing_newline ) { printf( "\n" ); } return( WR_CONTINUE ); }