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

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