From owner-svn-soc-all@FreeBSD.ORG Thu Jun 28 12:04:20 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id 827D4106567B for ; Thu, 28 Jun 2012 12:04:18 +0000 (UTC) (envelope-from gmiller@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 28 Jun 2012 12:04:18 +0000 Date: Thu, 28 Jun 2012 12:04:18 +0000 From: gmiller@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120628120418.827D4106567B@hub.freebsd.org> Cc: Subject: socsvn commit: r238470 - in soc2012/gmiller/locking-head: . lib/libwitness X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 12:04:20 -0000 Author: gmiller Date: Thu Jun 28 12:04:18 2012 New Revision: 238470 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238470 Log: r238358@FreeBSD-dev: root | 2012-06-19 22:26:14 -0500 * Add pthread_mutex_unlock() wrapper * Add calls to add_lock() and remove_lock() in the wrappers * Add temporary debugging code to make sure the wrapped functions are tracking the locks held by the current thread correctly. Modified: soc2012/gmiller/locking-head/ (props changed) soc2012/gmiller/locking-head/lib/libwitness/lists.c soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/lists.c Thu Jun 28 11:58:10 2012 (r238469) +++ soc2012/gmiller/locking-head/lib/libwitness/lists.c Thu Jun 28 12:04:18 2012 (r238470) @@ -27,6 +27,7 @@ #include +#include #include #include "lists.h" @@ -34,6 +35,19 @@ _Thread_local SLIST_HEAD(lock_head, lock_entry) lock_head = SLIST_HEAD_INITIALIZER(lock_head); +// XXX: temporary debugging code +static void +dump_locks(void) { + struct lock_entry *entry; + int count = 1; + + SLIST_FOREACH(entry, &lock_head, lock_next) { + printf("[%d] %p\n", count++, entry->lock); + } + + puts(""); +} + void add_lock(void *lock) { @@ -43,6 +57,9 @@ entry->lock = lock; SLIST_INSERT_HEAD(&lock_head, entry, lock_next); + + printf("inserted lock %p\n", lock); + dump_locks(); } void @@ -58,4 +75,7 @@ break; } } + + printf("removed lock %p\n", lock); + dump_locks(); } Modified: soc2012/gmiller/locking-head/lib/libwitness/wrappers.c ============================================================================== --- soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Thu Jun 28 11:58:10 2012 (r238469) +++ soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Thu Jun 28 12:04:18 2012 (r238470) @@ -25,12 +25,38 @@ * */ +#include + #include +#include + +#include "lists.h" int _pthread_mutex_lock(pthread_mutex_t *mutex); +int _pthread_mutex_unlock(pthread_mutex_t *mutex); int pthread_mutex_lock(pthread_mutex_t *mutex) { - return _pthread_mutex_lock(mutex); + int ret; + + puts("pthread_mutex_lock()"); + + ret = _pthread_mutex_lock(mutex); + add_lock(mutex); + + return ret; +} + +int +pthread_mutex_unlock(pthread_mutex_t *mutex) +{ + int ret; + + puts("pthread_mutex_unlock()"); + + ret = _pthread_mutex_unlock(mutex); + remove_lock(mutex); + + return ret; }