Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] test the TRACE_get_[host|link]_variables
[simgrid.git] / examples / msg / tracing / user_variables.c
index 245e026..87a7fa0 100644 (file)
@@ -6,7 +6,12 @@
 
 /** @addtogroup MSG_examples
  * 
- * - <b>tracing/user_variables.c</b>: Demonstrates how to trace user-provided variables
+ * - <b>tracing/user_variables.c</b>: This program demonstrates how to
+ * trace user variables associated to the hosts of the platform file.
+ * You might want to run this program with the following parameters:
+ * --cfg=tracing:1
+ * --cfg=tracing/platform:1
+ * (See \ref tracing_tracing_options for details)
  */
 
 #include <stdio.h>
@@ -74,6 +79,27 @@ int main(int argc, char *argv[])
   MSG_launch_application(deployment_file);
 
   MSG_main();
+
+  //get user declared variables
+  unsigned int cursor;
+  char *variable;
+  xbt_dynar_t host_variables = TRACE_get_host_variables ();
+  if (host_variables){
+    XBT_INFO ("Declared host variables:");
+    xbt_dynar_foreach (host_variables, cursor, variable){
+      XBT_INFO ("%s", variable);
+    }
+    xbt_dynar_free (&host_variables);
+  }
+  xbt_dynar_t link_variables = TRACE_get_link_variables ();
+  if (link_variables){
+    XBT_INFO ("Declared link variables:");
+    xbt_dynar_foreach (link_variables, cursor, variable){
+      XBT_INFO ("%s", variable);
+    }
+    xbt_dynar_free (&link_variables);
+  }
+
   MSG_clean();
   return 0;
 }