diff options
-rw-r--r-- | TODO | 14 | ||||
-rw-r--r-- | ltrace.h | 3 | ||||
-rw-r--r-- | process_event.c | 5 | ||||
-rw-r--r-- | sysdeps/linux-gnu/events.c | 3 | ||||
-rw-r--r-- | sysdeps/linux-gnu/trace.c | 17 |
5 files changed, 13 insertions, 29 deletions
@@ -14,17 +14,11 @@ * More architectures, cleaner way to port * More operating systems (solaris?) * Option -I (inter-library calls) -* Modify ARGTYPE_STRING[0-5] types so that they not stop displaying chars when '\0' is encountered +* Modify ARGTYPE_STRING[0-5] types so that they don't stop displaying chars when '\0' is seen * Get rid of EVENT_ARCH_SYSCALL and EVENT_ARCH_SYSRET -* EVENT_FORK, EVENT_CLONE, EVENT_EXEC instead of fork_p() and exec_p() -* If EVENT_FORK is received: - + Add the new process to the list, with a state of "future child of XXX" -* If EVENT_CLONE is received: - + Add the new process to the list, with a state of "future clone of XXX" +* EVENT_EXEC instead of exec_p() * If EVENT_EXEC is received: + Clean structs with breakpoints, open new created program -* If a signal is received from an an unknown process, add it to the list, - with a state of "new process" * Cleaner way to use breakpoints: + BP is placed in the PLT + When control hits there: @@ -42,3 +36,7 @@ without having to remove it * Get rid of GNU's autoconf stuff * List source dependencies in Makefile +* Create different ltrace processes to trace different children +* debug: change "-d" option to be something like "-d elf,events", or "-d breakpoints" +* Find out if a process is sharing memory with its parent? +* When using -p, find out if that process is sharing memory with other processes @@ -161,7 +161,7 @@ enum Process_State { typedef struct Process Process; struct Process { Process_State state; - Process *parent; /* needed by STATE_FUTURE_{FORK,CLONE} */ + Process *parent; /* needed by STATE_BEING_CREATED */ char *filename; pid_t pid; struct dict *breakpoints; @@ -259,7 +259,6 @@ extern void *get_stack_pointer(Process *proc); extern void *get_return_addr(Process *proc, void *stack_pointer); extern void enable_breakpoint(pid_t pid, Breakpoint *sbp); extern void disable_breakpoint(pid_t pid, const Breakpoint *sbp); -extern int fork_p(Process *proc, int sysnum); extern int exec_p(Process *proc, int sysnum); extern int was_exec(Process *proc, int status); extern int syscall_p(Process *proc, int status, int *sysnum); diff --git a/process_event.c b/process_event.c index 94ecaac..3653651 100644 --- a/process_event.c +++ b/process_event.c @@ -131,6 +131,7 @@ process_clone(Event * event) { memcpy(p, event->proc, sizeof(Process)); p->breakpoints = dict_clone(event->proc->breakpoints, address_clone, breakpoint_clone); p->pid = event->e_un.newpid; + p->parent = event->proc; if (pending_new(p->pid)) { pending_new_remove(p->pid); @@ -144,8 +145,10 @@ process_clone(Event * event) { list_of_processes = p; } else { p->state = STATE_BEING_CREATED; + p->next = list_of_processes; + list_of_processes = p; } - /* look for previous process_new() */ + continue_process(event->proc->pid); } static void diff --git a/sysdeps/linux-gnu/events.c b/sysdeps/linux-gnu/events.c index 6dedcc9..dee4fc7 100644 --- a/sysdeps/linux-gnu/events.c +++ b/sysdeps/linux-gnu/events.c @@ -44,8 +44,9 @@ next_event(void) { exit(1); } event.proc = pid2proc(pid); - if (!event.proc) { + if (!event.proc || event.proc->state == STATE_BEING_CREATED) { event.type = EVENT_NEW; + event.e_un.newpid = pid; debug(DEBUG_EVENT, "event: NEW: pid=%d", pid); return &event; } diff --git a/sysdeps/linux-gnu/trace.c b/sysdeps/linux-gnu/trace.c index 0098c1e..1eb06be 100644 --- a/sysdeps/linux-gnu/trace.c +++ b/sysdeps/linux-gnu/trace.c @@ -95,23 +95,6 @@ umovelong (Process *proc, void *addr, long *result, arg_type_info *info) { } #endif - -/* Returns 1 if the sysnum may make a new child to be created - * (ie, with fork() or clone()) - * Returns 0 otherwise. - */ -int -fork_p(Process *proc, int sysnum) { - unsigned int i; - if (proc->personality - >= sizeof fork_exec_syscalls / sizeof(fork_exec_syscalls[0])) - return 0; - for (i = 0; i < sizeof(fork_exec_syscalls[0]) / sizeof(int) - 1; ++i) - if (sysnum == fork_exec_syscalls[proc->personality][i]) - return 1; - return 0; -} - /* Returns 1 if the sysnum may make the process exec other program */ int |