aboutsummaryrefslogtreecommitdiff
path: root/breakpoints.c
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2012-03-27 03:07:35 +0200
committerPetr Machata <pmachata@redhat.com>2012-04-19 01:22:33 +0200
commit55ac932f2802f85c53792153ac909dcd8a690c5c (patch)
treeb86e88be70686a03a33b2d009ba51dceafe279f3 /breakpoints.c
parentbb790604dcaa546737417bf7df8587b3096fa6a5 (diff)
downloadltrace-55ac932f2802f85c53792153ac909dcd8a690c5c.tar.gz
Add breakpoint_set_callbacks, split off breakpoint_init, adjust callers
Diffstat (limited to 'breakpoints.c')
-rw-r--r--breakpoints.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/breakpoints.c b/breakpoints.c
index 08e15cc..f522598 100644
--- a/breakpoints.c
+++ b/breakpoints.c
@@ -20,7 +20,17 @@ breakpoint_on_hit(struct breakpoint *bp, struct Process *proc)
{
assert(bp != NULL);
if (bp->cbs != NULL && bp->cbs->on_hit != NULL)
- (bp->cbs->on_hit) (bp, proc);
+ (bp->cbs->on_hit)(bp, proc);
+}
+
+void
+breakpoint_on_continue(struct breakpoint *bp, struct Process *proc)
+{
+ assert(bp != NULL);
+ if (bp->cbs != NULL && bp->cbs->on_continue != NULL)
+ (bp->cbs->on_continue)(bp, proc);
+ else
+ continue_after_breakpoint(proc, bp);
}
/*****************************************************************************/
@@ -50,10 +60,9 @@ arch_breakpoint_destroy(struct breakpoint *sbp)
int
breakpoint_init(struct breakpoint *bp, struct Process *proc,
- target_address_t addr, struct library_symbol *libsym,
- struct bp_callbacks *cbs)
+ target_address_t addr, struct library_symbol *libsym)
{
- bp->cbs = cbs;
+ bp->cbs = NULL;
bp->addr = addr;
memset(bp->orig_value, 0, sizeof(bp->orig_value));
bp->enabled = 0;
@@ -62,6 +71,14 @@ breakpoint_init(struct breakpoint *bp, struct Process *proc,
}
void
+breakpoint_set_callbacks(struct breakpoint *bp, struct bp_callbacks *cbs)
+{
+ if (bp->cbs != NULL)
+ assert(bp->cbs == NULL);
+ bp->cbs = cbs;
+}
+
+void
breakpoint_destroy(struct breakpoint *bp)
{
if (bp == NULL)
@@ -102,7 +119,7 @@ insert_breakpoint(Process *proc, void *addr,
if (sbp == NULL) {
sbp = malloc(sizeof(*sbp));
if (sbp == NULL
- || breakpoint_init(sbp, proc, addr, libsym, NULL) < 0
+ || breakpoint_init(sbp, proc, addr, libsym) < 0
|| dict_enter(leader->breakpoints, addr, sbp) < 0) {
free(sbp);
return NULL;