void core(t_machine *vm, t_exec *begin, T_TEAM lampions, void *mem) { int cont; t_graph *g; t_instruct *ops; int dec; cont = 1; dec = 1; ops = init_call(); vm->cycle_to_die = CYCLE_TO_DIE; g = init(begin, lampions); g->lampions = lampions; while (begin && (vm->n_cycles < vm->dump || vm->dump == NO_DUMP) && cont) { g->vm = vm; gere_event(g, &cont, 0, dec); check_for_near(begin, &begin, vm->cycle_to_die); dec = call(begin, lampions, mem, ops); vm->last_live = last(lampions, vm->last_live); count_and_live(vm, begin); vm->n_cycles++; } if (cont) gere_event(g, &cont, 1, 0); if (vm->dump != NO_DUMP || !cont) opt_dump(mem); }
int main(int argc, char *argv[]) { long call_num; int status; int insyscall = 0; char **args; if(argc < 4){ printf("Usage: tracer xx rodata_addr rodata_size\n"); return 0; } rodata_addr_start = atoi(argv[2]); rodata_size = atoi(argv[3]); rodata_addr_end = rodata_size + rodata_addr_start; init_call(); child = fork(); if (child == 0) { ptrace(PTRACE_TRACEME, 0, NULL, NULL); if(argc <= 4) args = NULL; else args = &argv[4]; close(1); execve(argv[1], args, NULL); } else { while (1) { wait(&status); if (WIFEXITED(status)) break; call_num = ptrace(PTRACE_PEEKUSER, child, BYTES * ORIG_REG0, NULL); if (insyscall == 0) { insyscall = 1; reg0 = ptrace(PTRACE_PEEKUSER, child, BYTES * REG0, NULL); } else { insyscall = 0; ptrace(PTRACE_GETREGS, child, NULL, ®s); syscall_trace[call_num](call_num); } ptrace(PTRACE_SYSCALL, child, NULL, NULL); } } return 0; }