socsvn commit: r240482 - in soc2012/gmiller/locking-head: .
lib/libwitness
gmiller at FreeBSD.org
gmiller at FreeBSD.org
Fri Aug 17 23:08:28 UTC 2012
Author: gmiller
Date: Fri Aug 17 23:08:26 2012
New Revision: 240482
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=240482
Log:
r240503 at FreeBSD-dev: root | 2012-08-15 14:48:26 -0500
Move all of the remaining API functions into api.c.
Deleted:
soc2012/gmiller/locking-head/lib/libwitness/logs.c
Modified:
soc2012/gmiller/locking-head/ (props changed)
soc2012/gmiller/locking-head/lib/libwitness/Makefile
soc2012/gmiller/locking-head/lib/libwitness/api.c
soc2012/gmiller/locking-head/lib/libwitness/lists.c
soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c
soc2012/gmiller/locking-head/lib/libwitness/witness.h
Modified: soc2012/gmiller/locking-head/lib/libwitness/Makefile
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/Makefile Fri Aug 17 23:05:44 2012 (r240481)
+++ soc2012/gmiller/locking-head/lib/libwitness/Makefile Fri Aug 17 23:08:26 2012 (r240482)
@@ -4,7 +4,7 @@
LIB= witness
SHLIB_MAJOR= 1
-SRCS= api.c graph.c lists.c logs.c lockinfo.c xml.c unwind.c
+SRCS= api.c graph.c lists.c lockinfo.c xml.c unwind.c
DPADD= ${LIBTHR}
LDADD= -lthr
Modified: soc2012/gmiller/locking-head/lib/libwitness/api.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/api.c Fri Aug 17 23:05:44 2012 (r240481)
+++ soc2012/gmiller/locking-head/lib/libwitness/api.c Fri Aug 17 23:08:26 2012 (r240482)
@@ -491,3 +491,187 @@
return (ret);
}
+int
+pthread_lor_begin_np(struct pthread_lor_np *lor)
+{
+ int ret = 0;
+
+ lor->name_first = NULL;
+ lor->first_trace = NULL;
+ lor->name_second = NULL;
+ lor->second_trace = NULL;
+
+ enter_witness();
+
+ lor->_pvt = malloc(sizeof(struct _pthread_lor_private));
+ if (lor->_pvt == NULL) {
+ ret = ENOMEM;
+ } else {
+ lor->_pvt->last_record = NULL;
+ }
+
+ leave_witness();
+
+ return (ret);
+}
+
+int
+pthread_lor_next_np(struct pthread_lor_np *lor)
+{
+ int res = 0;
+
+ enter_witness();
+
+ if (lor->_pvt == NULL || lor->_pvt->last_record == NULL) {
+ lor->_pvt->last_record = STAILQ_FIRST(&lor_head);
+ } else {
+ lor->_pvt->last_record =
+ STAILQ_NEXT(lor->_pvt->last_record, lor_next);
+ }
+
+ if (lor->_pvt->last_record != NULL) {
+ lor->name_first =
+ strdup(get_lock_name(lor->_pvt->last_record->lock_first));
+ lor->first_trace =
+ strdup(lor->_pvt->last_record->first_trace);
+ lor->name_second =
+ strdup(get_lock_name(lor->_pvt->last_record->lock_second));
+ lor->second_trace =
+ strdup(lor->_pvt->last_record->second_trace);
+
+ res = 1;
+ }
+
+ leave_witness();
+
+ return (res);
+}
+
+void
+pthread_lor_end_np(struct pthread_lor_np *lor)
+{
+ if (lor->_pvt != NULL) {
+ free(lor->_pvt);
+ lor->_pvt = NULL;
+ }
+
+ if (lor->name_first != NULL) {
+ free(lor->name_first);
+ }
+
+ if (lor->name_second != NULL) {
+ free(lor->name_second);
+ }
+
+ if (lor->first_trace != NULL) {
+ free(lor->first_trace);
+ }
+
+ if (lor->second_trace != NULL) {
+ free(lor->second_trace);
+ }
+}
+
+void
+pthread_lor_clear_np(void)
+{
+ struct lor_entry *lor;
+ struct lor_entry *lor_temp;
+
+ enter_witness();
+
+ STAILQ_FOREACH_SAFE(lor, &lor_head, lor_next, lor_temp) {
+ STAILQ_REMOVE(&lor_head, lor, lor_entry, lor_next);
+
+ if (lor->first_trace != NULL) {
+ free(lor->first_trace);
+ }
+
+ if (lor->second_trace != NULL) {
+ free(lor->second_trace);
+ }
+
+ free(lor);
+ }
+
+ leave_witness();
+}
+
+int
+pthread_lockorder_begin_np(struct pthread_lockorder_np *node)
+{
+ int ret = 0;
+
+ enter_witness();
+
+ node->_pvt = malloc(sizeof(struct _pthread_lockorder_private));
+ if (node->_pvt == NULL) {
+ ret = ENOMEM;
+ } else {
+ node->_pvt->last_record = NULL;
+ node->name = NULL;
+ }
+
+ leave_witness();
+
+ return (ret);
+}
+
+int
+pthread_lockorder_next_np(struct pthread_lockorder_np *node)
+{
+ if (node->_pvt == NULL) {
+ return (0);
+ }
+
+ enter_witness();
+
+ if (node->_pvt->last_record == NULL) {
+ node->_pvt->last_record = SLIST_FIRST(&lock_info_head);
+ } else {
+ node->_pvt->last_record =
+ SLIST_NEXT(node->_pvt->last_record, lock_info_next);
+ }
+
+ if (node->_pvt->last_record == NULL) {
+ leave_witness();
+
+ return (0);
+ }
+
+ if (node->name != NULL) {
+ free(node->name);
+ }
+
+ node->name = strdup(get_lock_name(node->_pvt->last_record));
+ if (node->_pvt->last_record->child != NULL) {
+ node->child =
+ strdup(get_lock_name(node->_pvt->last_record->child));
+ } else {
+ node->child = NULL;
+ }
+ if (node->_pvt->last_record->sibling != NULL) {
+ node->sibling =
+ strdup(get_lock_name(node->_pvt->last_record->sibling));
+ } else {
+ node->sibling = NULL;
+ }
+
+ leave_witness();
+
+ return (1);
+}
+
+void
+pthread_lockorder_end_np(struct pthread_lockorder_np *node)
+{
+ if (node->_pvt != NULL) {
+ free(node->_pvt);
+ node->_pvt = NULL;
+ }
+
+ if (node->name != NULL) {
+ free(node->name);
+ node->name = NULL;
+ }
+}
Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/lists.c Fri Aug 17 23:05:44 2012 (r240481)
+++ soc2012/gmiller/locking-head/lib/libwitness/lists.c Fri Aug 17 23:08:26 2012 (r240482)
@@ -35,10 +35,27 @@
static _Thread_local SLIST_HEAD(lock_head, lock_entry) lock_head =
SLIST_HEAD_INITIALIZER(lock_head);
-
static int reset_count = 0;
static _Thread_local int thread_reset_count = 0;
static int exit_set = 0;
+struct lor_head lor_head = STAILQ_HEAD_INITIALIZER(lor_head);
+
+static void
+log_reversal(struct lock_info *lock, struct backtrace *lock_trace,
+ struct lock_info *previous, struct backtrace *previous_trace)
+{
+ struct lor_entry *entry;
+
+ entry = malloc(sizeof(struct lor_entry));
+ if (entry != NULL) {
+ entry->lock_first = previous;
+ entry->first_trace = trace_str(previous_trace);
+ entry->lock_second = lock;
+ entry->second_trace = trace_str(lock_trace);
+
+ STAILQ_INSERT_TAIL(&lor_head, entry, lor_next);
+ }
+}
void
free_frame(struct backtrace *trace)
Modified: soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Fri Aug 17 23:05:44 2012 (r240481)
+++ soc2012/gmiller/locking-head/lib/libwitness/lockinfo.c Fri Aug 17 23:08:26 2012 (r240482)
@@ -27,18 +27,11 @@
#include "witness.h"
-#define MAX_DEFAULT_NAME_LENGTH (80)
-
-static SLIST_HEAD(lock_info_head, lock_info) lock_info_head =
- SLIST_HEAD_INITIALIZER(lock_info_head);
+struct lock_info_head lock_info_head = SLIST_HEAD_INITIALIZER(lock_info_head);
static SLIST_HEAD(lock_instance_head, lock_instance) lock_instance_head =
SLIST_HEAD_INITIALIZER(lock_instance_head);
-struct _pthread_lockorder_private {
- struct lock_info *last_record;
-};
-
struct lock_instance *
lookup_lock(void *lock)
{
@@ -235,82 +228,3 @@
snprintf(info->name, MAX_DEFAULT_NAME_LENGTH, "%s_%p", prefix, lock);
}
-
-int
-pthread_lockorder_begin_np(struct pthread_lockorder_np *node)
-{
- int ret = 0;
-
- enter_witness();
-
- node->_pvt = malloc(sizeof(struct _pthread_lockorder_private));
- if (node->_pvt == NULL) {
- ret = ENOMEM;
- } else {
- node->_pvt->last_record = NULL;
- node->name = NULL;
- }
-
- leave_witness();
-
- return (ret);
-}
-
-int
-pthread_lockorder_next_np(struct pthread_lockorder_np *node)
-{
- if (node->_pvt == NULL) {
- return (0);
- }
-
- enter_witness();
-
- if (node->_pvt->last_record == NULL) {
- node->_pvt->last_record = SLIST_FIRST(&lock_info_head);
- } else {
- node->_pvt->last_record =
- SLIST_NEXT(node->_pvt->last_record, lock_info_next);
- }
-
- if (node->_pvt->last_record == NULL) {
- leave_witness();
-
- return (0);
- }
-
- if (node->name != NULL) {
- free(node->name);
- }
-
- node->name = strdup(get_lock_name(node->_pvt->last_record));
- if (node->_pvt->last_record->child != NULL) {
- node->child =
- strdup(get_lock_name(node->_pvt->last_record->child));
- } else {
- node->child = NULL;
- }
- if (node->_pvt->last_record->sibling != NULL) {
- node->sibling =
- strdup(get_lock_name(node->_pvt->last_record->sibling));
- } else {
- node->sibling = NULL;
- }
-
- leave_witness();
-
- return (1);
-}
-
-void
-pthread_lockorder_end_np(struct pthread_lockorder_np *node)
-{
- if (node->_pvt != NULL) {
- free(node->_pvt);
- node->_pvt = NULL;
- }
-
- if (node->name != NULL) {
- free(node->name);
- node->name = NULL;
- }
-}
Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/witness.h Fri Aug 17 23:05:44 2012 (r240481)
+++ soc2012/gmiller/locking-head/lib/libwitness/witness.h Fri Aug 17 23:08:26 2012 (r240482)
@@ -34,7 +34,8 @@
#include <stdlib.h>
#include <string.h>
-#define MAX_FRAME_ID_LENGTH (80)
+#define MAX_FRAME_ID_LENGTH (80)
+#define MAX_DEFAULT_NAME_LENGTH (80)
struct blessing {
SLIST_ENTRY(blessing) bless_next;
@@ -49,6 +50,8 @@
char *name;
};
+SLIST_HEAD(lock_info_head, lock_info);
+
struct lock_instance {
SLIST_ENTRY(lock_instance) lock_instance_next;
struct lock_info *info;
@@ -62,6 +65,27 @@
SLIST_HEAD(backtrace, stack_frame);
+struct lor_entry {
+ STAILQ_ENTRY(lor_entry) lor_next;
+ struct lock_info *lock_first;
+ char *first_trace;
+ struct lock_info *lock_second;
+ char *second_trace;
+};
+
+struct _pthread_lor_private {
+ struct lor_entry *last_record;
+};
+
+STAILQ_HEAD(lor_head, lor_entry);
+
+struct _pthread_lockorder_private {
+ struct lock_info *last_record;
+};
+
+extern struct lor_head lor_head;
+extern struct lock_info_head lock_info_head;
+
void add_lock(void *lock);
void remove_lock(void *lock);
void free_frame(struct backtrace *trace);
@@ -71,11 +95,6 @@
void reset_lists(void);
-void log_reversal(struct lock_info *lock,
- struct backtrace *lock_trace,
- struct lock_info *previous,
- struct backtrace *previous_trace);
-
int blessed(struct lock_info *first, struct lock_info *second);
void reset_lock_info(void);
void check_default_name(void *lock, const char *prefix);
More information about the svn-soc-all
mailing list