Skip to content

Commit 56134ff

Browse files
author
Petr Machata
committed
Add a new per-breakpoint callback on_install
1 parent f0d662e commit 56134ff

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

breakpoint.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of ltrace.
3-
* Copyright (C) 2012, 2013 Petr Machata, Red Hat Inc.
3+
* Copyright (C) 2012,2013,2014 Petr Machata, Red Hat Inc.
44
* Copyright (C) 2009 Juan Cespedes
55
*
66
* This program is free software; you can redistribute it and/or
@@ -46,6 +46,7 @@
4646
struct bp_callbacks {
4747
void (*on_hit)(struct breakpoint *bp, struct process *proc);
4848
void (*on_continue)(struct breakpoint *bp, struct process *proc);
49+
void (*on_install)(struct breakpoint *bp, struct process *proc);
4950
void (*on_retract)(struct breakpoint *bp, struct process *proc);
5051

5152
/* Create a new breakpoint that should handle return from the
@@ -84,6 +85,12 @@ void breakpoint_on_continue(struct breakpoint *bp, struct process *proc);
8485
* the instruction underneath it). */
8586
void breakpoint_on_retract(struct breakpoint *bp, struct process *proc);
8687

88+
/* Call ON_INSTALL handler of BP, if any is set. This should be
89+
* called after the breakpoint is enabled for the first time, not
90+
* every time it's enabled (such as after stepping over a site of a
91+
* temporarily disabled breakpoint). */
92+
void breakpoint_on_install(struct breakpoint *bp, struct process *proc);
93+
8794
/* Call GET_RETURN_BP handler of BP, if any is set. If none is set,
8895
* call CREATE_DEFAULT_RETURN_BP to obtain one. */
8996
int breakpoint_get_return_bp(struct breakpoint **ret,

breakpoints.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of ltrace.
3-
* Copyright (C) 2006,2007,2011,2012,2013 Petr Machata, Red Hat Inc.
3+
* Copyright (C) 2006,2007,2011,2012,2013,2014 Petr Machata, Red Hat Inc.
44
* Copyright (C) 2009 Juan Cespedes
55
* Copyright (C) 1998,2001,2002,2003,2007,2008,2009 Juan Cespedes
66
* Copyright (C) 2006 Ian Wienand
@@ -85,6 +85,14 @@ breakpoint_on_retract(struct breakpoint *bp, struct process *proc)
8585
(bp->cbs->on_retract)(bp, proc);
8686
}
8787

88+
void
89+
breakpoint_on_install(struct breakpoint *bp, struct process *proc)
90+
{
91+
assert(bp != NULL);
92+
if (bp->cbs != NULL && bp->cbs->on_install != NULL)
93+
(bp->cbs->on_install)(bp, proc);
94+
}
95+
8896
int
8997
breakpoint_get_return_bp(struct breakpoint **ret,
9098
struct breakpoint *bp, struct process *proc)
@@ -229,6 +237,7 @@ breakpoint_turn_on(struct breakpoint *bp, struct process *proc)
229237
if (bp->enabled == 1) {
230238
assert(proc->pid != 0);
231239
enable_breakpoint(proc, bp);
240+
breakpoint_on_install(bp, proc);
232241
}
233242
return 0;
234243
}

0 commit comments

Comments
 (0)