int main(UNUSED int ac, UNUSED char **av, char **env) { t_main s; int *jobs; if ((jobs = malloc(1 * sizeof(int))) == NULL) return (-1); jobs[0] = -1; jobs = update_jobs(jobs, 1); init_env(env, &s.my_env); init_history(&s.cmd, &s.history, &s.term, &s.stop); while (!s.stop && get_return_value(0, 0, 0, 0) == 0 && update_fils(0, -1) != -1) { save_pid(2, 0); get_signal(); if ((s.paths = get_paths()) != NULL) end_main(&s); is_too_much(0); } end_shell(s.history, s.term); save_pid(2, 0); close_fg(jobs, 0); return (get_return_value(0, 0, 0, 1)); }
int stop_this(char **arg, int i) { int j; j = 0; while (arg[i][j] && arg[i][j] != ' ' && arg[i][j] != '\t') j++; while (arg[i][j] && (arg[i][j] == ' ' || arg[i][j] == '\t')) j++; if (arg[i][j]) get_return_value(atoi(&arg[i][j]), 1, 1, 0); else get_return_value(0, 1, 1, 0); return (0); }
int main(int argc, char **argv){ printf("The filename is %s\n",filename); parse_system_call_name(filename); int pid; int i = 1; i+=2; pid = atoi(argv[1]); //printf("Hello, world (i=%d)!\n", pid); jint stat=0; jint res=0; long syscall; printf("Attaching to a process %d",pid); if ((ptrace(PTRACE_ATTACH, pid, NULL, NULL)) != 0) { printf("Could not attach to process, errno is %d",errno); } res = waitpid(pid, &stat, WUNTRACED); __android_log_print(ANDROID_LOG_INFO,LOG_TAG,"Status of the traced process %d\n",stat); ptrace(PTRACE_SETOPTIONS, pid, 0, PTRACE_O_TRACESYSGOOD); while(1){ if(trace_syscall(pid)!=0) break; #ifdef __arm__ print_syscall_arm(pid); #else print_syscall(pid); if(trace_syscall(pid)!=0) break; get_return_value(pid); #endif } cleanup_syscall_tabel(); return 0; }
void bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj) { struct finish_breakpoint_object *self_finishbp = (struct finish_breakpoint_object *) bp_obj; /* Can compute return_value only once. */ gdb_assert (!self_finishbp->return_value); if (!self_finishbp->return_type) return; TRY { struct value *function = value_object_to_value (self_finishbp->function_value); struct type *value_type = type_object_to_type (self_finishbp->return_type); /* bpfinishpy_init cannot finish into DUMMY_FRAME (throws an error in such case) so it is OK to always pass CTX_SAVER as NULL. */ struct value *ret = get_return_value (function, value_type, NULL); if (ret) { self_finishbp->return_value = value_to_value_object (ret); if (!self_finishbp->return_value) gdbpy_print_stack (); } else { Py_INCREF (Py_None); self_finishbp->return_value = Py_None; } } CATCH (except, RETURN_MASK_ALL) { gdbpy_convert_exception (except); gdbpy_print_stack (); }
void bpfinishpy_pre_stop_hook (struct breakpoint_object *bp_obj) { struct finish_breakpoint_object *self_finishbp = (struct finish_breakpoint_object *) bp_obj; volatile struct gdb_exception except; /* Can compute return_value only once. */ gdb_assert (!self_finishbp->return_value); if (!self_finishbp->return_type) return; TRY_CATCH (except, RETURN_MASK_ALL) { struct value *function = value_object_to_value (self_finishbp->function_value); struct type *value_type = type_object_to_type (self_finishbp->return_type); struct value *ret = get_return_value (function, value_type); if (ret) { self_finishbp->return_value = value_to_value_object (ret); if (!self_finishbp->return_value) gdbpy_print_stack (); } else { Py_INCREF (Py_None); self_finishbp->return_value = Py_None; } } if (except.reason < 0) { gdbpy_convert_exception (except); gdbpy_print_stack (); } }
int get_infos_process(pid_t pid, int status) { static char mode = 0; struct user usr; if (ptrace(PTRACE_GETREGS, pid, NULL, &usr) == -1) { if (WIFEXITED(status)) fprintf(stderr, "\t = ?\n+++ exited with %d +++\n", WEXITSTATUS(status)); else perror("ptrace <PTRACE_GETREGS> failed : "); return 1; } if (mode) { get_return_value(&usr); mode = 0; } else get_syscall_infos(pid, &usr, &mode); return 0; }
int get_infos_process(pid_t pid, int status, int fd, t_graph *graph) { struct user usr; t_data data; if (ptrace(PTRACE_GETREGS, pid, NULL, &usr) == -1) { if (WIFEXITED(status)) fprintf(stderr, "\t = ?\n+++ exited with %d +++\n", WEXITSTATUS(status)); else perror("ptrace <PTRACE_GETREGS> failed : "); graph_end(fd); return 1; } data.peektext = ptrace(PTRACE_PEEKTEXT, pid, usr.regs.rip, 0); data.fd = fd; data.pid = pid; get_syscall_infos(&usr, graph, &data); get_return_value(&usr, graph, &data); get_e8_call(&usr, graph, &data); get_ff_call(&usr, graph, &data); return (0); }