2 * This file is part of ltrace.
3 * Copyright (C) 2011,2012,2013,2014 Petr Machata, Red Hat Inc.
4 * Copyright (C) 2010 Joe Damato
5 * Copyright (C) 1998,2009 Juan Cespedes
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 #include <sys/types.h>
33 #include "breakpoint.h"
38 #include "value_dict.h"
39 #include "dwarf_prototypes.h"
41 #ifndef OS_HAVE_PROCESS_DATA
43 os_process_init(struct process *proc)
49 os_process_destroy(struct process *proc)
54 os_process_clone(struct process *retp, struct process *proc)
60 os_process_exec(struct process *proc)
66 #ifndef ARCH_HAVE_PROCESS_DATA
68 arch_process_init(struct process *proc)
74 arch_process_destroy(struct process *proc)
79 arch_process_clone(struct process *retp, struct process *proc)
85 arch_process_exec(struct process *proc)
91 #ifndef ARCH_HAVE_DYNLINK_DONE
93 arch_dynlink_done(struct process *proc)
98 static int add_process(struct process *proc, int was_exec);
99 static void unlist_process(struct process *proc);
102 destroy_unwind(struct process *proc)
104 #if defined(HAVE_LIBUNWIND)
105 if (proc->unwind_priv != NULL)
106 _UPT_destroy(proc->unwind_priv);
107 if (proc->unwind_as != NULL)
108 unw_destroy_addr_space(proc->unwind_as);
109 #endif /* defined(HAVE_LIBUNWIND) */
111 #if defined(HAVE_LIBDW)
112 if (proc->dwfl != NULL)
113 dwfl_end(proc->dwfl);
114 #endif /* defined(HAVE_LIBDW) */
118 process_bare_init(struct process *proc, const char *filename,
119 pid_t pid, int was_exec)
122 memset(proc, 0, sizeof(*proc));
124 proc->filename = strdup(filename);
125 if (proc->filename == NULL) {
127 free(proc->filename);
128 if (proc->breakpoints != NULL) {
129 dict_destroy(proc->breakpoints,
131 free(proc->breakpoints);
132 proc->breakpoints = NULL;
138 /* Add process so that we know who the leader is. */
140 if (add_process(proc, was_exec) < 0)
142 if (proc->leader == NULL) {
145 unlist_process(proc);
149 if (proc->leader == proc) {
150 proc->breakpoints = malloc(sizeof(*proc->breakpoints));
151 if (proc->breakpoints == NULL)
152 goto unlist_and_fail;
153 DICT_INIT(proc->breakpoints,
154 arch_addr_t, struct breakpoint *,
155 arch_addr_hash, arch_addr_eq, NULL);
157 proc->breakpoints = NULL;
160 #if defined(HAVE_LIBUNWIND)
161 if (options.bt_depth > 0) {
162 proc->unwind_priv = _UPT_create(pid);
163 proc->unwind_as = unw_create_addr_space(&_UPT_accessors, 0);
165 if (proc->unwind_priv == NULL || proc->unwind_as == NULL) {
167 "Couldn't initialize unwinding "
168 "for process %d\n", proc->pid);
169 destroy_unwind(proc);
170 proc->unwind_priv = NULL;
171 proc->unwind_as = NULL;
174 #endif /* defined(HAVE_LIBUNWIND) */
176 #if defined(HAVE_LIBDW)
177 proc->dwfl = NULL; /* Initialize for leader only on first library. */
178 #endif /* defined(HAVE_LIBDW) */
184 process_bare_destroy(struct process *proc, int was_exec)
186 dict_destroy(proc->breakpoints, NULL, NULL, NULL);
187 free(proc->breakpoints);
189 free(proc->filename);
190 unlist_process(proc);
191 destroy_unwind(proc);
196 process_init_main(struct process *proc)
198 if (breakpoints_init(proc) < 0) {
199 fprintf(stderr, "failed to init breakpoints %d\n",
208 process_init(struct process *proc, const char *filename, pid_t pid)
210 if (process_bare_init(proc, filename, pid, 0) < 0) {
212 fprintf(stderr, "failed to initialize process %d: %s\n",
213 pid, strerror(errno));
217 if (os_process_init(proc) < 0) {
218 process_bare_destroy(proc, 0);
222 if (arch_process_init(proc) < 0) {
223 os_process_destroy(proc);
224 process_bare_destroy(proc, 0);
228 if (proc->leader != proc) {
229 proc->e_machine = proc->leader->e_machine;
230 proc->e_class = proc->leader->e_class;
232 } else if (process_init_main(proc) < 0) {
233 process_bare_destroy(proc, 0);
239 static enum callback_status
240 destroy_breakpoint_cb(struct process *proc, struct breakpoint *bp, void *data)
242 breakpoint_destroy(bp);
247 // XXX see comment in handle_event.c
248 void callstack_pop(struct process *proc);
251 private_process_destroy(struct process *proc, int was_exec)
253 /* Pop remaining stack elements. */
254 while (proc->callstack_depth > 0) {
255 /* When this is called just before a process is
256 * destroyed, the breakpoints should either have been
257 * retracted by now, or were killed by exec. In any
258 * case, it's safe to pretend that there are no
259 * breakpoints associated with the stack elements, so
260 * that stack_pop doesn't attempt to destroy them. */
261 size_t i = proc->callstack_depth - 1;
262 if (!proc->callstack[i].is_syscall)
263 proc->callstack[i].return_addr = 0;
269 free(proc->filename);
271 /* Libraries and symbols. This is only relevant in
274 for (lib = proc->libraries; lib != NULL; ) {
275 struct library *next = lib->next;
276 library_destroy(lib);
280 proc->libraries = NULL;
283 if (proc->breakpoints != NULL) {
284 proc_each_breakpoint(proc, NULL, destroy_breakpoint_cb, NULL);
285 dict_destroy(proc->breakpoints, NULL, NULL, NULL);
286 free(proc->breakpoints);
287 proc->breakpoints = NULL;
290 destroy_unwind(proc);
294 process_destroy(struct process *proc)
296 arch_process_destroy(proc);
297 os_process_destroy(proc);
298 private_process_destroy(proc, 0);
302 process_exec(struct process *proc)
304 /* Call exec handlers first, before we destroy the main
306 if (arch_process_exec(proc) < 0
307 || os_process_exec(proc) < 0)
310 private_process_destroy(proc, 1);
312 if (process_bare_init(proc, NULL, proc->pid, 1) < 0)
314 if (process_init_main(proc) < 0) {
315 process_bare_destroy(proc, 1);
322 open_program(const char *filename, pid_t pid)
325 struct process *proc = malloc(sizeof(*proc));
326 if (proc == NULL || process_init(proc, filename, pid) < 0) {
333 struct clone_single_bp_data {
334 struct process *old_proc;
335 struct process *new_proc;
338 static enum callback_status
339 clone_single_bp(arch_addr_t *key, struct breakpoint **bpp, void *u)
341 struct breakpoint *bp = *bpp;
342 struct clone_single_bp_data *data = u;
344 struct breakpoint *clone = malloc(sizeof(*clone));
346 || breakpoint_clone(clone, data->new_proc, bp) < 0) {
351 if (proc_add_breakpoint(data->new_proc->leader, clone) < 0) {
352 breakpoint_destroy(clone);
359 process_clone(struct process *retp, struct process *proc, pid_t pid)
361 if (process_bare_init(retp, proc->filename, pid, 0) < 0) {
363 fprintf(stderr, "Failed to clone process %d to %d: %s\n",
364 proc->pid, pid, strerror(errno));
368 retp->tracesysgood = proc->tracesysgood;
369 retp->e_machine = proc->e_machine;
370 retp->e_class = proc->e_class;
372 /* For non-leader processes, that's all we need to do. */
373 if (retp->leader != retp)
376 /* Clone symbols first so that we can clone and relink
379 struct library **nlibp = &retp->libraries;
380 for (lib = proc->leader->libraries; lib != NULL; lib = lib->next) {
381 *nlibp = malloc(sizeof(**nlibp));
384 || library_clone(*nlibp, lib) < 0) {
389 process_bare_destroy(retp, 0);
391 /* Error when cloning. Unroll what was done. */
392 for (lib = retp->libraries; lib != NULL; ) {
393 struct library *next = lib->next;
394 library_destroy(lib);
401 nlibp = &(*nlibp)->next;
404 /* Now clone breakpoints. Symbol relinking is done in
405 * clone_single_bp. */
406 struct clone_single_bp_data data = {
410 if (DICT_EACH(proc->leader->breakpoints,
411 arch_addr_t, struct breakpoint *, NULL,
412 clone_single_bp, &data) != NULL)
415 /* And finally the call stack. */
416 /* XXX clearly the callstack handling should be moved to a
417 * separate module and this whole business extracted to
418 * callstack_clone, or callstack_element_clone. */
419 memcpy(retp->callstack, proc->callstack, sizeof(retp->callstack));
420 retp->callstack_depth = proc->callstack_depth;
423 for (i = 0; i < retp->callstack_depth; ++i) {
424 struct callstack_element *elem = &retp->callstack[i];
425 struct fetch_context *ctx = elem->fetch_context;
427 struct fetch_context *nctx = fetch_arg_clone(retp, ctx);
431 for (j = 0; j < i; ++j) {
432 nctx = retp->callstack[j].fetch_context;
433 fetch_arg_done(nctx);
434 elem->fetch_context = NULL;
438 elem->fetch_context = nctx;
441 if (elem->arguments != NULL) {
442 struct value_dict *nargs = malloc(sizeof(*nargs));
444 || val_dict_clone(nargs, elem->arguments) < 0) {
446 for (j = 0; j < i; ++j) {
447 nargs = retp->callstack[j].arguments;
448 val_dict_destroy(nargs);
450 elem->arguments = NULL;
453 /* Pretend that this round went well,
454 * so that fail3 frees I-th
459 elem->arguments = nargs;
462 /* If it's not a syscall, we need to find the
463 * corresponding library symbol in the cloned
465 if (!elem->is_syscall && elem->c_un.libfunc != NULL) {
466 struct library_symbol *libfunc = elem->c_un.libfunc;
467 int rc = proc_find_symbol(retp, libfunc,
468 NULL, &elem->c_un.libfunc);
473 /* At this point, retp is fully initialized, except for OS and
474 * arch parts, and we can call private_process_destroy. */
475 if (os_process_clone(retp, proc) < 0) {
476 private_process_destroy(retp, 0);
479 if (arch_process_clone(retp, proc) < 0) {
480 os_process_destroy(retp);
481 private_process_destroy(retp, 0);
489 open_one_pid(pid_t pid)
491 debug(DEBUG_PROCESS, "open_one_pid(pid=%d)", pid);
493 /* Get the filename first. Should the trace_pid fail, we can
494 * easily free it, untracing is more work. */
495 char *filename = pid2name(pid);
496 if (filename == NULL || trace_pid(pid) < 0) {
502 struct process *proc = open_program(filename, pid);
506 trace_set_options(proc);
511 static enum callback_status
512 start_one_pid(struct process *proc, void *data)
514 continue_process(proc->pid);
518 static enum callback_status
519 is_main(struct process *proc, struct library *lib, void *data)
521 return CBS_STOP_IF(lib->type == LT_LIBTYPE_MAIN);
525 process_hit_start(struct process *proc)
527 struct process *leader = proc->leader;
528 assert(leader != NULL);
530 struct library *mainlib
531 = proc_each_library(leader, NULL, is_main, NULL);
532 assert(mainlib != NULL);
533 linkmap_init(leader, mainlib->dyn_addr);
534 arch_dynlink_done(leader);
540 debug(DEBUG_PROCESS, "open_pid(pid=%d)", pid);
541 /* If we are already tracing this guy, we should be seeing all
542 * his children via normal tracing route. */
543 if (pid2proc(pid) != NULL)
546 /* First, see if we can attach the requested PID itself. */
547 if (open_one_pid(pid) < 0) {
548 fprintf(stderr, "Cannot attach to pid %u: %s\n",
549 pid, strerror(errno));
550 trace_fail_warning(pid);
554 /* Now attach to all tasks that belong to that PID. There's a
555 * race between process_tasks and open_one_pid. So when we
556 * fail in open_one_pid below, we just do another round.
557 * Chances are that by then that PID will have gone away, and
558 * that's why we have seen the failure. The processes that we
559 * manage to open_one_pid are stopped, so we should eventually
560 * reach a point where process_tasks doesn't give any new
561 * processes (because there's nobody left to produce
563 size_t old_ntasks = 0;
570 if (process_tasks(pid, &tasks, &ntasks) < 0) {
571 fprintf(stderr, "Cannot obtain tasks of pid %u: %s\n",
572 pid, strerror(errno));
577 for (i = 0; i < ntasks; ++i)
578 if (pid2proc(tasks[i]) == NULL
579 && open_one_pid(tasks[i]) < 0)
584 if (have_all && old_ntasks == ntasks)
589 struct process *leader = pid2proc(pid)->leader;
591 /* XXX Is there a way to figure out whether _start has
592 * actually already been hit? */
593 process_hit_start(leader);
595 /* Done. Continue everyone. */
596 each_task(leader, NULL, start_one_pid, NULL);
599 static enum callback_status
600 find_proc(struct process *proc, void *data)
602 return CBS_STOP_IF(proc->pid == (pid_t)(uintptr_t)data);
608 return each_process(NULL, &find_proc, (void *)(uintptr_t)pid);
611 static struct process *list_of_processes = NULL;
614 unlist_process(struct process *proc)
616 if (list_of_processes == proc) {
617 list_of_processes = list_of_processes->next;
622 for (tmp = list_of_processes; ; tmp = tmp->next) {
623 /* If the following assert fails, the process wasn't
625 assert(tmp->next != NULL);
627 if (tmp->next == proc) {
628 tmp->next = tmp->next->next;
635 each_process(struct process *start_after,
636 enum callback_status(*cb)(struct process *proc, void *data),
639 struct process *it = start_after == NULL ? list_of_processes
643 /* Callback might call remove_process. */
644 struct process *next = it->next;
645 switch ((*cb)(it, data)) {
659 each_task(struct process *proc, struct process *start_after,
660 enum callback_status(*cb)(struct process *proc, void *data),
663 assert(proc != NULL);
664 struct process *it = start_after == NULL ? proc->leader
668 struct process *leader = it->leader;
669 while (it != NULL && it->leader == leader) {
670 /* Callback might call remove_process. */
671 struct process *next = it->next;
672 switch ((*cb)(it, data)) {
687 add_process(struct process *proc, int was_exec)
689 struct process **leaderp = &list_of_processes;
691 pid_t tgid = process_leader(proc->pid);
693 /* Must have been terminated before we managed
694 * to fully attach. */
696 if (tgid == proc->pid) {
699 struct process *leader = pid2proc(tgid);
700 proc->leader = leader;
702 leaderp = &leader->next;
707 proc->next = *leaderp;
714 change_process_leader(struct process *proc, struct process *leader)
716 struct process **leaderp = &list_of_processes;
717 if (proc->leader == leader)
720 assert(leader != NULL);
721 unlist_process(proc);
723 leaderp = &leader->next;
725 proc->leader = leader;
726 proc->next = *leaderp;
730 static enum callback_status
731 clear_leader(struct process *proc, void *data)
733 debug(DEBUG_FUNCTION, "detach_task %d from leader %d",
734 proc->pid, proc->leader->pid);
740 remove_process(struct process *proc)
742 debug(DEBUG_FUNCTION, "remove_proc(pid=%d)", proc->pid);
744 if (proc->leader == proc)
745 each_task(proc, NULL, &clear_leader, NULL);
747 unlist_process(proc);
748 process_removed(proc);
749 process_destroy(proc);
754 install_event_handler(struct process *proc, struct event_handler *handler)
756 debug(DEBUG_FUNCTION, "install_event_handler(pid=%d, %p)", proc->pid, handler);
757 assert(proc->event_handler == NULL);
758 proc->event_handler = handler;
762 destroy_event_handler(struct process *proc)
764 struct event_handler *handler = proc->event_handler;
765 debug(DEBUG_FUNCTION, "destroy_event_handler(pid=%d, %p)", proc->pid, handler);
766 assert(handler != NULL);
767 if (handler->destroy != NULL)
768 handler->destroy(handler);
770 proc->event_handler = NULL;
774 breakpoint_for_symbol(struct library_symbol *libsym, struct process *proc)
777 assert(proc->leader == proc);
779 /* Don't enable latent or delayed symbols. */
780 if (libsym->latent || libsym->delayed) {
781 debug(DEBUG_FUNCTION,
782 "delayed and/or latent breakpoint pid=%d, %s@%p",
783 proc->pid, libsym->name, libsym->enter_addr);
787 bp_addr = sym2addr(proc, libsym);
789 /* If there is an artificial breakpoint on the same address,
790 * its libsym will be NULL, and we can smuggle our libsym
791 * there. That artificial breakpoint is there presumably for
792 * the callbacks, which we don't touch. If there is a real
793 * breakpoint, then this is a bug. ltrace-elf.c should filter
794 * symbols and ignore extra symbol aliases.
796 * The other direction is more complicated and currently not
797 * supported. If a breakpoint has custom callbacks, it might
798 * be also custom-allocated, and we would really need to swap
799 * the two: delete the one now in the dictionary, swap values
800 * around, and put the new breakpoint back in. */
801 struct breakpoint *bp;
802 if (DICT_FIND_VAL(proc->breakpoints, &bp_addr, &bp) == 0) {
803 /* MIPS backend makes duplicate requests. This is
804 * likely a bug in the backend. Currently there's no
805 * point assigning more than one symbol to a
806 * breakpoint, because when it hits, we won't know
807 * what to print out. But it's easier to fix it here
808 * before someone who understands MIPS has the time to
809 * look into it. So turn the sanity check off on
812 * http://lists.alioth.debian.org/pipermail/ltrace-devel/2012-November/000764.html
813 * http://lists.alioth.debian.org/pipermail/ltrace-devel/2012-November/000770.html
816 assert(bp->libsym == NULL);
822 bp = malloc(sizeof(*bp));
824 || breakpoint_init(bp, proc, bp_addr, libsym) < 0) {
829 if (proc_add_breakpoint(proc, bp) < 0) {
830 breakpoint_destroy(bp);
834 if (breakpoint_turn_on(bp, proc) < 0) {
835 proc_remove_breakpoint(proc, bp);
836 breakpoint_destroy(bp);
843 static enum callback_status
844 cb_breakpoint_for_symbol(struct library_symbol *libsym, void *data)
846 return CBS_STOP_IF(breakpoint_for_symbol(libsym, data) < 0);
850 proc_activate_latent_symbol(struct process *proc,
851 struct library_symbol *libsym)
853 assert(libsym->latent);
855 debug(DEBUG_FUNCTION, "activated latent symbol");
856 return breakpoint_for_symbol(libsym, proc);
860 proc_activate_delayed_symbol(struct process *proc,
861 struct library_symbol *libsym)
863 assert(libsym->delayed);
865 debug(DEBUG_FUNCTION, "activated delayed symbol");
866 return breakpoint_for_symbol(libsym, proc);
869 static enum callback_status
870 activate_latent_in(struct process *proc, struct library *lib, void *data)
872 struct library_exported_name *exported;
873 for (exported = data; exported != NULL; exported = exported->next) {
874 struct library_symbol *libsym = NULL;
875 while ((libsym = library_each_symbol(lib, libsym,
876 library_symbol_named_cb,
877 (void *)exported->name))
880 && proc_activate_latent_symbol(proc, libsym) < 0)
887 proc_add_library(struct process *proc, struct library *lib)
889 assert(lib->next == NULL);
890 lib->next = proc->libraries;
891 proc->libraries = lib;
892 debug(DEBUG_PROCESS, "added library %s@%p (%s) to %d",
893 lib->soname, lib->base, lib->pathname, proc->pid);
895 #if defined(HAVE_LIBDW)
898 /* Setup module tracking for libdwfl unwinding. */
899 struct process *leader = proc->leader;
902 static const Dwfl_Callbacks proc_callbacks = {
903 .find_elf = dwfl_linux_proc_find_elf,
904 .find_debuginfo = dwfl_standard_find_debuginfo
906 dwfl = dwfl_begin(&proc_callbacks);
909 "Couldn't initialize libdwfl unwinding "
910 "for process %d: %s\n", leader->pid,
915 dwfl_report_begin_add(dwfl);
916 if (dwfl_report_elf(dwfl, lib->soname,
918 (GElf_Addr) lib->base,
921 "dwfl_report_elf %s@%p (%s) %d: %s\n",
922 lib->soname, lib->base, lib->pathname,
923 proc->pid, dwfl_errmsg (-1));
924 dwfl_report_end(dwfl, NULL, NULL);
926 if (options.bt_depth > 0) {
927 if (leader->dwfl == NULL) {
928 int r = dwfl_linux_proc_attach(dwfl,
937 msg = dwfl_errmsg(-1);
940 fprintf(stderr, "Couldn't initialize "
941 "libdwfl (unwinding, prototype "
942 "import) for process %d: %s\n",
951 #endif /* defined(HAVE_LIBDW) */
953 /* Insert breakpoints for all active (non-latent) symbols. */
954 struct library_symbol *libsym = NULL;
955 while ((libsym = library_each_symbol(lib, libsym,
956 cb_breakpoint_for_symbol,
959 "Couldn't insert breakpoint for %s to %d: %s.\n",
960 libsym->name, proc->pid, strerror(errno));
962 /* Look through export list of the new library and compare it
963 * with latent symbols of all libraries (including this
964 * library itself). */
965 struct library *lib2 = NULL;
966 while ((lib2 = proc_each_library(proc, lib2, activate_latent_in,
967 lib->exported_names)) != NULL)
969 "Couldn't activate latent symbols for %s in %d: %s.\n",
970 lib2->soname, proc->pid, strerror(errno));
974 proc_remove_library(struct process *proc, struct library *lib)
976 struct library **libp;
977 for (libp = &proc->libraries; *libp != NULL; libp = &(*libp)->next)
986 proc_each_library(struct process *proc, struct library *it,
987 enum callback_status (*cb)(struct process *proc,
988 struct library *lib, void *data),
992 it = proc->libraries;
997 struct library *next = it->next;
999 switch (cb(proc, it, data)) {
1015 check_leader(struct process *proc)
1017 /* Only the group leader should be getting the breakpoints and
1018 * thus have ->breakpoint initialized. */
1019 assert(proc->leader != NULL);
1020 assert(proc->leader == proc);
1021 assert(proc->breakpoints != NULL);
1025 proc_add_breakpoint(struct process *proc, struct breakpoint *bp)
1027 debug(DEBUG_FUNCTION, "proc_add_breakpoint(pid=%d, %s@%p)",
1028 proc->pid, breakpoint_name(bp), bp->addr);
1031 /* XXX We might merge bp->libsym instead of the following
1032 * assert, but that's not necessary right now. Read the
1033 * comment in breakpoint_for_symbol. */
1034 assert(dict_find(proc->breakpoints, &bp->addr) == NULL);
1036 if (DICT_INSERT(proc->breakpoints, &bp->addr, &bp) < 0) {
1038 "couldn't enter breakpoint %s@%p to dictionary: %s\n",
1039 breakpoint_name(bp), bp->addr, strerror(errno));
1047 proc_remove_breakpoint(struct process *proc, struct breakpoint *bp)
1049 debug(DEBUG_FUNCTION, "proc_remove_breakpoint(pid=%d, %s@%p)",
1050 proc->pid, breakpoint_name(bp), bp->addr);
1052 int rc = DICT_ERASE(proc->breakpoints, &bp->addr, struct breakpoint *,
1057 struct each_breakpoint_data
1059 struct process *proc;
1060 enum callback_status (*cb)(struct process *proc,
1061 struct breakpoint *bp,
1066 static enum callback_status
1067 each_breakpoint_cb(arch_addr_t *key, struct breakpoint **bpp, void *d)
1069 struct each_breakpoint_data *data = d;
1070 return data->cb(data->proc, *bpp, data->cb_data);
1074 proc_each_breakpoint(struct process *proc, arch_addr_t *start,
1075 enum callback_status (*cb)(struct process *proc,
1076 struct breakpoint *bp,
1077 void *data), void *data)
1079 struct each_breakpoint_data dd = {
1084 return DICT_EACH(proc->breakpoints,
1085 arch_addr_t, struct breakpoint *, start,
1086 &each_breakpoint_cb, &dd);
1090 proc_find_symbol(struct process *proc, struct library_symbol *sym,
1091 struct library **retlib, struct library_symbol **retsym)
1093 struct library *lib = sym->lib;
1094 assert(lib != NULL);
1096 struct library *flib
1097 = proc_each_library(proc, NULL, library_with_key_cb, &lib->key);
1101 struct library_symbol *fsym
1102 = library_each_symbol(flib, NULL, library_symbol_named_cb,
1115 struct library_symbol *
1116 proc_each_symbol(struct process *proc, struct library_symbol *start_after,
1117 enum callback_status (*cb)(struct library_symbol *, void *),
1120 struct library *lib;
1121 for (lib = start_after != NULL ? start_after->lib : proc->libraries;
1122 lib != NULL; lib = lib->next) {
1123 start_after = library_each_symbol(lib, start_after, cb, data);
1124 if (start_after != NULL)
1131 #define DEF_READER(NAME, SIZE) \
1133 NAME(struct process *proc, arch_addr_t addr, \
1134 uint##SIZE##_t *lp) \
1137 uint##SIZE##_t dst; \
1140 if (umovebytes(proc, addr, &u.buf, sizeof(u.dst)) \
1147 DEF_READER(proc_read_8, 8)
1148 DEF_READER(proc_read_16, 16)
1149 DEF_READER(proc_read_32, 32)
1150 DEF_READER(proc_read_64, 64)