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"
40 #ifndef OS_HAVE_PROCESS_DATA
42 os_process_init(struct process *proc)
48 os_process_destroy(struct process *proc)
53 os_process_clone(struct process *retp, struct process *proc)
59 os_process_exec(struct process *proc)
65 #ifndef ARCH_HAVE_PROCESS_DATA
67 arch_process_init(struct process *proc)
73 arch_process_destroy(struct process *proc)
78 arch_process_clone(struct process *retp, struct process *proc)
84 arch_process_exec(struct process *proc)
90 #ifndef ARCH_HAVE_DYNLINK_DONE
92 arch_dynlink_done(struct process *proc)
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)
103 #if defined(HAVE_LIBUNWIND)
104 if (proc->unwind_priv != NULL)
105 _UPT_destroy(proc->unwind_priv);
106 if (proc->unwind_as != NULL)
107 unw_destroy_addr_space(proc->unwind_as);
108 #endif /* defined(HAVE_LIBUNWIND) */
110 #if defined(HAVE_LIBDW)
111 if (proc->dwfl != NULL)
112 dwfl_end(proc->dwfl);
113 #endif /* defined(HAVE_LIBDW) */
117 process_bare_init(struct process *proc, const char *filename,
118 pid_t pid, int was_exec)
121 memset(proc, 0, sizeof(*proc));
123 proc->filename = strdup(filename);
124 if (proc->filename == NULL) {
126 free(proc->filename);
127 if (proc->breakpoints != NULL) {
128 dict_destroy(proc->breakpoints,
130 free(proc->breakpoints);
131 proc->breakpoints = NULL;
137 /* Add process so that we know who the leader is. */
139 if (add_process(proc, was_exec) < 0)
141 if (proc->leader == NULL) {
144 unlist_process(proc);
148 if (proc->leader == proc) {
149 proc->breakpoints = malloc(sizeof(*proc->breakpoints));
150 if (proc->breakpoints == NULL)
151 goto unlist_and_fail;
152 DICT_INIT(proc->breakpoints,
153 arch_addr_t, struct breakpoint *,
154 arch_addr_hash, arch_addr_eq, NULL);
156 proc->breakpoints = NULL;
159 #if defined(HAVE_LIBUNWIND)
160 if (options.bt_depth > 0) {
161 proc->unwind_priv = _UPT_create(pid);
162 proc->unwind_as = unw_create_addr_space(&_UPT_accessors, 0);
164 if (proc->unwind_priv == NULL || proc->unwind_as == NULL) {
166 "Couldn't initialize unwinding "
167 "for process %d\n", proc->pid);
168 destroy_unwind(proc);
169 proc->unwind_priv = NULL;
170 proc->unwind_as = NULL;
173 #endif /* defined(HAVE_LIBUNWIND) */
175 #if defined(HAVE_LIBDW)
176 proc->dwfl = NULL; /* Initialize for leader only on first library. */
177 #endif /* defined(HAVE_LIBDW) */
183 process_bare_destroy(struct process *proc, int was_exec)
185 dict_destroy(proc->breakpoints, NULL, NULL, NULL);
186 free(proc->breakpoints);
188 free(proc->filename);
189 unlist_process(proc);
190 destroy_unwind(proc);
195 process_init_main(struct process *proc)
197 if (breakpoints_init(proc) < 0) {
198 fprintf(stderr, "failed to init breakpoints %d\n",
207 process_init(struct process *proc, const char *filename, pid_t pid)
209 if (process_bare_init(proc, filename, pid, 0) < 0) {
211 fprintf(stderr, "failed to initialize process %d: %s\n",
212 pid, strerror(errno));
216 if (os_process_init(proc) < 0) {
217 process_bare_destroy(proc, 0);
221 if (arch_process_init(proc) < 0) {
222 os_process_destroy(proc);
223 process_bare_destroy(proc, 0);
227 if (proc->leader != proc) {
228 proc->e_machine = proc->leader->e_machine;
229 proc->e_class = proc->leader->e_class;
231 } else if (process_init_main(proc) < 0) {
232 process_bare_destroy(proc, 0);
238 static enum callback_status
239 destroy_breakpoint_cb(struct process *proc, struct breakpoint *bp, void *data)
241 breakpoint_destroy(bp);
246 // XXX see comment in handle_event.c
247 void callstack_pop(struct process *proc);
250 private_process_destroy(struct process *proc, int was_exec)
252 /* Pop remaining stack elements. */
253 while (proc->callstack_depth > 0) {
254 /* When this is called just before a process is
255 * destroyed, the breakpoints should either have been
256 * retracted by now, or were killed by exec. In any
257 * case, it's safe to pretend that there are no
258 * breakpoints associated with the stack elements, so
259 * that stack_pop doesn't attempt to destroy them. */
260 size_t i = proc->callstack_depth - 1;
261 if (!proc->callstack[i].is_syscall)
262 proc->callstack[i].return_addr = 0;
268 free(proc->filename);
270 /* Libraries and symbols. This is only relevant in
273 for (lib = proc->libraries; lib != NULL; ) {
274 struct library *next = lib->next;
275 library_destroy(lib);
279 proc->libraries = NULL;
282 if (proc->breakpoints != NULL) {
283 proc_each_breakpoint(proc, NULL, destroy_breakpoint_cb, NULL);
284 dict_destroy(proc->breakpoints, NULL, NULL, NULL);
285 free(proc->breakpoints);
286 proc->breakpoints = NULL;
289 destroy_unwind(proc);
293 process_destroy(struct process *proc)
295 arch_process_destroy(proc);
296 os_process_destroy(proc);
297 private_process_destroy(proc, 0);
301 process_exec(struct process *proc)
303 /* Call exec handlers first, before we destroy the main
305 if (arch_process_exec(proc) < 0
306 || os_process_exec(proc) < 0)
309 private_process_destroy(proc, 1);
311 if (process_bare_init(proc, NULL, proc->pid, 1) < 0)
313 if (process_init_main(proc) < 0) {
314 process_bare_destroy(proc, 1);
321 open_program(const char *filename, pid_t pid)
324 struct process *proc = malloc(sizeof(*proc));
325 if (proc == NULL || process_init(proc, filename, pid) < 0) {
332 struct clone_single_bp_data {
333 struct process *old_proc;
334 struct process *new_proc;
337 static enum callback_status
338 clone_single_bp(arch_addr_t *key, struct breakpoint **bpp, void *u)
340 struct breakpoint *bp = *bpp;
341 struct clone_single_bp_data *data = u;
343 struct breakpoint *clone = malloc(sizeof(*clone));
345 || breakpoint_clone(clone, data->new_proc, bp) < 0) {
350 if (proc_add_breakpoint(data->new_proc->leader, clone) < 0) {
351 breakpoint_destroy(clone);
358 process_clone(struct process *retp, struct process *proc, pid_t pid)
360 if (process_bare_init(retp, proc->filename, pid, 0) < 0) {
362 fprintf(stderr, "Failed to clone process %d to %d: %s\n",
363 proc->pid, pid, strerror(errno));
367 retp->tracesysgood = proc->tracesysgood;
368 retp->e_machine = proc->e_machine;
369 retp->e_class = proc->e_class;
371 /* For non-leader processes, that's all we need to do. */
372 if (retp->leader != retp)
375 /* Clone symbols first so that we can clone and relink
378 struct library **nlibp = &retp->libraries;
379 for (lib = proc->leader->libraries; lib != NULL; lib = lib->next) {
380 *nlibp = malloc(sizeof(**nlibp));
383 || library_clone(*nlibp, lib) < 0) {
388 process_bare_destroy(retp, 0);
390 /* Error when cloning. Unroll what was done. */
391 for (lib = retp->libraries; lib != NULL; ) {
392 struct library *next = lib->next;
393 library_destroy(lib);
400 nlibp = &(*nlibp)->next;
403 /* Now clone breakpoints. Symbol relinking is done in
404 * clone_single_bp. */
405 struct clone_single_bp_data data = {
409 if (DICT_EACH(proc->leader->breakpoints,
410 arch_addr_t, struct breakpoint *, NULL,
411 clone_single_bp, &data) != NULL)
414 /* And finally the call stack. */
415 /* XXX clearly the callstack handling should be moved to a
416 * separate module and this whole business extracted to
417 * callstack_clone, or callstack_element_clone. */
418 memcpy(retp->callstack, proc->callstack, sizeof(retp->callstack));
419 retp->callstack_depth = proc->callstack_depth;
422 for (i = 0; i < retp->callstack_depth; ++i) {
423 struct callstack_element *elem = &retp->callstack[i];
424 struct fetch_context *ctx = elem->fetch_context;
426 struct fetch_context *nctx = fetch_arg_clone(retp, ctx);
430 for (j = 0; j < i; ++j) {
431 nctx = retp->callstack[j].fetch_context;
432 fetch_arg_done(nctx);
433 elem->fetch_context = NULL;
437 elem->fetch_context = nctx;
440 if (elem->arguments != NULL) {
441 struct value_dict *nargs = malloc(sizeof(*nargs));
443 || val_dict_clone(nargs, elem->arguments) < 0) {
445 for (j = 0; j < i; ++j) {
446 nargs = retp->callstack[j].arguments;
447 val_dict_destroy(nargs);
449 elem->arguments = NULL;
452 /* Pretend that this round went well,
453 * so that fail3 frees I-th
458 elem->arguments = nargs;
461 /* If it's not a syscall, we need to find the
462 * corresponding library symbol in the cloned
464 if (!elem->is_syscall && elem->c_un.libfunc != NULL) {
465 struct library_symbol *libfunc = elem->c_un.libfunc;
466 int rc = proc_find_symbol(retp, libfunc,
467 NULL, &elem->c_un.libfunc);
472 /* At this point, retp is fully initialized, except for OS and
473 * arch parts, and we can call private_process_destroy. */
474 if (os_process_clone(retp, proc) < 0) {
475 private_process_destroy(retp, 0);
478 if (arch_process_clone(retp, proc) < 0) {
479 os_process_destroy(retp);
480 private_process_destroy(retp, 0);
488 open_one_pid(pid_t pid)
490 debug(DEBUG_PROCESS, "open_one_pid(pid=%d)", pid);
492 /* Get the filename first. Should the trace_pid fail, we can
493 * easily free it, untracing is more work. */
494 char *filename = pid2name(pid);
495 if (filename == NULL || trace_pid(pid) < 0) {
501 struct process *proc = open_program(filename, pid);
505 trace_set_options(proc);
510 static enum callback_status
511 start_one_pid(struct process *proc, void *data)
513 continue_process(proc->pid);
517 static enum callback_status
518 is_main(struct process *proc, struct library *lib, void *data)
520 return CBS_STOP_IF(lib->type == LT_LIBTYPE_MAIN);
524 process_hit_start(struct process *proc)
526 struct process *leader = proc->leader;
527 assert(leader != NULL);
529 struct library *mainlib
530 = proc_each_library(leader, NULL, is_main, NULL);
531 assert(mainlib != NULL);
532 linkmap_init(leader, mainlib->dyn_addr);
533 arch_dynlink_done(leader);
539 debug(DEBUG_PROCESS, "open_pid(pid=%d)", pid);
540 /* If we are already tracing this guy, we should be seeing all
541 * his children via normal tracing route. */
542 if (pid2proc(pid) != NULL)
545 /* First, see if we can attach the requested PID itself. */
546 if (open_one_pid(pid) < 0) {
547 fprintf(stderr, "Cannot attach to pid %u: %s\n",
548 pid, strerror(errno));
549 trace_fail_warning(pid);
553 /* Now attach to all tasks that belong to that PID. There's a
554 * race between process_tasks and open_one_pid. So when we
555 * fail in open_one_pid below, we just do another round.
556 * Chances are that by then that PID will have gone away, and
557 * that's why we have seen the failure. The processes that we
558 * manage to open_one_pid are stopped, so we should eventually
559 * reach a point where process_tasks doesn't give any new
560 * processes (because there's nobody left to produce
562 size_t old_ntasks = 0;
569 if (process_tasks(pid, &tasks, &ntasks) < 0) {
570 fprintf(stderr, "Cannot obtain tasks of pid %u: %s\n",
571 pid, strerror(errno));
576 for (i = 0; i < ntasks; ++i)
577 if (pid2proc(tasks[i]) == NULL
578 && open_one_pid(tasks[i]) < 0)
583 if (have_all && old_ntasks == ntasks)
588 struct process *leader = pid2proc(pid)->leader;
590 /* XXX Is there a way to figure out whether _start has
591 * actually already been hit? */
592 process_hit_start(leader);
594 /* Done. Continue everyone. */
595 each_task(leader, NULL, start_one_pid, NULL);
598 static enum callback_status
599 find_proc(struct process *proc, void *data)
601 return CBS_STOP_IF(proc->pid == (pid_t)(uintptr_t)data);
607 return each_process(NULL, &find_proc, (void *)(uintptr_t)pid);
610 static struct process *list_of_processes = NULL;
613 unlist_process(struct process *proc)
615 if (list_of_processes == proc) {
616 list_of_processes = list_of_processes->next;
621 for (tmp = list_of_processes; ; tmp = tmp->next) {
622 /* If the following assert fails, the process wasn't
624 assert(tmp->next != NULL);
626 if (tmp->next == proc) {
627 tmp->next = tmp->next->next;
634 each_process(struct process *start_after,
635 enum callback_status(*cb)(struct process *proc, void *data),
638 struct process *it = start_after == NULL ? list_of_processes
642 /* Callback might call remove_process. */
643 struct process *next = it->next;
644 switch ((*cb)(it, data)) {
658 each_task(struct process *proc, struct process *start_after,
659 enum callback_status(*cb)(struct process *proc, void *data),
662 assert(proc != NULL);
663 struct process *it = start_after == NULL ? proc->leader
667 struct process *leader = it->leader;
668 while (it != NULL && it->leader == leader) {
669 /* Callback might call remove_process. */
670 struct process *next = it->next;
671 switch ((*cb)(it, data)) {
686 add_process(struct process *proc, int was_exec)
688 struct process **leaderp = &list_of_processes;
690 pid_t tgid = process_leader(proc->pid);
692 /* Must have been terminated before we managed
693 * to fully attach. */
695 if (tgid == proc->pid) {
698 struct process *leader = pid2proc(tgid);
699 proc->leader = leader;
701 leaderp = &leader->next;
706 proc->next = *leaderp;
713 change_process_leader(struct process *proc, struct process *leader)
715 struct process **leaderp = &list_of_processes;
716 if (proc->leader == leader)
719 assert(leader != NULL);
720 unlist_process(proc);
722 leaderp = &leader->next;
724 proc->leader = leader;
725 proc->next = *leaderp;
729 static enum callback_status
730 clear_leader(struct process *proc, void *data)
732 debug(DEBUG_FUNCTION, "detach_task %d from leader %d",
733 proc->pid, proc->leader->pid);
739 remove_process(struct process *proc)
741 debug(DEBUG_FUNCTION, "remove_proc(pid=%d)", proc->pid);
743 if (proc->leader == proc)
744 each_task(proc, NULL, &clear_leader, NULL);
746 unlist_process(proc);
747 process_removed(proc);
748 process_destroy(proc);
753 install_event_handler(struct process *proc, struct event_handler *handler)
755 debug(DEBUG_FUNCTION, "install_event_handler(pid=%d, %p)", proc->pid, handler);
756 assert(proc->event_handler == NULL);
757 proc->event_handler = handler;
761 destroy_event_handler(struct process *proc)
763 struct event_handler *handler = proc->event_handler;
764 debug(DEBUG_FUNCTION, "destroy_event_handler(pid=%d, %p)", proc->pid, handler);
765 assert(handler != NULL);
766 if (handler->destroy != NULL)
767 handler->destroy(handler);
769 proc->event_handler = NULL;
773 breakpoint_for_symbol(struct library_symbol *libsym, struct process *proc)
776 assert(proc->leader == proc);
778 /* Don't enable latent or delayed symbols. */
779 if (libsym->latent || libsym->delayed) {
780 debug(DEBUG_FUNCTION,
781 "delayed and/or latent breakpoint pid=%d, %s@%p",
782 proc->pid, libsym->name, libsym->enter_addr);
786 bp_addr = sym2addr(proc, libsym);
788 /* If there is an artificial breakpoint on the same address,
789 * its libsym will be NULL, and we can smuggle our libsym
790 * there. That artificial breakpoint is there presumably for
791 * the callbacks, which we don't touch. If there is a real
792 * breakpoint, then this is a bug. ltrace-elf.c should filter
793 * symbols and ignore extra symbol aliases.
795 * The other direction is more complicated and currently not
796 * supported. If a breakpoint has custom callbacks, it might
797 * be also custom-allocated, and we would really need to swap
798 * the two: delete the one now in the dictionary, swap values
799 * around, and put the new breakpoint back in. */
800 struct breakpoint *bp;
801 if (DICT_FIND_VAL(proc->breakpoints, &bp_addr, &bp) == 0) {
802 /* MIPS backend makes duplicate requests. This is
803 * likely a bug in the backend. Currently there's no
804 * point assigning more than one symbol to a
805 * breakpoint, because when it hits, we won't know
806 * what to print out. But it's easier to fix it here
807 * before someone who understands MIPS has the time to
808 * look into it. So turn the sanity check off on
811 * http://lists.alioth.debian.org/pipermail/ltrace-devel/2012-November/000764.html
812 * http://lists.alioth.debian.org/pipermail/ltrace-devel/2012-November/000770.html
815 assert(bp->libsym == NULL);
821 bp = malloc(sizeof(*bp));
823 || breakpoint_init(bp, proc, bp_addr, libsym) < 0) {
828 if (proc_add_breakpoint(proc, bp) < 0) {
829 breakpoint_destroy(bp);
833 if (breakpoint_turn_on(bp, proc) < 0) {
834 proc_remove_breakpoint(proc, bp);
835 breakpoint_destroy(bp);
842 static enum callback_status
843 cb_breakpoint_for_symbol(struct library_symbol *libsym, void *data)
845 return CBS_STOP_IF(breakpoint_for_symbol(libsym, data) < 0);
849 proc_activate_latent_symbol(struct process *proc,
850 struct library_symbol *libsym)
852 assert(libsym->latent);
854 debug(DEBUG_FUNCTION, "activated latent symbol");
855 return breakpoint_for_symbol(libsym, proc);
859 proc_activate_delayed_symbol(struct process *proc,
860 struct library_symbol *libsym)
862 assert(libsym->delayed);
864 debug(DEBUG_FUNCTION, "activated delayed symbol");
865 return breakpoint_for_symbol(libsym, proc);
868 static enum callback_status
869 activate_latent_in(struct process *proc, struct library *lib, void *data)
871 struct library_exported_name *exported;
872 for (exported = data; exported != NULL; exported = exported->next) {
873 struct library_symbol *libsym = NULL;
874 while ((libsym = library_each_symbol(lib, libsym,
875 library_symbol_named_cb,
876 (void *)exported->name))
879 && proc_activate_latent_symbol(proc, libsym) < 0)
886 proc_add_library(struct process *proc, struct library *lib)
888 assert(lib->next == NULL);
889 lib->next = proc->libraries;
890 proc->libraries = lib;
891 debug(DEBUG_PROCESS, "added library %s@%p (%s) to %d",
892 lib->soname, lib->base, lib->pathname, proc->pid);
894 #if defined(HAVE_LIBDW)
895 if (options.bt_depth > 0) {
896 /* Setup module tracking for libdwfl unwinding. */
897 struct process *leader = proc->leader;
898 Dwfl *dwfl = leader->dwfl;
900 static const Dwfl_Callbacks proc_callbacks = {
901 .find_elf = dwfl_linux_proc_find_elf,
902 .find_debuginfo = dwfl_standard_find_debuginfo
904 dwfl = dwfl_begin(&proc_callbacks);
907 "Couldn't initialize libdwfl unwinding "
908 "for process %d: %s\n", leader->pid,
913 dwfl_report_begin_add(dwfl);
914 if (dwfl_report_elf(dwfl, lib->soname,
916 (GElf_Addr) lib->base,
919 "dwfl_report_elf %s@%p (%s) %d: %s\n",
920 lib->soname, lib->base, lib->pathname,
921 proc->pid, dwfl_errmsg (-1));
922 dwfl_report_end(dwfl, NULL, NULL);
924 if (leader->dwfl == NULL) {
925 int r = dwfl_linux_proc_attach(dwfl,
934 msg = dwfl_errmsg(-1);
937 fprintf(stderr, "Couldn't initialize "
938 "libdwfl unwinding for "
945 #endif /* defined(HAVE_LIBDW) */
947 /* Insert breakpoints for all active (non-latent) symbols. */
948 struct library_symbol *libsym = NULL;
949 while ((libsym = library_each_symbol(lib, libsym,
950 cb_breakpoint_for_symbol,
953 "Couldn't insert breakpoint for %s to %d: %s.\n",
954 libsym->name, proc->pid, strerror(errno));
956 /* Look through export list of the new library and compare it
957 * with latent symbols of all libraries (including this
958 * library itself). */
959 struct library *lib2 = NULL;
960 while ((lib2 = proc_each_library(proc, lib2, activate_latent_in,
961 lib->exported_names)) != NULL)
963 "Couldn't activate latent symbols for %s in %d: %s.\n",
964 lib2->soname, proc->pid, strerror(errno));
968 proc_remove_library(struct process *proc, struct library *lib)
970 struct library **libp;
971 for (libp = &proc->libraries; *libp != NULL; libp = &(*libp)->next)
980 proc_each_library(struct process *proc, struct library *it,
981 enum callback_status (*cb)(struct process *proc,
982 struct library *lib, void *data),
986 it = proc->libraries;
991 struct library *next = it->next;
993 switch (cb(proc, it, data)) {
1009 check_leader(struct process *proc)
1011 /* Only the group leader should be getting the breakpoints and
1012 * thus have ->breakpoint initialized. */
1013 assert(proc->leader != NULL);
1014 assert(proc->leader == proc);
1015 assert(proc->breakpoints != NULL);
1019 proc_add_breakpoint(struct process *proc, struct breakpoint *bp)
1021 debug(DEBUG_FUNCTION, "proc_add_breakpoint(pid=%d, %s@%p)",
1022 proc->pid, breakpoint_name(bp), bp->addr);
1025 /* XXX We might merge bp->libsym instead of the following
1026 * assert, but that's not necessary right now. Read the
1027 * comment in breakpoint_for_symbol. */
1028 assert(dict_find(proc->breakpoints, &bp->addr) == NULL);
1030 if (DICT_INSERT(proc->breakpoints, &bp->addr, &bp) < 0) {
1032 "couldn't enter breakpoint %s@%p to dictionary: %s\n",
1033 breakpoint_name(bp), bp->addr, strerror(errno));
1041 proc_remove_breakpoint(struct process *proc, struct breakpoint *bp)
1043 debug(DEBUG_FUNCTION, "proc_remove_breakpoint(pid=%d, %s@%p)",
1044 proc->pid, breakpoint_name(bp), bp->addr);
1046 int rc = DICT_ERASE(proc->breakpoints, &bp->addr, struct breakpoint *,
1051 struct each_breakpoint_data
1053 struct process *proc;
1054 enum callback_status (*cb)(struct process *proc,
1055 struct breakpoint *bp,
1060 static enum callback_status
1061 each_breakpoint_cb(arch_addr_t *key, struct breakpoint **bpp, void *d)
1063 struct each_breakpoint_data *data = d;
1064 return data->cb(data->proc, *bpp, data->cb_data);
1068 proc_each_breakpoint(struct process *proc, arch_addr_t *start,
1069 enum callback_status (*cb)(struct process *proc,
1070 struct breakpoint *bp,
1071 void *data), void *data)
1073 struct each_breakpoint_data dd = {
1078 return DICT_EACH(proc->breakpoints,
1079 arch_addr_t, struct breakpoint *, start,
1080 &each_breakpoint_cb, &dd);
1084 proc_find_symbol(struct process *proc, struct library_symbol *sym,
1085 struct library **retlib, struct library_symbol **retsym)
1087 struct library *lib = sym->lib;
1088 assert(lib != NULL);
1090 struct library *flib
1091 = proc_each_library(proc, NULL, library_with_key_cb, &lib->key);
1095 struct library_symbol *fsym
1096 = library_each_symbol(flib, NULL, library_symbol_named_cb,
1109 struct library_symbol *
1110 proc_each_symbol(struct process *proc, struct library_symbol *start_after,
1111 enum callback_status (*cb)(struct library_symbol *, void *),
1114 struct library *lib;
1115 for (lib = start_after != NULL ? start_after->lib : proc->libraries;
1116 lib != NULL; lib = lib->next) {
1117 start_after = library_each_symbol(lib, start_after, cb, data);
1118 if (start_after != NULL)
1125 #define DEF_READER(NAME, SIZE) \
1127 NAME(struct process *proc, arch_addr_t addr, \
1128 uint##SIZE##_t *lp) \
1131 uint##SIZE##_t dst; \
1134 if (umovebytes(proc, addr, &u.buf, sizeof(u.dst)) \
1141 DEF_READER(proc_read_8, 8)
1142 DEF_READER(proc_read_16, 16)
1143 DEF_READER(proc_read_32, 32)
1144 DEF_READER(proc_read_64, 64)