From 38784a79c9c6f97f42fb874d4a5d8b8248cd6899 Mon Sep 17 00:00:00 2001
From: Hans-Peter Deifel <hpd@hpdeifel.de>
Date: Mon, 10 Oct 2016 15:40:16 +0200
Subject: [PATCH] Print syscall name together with state

This prints which syscall follows the current state to be able to label
the edges properly.
---
 files/mockup_prelude.cc | 6 +++---
 src/CFG/C.hs            | 2 +-
 test/CFG/CSpec.hs       | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/files/mockup_prelude.cc b/files/mockup_prelude.cc
index edb4196..5a865c0 100644
--- a/files/mockup_prelude.cc
+++ b/files/mockup_prelude.cc
@@ -99,8 +99,8 @@ uint32_t hash_os_state() {
     return first_hash ^ second_hash;
 }
 
-void _print_os_state(int line) {
-	kout << "Line " << line << " in state ";
+void _print_os_state(const char *syscall, int line) {
+	kout << "Line " << line << " before syscall " << syscall << " in state ";
 	kout << "0x" << hex << hash_os_state() << dec << endl;
 	fflush(stdout);
 }
@@ -120,7 +120,7 @@ int _decisionMaker(int i) {
 }
 
 void PreIdleHook() {
-	_print_os_state(__LINE__);
+	_print_os_state("PreIdleHook", __LINE__);
         ShutdownMachine();
 }
 
diff --git a/src/CFG/C.hs b/src/CFG/C.hs
index 578e19c..bf38d0f 100644
--- a/src/CFG/C.hs
+++ b/src/CFG/C.hs
@@ -77,7 +77,7 @@ instrToC (IfThanElse decision left right) =
   "  goto " <> right <> ";"
 instrToC (Call ident False) = ident <> "();"
 instrToC (Call ident True)  =
-  "_print_os_state(__LINE__);\n"
+  "_print_os_state(\"" <> ident <> "\", __LINE__);\n"
   <> ident <> "();"
 instrToC Return = "return;"
 
diff --git a/test/CFG/CSpec.hs b/test/CFG/CSpec.hs
index ed29d4a..e64ebf8 100644
--- a/test/CFG/CSpec.hs
+++ b/test/CFG/CSpec.hs
@@ -41,7 +41,7 @@ example1OutputLines =
   , "  goto Two;"
   , "else"
   , "  goto Zero;"
-  , "_print_os_state(__LINE__);"
+  , "_print_os_state(\"syscall\", __LINE__);"
   , "syscall();"
   , "Two:"
   , "goto One;"
-- 
GitLab