STATIC void resolveImageSamples( void ) /*************************************/ { image_info *curr_image; massgd_sample_addr **massgd_data; mod_info *curr_mod; file_info *curr_file; rtn_info *curr_rtn; address *addr; sample_index_t tick_index; mod_handle mh; sym_handle *sh; long int count; int count2; int count3; int count4; int index; int index2; sh = alloca( DIPHandleSize( HK_SYM ) ); massgd_data = CurrSIOData->massaged_sample; tick_index = 1; index = 0; index2 = 0; for( count = 0; count < CurrSIOData->number_massaged; ++count, ++index2 ) { if( index2 > MAX_MASSGD_BUCKET_INDEX ) { ++index; index2 = 0; } addr = massgd_data[index][index2].raw; if( AddrMod( *addr, &mh ) == SR_NONE ) { curr_image = AddrImage( addr ); if( curr_image == NULL ) { curr_image = CurrSIOData->images[0]; } curr_mod = curr_image->module[0]; curr_rtn = curr_mod->mod_file[0]->routine[0]; } else { curr_image = *(image_info **)ImageExtra( mh ); curr_mod = findCurrMod( curr_image, mh ); if( AddrSym( mh, *addr, sh ) == SR_NONE ) { curr_rtn = curr_mod->mod_file[0]->routine[0]; } else { curr_rtn = findCurrRtn( curr_mod, sh ); /**/ myassert( curr_rtn != NULL ); } } if( curr_rtn != NULL ) { curr_rtn->tick_count += massgd_data[index][index2].hits; if( curr_rtn->first_tick_index == 0 ) { curr_rtn->first_tick_index = tick_index; if( curr_mod->first_tick_index == 0 || curr_mod->first_tick_index > tick_index ) { curr_mod->first_tick_index = tick_index; } } curr_rtn->last_tick_index = tick_index; } tick_index++; } CurrSIOData->max_time = 0; count = 0; while( count < CurrSIOData->image_count ) { curr_image = CurrSIOData->images[count]; curr_image->max_time = 0; count2 = 0; while( count2 < curr_image->mod_count ) { curr_mod = curr_image->module[count2]; curr_mod->max_time = 0; count3 = 0; while( count3 < curr_mod->file_count ) { curr_file = curr_mod->mod_file[count3]; curr_rtn = curr_file->routine[0]; if( curr_rtn->unknown_routine && curr_rtn->tick_count == 0 ) { curr_rtn->ignore_unknown_rtn = true; curr_file->ignore_unknown_rtn = true; } curr_file->max_time = 0; count4 = 0; while( count4 < curr_file->rtn_count ) { curr_rtn = curr_file->routine[count4]; curr_file->agg_count += curr_rtn->tick_count; if( curr_rtn->tick_count > curr_file->max_time ) { curr_file->max_time = curr_rtn->tick_count; } count4++; } curr_mod->agg_count += curr_file->agg_count; if( curr_file->agg_count > curr_mod->max_time ) { curr_mod->max_time = curr_file->agg_count; } count3++; } curr_file = curr_mod->mod_file[0]; if( curr_file->unknown_file && curr_file->agg_count == 0 ) { curr_file->ignore_unknown_file = true; curr_mod->ignore_unknown_file = true; } curr_image->agg_count += curr_mod->agg_count; if( curr_mod->agg_count > curr_image->max_time ) { curr_image->max_time = curr_mod->agg_count; } count2++; } curr_mod = curr_image->module[0]; if( curr_mod->unknown_module && curr_mod->agg_count == 0 ) { curr_mod->ignore_unknown_mod = true; curr_image->ignore_unknown_mod = true; } if( curr_image->agg_count > CurrSIOData->max_time ) { CurrSIOData->max_time = curr_image->agg_count; } count++; } curr_image = CurrSIOData->images[0]; if( curr_image->unknown_image && curr_image->agg_count == 0 ) { curr_image->ignore_unknown_image = true; } }
wp_asmfile *WPAsmOpen( sio_data * curr_sio, int src_row, bool quiet ) /*******************************************************************/ { wp_asmfile * wpasm_file; cue_handle * ch; cue_handle * ch2; mod_info * curr_mod; file_info * curr_file; massgd_sample_addr * samp_data; wp_asmline * asm_line; mod_handle mh; file_handle fh; address addr; cue_fileid fid; search_result cue_find; int rows; int asm_group; int asm_row; int file_index; int addr_cmp; clicks_t addr_tick_index; quiet=quiet; ch = alloca( DIPHandleSize( HK_CUE ) ); ch2 = alloca( DIPHandleSize( HK_CUE ) ); curr_file = curr_sio->curr_file; curr_mod = curr_sio->curr_mod; if( curr_file->fid == 0 || LineCue( curr_mod->mh, curr_sio->curr_file->fid, src_row, 0, ch2 ) == SR_NONE ) { ch2 = NULL; } fh = ExeOpen( curr_sio->curr_image->name ); if( fh == -1 ) { ErrorMsg( LIT( Exe_Not_Found ), curr_sio->curr_image->name ); return( NULL ); } wpasm_file = ProfCAlloc( sizeof(wp_asmfile) ); curr_sio->asm_file = wpasm_file; wpasm_file->asm_buff = ProfAlloc( MAX_ASM_BUFF_LEN ); wpasm_file->asm_buff_len = MAX_ASM_BUFF_LEN; SetNumBytes( 0 ); SetExeFile( fh, false ); wpasm_file->fh = fh; addr = ModAddr( curr_mod->mh ); SetExeOffset( addr ); wpasm_file->max_time = 0; addr_tick_index = curr_mod->first_tick_index - 1; samp_data = WPGetMassgdSampData( curr_sio, addr_tick_index++ ); wpasm_file->asm_data = ProfAlloc( sizeof(wp_asm_groups) ); wpasm_file->asm_data[0].asm_lines = ProfAlloc( MAX_ASM_LINE_SIZE ); wpasm_file->asm_groups = 0; rows = 0; for( ;; ) { mh = curr_mod->mh; if( EndOfSegment() || AddrMod( addr, &mh ) == SR_NONE || mh != curr_mod->mh ) break; cue_find = (AddrCue( curr_mod->mh, addr, ch ) == SR_EXACT); if( ch2 != NULL && CueCmp( ch, ch2 ) == 0 ) { wpasm_file->entry_line = rows; ch2 = NULL; } asm_line = WPGetAsmLoc( wpasm_file, rows, &asm_group, &asm_row ); if( cue_find ) { asm_line->source_line = true; asm_line->u.src.line = CueLine( ch ); asm_line->u.src.src_file = NULL; if( !curr_file->unknown_file ) { fid = CueFileId( ch ); file_index = 0; while( file_index < curr_mod->file_count ) { curr_file = curr_mod->mod_file[file_index]; if( curr_file->fid == fid ) { asm_line->u.src.src_file = FOpenSource( curr_file->name, mh, fid ); break; } file_index++; } } rows++; asm_line = WPGetAsmLoc( wpasm_file, rows, &asm_group, &asm_row ); } asm_line = &wpasm_file->asm_data[asm_group].asm_lines[asm_row]; asm_line->source_line = false; asm_line->u.asm_line.addr = addr; asm_line->u.asm_line.tick_count = 0; for( ;; ) { if( samp_data == NULL ) break; addr_cmp = AddrCmp( &addr, samp_data->raw ); if( addr_cmp < 0 ) break; if( addr_cmp == 0 ) { asm_line->u.asm_line.tick_count = samp_data->hits; if( asm_line->u.asm_line.tick_count > wpasm_file->max_time ) { wpasm_file->max_time = asm_line->u.asm_line.tick_count; } } samp_data = WPGetMassgdSampData( curr_sio, addr_tick_index++ ); } rows++; CodeAdvance( &addr ); } WPGetAsmLoc( wpasm_file, rows, &asm_group, &asm_row ); wpasm_file->asm_data[asm_group].asm_lines = ProfRealloc( wpasm_file->asm_data[asm_group].asm_lines, sizeof(wp_asmline)*(asm_row+1) ); wpasm_file->asm_rows = rows; return( wpasm_file ); }