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

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