From e13cc58823c34f8e9f01b17bee7eafc4e6af77a2 Mon Sep 17 00:00:00 2001
From: "thomas.dilasser" <thomas.dilasser@ensiie.fr>
Date: Sat, 20 Oct 2018 21:21:24 +0200
Subject: [PATCH] add a print function and function name in execute

---
 functions/aux_values.c | 13 +++++++++++++
 functions/aux_values.h |  1 +
 plugin.cpp             |  5 +++--
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/functions/aux_values.c b/functions/aux_values.c
index 6c93048..cbdb391 100644
--- a/functions/aux_values.c
+++ b/functions/aux_values.c
@@ -15,3 +15,16 @@ void edit_all_aux_value(function * fun,int *i)
                 bb->aux = i;
         }
 }
+
+void print_bb_aux(function * fun)
+{
+        basic_block bb;
+        FOR_ALL_BB_FN(bb,fun)
+        {
+                if (bb->aux !=NULL && *((int *)bb->aux)>=0)
+                {
+                        printf("bb aux value here : %i\n",*((int *)bb->aux));
+                }
+        }
+}
+
diff --git a/functions/aux_values.h b/functions/aux_values.h
index 46de337..78069ca 100644
--- a/functions/aux_values.h
+++ b/functions/aux_values.h
@@ -3,5 +3,6 @@
 
 void edit_aux_value(basic_block bb, int *i);
 void edit_all_aux_value(function * fun,int *i);
+void print_bb_aux(function * fun);
 
 #endif
diff --git a/plugin.cpp b/plugin.cpp
index d87b347..acbfcf0 100755
--- a/plugin.cpp
+++ b/plugin.cpp
@@ -71,7 +71,7 @@ class my_pass : public gimple_opt_pass
                 /* Gate function (shall we apply this pass?) */
                 bool gate (function * fun)
                 {
-                        printf("plugin: gate... \n");
+                        printf("=> plugin: gate... \n");
                         return true;
                 }
 
@@ -80,7 +80,8 @@ class my_pass : public gimple_opt_pass
                 /* Execute function */
                 unsigned int execute (function *fun)
                 {
-                        printf("plugin: execute...\n");
+                        printf("=> plugin: execute...\n");
+			printf("... in function %s\n", function_name(fun));
 			edit_all_aux_value(fun,(int*)NULL);
 			return 0;
                 }
-- 
GitLab