model: add variable arguments for bug messages
authorBrian Norris <banorris@uci.edu>
Thu, 4 Apr 2013 08:25:34 +0000 (01:25 -0700)
committerBrian Norris <banorris@uci.edu>
Fri, 5 Apr 2013 17:29:04 +0000 (10:29 -0700)
model.cc
model.h

index feda416222de94f460291ee7f6a6ea15a21ddf22..cbd5617d8238f9326720fbcfb7dfb9c08864b6e3 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -2,6 +2,7 @@
 #include <algorithm>
 #include <mutex>
 #include <new>
+#include <stdarg.h>
 
 #include "model.h"
 #include "action.h"
@@ -419,9 +420,16 @@ bool ModelChecker::is_complete_execution() const
  * @param msg Descriptive message for the bug (do not include newline char)
  * @return True if bug is immediately-feasible
  */
-bool ModelChecker::assert_bug(const char *msg)
+bool ModelChecker::assert_bug(const char *msg, ...)
 {
-       priv->bugs.push_back(new bug_message(msg));
+       char str[800];
+
+       va_list ap;
+       va_start(ap, msg);
+       vsnprintf(str, sizeof(str), msg, ap);
+       va_end(ap);
+
+       priv->bugs.push_back(new bug_message(str));
 
        if (isfeasibleprefix()) {
                set_assert();
diff --git a/model.h b/model.h
index 73272809873ca66b11de81916f75c288953e4826..8fdfc47ae41a8fc0419d04c1570075bdddb0243e 100644 (file)
--- a/model.h
+++ b/model.h
@@ -132,7 +132,7 @@ public:
        void check_promises(thread_id_t tid, ClockVector *old_cv, ClockVector *merge_cv);
        bool isfeasibleprefix() const;
 
-       bool assert_bug(const char *msg);
+       bool assert_bug(const char *msg, ...);
        void assert_user_bug(const char *msg);
 
        const model_params params;