From 2d0d4ac38e05905a6633b3f2d5112ccadd45c27f Mon Sep 17 00:00:00 2001 From: bdemsky Date: Sat, 25 Jan 2014 14:04:13 -0800 Subject: [PATCH] Annotation Support --- Makefile | 2 +- action.cc | 8 +++++++- action.h | 5 ++++- include/cdsannotate.h | 7 +++++++ libannotate.cc | 14 ++++++++++++++ 5 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 include/cdsannotate.h create mode 100644 libannotate.cc diff --git a/Makefile b/Makefile index 37bdcd11..f44a8953 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ OBJECTS := libthreads.o schedule.o model.o threads.o librace.o action.o \ nodestack.o clockvector.o main.o snapshot-interface.o cyclegraph.o \ datarace.o impatomic.o cmodelint.o \ snapshot.o malloc.o mymemory.o common.o mutex.o promise.o conditionvariable.o \ - context.o scanalysis.o execution.o plugins.o + context.o scanalysis.o execution.o plugins.o libannotate.o CPPFLAGS += -Iinclude -I. LDFLAGS := -ldl -lrt -rdynamic diff --git a/action.cc b/action.cc index 3d38e81c..2010a0b6 100644 --- a/action.cc +++ b/action.cc @@ -192,6 +192,11 @@ bool ModelAction::is_initialization() const return type == ATOMIC_INIT; } +bool ModelAction::is_annotation() const +{ + return type == ATOMIC_ANNOTATION; +} + bool ModelAction::is_relaxed() const { return order == std::memory_order_relaxed; @@ -547,7 +552,8 @@ const char * ModelAction::get_type_str() const case ATOMIC_TRYLOCK: return "trylock"; case ATOMIC_WAIT: return "wait"; case ATOMIC_NOTIFY_ONE: return "notify one"; - case ATOMIC_NOTIFY_ALL: return "notify all"; + case ATOMIC_NOTIFY_ALL: return "notify all"; + case ATOMIC_ANNOTATION: return "atomic annotation"; default: return "unknown type"; }; } diff --git a/action.h b/action.h index d7d86ced..ad3b828a 100644 --- a/action.h +++ b/action.h @@ -70,7 +70,9 @@ typedef enum action_type { ATOMIC_UNLOCK, /**< An unlock action */ ATOMIC_NOTIFY_ONE, /**< A notify_one action */ ATOMIC_NOTIFY_ALL, /**< A notify all action */ - ATOMIC_WAIT /**< A wait action */ + ATOMIC_WAIT, /**< A wait action */ + ATOMIC_ANNOTATION /**< An annotation action to pass information + to a trace analysis */ } action_type_t; /* Forward declaration */ @@ -142,6 +144,7 @@ public: bool is_rmw() const; bool is_fence() const; bool is_initialization() const; + bool is_annotation() const; bool is_relaxed() const; bool is_acquire() const; bool is_release() const; diff --git a/include/cdsannotate.h b/include/cdsannotate.h new file mode 100644 index 00000000..bb6e3d6e --- /dev/null +++ b/include/cdsannotate.h @@ -0,0 +1,7 @@ +#ifndef CDS_ANNOTATE_H +#define CDS_ANNOTATE_H +#include + +void cdsannotate(uint64_t analysistype, void *annotation); + +#endif diff --git a/libannotate.cc b/libannotate.cc new file mode 100644 index 00000000..b1fad8af --- /dev/null +++ b/libannotate.cc @@ -0,0 +1,14 @@ +#include +#include "common.h" +#include "action.h" +#include "model.h" + +/** Pass in an annotation that a trace analysis will use. The + * analysis type is a unique number that specifies which trace + * analysis needs the annotation. The reference is to a data + * structure that the trace understands. */ + +void cdsannotate(uint64_t analysistype, void *annotation) { + /* seq_cst is just a 'don't care' parameter */ + model->switch_to_master(new ModelAction(ATOMIC_ANNOTATION, std::memory_order_seq_cst, annotation, analysistype)); +} -- 2.34.1