Lines Matching refs:proc

59 static void callstack_push_syscall(struct process *proc, int sysnum);
60 static void callstack_push_symfunc(struct process *proc, struct breakpoint *bp);
64 void callstack_pop(struct process *proc);
66 static char *shortsignal(struct process *proc, int signum);
67 static char *sysname(struct process *proc, int sysnum);
68 static char *arch_sysname(struct process *proc, int sysnum);
71 call_handler(struct process *proc, Event *event) in call_handler() argument
73 assert(proc != NULL); in call_handler()
75 struct event_handler *handler = proc->event_handler; in call_handler()
91 event->proc ? event->proc->pid : -1, event->type); in handle_event()
97 if (event->proc != NULL) { in handle_event()
98 event = call_handler(event->proc, event); in handle_event()
105 if (event->proc != NULL in handle_event()
106 && event->proc->leader != NULL in handle_event()
107 && event->proc != event->proc->leader) { in handle_event()
108 event = call_handler(event->proc->leader, event); in handle_event()
120 assert(event->proc != NULL); in handle_event()
122 event->proc->pid, in handle_event()
123 shortsignal(event->proc, event->e_un.signum), in handle_event()
129 assert(event->proc != NULL); in handle_event()
131 event->proc->pid, in handle_event()
137 assert(event->proc != NULL); in handle_event()
139 event->proc->pid, in handle_event()
140 shortsignal(event->proc, event->e_un.signum), in handle_event()
146 assert(event->proc != NULL); in handle_event()
148 event->proc->pid, in handle_event()
149 sysname(event->proc, event->e_un.sysnum), in handle_event()
155 assert(event->proc != NULL); in handle_event()
157 event->proc->pid, in handle_event()
158 sysname(event->proc, event->e_un.sysnum), in handle_event()
164 assert(event->proc != NULL); in handle_event()
166 event->proc->pid, in handle_event()
167 arch_sysname(event->proc, event->e_un.sysnum), in handle_event()
173 assert(event->proc != NULL); in handle_event()
175 event->proc->pid, in handle_event()
176 arch_sysname(event->proc, event->e_un.sysnum), in handle_event()
183 assert(event->proc != NULL); in handle_event()
185 event->proc->pid, event->e_un.newpid); in handle_event()
190 assert(event->proc != NULL); in handle_event()
192 event->proc->pid); in handle_event()
197 assert(event->proc != NULL); in handle_event()
199 event->proc->pid, event->e_un.brk_addr); in handle_event()
271 debug(DEBUG_FUNCTION, "handle_clone(pid=%d)", event->proc->pid); in handle_clone()
273 struct process *proc = malloc(sizeof(*proc)); in handle_clone() local
275 if (proc == NULL in handle_clone()
276 || process_clone(proc, event->proc, newpid) < 0) { in handle_clone()
277 free(proc); in handle_clone()
278 proc = NULL; in handle_clone()
284 proc->parent = event->proc; in handle_clone()
288 proc->arch_ptr = NULL; in handle_clone()
294 if (proc != NULL) { in handle_clone()
295 proc->event_handler = NULL; in handle_clone()
296 if (event->proc->state == STATE_ATTACHED in handle_clone()
298 proc->state = STATE_ATTACHED; in handle_clone()
300 proc->state = STATE_IGNORED; in handle_clone()
305 } else if (proc != NULL) { in handle_clone()
306 proc->state = STATE_BEING_CREATED; in handle_clone()
310 continue_process(event->proc->pid); in handle_clone()
311 else if (proc != NULL) in handle_clone()
312 continue_after_vfork(proc); in handle_clone()
322 struct process *proc = pid2proc(event->e_un.newpid); in handle_new() local
323 if (!proc) { in handle_new()
326 assert(proc->state == STATE_BEING_CREATED); in handle_new()
328 proc->state = STATE_ATTACHED; in handle_new()
330 proc->state = STATE_IGNORED; in handle_new()
332 continue_process(proc->pid); in handle_new()
337 shortsignal(struct process *proc, int signum) in shortsignal() argument
350 debug(DEBUG_FUNCTION, "shortsignal(pid=%d, signum=%d)", proc->pid, signum); in shortsignal()
352 assert(proc->personality < sizeof signalents / sizeof signalents[0]); in shortsignal()
353 if (signum < 0 || signum >= nsignals[proc->personality]) { in shortsignal()
356 return signalents[proc->personality][signum]; in shortsignal()
361 sysname(struct process *proc, int sysnum) in sysname() argument
376 debug(DEBUG_FUNCTION, "sysname(pid=%d, sysnum=%d)", proc->pid, sysnum); in sysname()
378 assert(proc->personality < sizeof syscallents / sizeof syscallents[0]); in sysname()
379 if (sysnum < 0 || sysnum >= nsyscalls[proc->personality]) { in sysname()
383 return syscallents[proc->personality][sysnum]; in sysname()
388 arch_sysname(struct process *proc, int sysnum) in arch_sysname() argument
396 debug(DEBUG_FUNCTION, "arch_sysname(pid=%d, sysnum=%d)", proc->pid, sysnum); in arch_sysname()
413 debug(DEBUG_FUNCTION, "handle_signal(pid=%d, signum=%d)", event->proc->pid, event->e_un.signum); in handle_signal()
414 if (event->proc->state != STATE_IGNORED && !options.no_signals) { in handle_signal()
415 output_line(event->proc, "--- %s (%s) ---", in handle_signal()
416 shortsignal(event->proc, event->e_un.signum), in handle_signal()
419 continue_after_signal(event->proc->pid, event->e_un.signum); in handle_signal()
466 account_current_callstack(struct process *proc) in account_current_callstack() argument
471 struct timedelta spent[proc->callstack_depth]; in account_current_callstack()
474 for (i = 0; i < proc->callstack_depth; ++i) { in account_current_callstack()
475 struct callstack_element *elem = &proc->callstack[i]; in account_current_callstack()
479 for (i = 0; i < proc->callstack_depth; ++i) { in account_current_callstack()
480 struct callstack_element *elem = &proc->callstack[i]; in account_current_callstack()
483 const char *name = sysname(proc, elem->c_un.syscall); in account_current_callstack()
502 debug(DEBUG_FUNCTION, "handle_exit(pid=%d, status=%d)", event->proc->pid, event->e_un.ret_val); in handle_exit()
503 if (event->proc->state != STATE_IGNORED) { in handle_exit()
504 output_line(event->proc, "+++ exited (status %d) +++", in handle_exit()
508 account_current_callstack(event->proc); in handle_exit()
509 remove_process(event->proc); in handle_exit()
514 …debug(DEBUG_FUNCTION, "handle_exit_signal(pid=%d, signum=%d)", event->proc->pid, event->e_un.signu… in handle_exit_signal()
515 if (event->proc->state != STATE_IGNORED) { in handle_exit_signal()
516 output_line(event->proc, "+++ killed by %s +++", in handle_exit_signal()
517 shortsignal(event->proc, event->e_un.signum)); in handle_exit_signal()
520 account_current_callstack(event->proc); in handle_exit_signal()
521 remove_process(event->proc); in handle_exit_signal()
525 output_syscall(struct process *proc, const char *name, enum tof tof, in output_syscall() argument
535 output_left(tof, proc, &syscall); in output_syscall()
539 output_right(tof, proc, &syscall, spent); in output_syscall()
547 output_syscall_left(struct process *proc, const char *name) in output_syscall_left() argument
549 output_syscall(proc, name, LT_TOF_SYSCALL, true, NULL); in output_syscall_left()
553 output_syscall_right(struct process *proc, const char *name, in output_syscall_right() argument
556 output_syscall(proc, name, LT_TOF_SYSCALLR, false, spent); in output_syscall_right()
562 debug(DEBUG_FUNCTION, "handle_syscall(pid=%d, sysnum=%d)", event->proc->pid, event->e_un.sysnum); in handle_syscall()
563 if (event->proc->state != STATE_IGNORED) { in handle_syscall()
564 callstack_push_syscall(event->proc, event->e_un.sysnum); in handle_syscall()
566 output_syscall_left(event->proc, in handle_syscall()
567 sysname(event->proc, in handle_syscall()
570 continue_after_syscall(event->proc, event->e_un.sysnum, 0); in handle_syscall()
576 struct process *proc = event->proc; in handle_exec() local
580 pid_t pid = proc->pid; in handle_exec()
582 debug(DEBUG_FUNCTION, "handle_exec(pid=%d)", proc->pid); in handle_exec()
583 if (proc->state == STATE_IGNORED) { in handle_exec()
586 remove_process(proc); in handle_exec()
589 output_line(proc, "--- Called exec() ---"); in handle_exec()
591 account_current_callstack(proc); in handle_exec()
593 if (process_exec(proc) < 0) { in handle_exec()
599 continue_after_exec(proc); in handle_exec()
604 …debug(DEBUG_FUNCTION, "handle_arch_syscall(pid=%d, sysnum=%d)", event->proc->pid, event->e_un.sysn… in handle_arch_syscall()
605 if (event->proc->state != STATE_IGNORED) { in handle_arch_syscall()
606 callstack_push_syscall(event->proc, 0xf0000 + event->e_un.sysnum); in handle_arch_syscall()
608 output_syscall_left(event->proc, in handle_arch_syscall()
609 arch_sysname(event->proc, in handle_arch_syscall()
613 continue_process(event->proc->pid); in handle_arch_syscall()
620 event->proc->pid, event->e_un.sysnum); in handle_x_sysret()
622 unsigned d = event->proc->callstack_depth; in handle_x_sysret()
624 struct callstack_element *elem = &event->proc->callstack[d - 1]; in handle_x_sysret()
627 if (event->proc->state != STATE_IGNORED) { in handle_x_sysret()
630 output_syscall_right(event->proc, in handle_x_sysret()
631 name_cb(event->proc, in handle_x_sysret()
635 callstack_pop(event->proc); in handle_x_sysret()
637 continue_after_syscall(event->proc, event->e_un.sysnum, 1); in handle_x_sysret()
653 output_right_tos(struct process *proc) in output_right_tos() argument
655 size_t d = proc->callstack_depth; in output_right_tos()
657 struct callstack_element *elem = &proc->callstack[d - 1]; in output_right_tos()
660 if (proc->state != STATE_IGNORED) { in output_right_tos()
665 output_right(LT_TOF_FUNCTIONR, proc, elem->c_un.libfunc, in output_right_tos()
671 void arch_symbol_ret(struct process *proc, struct library_symbol *libsym) in arch_symbol_ret() argument
681 struct process *leader = event->proc->leader; in handle_breakpoint()
686 continue_process(event->proc->pid); in handle_breakpoint()
691 event->proc->pid, brk_addr); in handle_breakpoint()
694 for (i = event->proc->callstack_depth - 1; i >= 0; i--) { in handle_breakpoint()
695 if (brk_addr == event->proc->callstack[i].return_addr) { in handle_breakpoint()
696 for (j = event->proc->callstack_depth - 1; j > i; j--) in handle_breakpoint()
697 callstack_pop(event->proc); in handle_breakpoint()
700 event->proc->callstack[i].c_un.libfunc; in handle_breakpoint()
702 arch_symbol_ret(event->proc, libsym); in handle_breakpoint()
703 output_right_tos(event->proc); in handle_breakpoint()
704 callstack_pop(event->proc); in handle_breakpoint()
712 while (event->proc->callstack_depth > 0) { in handle_breakpoint()
714 size_t d = event->proc->callstack_depth; in handle_breakpoint()
715 prev = &event->proc->callstack[d - 1]; in handle_breakpoint()
721 arch_symbol_ret(event->proc, in handle_breakpoint()
723 output_right_tos(event->proc); in handle_breakpoint()
724 callstack_pop(event->proc); in handle_breakpoint()
732 continue_after_breakpoint(event->proc, sbp); in handle_breakpoint()
734 set_instruction_pointer(event->proc, brk_addr); in handle_breakpoint()
735 continue_process(event->proc->pid); in handle_breakpoint()
742 breakpoint_on_hit(sbp, event->proc); in handle_breakpoint()
743 else if (event->proc->state != STATE_IGNORED) in handle_breakpoint()
744 output_line(event->proc, in handle_breakpoint()
751 if (event->proc->state != STATE_IGNORED in handle_breakpoint()
753 event->proc->stack_pointer = get_stack_pointer(event->proc); in handle_breakpoint()
754 callstack_push_symfunc(event->proc, sbp); in handle_breakpoint()
756 output_left(LT_TOF_FUNCTION, event->proc, in handle_breakpoint()
760 breakpoint_on_continue(sbp, event->proc); in handle_breakpoint()
763 set_instruction_pointer(event->proc, brk_addr); in handle_breakpoint()
766 continue_process(event->proc->pid); in handle_breakpoint()
770 callstack_push_syscall(struct process *proc, int sysnum) in callstack_push_syscall() argument
774 debug(DEBUG_FUNCTION, "callstack_push_syscall(pid=%d, sysnum=%d)", proc->pid, sysnum); in callstack_push_syscall()
776 if (proc->callstack_depth == MAX_CALLDEPTH - 1) { in callstack_push_syscall()
782 elem = &proc->callstack[proc->callstack_depth]; in callstack_push_syscall()
788 proc->callstack_depth++; in callstack_push_syscall()
796 callstack_push_symfunc(struct process *proc, struct breakpoint *bp) in callstack_push_symfunc() argument
801 proc->pid, bp->libsym->name); in callstack_push_symfunc()
803 if (proc->callstack_depth == MAX_CALLDEPTH - 1) { in callstack_push_symfunc()
809 elem = &proc->callstack[proc->callstack_depth++]; in callstack_push_symfunc()
815 if (breakpoint_get_return_bp(&rbp, bp, proc) == 0 in callstack_push_symfunc()
817 struct breakpoint *ext_rbp = insert_breakpoint(proc, rbp); in callstack_push_symfunc()
834 callstack_pop(struct process *proc) in callstack_pop() argument
837 assert(proc->callstack_depth > 0); in callstack_pop()
839 debug(DEBUG_FUNCTION, "callstack_pop(pid=%d)", proc->pid); in callstack_pop()
840 elem = &proc->callstack[proc->callstack_depth - 1]; in callstack_pop()
843 = address2bpstruct(proc->leader, elem->return_addr); in callstack_pop()
845 breakpoint_on_hit(bp, proc); in callstack_pop()
846 delete_breakpoint(proc, bp); in callstack_pop()
858 proc->callstack_depth--; in callstack_pop()