wpsamp.c
来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 1,543 行 · 第 1/4 页
C
1,543 行
return( B_TRUE );
}
STATIC bint sfileGetLine( a_window *wnd, int row )
/************************************************/
{
sio_data *curr_sio;
file_info *curr_file;
curr_sio = WndExtra( wnd );
sampNewRow = row != curr_sio->curr_proc_row;
if( sampNewRow ) {
curr_sio->curr_proc_row = row;
curr_file = SFileGetFile( wnd, row );
if( curr_file == NULL ) {
return( B_FALSE );
}
dispHighLight = B_FALSE;
dispName = curr_file->name;
dispCount = curr_file->agg_count;
localTicks = curr_sio->curr_mod->agg_count;
maxTime = curr_sio->curr_mod->max_time;
barMaxTime = curr_sio->curr_mod->bar_max;
absGraphBar = curr_sio->curr_mod->abs_bar;
relGraphBar = curr_sio->curr_mod->rel_bar;
}
return( B_TRUE );
}
STATIC bint srtnGetLine( a_window *wnd, int row )
/***********************************************/
{
sio_data *curr_sio;
rtn_info *curr_rtn;
curr_sio = WndExtra( wnd );
sampNewRow = row != curr_sio->curr_proc_row;
if( sampNewRow ) {
curr_sio->curr_proc_row = row;
curr_rtn = SRtnGetRoutine( wnd, row );
if( curr_rtn == NULL ) {
return( B_FALSE );
}
dispHighLight = B_FALSE;
dispName = curr_rtn->name;
dispCount = curr_rtn->tick_count;
localTicks = curr_sio->curr_file->agg_count;
maxTime = curr_sio->curr_file->max_time;
barMaxTime = curr_sio->curr_file->bar_max;
absGraphBar = curr_sio->curr_file->abs_bar;
relGraphBar = curr_sio->curr_file->rel_bar;
}
return( B_TRUE );
}
STATIC bint ssrcGetLine( a_window *wnd, int row )
/***********************************************/
{
sio_data *curr_sio;
wp_srcfile *wp_src;
wp_srcline *lines;
int index;
int adjusted_row;
curr_sio = WndExtra( wnd );
if( curr_sio->src_file == NULL ) {
return( B_FALSE );
}
adjusted_row = row + 1;
sampNewRow = row != curr_sio->curr_proc_row;
if( sampNewRow ) {
curr_sio->curr_proc_row = row;
dispName = WPSourceGetLine( wnd, adjusted_row );
if( dispName == NULL ) {
return( B_FALSE );
}
dispHighLight = B_FALSE;
wp_src = curr_sio->src_file;
lines = wp_src->src_lines;
dispCount = 0;
index = 0;
while( index < wp_src->wp_line_count ) {
if( adjusted_row == lines[index].line ) {
dispCount = lines[index].tick_count;
break;
}
index++;
}
localTicks = curr_sio->curr_file->agg_count;
maxTime = wp_src->max_time;
barMaxTime = curr_sio->asm_src_info.bar_max;
absGraphBar = curr_sio->asm_src_info.abs_bar;
relGraphBar = curr_sio->asm_src_info.rel_bar;
}
return( B_TRUE );
}
STATIC bint sasmGetLine( a_window *wnd, int row )
/***********************************************/
{
sio_data *curr_sio;
wp_asmfile *wpasm_file;
wp_asmline *asm_line;
int asm_group;
int asm_row;
curr_sio = WndExtra( wnd );
if( curr_sio->asm_file == NULL ) {
return( B_FALSE );
}
sampNewRow = row != curr_sio->curr_proc_row;
if( sampNewRow ) {
curr_sio->curr_proc_row = row;
dispName = WPAsmGetLine( wnd, row );
if( dispName == NULL ) {
return( B_FALSE );
}
wpasm_file = curr_sio->asm_file;
asm_line = WPGetAsmLoc( wpasm_file, row, &asm_group, &asm_row );
dispHighLight = asm_line->source_line;
if( dispHighLight ) {
dispCount = 0;
} else {
dispCount = asm_line->u.asm_line.tick_count;
}
localTicks = curr_sio->curr_mod->agg_count;
maxTime = wpasm_file->max_time;
barMaxTime = curr_sio->asm_src_info.bar_max;
absGraphBar = curr_sio->asm_src_info.abs_bar;
relGraphBar = curr_sio->asm_src_info.rel_bar;
} else if( dispName == NULL ) {
return( B_FALSE );
}
return( B_TRUE );
}
STATIC bint sampleSetLine( a_window *wnd, int row, int piece,
wnd_line_piece *line )
/************************************************************/
{
sio_data *curr_sio;
clicks_t bar_range;
gui_ord catcher_extent;
gui_ord slacker;
int wnd_rows;
if( piece >= PIECE_LAST ) {
return( B_FALSE );
}
curr_sio = WndExtra( wnd );
wnd_rows = SampleNumRows( wnd );
if( row > wnd_rows-1 ) {
Ring();
return( B_FALSE );
}
if( sampNewRow ) {
catcher_extent = BAR_TAIL_POINT - (WndMaxCharX( wnd ) / 2);
catcher_extent = WPPixelTruncWidth( catcher_extent );
bar_range = catcher_extent * dispCount;
if( curr_sio->total_samples == 0 ) {
curr_sio->total_samples = 1;
}
if( localTicks == 0 ) {
localTicks = 1;
}
if( maxTime == 0 ) {
maxTime = 1;
}
slacker = WPPixelWidth( wnd );
if( !absGraphBar ) {
bar2Extent = 0;
} else {
if( !barMaxTime || relGraphBar ) {
bar2Extent = bar_range / curr_sio->total_samples;
} else {
bar2Extent = bar_range / maxTime;
}
if( bar2Extent < slacker && bar_range != 0 ) {
bar2Extent = slacker;
}
}
if( !relGraphBar ) {
barExtent = 0;
} else {
if( barMaxTime ) {
barExtent = bar_range / maxTime;
} else {
barExtent = bar_range / localTicks;
}
if( barExtent < slacker && bar_range != 0 ) {
barExtent = slacker;
}
}
barExtent = WPPixelTruncWidth( barExtent );
bar2Extent = WPPixelTruncWidth( bar2Extent );
if( barExtent < bar2Extent ) {
barExtent = bar2Extent;
}
}
if( piece == PIECE_MOUSE_CATCHER ) {
line->indent = 0;
line->text = LIT( Empty_Str );
line->extent = catcher_extent - barExtent;
line->tabstop = B_FALSE;
line->master_tabstop = B_TRUE;
} else if( piece == PIECE_BAR ) {
line->extent = barExtent;
line->indent = BAR_TAIL_POINT - barExtent;
if( WPPixelTruncWidth( WndMaxCharX( wnd ) / 2 ) == 0 ) {
line->indent -= WndMaxCharX( wnd ) / 2;
}
if( barExtent || bar2Extent ) {
barData.bar_style = GUI_BAR_SHADOW;
barData.bar_colour = WPA_REL_BAR;
barData.bar_colour2 = WPA_ABS_BAR;
barData.bar_size2 = bar2Extent;
barData.bar_group = B_TRUE;
barData.bar_selected = B_FALSE;
line->draw_bar = B_TRUE;
line->text = (char *)&barData;
} else {
line->text = LIT( Empty_Str );
}
line->tabstop = B_FALSE;
line->master_tabstop = B_TRUE;
} else if( piece == PIECE_SEPARATOR ) {
line->indent = SEPARATOR_POINT;
line->vertical_line = B_TRUE;
line->text = LIT( Empty_Str );
line->attr = WPA_PLAIN;
line->tabstop = B_FALSE;
line->master_tabstop = B_TRUE;
} else if( piece == PIECE_DETAIL_NAME ) {
line->indent = SEPARATOR_POINT + WndMaxCharX( wnd );
line->text = dispName;
if( dispHighLight ) {
line->attr = WPA_STANDOUT;
} else {
line->attr = WPA_PLAIN;
}
line->tabstop = B_TRUE;
line->master_tabstop = B_TRUE;
} else {
return( B_FALSE );
}
return( B_TRUE );
}
STATIC void findRtnFromRow( sio_data *curr_sio, int row )
/*******************************************************/
{
file_info *curr_file;
rtn_info *curr_rtn;
cue_handle *ch;
sym_handle *sh;
int index;
mod_handle mh;
address addr;
index = 0;
ch = __alloca( DIPHandleSize( HK_CUE ) );
curr_file = curr_sio->curr_file;
mh = curr_sio->curr_mod->mh;
if( LineCue( mh, curr_sio->curr_file->fid, row, 0, ch ) == SR_NONE ) {
if( LineCue( mh, curr_sio->curr_file->fid, 0, 0, ch ) == SR_NONE ) return;
}
sh = __alloca( DIPHandleSize( HK_SYM ) );
addr = CueAddr( ch );
if( AddrSym( mh, addr, sh ) == SR_NONE ) return;
while( index < curr_file->rtn_count ) {
curr_rtn = curr_file->routine[index];
if( curr_rtn->sh != NULL
&& SymCmp( curr_rtn->sh, sh ) == 0 ) {
curr_sio->curr_rtn = curr_rtn;
break;
}
index++;
}
}
STATIC void sampFixDirtyCurr( a_window *wnd )
/*******************************************/
{
sio_data *curr_sio;
wp_srcfile *src_file;
rtn_info *curr_rtn;
int src_line;
int row;
int piece;
curr_sio = WndExtra( wnd );
WndGetCurrent( wnd, &row, &piece );
if( row == WND_NO_ROW ) return;
if( curr_sio->level_open == LEVEL_SAMPLE ) {
if( !simageGetLine( wnd, row ) ) return;
} else if( curr_sio->level_open == LEVEL_IMAGE ) {
if( !smodGetLine( wnd, row ) ) return;
} else if( curr_sio->level_open == LEVEL_MODULE ) {
if( !sfileGetLine( wnd, row ) ) return;
} else if( curr_sio->level_open == LEVEL_FILE ) {
if( !srtnGetLine( wnd, row ) ) return;
} else {
if( curr_sio->level_open == LEVEL_ROUTINE ) {
if( !ssrcGetLine( wnd, row ) ) return;
} else {
if( !sasmGetLine( wnd, row ) ) return;
}
src_line = row + 1;
if( curr_sio->level_open == LEVEL_SOURCE ) {
src_line = WPAsmFindSrcLine( curr_sio, src_line );
}
curr_rtn = curr_sio->curr_rtn;
findRtnFromRow( curr_sio, src_line );
if( curr_rtn != curr_sio->curr_rtn ) {
WndRowDirty( wnd, LEVEL_ROUTINE-STATUS_ROW-1+WndTop(wnd) );
}
src_file = curr_sio->src_file;
if( src_file != NULL ) {
src_file->samp_line = src_line;
}
}
curr_sio->curr_proc_row = -WND_MAX_ROW;
if( row != curr_sio->curr_display_row ) {
curr_sio->curr_display_row = row;
if( curr_sio->total_samples == 0 || localTicks == 0 ) {
curr_sio->abs_count = 0;
curr_sio->rel_count = 0;
} else {
curr_sio->abs_count = (dispCount*1000) / curr_sio->total_samples;
curr_sio->rel_count = (dispCount*1000) / localTicks;
}
curr_sio->abs_on_screen = absGraphBar;
curr_sio->rel_on_screen = relGraphBar;
if( dispCount > 0 ) {
if( curr_sio->rel_count == 0 ) {
curr_sio->rel_count = 1;
}
if( curr_sio->abs_count == 0 ) {
curr_sio->abs_count = 1;
}
}
WndRowDirty( wnd, -2+WndTop(wnd) );
}
}
STATIC int simageDetailLine( a_window *wnd, int row, bint multi_level )
/*********************************************************************/
{
sio_data *curr_sio;
image_info *image;
curr_sio = WndExtra( wnd );
image = SImageGetImage( wnd, row );
if( image == NULL ) {
if( !multi_level ) {
Ring();
}
return( row );
}
if( image->exe_not_found ) {
if( !multi_level ) {
ErrorMsg( LIT( Exe_Not_Found ), image->name );
}
return( row );
}
if( image->dip_handle == NO_MOD ) {
if( !multi_level ) {
ErrorMsg( LIT( No_Symbol_Info ), image->name );
}
return( row );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?