proc.h revision 6d8aa0bba1fb9473f6e92738975f6be73a6ac722
12b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata/* 22b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * This file is part of ltrace. 32b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * Copyright (C) 2010,2011,2012 Petr Machata, Red Hat Inc. 42b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * Copyright (C) 2010 Joe Damato 52b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * Copyright (C) 1998,2001,2008,2009 Juan Cespedes 62b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * 72b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * This program is free software; you can redistribute it and/or 82b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * modify it under the terms of the GNU General Public License as 92b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * published by the Free Software Foundation; either version 2 of the 102b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * License, or (at your option) any later version. 112b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * 122b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * This program is distributed in the hope that it will be useful, but 132b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * WITHOUT ANY WARRANTY; without even the implied warranty of 142b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 152b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * General Public License for more details. 162b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * 172b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * You should have received a copy of the GNU General Public License 182b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * along with this program; if not, write to the Free Software 192b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 202b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * 02110-1301 USA 212b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata */ 222b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata 23366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata#ifndef _PROC_H_ 24366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata#define _PROC_H_ 25366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 268a568dd4ad368d37c059ec9c8da0e894417a27d9Petr Machata#include "config.h" 278a568dd4ad368d37c059ec9c8da0e894417a27d9Petr Machata 28d2c5dfdf0c746bb0d0365505577461f0058aedf9Andrey Zonov#include <sys/time.h> 29d2c5dfdf0c746bb0d0365505577461f0058aedf9Andrey Zonov 30366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata#if defined(HAVE_LIBUNWIND) 31366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata# include <libunwind.h> 32366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata#endif /* defined(HAVE_LIBUNWIND) */ 33366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 34366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata#include "ltrace.h" 35366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata#include "dict.h" 36744f255ed0d676896dbe2f326b9c353c56438f0aPetr Machata#include "sysdep.h" 37a24021c5abfa8c2482e3224f14ac191cd0826a8fPetr Machata#include "callback.h" 386d8aa0bba1fb9473f6e92738975f6be73a6ac722Petr Machata#include "forward.h" 392b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata 40366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machatastruct event_handler { 41366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata /* Event handler that overrides the default one. Should 42366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata * return NULL if the event was handled, otherwise the 43366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata * returned event is passed to the default handler. */ 44366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata Event *(*on_event)(struct event_handler *self, Event *event); 45366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 46366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata /* Called when the event handler removal is requested. */ 47366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata void (*destroy)(struct event_handler *self); 48366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata}; 49366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 50366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machataenum process_state { 51366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata STATE_ATTACHED = 0, 52366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata STATE_BEING_CREATED, 53366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata STATE_IGNORED /* ignore this process (it's a fork and no -f was used) */ 54366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata}; 55366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 56f6ec08afb96292fd3c802c1f633d8de249664c72Petr Machatastruct output_state { 57f6ec08afb96292fd3c802c1f633d8de249664c72Petr Machata size_t params_left; 58f6ec08afb96292fd3c802c1f633d8de249664c72Petr Machata int need_delim; 59f6ec08afb96292fd3c802c1f633d8de249664c72Petr Machata}; 60f6ec08afb96292fd3c802c1f633d8de249664c72Petr Machata 61366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machatastruct callstack_element { 62366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata union { 63366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata int syscall; 64366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata struct library_symbol * libfunc; 65366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata } c_un; 66366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata int is_syscall; 67366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata void * return_addr; 68366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata struct timeval time_spent; 69f6ec08afb96292fd3c802c1f633d8de249664c72Petr Machata struct fetch_context *fetch_context; 7094078ecce3a103c28457e6f90f1e5b0dacc61146Petr Machata struct value_dict *arguments; 71f6ec08afb96292fd3c802c1f633d8de249664c72Petr Machata struct output_state out; 72366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata}; 73366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 74366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata/* XXX We should get rid of this. */ 75366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata#define MAX_CALLDEPTH 64 76366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 77366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata/* XXX We would rather have this all organized a little differently, 78366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata * have Process for the whole group and Task for what's there for 79366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata * per-thread stuff. But for now this is the less invasive way of 80366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata * structuring it. */ 81fd43ef7bb48260aadd4d8335371f75015e680108Petr Machatatypedef struct Process Process; 82366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machatastruct Process { 83366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata enum process_state state; 84366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata Process * parent; /* needed by STATE_BEING_CREATED */ 85366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata char * filename; 86366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata pid_t pid; 87366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 88366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata /* Dictionary of breakpoints (which is a mapping 89366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata * address->breakpoint). This is NULL for non-leader 90ecb082f480f057dc166c9d62e8776c892caf5e11Petr Machata * processes. XXX note that we store addresses (keys) by 91bac2da505ee174b7fb984b975c5938f88f0dbab2Petr Machata * value. That assumes that arch_addr_t fits in host 92ecb082f480f057dc166c9d62e8776c892caf5e11Petr Machata * pointer. */ 93366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata Dict * breakpoints; 94366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 95366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata int mask_32bit; /* 1 if 64-bit ltrace is tracing 32-bit process */ 96366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata unsigned int personality; 97366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata int tracesysgood; /* signal indicating a PTRACE_SYSCALL trap */ 98366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 99ba1664b062414481d0f37d06bb01a19874c8d481Petr Machata size_t callstack_depth; 100366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata struct callstack_element callstack[MAX_CALLDEPTH]; 10176dd9290bd760f363a6f39db06020e61e3f7b345Petr Machata 10276dd9290bd760f363a6f39db06020e61e3f7b345Petr Machata /* Linked list of libraries in backwards order of mapping. 10376dd9290bd760f363a6f39db06020e61e3f7b345Petr Machata * The last element is the executed binary itself. */ 1042b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata struct library *libraries; 105366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 106366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata /* Arch-dependent: */ 107366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata void * instruction_pointer; 108366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata void * stack_pointer; /* To get return addr, args... */ 109366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata void * return_addr; 110366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata void * arch_ptr; 1114d4e1b853db0c97b7c7f023bc301e3c3eee58ce4Petr Machata 1124d4e1b853db0c97b7c7f023bc301e3c3eee58ce4Petr Machata /* XXX We would like to replace this with a pointer to ABI 1134d4e1b853db0c97b7c7f023bc301e3c3eee58ce4Petr Machata * object that would provide the relevant services, instead of 1144d4e1b853db0c97b7c7f023bc301e3c3eee58ce4Petr Machata * checking the necessary flags in the back end ad 1154d4e1b853db0c97b7c7f023bc301e3c3eee58ce4Petr Machata * nauseam. */ 116366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata short e_machine; 1174d4e1b853db0c97b7c7f023bc301e3c3eee58ce4Petr Machata char e_class; 1184d4e1b853db0c97b7c7f023bc301e3c3eee58ce4Petr Machata 1194d4e1b853db0c97b7c7f023bc301e3c3eee58ce4Petr Machata /* XXX this shoudl go to ARM's arch_process_data. */ 120366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata#ifdef __arm__ 121366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata int thumb_mode; /* ARM execution mode: 0: ARM, 1: Thumb */ 122366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata#endif 123366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 124366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata#if defined(HAVE_LIBUNWIND) 125366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata /* libunwind address space */ 126366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata unw_addr_space_t unwind_as; 127366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata void *unwind_priv; 128366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata#endif /* defined(HAVE_LIBUNWIND) */ 129366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 130366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata /* Set in leader. */ 131366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata struct event_handler *event_handler; 132366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 133366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata /** 134366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata * Process chaining. 135366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata **/ 136366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata Process * next; 137366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 138366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata /* LEADER points to the leader thread of the POSIX.1 process. 139366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata If X->LEADER == X, then X is the leader thread and the 140366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata Process structures chained by NEXT represent other threads, 141366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata up until, but not including, the next leader thread. 142366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata LEADER may be NULL after the leader has already exited. In 143366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata that case this process is waiting to be collected. */ 144366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata Process * leader; 145744f255ed0d676896dbe2f326b9c353c56438f0aPetr Machata 1460f6e6d9861ce790cb8b7d07aca28a5878d705359Petr Machata struct os_process_data os; 147744f255ed0d676896dbe2f326b9c353c56438f0aPetr Machata struct arch_process_data arch; 148366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata}; 149366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 15075934ad3b30790f6a892069576d0790a351ef101Petr Machata/* Initialize a process given a path to binary FILENAME, with a PID, 15175934ad3b30790f6a892069576d0790a351ef101Petr Machata * and add the process to an internal chain of traced processes. */ 15275934ad3b30790f6a892069576d0790a351ef101Petr Machataint process_init(struct Process *proc, const char *filename, pid_t pid); 1532b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata 1543d0c91c0c7b425e2866f9c65f655d399693328a5Petr Machata/* PROC underwent an exec. This is a bit like process_destroy 1553d0c91c0c7b425e2866f9c65f655d399693328a5Petr Machata * followed by process_init, except that some state is kept and the 1563d0c91c0c7b425e2866f9c65f655d399693328a5Petr Machata * process doesn't lose it's place in the list of processes. */ 1573d0c91c0c7b425e2866f9c65f655d399693328a5Petr Machataint process_exec(struct Process *proc); 1583d0c91c0c7b425e2866f9c65f655d399693328a5Petr Machata 1593d0c91c0c7b425e2866f9c65f655d399693328a5Petr Machata/* Release any memory allocated for PROC (but not PROC itself). Does 1603d0c91c0c7b425e2866f9c65f655d399693328a5Petr Machata * NOT remove PROC from internal chain. 1613d0c91c0c7b425e2866f9c65f655d399693328a5Petr Machata * 1623d0c91c0c7b425e2866f9c65f655d399693328a5Petr Machata * XXX clearly this init/destroy pair is different than others and 1633d0c91c0c7b425e2866f9c65f655d399693328a5Petr Machata * should be fixed. process_init should presumably be separate from 1643d0c91c0c7b425e2866f9c65f655d399693328a5Petr Machata * process_add. */ 1653d0c91c0c7b425e2866f9c65f655d399693328a5Petr Machatavoid process_destroy(struct Process *proc); 1663d0c91c0c7b425e2866f9c65f655d399693328a5Petr Machata 16775934ad3b30790f6a892069576d0790a351ef101Petr Machatastruct Process *open_program(const char *filename, pid_t pid); 168366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machatavoid open_pid(pid_t pid); 169366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr MachataProcess * pid2proc(pid_t pid); 1702b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata 1712b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata/* Clone the contents of PROC into the memory referenced by RETP. 1722b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * Returns 0 on success or a negative value on failure. */ 1732b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machataint process_clone(struct Process *retp, struct Process *proc, pid_t pid); 1742b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata 175a24021c5abfa8c2482e3224f14ac191cd0826a8fPetr Machata/* Iterate through the processes that ltrace currently traces. Tasks 176a24021c5abfa8c2482e3224f14ac191cd0826a8fPetr Machata * are considered to be processes for the purpose of this iterator. 177a24021c5abfa8c2482e3224f14ac191cd0826a8fPetr Machata * See callback.h for notes on iteration interfaces. */ 17874132a447b18c588c698ecfb8cf4ad4b16360f2fPetr MachataProcess *each_process(Process *start_after, 1792b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata enum callback_status (*cb)(struct Process *proc, 1802b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata void *data), 181366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata void *data); 1822b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata 183a24021c5abfa8c2482e3224f14ac191cd0826a8fPetr Machata/* Iterate through list of tasks of given process PROC. See 184a24021c5abfa8c2482e3224f14ac191cd0826a8fPetr Machata * callback.h for notes on iteration interfaces. */ 18574132a447b18c588c698ecfb8cf4ad4b16360f2fPetr MachataProcess *each_task(struct Process *proc, struct Process *start_after, 1862b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata enum callback_status (*cb)(struct Process *proc, 1872b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata void *data), 188366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata void *data); 1892b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata 190366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machatavoid change_process_leader(Process *proc, Process *leader); 191fd2641c0d27705c89d224e3205b1296110b6598cPetr Machata 192fd2641c0d27705c89d224e3205b1296110b6598cPetr Machata/* Remove process from the list of traced processes, drop any events 193fd2641c0d27705c89d224e3205b1296110b6598cPetr Machata * in the event queue, destroy it and free memory. */ 194fd2641c0d27705c89d224e3205b1296110b6598cPetr Machatavoid remove_process(struct Process *proc); 195fd2641c0d27705c89d224e3205b1296110b6598cPetr Machata 196366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machatavoid install_event_handler(Process *proc, struct event_handler *handler); 197366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machatavoid destroy_event_handler(Process *proc); 198366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata 1992b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata/* Add a library LIB to the list of PROC's libraries. */ 2002b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machatavoid proc_add_library(struct Process *proc, struct library *lib); 2012b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata 2022b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata/* Remove LIB from list of PROC's libraries. Returns 0 if the library 2032b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata * was found and unlinked, otherwise returns a negative value. */ 2042b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machataint proc_remove_library(struct Process *proc, struct library *lib); 2052b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata 206ef2fd27a347bbb0e7cca7fdee97422f6ae4d4bdaPetr Machata/* Clear a delayed flag. If a symbol is neither latent, nor delayed, 207ef2fd27a347bbb0e7cca7fdee97422f6ae4d4bdaPetr Machata * a breakpoint is inserted for it. Returns 0 if the activation was 208ef2fd27a347bbb0e7cca7fdee97422f6ae4d4bdaPetr Machata * successful or a negative value if it failed. Note that if a symbol 209ef2fd27a347bbb0e7cca7fdee97422f6ae4d4bdaPetr Machata * is both latent and delayed, this will not enable the corresponding 210ef2fd27a347bbb0e7cca7fdee97422f6ae4d4bdaPetr Machata * breakpoint. */ 211ef2fd27a347bbb0e7cca7fdee97422f6ae4d4bdaPetr Machataint proc_activate_delayed_symbol(struct Process *proc, 212ef2fd27a347bbb0e7cca7fdee97422f6ae4d4bdaPetr Machata struct library_symbol *libsym); 213ef2fd27a347bbb0e7cca7fdee97422f6ae4d4bdaPetr Machata 214a24021c5abfa8c2482e3224f14ac191cd0826a8fPetr Machata/* Iterate through the libraries of PROC. See callback.h for notes on 215a24021c5abfa8c2482e3224f14ac191cd0826a8fPetr Machata * iteration interfaces. */ 2162b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machatastruct library *proc_each_library(struct Process *proc, struct library *start, 2172b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata enum callback_status (*cb)(struct Process *p, 2182b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata struct library *l, 2192b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata void *data), 2202b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata void *data); 2212b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata 22252dbfb161efeab85bddc880966db2f7af9b9cf9aPetr Machata/* Insert BP into PROC. */ 22352dbfb161efeab85bddc880966db2f7af9b9cf9aPetr Machataint proc_add_breakpoint(struct Process *proc, struct breakpoint *bp); 22452dbfb161efeab85bddc880966db2f7af9b9cf9aPetr Machata 225f7fee43f72667f453bba5aaeea6b5490ece6792aPetr Machata/* Remove BP from PROC. This has no reason to fail in runtime. If it 226f7fee43f72667f453bba5aaeea6b5490ece6792aPetr Machata * does not find BP in PROC, it's hard error guarded by assertion. */ 227f7fee43f72667f453bba5aaeea6b5490ece6792aPetr Machatavoid proc_remove_breakpoint(struct Process *proc, struct breakpoint *bp); 2282b46cfc1127d390eddd9593fe5ce5399c1f68130Petr Machata 229a24021c5abfa8c2482e3224f14ac191cd0826a8fPetr Machata/* Iterate through the breakpoints of PROC. See callback.h for notes 230a24021c5abfa8c2482e3224f14ac191cd0826a8fPetr Machata * on iteration interfaces. */ 231d3cc9889fdfe2e523e99ca5f664f8ae4b3936612Petr Machatavoid *proc_each_breakpoint(struct Process *proc, void *start, 232d3cc9889fdfe2e523e99ca5f664f8ae4b3936612Petr Machata enum callback_status (*cb)(struct Process *proc, 233d3cc9889fdfe2e523e99ca5f664f8ae4b3936612Petr Machata struct breakpoint *bp, 234d3cc9889fdfe2e523e99ca5f664f8ae4b3936612Petr Machata void *data), 235d3cc9889fdfe2e523e99ca5f664f8ae4b3936612Petr Machata void *data); 236d3cc9889fdfe2e523e99ca5f664f8ae4b3936612Petr Machata 237cc77b0e0e735d598f4bc746f8e79b6cd342bd606Edgar E. Iglesias/* Iterate through the dynamic section at src_addr looking for D_TAG. 238cc77b0e0e735d598f4bc746f8e79b6cd342bd606Edgar E. Iglesias * If tag is found, fill it's value in RET and return 0. 239cc77b0e0e735d598f4bc746f8e79b6cd342bd606Edgar E. Iglesias * If tag is not found, return a negative value. */ 240cc77b0e0e735d598f4bc746f8e79b6cd342bd606Edgar E. Iglesiasint proc_find_dynamic_entry_addr(struct Process *proc, arch_addr_t src_addr, 241cc77b0e0e735d598f4bc746f8e79b6cd342bd606Edgar E. Iglesias int d_tag, arch_addr_t *ret); 242165b566a50b2bd560af3bd9649e456915397066bPetr Machata 243165b566a50b2bd560af3bd9649e456915397066bPetr Machata/* Finds a symbol corresponding to LIBSYM in a process PROC. Returns 244165b566a50b2bd560af3bd9649e456915397066bPetr Machata * 0 and sets *RETLIB and *RETSYM if the corresponding pointer is 245165b566a50b2bd560af3bd9649e456915397066bPetr Machata * non-NULL. Returns a negative value when the symbols couldn't be 246165b566a50b2bd560af3bd9649e456915397066bPetr Machata * found. */ 247165b566a50b2bd560af3bd9649e456915397066bPetr Machataint proc_find_symbol(struct Process *proc, struct library_symbol *sym, 248165b566a50b2bd560af3bd9649e456915397066bPetr Machata struct library **retlib, struct library_symbol **retsym); 249165b566a50b2bd560af3bd9649e456915397066bPetr Machata 250366c2f46d844f040458df9b7e35fc3b8527ed2d3Petr Machata#endif /* _PROC_H_ */ 251