diff options
author | Petr Machata <pmachata@redhat.com> | 2012-02-07 16:41:03 +0100 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2012-04-19 00:52:21 +0200 |
commit | 61196a4a81e77322bf1f3dc609007f5d35a5103a (patch) | |
tree | 918d0a01a58b3807eaea360516b990093cd1cd03 | |
parent | 02648a119092bb5b64918063521237f257283c72 (diff) | |
download | ltrace-61196a4a81e77322bf1f3dc609007f5d35a5103a.tar.gz |
Drop Process::breakpoints_enabled
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | breakpoints.c | 98 | ||||
-rw-r--r-- | common.h | 1 | ||||
-rw-r--r-- | proc.c | 8 | ||||
-rw-r--r-- | sysdeps/linux-gnu/events.c | 2 |
5 files changed, 55 insertions, 60 deletions
@@ -7,6 +7,12 @@ 2012-02-07 Petr Machata <pmachata@redhat.com> + * common.h (struct Process.breakpoints_enabled): Drop. + * breakpoints.c, proc.c: Drop uses of breakpoints_enabled. + * sysdeps/linux-gnu/events.c: Likewise. + +2012-02-07 Petr Machata <pmachata@redhat.com> + * breakpoint.h (struct bp_callbacks): New structure. (struct breakpoint.cbs): New field of above type. (breakpoint_on_hit, breakpoint_on_destroy): New interfaces. diff --git a/breakpoints.c b/breakpoints.c index bb257ed..7876756 100644 --- a/breakpoints.c +++ b/breakpoints.c @@ -124,60 +124,57 @@ enable_bp_cb(void *addr, void *sbp, void *proc) void enable_all_breakpoints(Process *proc) { debug(DEBUG_FUNCTION, "enable_all_breakpoints(pid=%d)", proc->pid); - if (proc->breakpoints_enabled <= 0) { #ifdef __powerpc__ - unsigned long a; - - /* - * PPC HACK! (XXX FIXME TODO) - * If the dynamic linker hasn't populated the PLT then - * dont enable the breakpoints - */ - if (options.libcalls) { - a = ptrace(PTRACE_PEEKTEXT, proc->pid, - sym2addr(proc, proc->list_of_symbols), - 0); - if (a == 0x0) - return; - } + unsigned long a; + + /* + * PPC HACK! (XXX FIXME TODO) + * If the dynamic linker hasn't populated the PLT then + * dont enable the breakpoints + */ + if (options.libcalls) { + a = ptrace(PTRACE_PEEKTEXT, proc->pid, + sym2addr(proc, proc->list_of_symbols), + 0); + if (a == 0x0) + return; + } #endif - debug(1, "Enabling breakpoints for pid %u...", proc->pid); - if (proc->breakpoints) { - dict_apply_to_all(proc->breakpoints, enable_bp_cb, - proc); - } + debug(1, "Enabling breakpoints for pid %u...", proc->pid); + if (proc->breakpoints) { + dict_apply_to_all(proc->breakpoints, enable_bp_cb, + proc); + } #ifdef __mips__ - { - /* - * I'm sure there is a nicer way to do this. We need to - * insert breakpoints _after_ the child has been started. - */ - struct library_symbol *sym; - struct library_symbol *new_sym; - sym=proc->list_of_symbols; - while(sym){ - void *addr= sym2addr(proc,sym); - if(!addr){ - sym=sym->next; - continue; - } - if(dict_find_entry(proc->breakpoints,addr)){ - sym=sym->next; - continue; - } - debug(2,"inserting bp %p %s",addr,sym->name); - new_sym=malloc(sizeof(*new_sym) + strlen(sym->name) + 1); - memcpy(new_sym,sym,sizeof(*new_sym) + strlen(sym->name) + 1); - new_sym->next=proc->list_of_symbols; - proc->list_of_symbols=new_sym; - insert_breakpoint(proc, addr, new_sym); + { + /* + * I'm sure there is a nicer way to do this. We need to + * insert breakpoints _after_ the child has been started. + */ + struct library_symbol *sym; + struct library_symbol *new_sym; + sym=proc->list_of_symbols; + while(sym){ + void *addr= sym2addr(proc,sym); + if(!addr){ + sym=sym->next; + continue; + } + if(dict_find_entry(proc->breakpoints,addr)){ sym=sym->next; + continue; } + debug(2,"inserting bp %p %s",addr,sym->name); + new_sym=malloc(sizeof(*new_sym) + strlen(sym->name) + 1); + memcpy(new_sym,sym,sizeof(*new_sym) + strlen(sym->name) + 1); + new_sym->next=proc->list_of_symbols; + proc->list_of_symbols=new_sym; + insert_breakpoint(proc, addr, new_sym); + sym=sym->next; } -#endif } - proc->breakpoints_enabled = 1; +#endif } static void @@ -193,11 +190,7 @@ void disable_all_breakpoints(Process *proc) { debug(DEBUG_FUNCTION, "disable_all_breakpoints(pid=%d)", proc->pid); assert(proc->leader == proc); - if (proc->breakpoints_enabled) { - debug(1, "Disabling breakpoints for pid %u...", proc->pid); - dict_apply_to_all(proc->breakpoints, disable_bp_cb, proc); - } - proc->breakpoints_enabled = 0; + dict_apply_to_all(proc->breakpoints, disable_bp_cb, proc); } static void @@ -269,7 +262,7 @@ breakpoints_init(Process *proc, int enable) } struct breakpoint *entry_bp - = insert_breakpoint(proc, (void *)entry, NULL, 1); + = insert_breakpoint(proc, (void *)(uintptr_t)entry, NULL, 1); if (entry_bp == NULL) { fprintf(stderr, "fail!\n"); goto fail; @@ -281,7 +274,6 @@ breakpoints_init(Process *proc, int enable) entry_bp->cbs = &entry_callbacks; proc->callstack_depth = 0; - proc->breakpoints_enabled = -1; return 0; } @@ -180,7 +180,6 @@ struct Process { * processes. */ Dict * breakpoints; - int breakpoints_enabled; /* -1:not enabled yet, 0:disabled, 1:enabled */ int mask_32bit; /* 1 if 64-bit ltrace is tracing 32-bit process */ unsigned int personality; int tracesysgood; /* signal indicating a PTRACE_SYSCALL trap */ @@ -27,7 +27,6 @@ open_program(char *filename, pid_t pid, int enable) { } proc->filename = strdup(filename); - proc->breakpoints_enabled = -1; proc->pid = pid; #if defined(HAVE_LIBUNWIND) proc->unwind_priv = _UPT_create(pid); @@ -40,13 +39,15 @@ open_program(char *filename, pid_t pid, int enable) { return NULL; } - if (proc->leader == proc) + if (proc->leader == proc) { + trace_set_options(proc, proc->pid); if (breakpoints_init(proc, enable)) { fprintf(stderr, "failed to init breakpoints %d\n", proc->pid); remove_process(proc); return NULL; } + } return proc; } @@ -74,11 +75,10 @@ open_one_pid(pid_t pid) return 0; } -enum pcb_status +static enum pcb_status start_one_pid(Process * proc, void * data) { continue_process(proc->pid); - proc->breakpoints_enabled = 1; return pcb_cont; } diff --git a/sysdeps/linux-gnu/events.c b/sysdeps/linux-gnu/events.c index bf6afc2..0167049 100644 --- a/sysdeps/linux-gnu/events.c +++ b/sysdeps/linux-gnu/events.c @@ -173,8 +173,6 @@ next_event(void) } get_arch_dep(event.proc); debug(3, "event from pid %u", pid); - if (event.proc->breakpoints_enabled == -1) - trace_set_options(event.proc, event.proc->pid); Process *leader = event.proc->leader; if (leader == event.proc) { if (!event.proc->libdl_hooked) { |