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

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