int main_() { int x1 = 1; int *p1 = &x1; int i_arr[3] = {10,20,30}; int *ipp; int first_addr = i_arr; printf("x1 : %d\t", x1); printf("*p1 : %d\n", *p1); (*p1)+=5; printf("x1 : %d\t", x1); printf("*p1 : %d\n", *p1); change_param(p1); printf("x1 : %d\t", x1); printf("*p1 : %d\n", *p1); change_param(&x1); printf("x1 : %d\t", x1); printf("*p1 : %d\n", *p1); printf("sizeof(i_arr) : %d\n", sizeof(i_arr)); printf("i_arr : %d\n", i_arr); printf("i_arr+1 : %d\n", i_arr+1); print_array(i_arr, 3); change_param(&i_arr[0]); print_array(i_arr, 3); change_param(i_arr+1); print_array(i_arr, 3); change_param(i_arr+2); print_array(i_arr, 3); ipp = (int*)0x12ff20; // assign the address of first element of the array to ipp *(int*)first_addr = 0xA; *(int*)(first_addr+4) = 0xB; *(int*)(first_addr+8) = 0xC; print_array(i_arr, 3); getchar(); return EXIT_SUCCESS; }
static int inp_debug_events (VisPluginData *plugin, VisEventQueue *events) { VisEvent ev; while (visual_event_queue_poll (events, &ev)) { switch (ev.type) { case VISUAL_EVENT_PARAM: { VisParamEntry *param = ev.event.param.param; change_param (plugin, param); } default:; /* discard */ } } return 0; }
void alldone(int estatus) { char *ptr; #if defined(WIN32) || defined(WIN64) struct _stat x; #else struct stat x; #endif if (preprocessonly == 0 && strlen(out1) > 0) { (void) unlink((const char *) out1); } (void) unlink(TMP_FILE1); (void) unlink(TMP_FILE2); if (!buzzed && seedy && !analyze && !export_ast && !s_trail && !preprocessonly && depth > 0) { printf("seed used: %d\n", SeedUsed); } if (!buzzed && xspin && (analyze || s_trail)) { if (estatus) { printf("spin: %d error(s) - aborting\n", estatus); } else { printf("Exit-Status 0\n"); } } if (buzzed && replay && !has_code && !estatus) { extern QH *qh; QH *j; int i; char *tmp = (char *) emalloc(strlen("spin -t") + strlen(pan_runtime) + strlen(Fname->name) + 8); pan_runtime = (char *) emalloc(2048); /* more than enough */ sprintf(pan_runtime, "-n%d ", SeedUsed); if (jumpsteps) { sprintf(&pan_runtime[strlen(pan_runtime)], "-j%d ", jumpsteps); } if (trailfilename) { sprintf(&pan_runtime[strlen(pan_runtime)], "-k%s ", *trailfilename); } if (cutoff) { sprintf(&pan_runtime[strlen(pan_runtime)], "-u%d ", cutoff); } for (i = 1; i <= PreCnt; i++) { strcat(pan_runtime, PreArg[i]); strcat(pan_runtime, " "); } for (j = qh; j; j = j->nxt) { sprintf(&pan_runtime[strlen(pan_runtime)], "-q%d ", j->n); } if (strcmp(PreProc, CPP) != 0) { sprintf(&pan_runtime[strlen(pan_runtime)], "\"-P%s\" ", PreProc); } /* -oN options 1..5 are ignored in simulations */ if (old_priority_rules) strcat(pan_runtime, "-o6 "); if (!implied_semis) strcat(pan_runtime, "-o7 "); if (no_print) strcat(pan_runtime, "-b "); if (no_wrapup) strcat(pan_runtime, "-B "); if (columns == 1) strcat(pan_runtime, "-c "); if (columns == 2) strcat(pan_runtime, "-M "); if (seedy == 1) strcat(pan_runtime, "-h "); if (like_java == 1) strcat(pan_runtime, "-J "); if (old_scope_rules) strcat(pan_runtime, "-O "); if (notabs) strcat(pan_runtime, "-T "); if (verbose&1) strcat(pan_runtime, "-g "); if (verbose&2) strcat(pan_runtime, "-l "); if (verbose&4) strcat(pan_runtime, "-p "); if (verbose&8) strcat(pan_runtime, "-r "); if (verbose&16) strcat(pan_runtime, "-s "); if (verbose&32) strcat(pan_runtime, "-v "); if (verbose&64) strcat(pan_runtime, "-w "); if (m_loss) strcat(pan_runtime, "-m "); sprintf(tmp, "spin -t %s %s", pan_runtime, Fname->name); estatus = e_system(1, tmp); /* replay */ exit(estatus); /* replay without c_code */ } if (buzzed && (!replay || has_code) && !estatus) { char *tmp, *tmp2 = NULL, *P_X; char *C_X = (buzzed == 2) ? "-O" : ""; if (replay && strlen(pan_comptime) == 0) { #if defined(WIN32) || defined(WIN64) P_X = "pan"; #else P_X = "./pan"; #endif if (stat(P_X, (struct stat *)&x) < 0) { goto recompile; /* no executable pan for replay */ } tmp = (char *) emalloc(8 + strlen(P_X) + strlen(pan_runtime) +4); /* the final +4 is too allow adding " &" in some cases */ sprintf(tmp, "%s %s", P_X, pan_runtime); goto runit; } #if defined(WIN32) || defined(WIN64) P_X = "-o pan pan.c && pan"; #else P_X = "-o pan pan.c && ./pan"; #endif /* swarm and biterate randomization additions */ if (!replay && itsr) /* iterative search refinement */ { if (!strstr(pan_comptime, "-DBITSTATE")) { add_comptime("-DBITSTATE"); } if (!strstr(pan_comptime, "-DPUTPID")) { add_comptime("-DPUTPID"); } if (!strstr(pan_comptime, "-DT_RAND") && !strstr(pan_comptime, "-DT_REVERSE")) { add_runtime("-T0 "); /* controls t_reverse */ } if (!strstr(pan_runtime, "-P") /* runtime flag */ || pan_runtime[2] < '0' || pan_runtime[2] > '1') /* no -P0 or -P1 */ { add_runtime("-P0 "); /* controls p_reverse */ } if (!strstr(pan_runtime, "-w")) { add_runtime("-w18 "); /* -w18 = 256K */ } else { char nv[32]; int x; x = omit_str(pan_runtime, "-w"); if (x >= 0) { sprintf(nv, "-w%d ", x); add_runtime(nv); /* added spaces */ } } if (!strstr(pan_runtime, "-h")) { add_runtime("-h0 "); /* 0..499 */ /* leave 2 spaces for increments up to -h499 */ } else if (!strstr(pan_runtime, "-hash")) { char nv[32]; int x; x = omit_str(pan_runtime, "-h"); if (x >= 0) { sprintf(nv, "-h%d ", x%500); add_runtime(nv); /* added spaces */ } } if (!strstr(pan_runtime, "-k")) { add_runtime("-k1 "); /* 1..3 */ } else { char nv[32]; int x; x = omit_str(pan_runtime, "-k"); if (x >= 0) { sprintf(nv, "-k%d ", x%4); add_runtime(nv); /* added spaces */ } } if (strstr(pan_runtime, "-p_rotate")) { char nv[32]; int x; x = omit_str(pan_runtime, "-p_rotate"); if (x < 0) { x = 0; } sprintf(nv, "-p_rotate%d ", x%256); add_runtime(nv); /* added spaces */ } else if (strstr(pan_runtime, "-p_permute") == 0) { add_runtime("-p_rotate0 "); } if (strstr(pan_runtime, "-RS")) { (void) omit_str(pan_runtime, "-RS"); } /* need room for at least 10 digits */ add_runtime("-RS1234567890 "); change_rs(pan_runtime); } recompile: if (strstr(PreProc, "cpp")) /* unix/linux */ { strcpy(PreProc, "gcc"); /* need compiler */ } else if ((tmp = strstr(PreProc, "-E")) != NULL) { *tmp = '\0'; /* strip preprocessing flags */ } final_fiddle(); tmp = (char *) emalloc(8 + /* account for alignment */ strlen(PreProc) + strlen(C_X) + strlen(pan_comptime) + strlen(P_X) + strlen(pan_runtime) + strlen(" -p_reverse & ")); tmp2 = tmp; /* P_X ends with " && ./pan " */ sprintf(tmp, "%s %s %s %s %s", PreProc, C_X, pan_comptime, P_X, pan_runtime); if (!replay) { if (itsr < 0) /* swarm only */ { strcat(tmp, " &"); /* after ./pan */ itsr = -itsr; /* now same as biterate */ } /* do compilation first * split cc command from run command * leave cc in tmp, and set tmp2 to run */ if ((ptr = strstr(tmp, " && ")) != NULL) { tmp2 = ptr + 4; /* first run */ *ptr = '\0'; } } if (has_ltl) { (void) unlink("_spin_nvr.tmp"); } #ifdef PC /* make sure that if compilation fails we do not continue */ (void) unlink("./pan.exe"); #else (void) unlink("./pan"); #endif runit: estatus = e_system(1, tmp); /* compile */ if (replay || estatus < 0) { goto skipahead; } /* !replay */ if (itsr == 0) /* single run */ { estatus = e_system(1, tmp2); } else if (itsr > 0) /* iterative search refinement */ { int is_swarm = 0; if (tmp2 != tmp) /* swarm: did only compilation so far */ { tmp = tmp2; /* now we point to the run command */ estatus = e_system(1, tmp); /* first run */ } itsr--; /* count down */ /* the following are added back randomly later */ (void) omit_str(tmp, "-p_reverse"); /* replaced by spaces */ (void) omit_str(tmp, "-p_normal"); if (strstr(tmp, " &") != NULL) { (void) omit_str(tmp, " &"); is_swarm = 1; } /* increase -w every itsr_n-th run */ if ((itsr_n > 0 && (itsr == 0 || (itsr%itsr_n) != 0)) || (change_param(tmp, "-w", 36) >= 0)) /* max 4G bit statespace */ { (void) change_param(tmp, "-h", 500); /* hash function 0.499 */ (void) change_param(tmp, "-p_rotate", 256); /* if defined */ (void) change_param(tmp, "-k", 4); /* nr bits per state 0->1,1,2,3 */ (void) change_param(tmp, "-T", 2); /* with or without t_reverse*/ (void) change_param(tmp, "-P", 2); /* -P 0..1 != p_reverse */ change_rs(tmp); /* change random seed */ string_trim(tmp); if (rand()%5 == 0) /* 20% of all runs */ { strcat(tmp, " -p_reverse "); /* at end, so this overrides -p_rotateN, if there */ /* but -P0..1 disable this in 50% of the cases */ /* so its really activated in 10% of all runs */ } else if (rand()%6 == 0) /* override p_rotate and p_reverse */ { strcat(tmp, " -p_normal "); } if (is_swarm) { strcat(tmp, " &"); } goto runit; } } skipahead: (void) unlink("pan.b"); (void) unlink("pan.c"); (void) unlink("pan.h"); (void) unlink("pan.m"); (void) unlink("pan.p"); (void) unlink("pan.t"); } exit(estatus); }
LOCAL void change_states_param( Front *front, Wave *wave, int comp, Gas_param *new_param) { HYPER_SURF *hs; HYPER_SURF_ELEMENT *hse; POINT *pt; SURFACE **s; Locstate stl, str, ref_st; int i, d, gridmax, vgmax[MAXD], tmp, ic[MAXD]; FD_DATA *fd_data; INTERFACE *intfc = front->interf; int dim = intfc->dim; printf("#change dirichlet boundary condition params.\n"); for(s=intfc->surfaces; s && *s; s++) { hs = Hyper_surf(*s); if(wave_type(hs) != DIRICHLET_BOUNDARY) continue; if(boundary_state_data(hs) == NULL) continue; fd_data = (FD_DATA *)boundary_state_data(hs); ref_st = fd_data->state; if(gas_params_for_comp(comp, intfc) != Params(ref_st)) continue; printf("change param for FD_DATA.\n"); verbose_print_state("bf ref", ref_st); change_param(ref_st, comp, new_param); verbose_print_state("af ref", ref_st); } printf("#change intfc params.\n"); next_point(intfc, NULL,NULL,NULL); while (next_point(intfc,&pt,&hse,&hs)) { slsr(pt,hse,hs,&stl,&str); change_param(str,positive_component(hs),new_param); change_param(stl,negative_component(hs),new_param); if(the_point(pt)) { printf("%d %d\n", negative_component(hs), positive_component(hs)); verbose_print_state("stl", stl); verbose_print_state("str", str); } } //check_print_intfc("After change intfc params", "ch_param", 'g', // intfc, 1, -1, NO); printf("#change interior params.\n"); gridmax = 1; for (d = 0; d < dim; d++) { vgmax[d] = wave->rect_grid->gmax[d] + wave->rect_grid->lbuf[d] + wave->rect_grid->ubuf[d]; gridmax *= vgmax[d]; } for (i = 0; i < gridmax; i++) { tmp = i; for (d = 0; d < dim; d++) { ic[d] = tmp % vgmax[d] - wave->rect_grid->lbuf[d]; tmp /= vgmax[d]; } change_param(Rect_state(ic,wave), Rect_comp(ic,wave), new_param); } }