From 7de7b7c35d385a48c7bea5e63a98687664cab9c8 Mon Sep 17 00:00:00 2001
From: Petr Rockai <me@mornfall.net>
Date: Mon, 24 Jun 2019 22:25:37 +0000
Subject: [PATCH] MC: Add a context module for tracking a path condition.

---
 divine/mc/ctx-assume.hpp | 48 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 divine/mc/ctx-assume.hpp

diff --git a/divine/mc/ctx-assume.hpp b/divine/mc/ctx-assume.hpp
new file mode 100644
index 000000000..64a5e01f0
--- /dev/null
+++ b/divine/mc/ctx-assume.hpp
@@ -0,0 +1,48 @@
+// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+
+/*
+ * (c) 2019 Petr RoÄŤkai <code@fixp.eu>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#pragma once
+#include <divine/vm/types.hpp>
+#include <divine/vm/pointer.hpp>
+#include <divine/smt/extract.hpp>
+#include <brick-compose>
+
+namespace divine::mc
+{
+    template< typename next >
+    struct ctx_assume_ : next
+    {
+        vm::HeapPointer _assume;
+
+        using next::trace;
+        void trace( vm::TraceAssume ta )
+        {
+            _assume = ta.ptr;
+            if ( this->debug_allowed() )
+            {
+                brick::smt::Context ctx;
+                smt::extract::SMTLib2 extract( this->heap(), ctx, "", false );
+                auto assume = extract.read( ta.ptr );
+                auto n = extract.convert( assume->binary.left );
+                trace( "ASSUME " + to_string( n ) );
+            }
+        }
+    };
+
+    using ctx_assume = brq::module< ctx_assume_ >;
+}
-- 
GitLab