aboutsummaryrefslogtreecommitdiff
path: root/breakpoints.c
diff options
context:
space:
mode:
Diffstat (limited to 'breakpoints.c')
-rw-r--r--breakpoints.c98
1 files changed, 45 insertions, 53 deletions
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;
}