Blame SOURCES/ltrace-0.7.91-breakpoint-on_install.patch

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