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

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