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

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