static void cov_state_on(char *arg) { if (cov_state == COV_START) { //run this function first time cov_init(prof_start, prof_end); register_callback(cov_readmem_callback, Mem_read_callback); register_callback(cov_writemem_callback, Mem_write_callback); register_callback(cov_execmem_callback, Step_callback); }else printf("code coverage state: on\n"); cov_state = COV_ON; }
int main(int _argc,const char *_argv[]){ cov_state cvs[NUM_PROCS]; #if COMPUTE_NATHAN trans_ctx ctx[NUM_PROCS]; double r[SUPPORT*SUPPORT]; /* maximum for 2d */ #else trans_ctx *ctx=NULL; #endif int i; #if BLOCKSIZE==4 f=OD_FILTER_PARAMS4; #elif BLOCKSIZE==8 f=OD_FILTER_PARAMS8; #elif BLOCKSIZE==16 f=OD_FILTER_PARAMS16; #else # error "Need filter params for this block size." #endif for(i=0;i<NUM_PROCS;i++){ #if USE_2D cov_init(&cvs[i],SUPPORT*SUPPORT); #else cov_init(&cvs[i],SUPPORT); #endif } #if COMPUTE_NATHAN for(i=0;i<NUM_PROCS;i++){ #if USE_2D trans_data_init(&ctx[i].td,SUPPORT*SUPPORT); #else trans_data_init(&ctx[i].td,SUPPORT); #endif } #endif OD_OMP_SET_THREADS(NUM_PROCS); process_files(ctx,cvs,_argc,_argv); for(i=1;i<NUM_PROCS;i++) cov_combine(&cvs[0],&cvs[i]); cov_compute(&cvs[0]); #if COMPUTE_NATHAN for(i=1;i<NUM_PROCS;i++) trans_data_combine(&ctx[0].td,&ctx[i].td); trans_data_normalize(&ctx[0].td); #endif #if PRINT_COV { int i,j; fprintf(stdout,"collapsed_cov=\n"); for(j=0;j<cvs[0].sz/SUPPORT;j++){ for(i=0;i<SUPPORT;i++){ fprintf(stdout,"%s %- 12.6G",i>0?",":"",cvs[0].cov[j*SUPPORT+i]); } fprintf(stdout,"\n"); } } #endif #if USE_2D #if COMPUTE_NATHAN fprintf(stdout,"original cg=%-24.16G\n", cg_2d((double(*)[SUPPORT][SUPPORT][SUPPORT])ctx[0].td.cov,f)); trans_data_collapse(&ctx[0].td,SUPPORT,r); fprintf(stdout,"collapse cg=%-24.16G\n", cg_2d_collapsed((double(*)[SUPPORT])r,f)); #endif fprintf(stdout,"monty cg=%-24.16G\n", cg_2d_collapsed((double(*)[SUPPORT])cvs[0].cov,f)); #else #if COMPUTE_NATHAN fprintf(stdout,"original cg=%-24.16G\n", cg_1d((double (*)[SUPPORT])ctx[0].td.cov,f)); trans_data_collapse(&ctx[0].td,1,r); fprintf(stdout,"collapse cg=%-24.16G\n", cg_1d_collapsed(r,f)); #endif fprintf(stdout,"monty cg=%-24.16G\n", cg_1d_collapsed(cvs[0].cov,f)); #endif for(i=0;i<NUM_PROCS;i++) cov_clear(&cvs[i]); #if COMPUTE_NATHAN for(i=0;i<NUM_PROCS;i++) trans_data_clear(&ctx[i].td); #endif return EXIT_SUCCESS; }
/** * Initialize all the gloval variable */ static int init () { static int done = 0; int ret = -1; if (!done) { done = 1; /*some option should init before read config. e.g. uart option. */ #if 0 /*move to common/ctrl related function */ initialize_all_devices (); initialize_all_arch (); /* parse skyeye.conf to set skyeye_config */ skyeye_option_init (&skyeye_config); if((ret = skyeye_read_config()) < 0) return ret; #endif #if 0 /* we should check if some members of skyeye_config is initialized */ if(!skyeye_config.arch){ fprintf(stderr, "arch is not initialization or you have not provide arch option in skyeye.conf.\n"); skyeye_exit(-1); } if(!skyeye_config.mach){ fprintf(stderr, "mach is not initialization or you have not provide mach option in skyeye.conf.\n"); skyeye_exit(-1); } #endif #if 0 /*move to module loading stage */ /* initialize register type for gdb server */ if((ret = init_register_type()) < 0) return ret;/* Failed to initialize register type */ #endif #if 0 arch_instance = (generic_arch_t *) malloc (sizeof (generic_arch_t)); if (!arch_instance) { printf ("malloc error!\n"); return -1; } arch_instance->init = skyeye_config.arch->init; arch_instance->reset = skyeye_config.arch->reset; arch_instance->step_once = skyeye_config.arch->step_once; arch_instance->set_pc = skyeye_config.arch->set_pc; arch_instance->get_pc = skyeye_config.arch->get_pc; arch_instance->ICE_write_byte = skyeye_config.arch->ICE_write_byte; arch_instance->ICE_read_byte = skyeye_config.arch->ICE_read_byte; arch_instance->init (); arch_instance->reset (); arch_instance->big_endian = Big_endian; #endif #if 0 /* move to module loading stage */ skyeye_uart_converter_setup(); #endif #if 0 if(skyeye_config.code_cov.prof_on) cov_init(skyeye_config.code_cov.start, skyeye_config.code_cov.end); #endif #if 0 mem_reset(); /* initialize of memory module */ #endif } return 1; }