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 938e690..87a7fa0 100644 (file)
@@ -4,6 +4,16 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+/** @addtogroup MSG_examples
+ * 
+ * - <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>
 #include "msg/msg.h"
 #include "xbt/sysdep.h"         /* calloc, printf */
@@ -69,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;
 }