if (is_read()) {
if (reads_from)
model_print(" Rf: %-3d", reads_from->get_seq_number());
- else
+ else if (reads_from_promise) {
+ int idx = model->get_promise_number(reads_from_promise);
+ if (idx >= 0)
+ model_print(" Rf: P%-2d", idx);
+ else
+ model_print(" RF: P? ");
+ } else
model_print(" Rf: ? ");
}
if (cv) {
return get_thread(act->get_tid());
}
+/**
+ * @brief Get a Promise's "promise number"
+ *
+ * A "promise number" is an index number that is unique to a promise, valid
+ * only for a specific snapshot of an execution trace. Promises may come and go
+ * as they are generated an resolved, so an index only retains meaning for the
+ * current snapshot.
+ *
+ * @param promise The Promise to check
+ * @return The promise index, if the promise still is valid; otherwise -1
+ */
+int ModelChecker::get_promise_number(const Promise *promise) const
+{
+ for (unsigned int i = 0; i < promises->size(); i++)
+ if ((*promises)[i] == promise)
+ return i;
+ /* Not found */
+ return -1;
+}
+
/**
* @brief Check if a Thread is currently enabled
* @param t The Thread to check
void remove_thread(Thread *t);
Thread * get_thread(thread_id_t tid) const;
Thread * get_thread(const ModelAction *act) const;
+ int get_promise_number(const Promise *promise) const;
bool is_enabled(Thread *t) const;
bool is_enabled(thread_id_t tid) const;