|
|
5cd83f |
From 56134ff5442bee4e128b189bb86cfc97dcb6f60a Mon Sep 17 00:00:00 2001
|
|
|
5cd83f |
From: Petr Machata <pmachata@redhat.com>
|
|
|
5cd83f |
Date: Fri, 10 Jan 2014 20:05:15 +0100
|
|
|
5cd83f |
Subject: [PATCH 1/2] Add a new per-breakpoint callback on_install
|
|
|
5cd83f |
|
|
|
5cd83f |
---
|
|
|
5cd83f |
breakpoint.h | 9 ++++++++-
|
|
|
5cd83f |
breakpoints.c | 11 ++++++++++-
|
|
|
5cd83f |
2 files changed, 18 insertions(+), 2 deletions(-)
|
|
|
5cd83f |
|
|
|
5cd83f |
diff --git a/breakpoint.h b/breakpoint.h
|
|
|
5cd83f |
index 95964a8..c36f673 100644
|
|
|
5cd83f |
--- a/breakpoint.h
|
|
|
5cd83f |
+++ b/breakpoint.h
|
|
|
5cd83f |
@@ -1,6 +1,6 @@
|
|
|
5cd83f |
/*
|
|
|
5cd83f |
* This file is part of ltrace.
|
|
|
5cd83f |
- * Copyright (C) 2012, 2013 Petr Machata, Red Hat Inc.
|
|
|
5cd83f |
+ * Copyright (C) 2012,2013,2014 Petr Machata, Red Hat Inc.
|
|
|
5cd83f |
* Copyright (C) 2009 Juan Cespedes
|
|
|
5cd83f |
*
|
|
|
5cd83f |
* This program is free software; you can redistribute it and/or
|
|
|
5cd83f |
@@ -46,6 +46,7 @@
|
|
|
5cd83f |
struct bp_callbacks {
|
|
|
5cd83f |
void (*on_hit)(struct breakpoint *bp, struct process *proc);
|
|
|
5cd83f |
void (*on_continue)(struct breakpoint *bp, struct process *proc);
|
|
|
5cd83f |
+ void (*on_install)(struct breakpoint *bp, struct process *proc);
|
|
|
5cd83f |
void (*on_retract)(struct breakpoint *bp, struct process *proc);
|
|
|
5cd83f |
|
|
|
5cd83f |
/* Create a new breakpoint that should handle return from the
|
|
|
5cd83f |
@@ -84,6 +85,12 @@ void breakpoint_on_continue(struct breakpoint *bp, struct process *proc);
|
|
|
5cd83f |
* the instruction underneath it). */
|
|
|
5cd83f |
void breakpoint_on_retract(struct breakpoint *bp, struct process *proc);
|
|
|
5cd83f |
|
|
|
5cd83f |
+/* Call ON_INSTALL handler of BP, if any is set. This should be
|
|
|
5cd83f |
+ * called after the breakpoint is enabled for the first time, not
|
|
|
5cd83f |
+ * every time it's enabled (such as after stepping over a site of a
|
|
|
5cd83f |
+ * temporarily disabled breakpoint). */
|
|
|
5cd83f |
+void breakpoint_on_install(struct breakpoint *bp, struct process *proc);
|
|
|
5cd83f |
+
|
|
|
5cd83f |
/* Call GET_RETURN_BP handler of BP, if any is set. If none is set,
|
|
|
5cd83f |
* call CREATE_DEFAULT_RETURN_BP to obtain one. */
|
|
|
5cd83f |
int breakpoint_get_return_bp(struct breakpoint **ret,
|
|
|
5cd83f |
diff --git a/breakpoints.c b/breakpoints.c
|
|
|
5cd83f |
index 947cb71..c3fa275 100644
|
|
|
5cd83f |
--- a/breakpoints.c
|
|
|
5cd83f |
+++ b/breakpoints.c
|
|
|
5cd83f |
@@ -1,6 +1,6 @@
|
|
|
5cd83f |
/*
|
|
|
5cd83f |
* This file is part of ltrace.
|
|
|
5cd83f |
- * Copyright (C) 2006,2007,2011,2012,2013 Petr Machata, Red Hat Inc.
|
|
|
5cd83f |
+ * Copyright (C) 2006,2007,2011,2012,2013,2014 Petr Machata, Red Hat Inc.
|
|
|
5cd83f |
* Copyright (C) 2009 Juan Cespedes
|
|
|
5cd83f |
* Copyright (C) 1998,2001,2002,2003,2007,2008,2009 Juan Cespedes
|
|
|
5cd83f |
* Copyright (C) 2006 Ian Wienand
|
|
|
5cd83f |
@@ -85,6 +85,14 @@ breakpoint_on_retract(struct breakpoint *bp, struct process *proc)
|
|
|
5cd83f |
(bp->cbs->on_retract)(bp, proc);
|
|
|
5cd83f |
}
|
|
|
5cd83f |
|
|
|
5cd83f |
+void
|
|
|
5cd83f |
+breakpoint_on_install(struct breakpoint *bp, struct process *proc)
|
|
|
5cd83f |
+{
|
|
|
5cd83f |
+ assert(bp != NULL);
|
|
|
5cd83f |
+ if (bp->cbs != NULL && bp->cbs->on_install != NULL)
|
|
|
5cd83f |
+ (bp->cbs->on_install)(bp, proc);
|
|
|
5cd83f |
+}
|
|
|
5cd83f |
+
|
|
|
5cd83f |
int
|
|
|
5cd83f |
breakpoint_get_return_bp(struct breakpoint **ret,
|
|
|
5cd83f |
struct breakpoint *bp, struct process *proc)
|
|
|
5cd83f |
@@ -229,6 +237,7 @@ breakpoint_turn_on(struct breakpoint *bp, struct process *proc)
|
|
|
5cd83f |
if (bp->enabled == 1) {
|
|
|
5cd83f |
assert(proc->pid != 0);
|
|
|
5cd83f |
enable_breakpoint(proc, bp);
|
|
|
5cd83f |
+ breakpoint_on_install(bp, proc);
|
|
|
5cd83f |
}
|
|
|
5cd83f |
return 0;
|
|
|
5cd83f |
}
|
|
|
5cd83f |
--
|
|
|
5cd83f |
1.7.6.5
|
|
|
5cd83f |
|