--- /dev/null
+#ifndef __BUGMESSAGE_H__
+#define __BUGMESSAGE_H__
+
+#include "common.h"
+#include "mymemory.h"
+
+struct bug_message {
+ bug_message(const char *str) {
+ const char *fmt = " [BUG] %s\n";
+ msg = (char *)snapshot_malloc(strlen(fmt) + strlen(str));
+ sprintf(msg, fmt, str);
+ }
+ ~bug_message() { if (msg) snapshot_free(msg); }
+
+ char *msg;
+ void print() { model_print("%s", msg); }
+
+ SNAPSHOTALLOC
+};
+
+#endif /* __BUGMESSAGE_H__ */
/* global "model" object */
#include "model.h"
+#include "params.h"
#include "snapshot-interface.h"
#include "scanalysis.h"
#include "threads-model.h"
#include "output.h"
#include "traceanalysis.h"
+#include "bugmessage.h"
#define INITIAL_THREAD_ID 0
ModelChecker *model;
-struct bug_message {
- bug_message(const char *str) {
- const char *fmt = " [BUG] %s\n";
- msg = (char *)snapshot_malloc(strlen(fmt) + strlen(str));
- sprintf(msg, fmt, str);
- }
- ~bug_message() { if (msg) snapshot_free(msg); }
-
- char *msg;
- void print() { model_print("%s", msg); }
-
- SNAPSHOTALLOC
-};
-
/**
* Structure for holding small ModelChecker members that should be snapshotted
*/
thrd_last_action(new SnapVector<ModelAction *>(1)),
thrd_last_fence_release(new SnapVector<ModelAction *>()),
node_stack(new NodeStack()),
- trace_analyses(new ModelVector<Trace_Analysis *>()),
+ trace_analyses(new ModelVector<TraceAnalysis *>()),
priv(new struct model_snapshot_members()),
mo_graph(new CycleGraph())
{
user_main(model->params.argc, model->params.argv);
}
+/** @return True if the execution has taken too many steps */
+bool ModelChecker::too_many_steps() const
+{
+ return params.bound != 0 && priv->used_sequence_numbers > params.bound;
+}
+
bool ModelChecker::should_terminate_execution()
{
/* Infeasible -> don't take any more steps */
return true;
}
- if (params.bound != 0 && priv->used_sequence_numbers > params.bound)
+ if (too_many_steps())
return true;
return false;
}
#include "modeltypes.h"
#include "stl-model.h"
#include "context.h"
+#include "params.h"
/* Forward declaration */
class Node;
class Scheduler;
class Thread;
class ClockVector;
-class Trace_Analysis;
+class TraceAnalysis;
struct model_snapshot_members;
/** @brief Shorthand for a list of release sequence heads */
typedef ModelVector<const ModelAction *> rel_heads_list_t;
typedef SnapList<ModelAction *> action_list_t;
-/**
- * Model checker parameter structure. Holds run-time configuration options for
- * the model checker.
- */
-struct model_params {
- int maxreads;
- int maxfuturedelay;
- bool yieldon;
- bool sc_trace_analysis;
- unsigned int fairwindow;
- unsigned int enabledcount;
- unsigned int bound;
- unsigned int uninitvalue;
-
- /** @brief Maximum number of future values that can be sent to the same
- * read */
- int maxfuturevalues;
-
- /** @brief Only generate a new future value/expiration pair if the
- * expiration time exceeds the existing one by more than the slop
- * value */
- unsigned int expireslop;
-
- /** @brief Verbosity (0 = quiet; 1 = noisy) */
- int verbose;
-
- /** @brief Command-line argument count to pass to user program */
- int argc;
-
- /** @brief Command-line arguments to pass to user program */
- char **argv;
-};
-
/** @brief Model checker execution stats */
struct execution_stats {
int num_total; /**< @brief Total number of executions */
const model_params params;
Node * get_curr_node() const;
- void add_trace_analysis(Trace_Analysis * a) {
+ void add_trace_analysis(TraceAnalysis *a) {
trace_analyses->push_back(a);
}
SnapVector<ModelAction *> * const thrd_last_action;
SnapVector<ModelAction *> * const thrd_last_fence_release;
NodeStack * const node_stack;
- ModelVector<Trace_Analysis *> * trace_analyses;
+ ModelVector<TraceAnalysis *> * trace_analyses;
/** Private data members that should be snapshotted. They are grouped
bool is_feasible_prefix_ignore_relseq() const;
bool is_infeasible() const;
bool is_deadlocked() const;
+ bool too_many_steps() const;
bool is_complete_execution() const;
bool have_bug_reports() const;
void print_bugs() const;
--- /dev/null
+#ifndef __PARAMS_H__
+#define __PARAMS_H__
+
+/**
+ * Model checker parameter structure. Holds run-time configuration options for
+ * the model checker.
+ */
+struct model_params {
+ int maxreads;
+ int maxfuturedelay;
+ bool yieldon;
+ bool sc_trace_analysis;
+ unsigned int fairwindow;
+ unsigned int enabledcount;
+ unsigned int bound;
+ unsigned int uninitvalue;
+
+ /** @brief Maximum number of future values that can be sent to the same
+ * read */
+ int maxfuturevalues;
+
+ /** @brief Only generate a new future value/expiration pair if the
+ * expiration time exceeds the existing one by more than the slop
+ * value */
+ unsigned int expireslop;
+
+ /** @brief Verbosity (0 = quiet; 1 = noisy) */
+ int verbose;
+
+ /** @brief Command-line argument count to pass to user program */
+ int argc;
+
+ /** @brief Command-line arguments to pass to user program */
+ char **argv;
+};
+
+#endif /* __PARAMS_H__ */
#include "traceanalysis.h"
#include "hashtable.h"
-class SCAnalysis : public Trace_Analysis {
+class SCAnalysis : public TraceAnalysis {
public:
SCAnalysis();
~SCAnalysis();
#define TRACE_ANALYSIS_H
#include "model.h"
-class Trace_Analysis {
+class TraceAnalysis {
public:
virtual void analyze(action_list_t *) = 0;
SNAPSHOTALLOC