Lines Matching refs:proc

42 os_process_init(struct process *proc)  in os_process_init()  argument
48 os_process_destroy(struct process *proc) in os_process_destroy() argument
53 os_process_clone(struct process *retp, struct process *proc) in os_process_clone() argument
59 os_process_exec(struct process *proc) in os_process_exec() argument
67 arch_process_init(struct process *proc) in arch_process_init() argument
73 arch_process_destroy(struct process *proc) in arch_process_destroy() argument
78 arch_process_clone(struct process *retp, struct process *proc) in arch_process_clone() argument
84 arch_process_exec(struct process *proc) in arch_process_exec() argument
92 arch_dynlink_done(struct process *proc) in arch_dynlink_done() argument
97 static int add_process(struct process *proc, int was_exec);
98 static void unlist_process(struct process *proc);
101 destroy_unwind(struct process *proc) in destroy_unwind() argument
104 if (proc->unwind_priv != NULL) in destroy_unwind()
105 _UPT_destroy(proc->unwind_priv); in destroy_unwind()
106 if (proc->unwind_as != NULL) in destroy_unwind()
107 unw_destroy_addr_space(proc->unwind_as); in destroy_unwind()
111 if (proc->dwfl != NULL) in destroy_unwind()
112 dwfl_end(proc->dwfl); in destroy_unwind()
117 process_bare_init(struct process *proc, const char *filename, in process_bare_init() argument
121 memset(proc, 0, sizeof(*proc)); in process_bare_init()
123 proc->filename = strdup(filename); in process_bare_init()
124 if (proc->filename == NULL) { in process_bare_init()
126 free(proc->filename); in process_bare_init()
127 if (proc->breakpoints != NULL) { in process_bare_init()
128 dict_destroy(proc->breakpoints, in process_bare_init()
130 free(proc->breakpoints); in process_bare_init()
131 proc->breakpoints = NULL; in process_bare_init()
138 proc->pid = pid; in process_bare_init()
139 if (add_process(proc, was_exec) < 0) in process_bare_init()
141 if (proc->leader == NULL) { in process_bare_init()
144 unlist_process(proc); in process_bare_init()
148 if (proc->leader == proc) { in process_bare_init()
149 proc->breakpoints = malloc(sizeof(*proc->breakpoints)); in process_bare_init()
150 if (proc->breakpoints == NULL) in process_bare_init()
152 DICT_INIT(proc->breakpoints, in process_bare_init()
156 proc->breakpoints = NULL; in process_bare_init()
161 proc->unwind_priv = _UPT_create(pid); in process_bare_init()
162 proc->unwind_as = unw_create_addr_space(&_UPT_accessors, 0); in process_bare_init()
164 if (proc->unwind_priv == NULL || proc->unwind_as == NULL) { in process_bare_init()
167 "for process %d\n", proc->pid); in process_bare_init()
168 destroy_unwind(proc); in process_bare_init()
169 proc->unwind_priv = NULL; in process_bare_init()
170 proc->unwind_as = NULL; in process_bare_init()
176 proc->dwfl = NULL; /* Initialize for leader only on first library. */ in process_bare_init()
183 process_bare_destroy(struct process *proc, int was_exec) in process_bare_destroy() argument
185 dict_destroy(proc->breakpoints, NULL, NULL, NULL); in process_bare_destroy()
186 free(proc->breakpoints); in process_bare_destroy()
188 free(proc->filename); in process_bare_destroy()
189 unlist_process(proc); in process_bare_destroy()
190 destroy_unwind(proc); in process_bare_destroy()
195 process_init_main(struct process *proc) in process_init_main() argument
197 if (breakpoints_init(proc) < 0) { in process_init_main()
199 proc->pid); in process_init_main()
207 process_init(struct process *proc, const char *filename, pid_t pid) in process_init() argument
209 if (process_bare_init(proc, filename, pid, 0) < 0) { in process_init()
216 if (os_process_init(proc) < 0) { in process_init()
217 process_bare_destroy(proc, 0); in process_init()
221 if (arch_process_init(proc) < 0) { in process_init()
222 os_process_destroy(proc); in process_init()
223 process_bare_destroy(proc, 0); in process_init()
227 if (proc->leader != proc) { in process_init()
228 proc->e_machine = proc->leader->e_machine; in process_init()
229 proc->e_class = proc->leader->e_class; in process_init()
230 get_arch_dep(proc); in process_init()
231 } else if (process_init_main(proc) < 0) { in process_init()
232 process_bare_destroy(proc, 0); in process_init()
239 destroy_breakpoint_cb(struct process *proc, struct breakpoint *bp, void *data) in destroy_breakpoint_cb() argument
247 void callstack_pop(struct process *proc);
250 private_process_destroy(struct process *proc, int was_exec) in private_process_destroy() argument
253 while (proc->callstack_depth > 0) { in private_process_destroy()
260 size_t i = proc->callstack_depth - 1; in private_process_destroy()
261 if (!proc->callstack[i].is_syscall) in private_process_destroy()
262 proc->callstack[i].return_addr = 0; in private_process_destroy()
264 callstack_pop(proc); in private_process_destroy()
268 free(proc->filename); in private_process_destroy()
273 for (lib = proc->libraries; lib != NULL; ) { in private_process_destroy()
279 proc->libraries = NULL; in private_process_destroy()
282 if (proc->breakpoints != NULL) { in private_process_destroy()
283 proc_each_breakpoint(proc, NULL, destroy_breakpoint_cb, NULL); in private_process_destroy()
284 dict_destroy(proc->breakpoints, NULL, NULL, NULL); in private_process_destroy()
285 free(proc->breakpoints); in private_process_destroy()
286 proc->breakpoints = NULL; in private_process_destroy()
289 destroy_unwind(proc); in private_process_destroy()
293 process_destroy(struct process *proc) in process_destroy() argument
295 arch_process_destroy(proc); in process_destroy()
296 os_process_destroy(proc); in process_destroy()
297 private_process_destroy(proc, 0); in process_destroy()
301 process_exec(struct process *proc) in process_exec() argument
305 if (arch_process_exec(proc) < 0 in process_exec()
306 || os_process_exec(proc) < 0) in process_exec()
309 private_process_destroy(proc, 1); in process_exec()
311 if (process_bare_init(proc, NULL, proc->pid, 1) < 0) in process_exec()
313 if (process_init_main(proc) < 0) { in process_exec()
314 process_bare_destroy(proc, 1); in process_exec()
324 struct process *proc = malloc(sizeof(*proc)); in open_program() local
325 if (proc == NULL || process_init(proc, filename, pid) < 0) { in open_program()
326 free(proc); in open_program()
329 return proc; in open_program()
358 process_clone(struct process *retp, struct process *proc, pid_t pid) in process_clone() argument
360 if (process_bare_init(retp, proc->filename, pid, 0) < 0) { in process_clone()
363 proc->pid, pid, strerror(errno)); in process_clone()
367 retp->tracesysgood = proc->tracesysgood; in process_clone()
368 retp->e_machine = proc->e_machine; in process_clone()
369 retp->e_class = proc->e_class; in process_clone()
379 for (lib = proc->leader->libraries; lib != NULL; lib = lib->next) { in process_clone()
406 .old_proc = proc, in process_clone()
409 if (DICT_EACH(proc->leader->breakpoints, in process_clone()
418 memcpy(retp->callstack, proc->callstack, sizeof(retp->callstack)); in process_clone()
419 retp->callstack_depth = proc->callstack_depth; in process_clone()
474 if (os_process_clone(retp, proc) < 0) { in process_clone()
478 if (arch_process_clone(retp, proc) < 0) { in process_clone()
501 struct process *proc = open_program(filename, pid); in open_one_pid() local
502 if (proc == NULL) in open_one_pid()
505 trace_set_options(proc); in open_one_pid()
511 start_one_pid(struct process *proc, void *data) in start_one_pid() argument
513 continue_process(proc->pid); in start_one_pid()
518 is_main(struct process *proc, struct library *lib, void *data) in is_main() argument
524 process_hit_start(struct process *proc) in process_hit_start() argument
526 struct process *leader = proc->leader; in process_hit_start()
599 find_proc(struct process *proc, void *data) in find_proc() argument
601 return CBS_STOP_IF(proc->pid == (pid_t)(uintptr_t)data); in find_proc()
613 unlist_process(struct process *proc) in unlist_process() argument
615 if (list_of_processes == proc) { in unlist_process()
626 if (tmp->next == proc) { in unlist_process()
635 enum callback_status(*cb)(struct process *proc, void *data), in each_process() argument
658 each_task(struct process *proc, struct process *start_after, in each_task() argument
659 enum callback_status(*cb)(struct process *proc, void *data), in each_task() argument
662 assert(proc != NULL); in each_task()
663 struct process *it = start_after == NULL ? proc->leader in each_task()
686 add_process(struct process *proc, int was_exec) in add_process() argument
689 if (proc->pid) { in add_process()
690 pid_t tgid = process_leader(proc->pid); in add_process()
695 if (tgid == proc->pid) { in add_process()
696 proc->leader = proc; in add_process()
699 proc->leader = leader; in add_process()
706 proc->next = *leaderp; in add_process()
707 *leaderp = proc; in add_process()
713 change_process_leader(struct process *proc, struct process *leader) in change_process_leader() argument
716 if (proc->leader == leader) in change_process_leader()
720 unlist_process(proc); in change_process_leader()
721 if (proc != leader) in change_process_leader()
724 proc->leader = leader; in change_process_leader()
725 proc->next = *leaderp; in change_process_leader()
726 *leaderp = proc; in change_process_leader()
730 clear_leader(struct process *proc, void *data) in clear_leader() argument
733 proc->pid, proc->leader->pid); in clear_leader()
734 proc->leader = NULL; in clear_leader()
739 remove_process(struct process *proc) in remove_process() argument
741 debug(DEBUG_FUNCTION, "remove_proc(pid=%d)", proc->pid); in remove_process()
743 if (proc->leader == proc) in remove_process()
744 each_task(proc, NULL, &clear_leader, NULL); in remove_process()
746 unlist_process(proc); in remove_process()
747 process_removed(proc); in remove_process()
748 process_destroy(proc); in remove_process()
749 free(proc); in remove_process()
753 install_event_handler(struct process *proc, struct event_handler *handler) in install_event_handler() argument
755 debug(DEBUG_FUNCTION, "install_event_handler(pid=%d, %p)", proc->pid, handler); in install_event_handler()
756 assert(proc->event_handler == NULL); in install_event_handler()
757 proc->event_handler = handler; in install_event_handler()
761 destroy_event_handler(struct process *proc) in destroy_event_handler() argument
763 struct event_handler *handler = proc->event_handler; in destroy_event_handler()
764 debug(DEBUG_FUNCTION, "destroy_event_handler(pid=%d, %p)", proc->pid, handler); in destroy_event_handler()
769 proc->event_handler = NULL; in destroy_event_handler()
773 breakpoint_for_symbol(struct library_symbol *libsym, struct process *proc) in breakpoint_for_symbol() argument
776 assert(proc->leader == proc); in breakpoint_for_symbol()
782 proc->pid, libsym->name, libsym->enter_addr); in breakpoint_for_symbol()
786 bp_addr = sym2addr(proc, libsym); in breakpoint_for_symbol()
801 if (DICT_FIND_VAL(proc->breakpoints, &bp_addr, &bp) == 0) { in breakpoint_for_symbol()
823 || breakpoint_init(bp, proc, bp_addr, libsym) < 0) { in breakpoint_for_symbol()
828 if (proc_add_breakpoint(proc, bp) < 0) { in breakpoint_for_symbol()
833 if (breakpoint_turn_on(bp, proc) < 0) { in breakpoint_for_symbol()
834 proc_remove_breakpoint(proc, bp); in breakpoint_for_symbol()
849 proc_activate_latent_symbol(struct process *proc, in proc_activate_latent_symbol() argument
855 return breakpoint_for_symbol(libsym, proc); in proc_activate_latent_symbol()
859 proc_activate_delayed_symbol(struct process *proc, in proc_activate_delayed_symbol() argument
865 return breakpoint_for_symbol(libsym, proc); in proc_activate_delayed_symbol()
869 activate_latent_in(struct process *proc, struct library *lib, void *data) in activate_latent_in() argument
879 && proc_activate_latent_symbol(proc, libsym) < 0) in activate_latent_in()
886 proc_add_library(struct process *proc, struct library *lib) in proc_add_library() argument
889 lib->next = proc->libraries; in proc_add_library()
890 proc->libraries = lib; in proc_add_library()
892 lib->soname, lib->base, lib->pathname, proc->pid); in proc_add_library()
897 struct process *leader = proc->leader; in proc_add_library()
921 proc->pid, dwfl_errmsg (-1)); in proc_add_library()
951 proc)) != NULL) in proc_add_library()
954 libsym->name, proc->pid, strerror(errno)); in proc_add_library()
960 while ((lib2 = proc_each_library(proc, lib2, activate_latent_in, in proc_add_library()
964 lib2->soname, proc->pid, strerror(errno)); in proc_add_library()
968 proc_remove_library(struct process *proc, struct library *lib) in proc_remove_library() argument
971 for (libp = &proc->libraries; *libp != NULL; libp = &(*libp)->next) in proc_remove_library()
980 proc_each_library(struct process *proc, struct library *it, in proc_each_library() argument
981 enum callback_status (*cb)(struct process *proc, in proc_each_library() argument
986 it = proc->libraries; in proc_each_library()
993 switch (cb(proc, it, data)) { in proc_each_library()
1009 check_leader(struct process *proc) in check_leader() argument
1013 assert(proc->leader != NULL); in check_leader()
1014 assert(proc->leader == proc); in check_leader()
1015 assert(proc->breakpoints != NULL); in check_leader()
1019 proc_add_breakpoint(struct process *proc, struct breakpoint *bp) in proc_add_breakpoint() argument
1022 proc->pid, breakpoint_name(bp), bp->addr); in proc_add_breakpoint()
1023 check_leader(proc); in proc_add_breakpoint()
1028 assert(dict_find(proc->breakpoints, &bp->addr) == NULL); in proc_add_breakpoint()
1030 if (DICT_INSERT(proc->breakpoints, &bp->addr, &bp) < 0) { in proc_add_breakpoint()
1041 proc_remove_breakpoint(struct process *proc, struct breakpoint *bp) in proc_remove_breakpoint() argument
1044 proc->pid, breakpoint_name(bp), bp->addr); in proc_remove_breakpoint()
1045 check_leader(proc); in proc_remove_breakpoint()
1046 int rc = DICT_ERASE(proc->breakpoints, &bp->addr, struct breakpoint *, in proc_remove_breakpoint()
1053 struct process *proc; member
1054 enum callback_status (*cb)(struct process *proc,
1064 return data->cb(data->proc, *bpp, data->cb_data); in each_breakpoint_cb()
1068 proc_each_breakpoint(struct process *proc, arch_addr_t *start, in proc_each_breakpoint() argument
1069 enum callback_status (*cb)(struct process *proc, in proc_each_breakpoint() argument
1074 .proc = proc, in proc_each_breakpoint()
1078 return DICT_EACH(proc->breakpoints, in proc_each_breakpoint()
1084 proc_find_symbol(struct process *proc, struct library_symbol *sym, in proc_find_symbol() argument
1091 = proc_each_library(proc, NULL, library_with_key_cb, &lib->key); in proc_find_symbol()
1110 proc_each_symbol(struct process *proc, struct library_symbol *start_after, in proc_each_symbol() argument
1115 for (lib = start_after != NULL ? start_after->lib : proc->libraries; in proc_each_symbol()
1127 NAME(struct process *proc, arch_addr_t addr, \
1134 if (umovebytes(proc, addr, &u.buf, sizeof(u.dst)) \