From 10e19f222985c1a2da41d3179643703d794faf57 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Tue, 4 Jun 2019 12:51:19 -0700 Subject: [PATCH] Revert "remove plugins" This reverts commit e92e6791f399195438d687925a7e6020047b4c60. --- Makefile | 2 +- execution.cc | 4 ++-- main.cc | 43 ++++++++++++++++++++++++++++++++++++++----- model.cc | 2 +- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 313445da..e47c4ada 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 conditionvariable.o \ - context.o execution.o libannotate.o pthread.o futex.o + context.o execution.o libannotate.o plugins.o pthread.o futex.o CPPFLAGS += -Iinclude -I. LDFLAGS := -ldl -lrt -rdynamic diff --git a/execution.cc b/execution.cc index 8fba766b..62a7346b 100644 --- a/execution.cc +++ b/execution.cc @@ -77,8 +77,8 @@ ModelExecution::ModelExecution(ModelChecker *m, mo_graph(new CycleGraph()) { /* Initialize a model-checker thread, for special ModelActions */ - model_thread = new Thread(get_next_id()); // L: Create model thread - add_thread(model_thread); // L: Add model thread to scheduler + model_thread = new Thread(get_next_id()); + add_thread(model_thread); scheduler->register_engine(this); node_stack->register_engine(this); } diff --git a/main.cc b/main.cc index 0f1fbf2b..199e23bf 100644 --- a/main.cc +++ b/main.cc @@ -15,6 +15,7 @@ #include "model.h" #include "params.h" #include "snapshot-interface.h" +#include "plugins.h" static void param_defaults(struct model_params *params) { @@ -27,6 +28,7 @@ static void param_defaults(struct model_params *params) static void print_usage(const char *program_name, struct model_params *params) { + ModelVector * registeredanalysis=getRegisteredTraceAnalysis(); /* Reset defaults before printing */ param_defaults(params); @@ -65,10 +67,29 @@ static void print_usage(const char *program_name, struct model_params *params) params->verbose, params->uninitvalue, params->maxexecutions); - + model_print("Analysis plugins:\n"); + for(unsigned int i=0;isize();i++) { + TraceAnalysis * analysis=(*registeredanalysis)[i]; + model_print("%s\n", analysis->name()); + } exit(EXIT_SUCCESS); } +bool install_plugin(char * name) { + ModelVector * registeredanalysis=getRegisteredTraceAnalysis(); + ModelVector * installedanalysis=getInstalledTraceAnalysis(); + + for(unsigned int i=0;isize();i++) { + TraceAnalysis * analysis=(*registeredanalysis)[i]; + if (strcmp(name, analysis->name())==0) { + installedanalysis->push_back(analysis); + return false; + } + } + model_print("Analysis %s Not Found\n", name); + return true; +} + static void parse_options(struct model_params *params, int argc, char **argv) { const char *shortopts = "ht:o:e:b:u:x:v::"; @@ -105,7 +126,7 @@ static void parse_options(struct model_params *params, int argc, char **argv) case 'u': params->uninitvalue = atoi(optarg); break; -/** case 't': + case 't': if (install_plugin(optarg)) error = true; break; @@ -116,7 +137,6 @@ static void parse_options(struct model_params *params, int argc, char **argv) error = true; } break; -*/ default: /* '?' */ error = true; break; @@ -140,12 +160,25 @@ static void parse_options(struct model_params *params, int argc, char **argv) int main_argc; char **main_argv; +static void install_trace_analyses(ModelExecution *execution) +{ + ModelVector * installedanalysis=getInstalledTraceAnalysis(); + for(unsigned int i=0;isize();i++) { + TraceAnalysis * ta=(*installedanalysis)[i]; + ta->setExecution(execution); + model->add_trace_analysis(ta); + /** Call the installation event for each installed plugin */ + ta->actionAtInstallation(); + } +} + /** The model_main function contains the main model checking loop. */ static void model_main() { struct model_params params; param_defaults(¶ms); + register_plugins(); parse_options(¶ms, main_argc, main_argv); @@ -154,8 +187,8 @@ static void model_main() snapshot_stack_init(); - model = new ModelChecker(params); // L: Model thread is created -// install_trace_analyses(model->get_execution()); L: disable plugin + model = new ModelChecker(params); + install_trace_analyses(model->get_execution()); snapshot_record(0); model->run(); diff --git a/model.cc b/model.cc index f277970a..e9f34da5 100644 --- a/model.cc +++ b/model.cc @@ -28,7 +28,7 @@ ModelChecker::ModelChecker(struct model_params params) : exit_flag(false), scheduler(new Scheduler()), node_stack(new NodeStack()), - execution(new ModelExecution(this, &this->params, scheduler, node_stack)), // L: Model thread is created inside + execution(new ModelExecution(this, &this->params, scheduler, node_stack)), execution_number(1), diverge(NULL), earliest_diverge(NULL), -- 2.34.1