Don't turn on breakpoints when library is added
- this likely breaks tracing from libraries on x86s, but fixes ppc base
binary tracing for non-secure ppc32 cases. We'll need to tweak this
to enable the library PLTs
diff --git a/breakpoints.c b/breakpoints.c
index 5cc75bb..5a68d89 100644
--- a/breakpoints.c
+++ b/breakpoints.c
@@ -292,15 +292,24 @@
};
static void
+turn_on_breakpoint(void *addr, void *sbp, void *proc)
+{
+ struct breakpoint *bp = sbp;
+ if (breakpoint_turn_on(bp) < 0) {
+ error(0, errno, "couldn't turn on breakpoint @%p", bp->addr);
+ /* XXX handle me. */
+ }
+}
+
+static void
entry_breakpoint_on_hit(struct breakpoint *a, struct Process *proc)
{
struct entry_breakpoint *bp = (void *)a;
fprintf(stderr, "entry_callback_hit\n");
if (proc == NULL || proc->leader == NULL)
return;
- delete_breakpoint(proc, bp->super.addr); // xxx
- //enable_all_breakpoints(proc);
-
+ delete_breakpoint(proc, bp->super.addr);
+ dict_apply_to_all(proc->breakpoints, turn_on_breakpoint, proc);
linkmap_init(proc, bp->dyn_addr);
}
diff --git a/proc.c b/proc.c
index 8c42c4a..7568a75 100644
--- a/proc.c
+++ b/proc.c
@@ -487,9 +487,20 @@
{
struct Process *proc = data;
- if (filter_matches_symbol(options.filter, libsym)
- && insert_breakpoint(proc, libsym->enter_addr, libsym) == NULL)
- return CBS_STOP;
+ if (!filter_matches_symbol(options.filter, libsym))
+ return CBS_CONT;
+
+ struct breakpoint *bp = malloc(sizeof(*bp));
+ if (bp == NULL
+ || breakpoint_init(bp, proc, libsym->enter_addr, libsym) < 0) {
+ fail:
+ free(bp);
+ return CBS_FAIL;
+ }
+ if (proc_add_breakpoint(proc, bp) < 0) {
+ breakpoint_destroy(bp);
+ goto fail;
+ }
return CBS_CONT;
}