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

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