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

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