Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
creating a source file dedicated to handle the categories
authorschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 15 Sep 2010 15:58:20 +0000 (15:58 +0000)
committerschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 15 Sep 2010 15:58:20 +0000 (15:58 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8185 48e7efb5-ca39-0410-a469-dd3cf9ba447f

buildtools/Cmake/DefinePackages.cmake
src/instr/categories.c [new file with mode: 0644]
src/instr/interface.c
src/instr/msg_task_instr.c
src/instr/private.h
src/instr/smx_instr.c

index ed0ef31..2b5b50b 100755 (executable)
@@ -326,6 +326,7 @@ set(LUA_SRC
 
 set(TRACING_SRC
        src/instr/instr_config.c
+       src/instr/categories.c
        src/instr/interface.c
        src/instr/general.c
        src/instr/paje.c
diff --git a/src/instr/categories.c b/src/instr/categories.c
new file mode 100644 (file)
index 0000000..74d5a60
--- /dev/null
@@ -0,0 +1,47 @@
+/* Copyright (c) 2010. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* 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. */
+
+#include "instr/private.h"
+
+#ifdef HAVE_TRACING
+
+static xbt_dict_t current_task_category = NULL;
+
+void __TRACE_category_init ()
+{
+  current_task_category = xbt_dict_new();
+}
+
+void __TRACE_category_set (smx_process_t proc, const char *category)
+{
+  char processid[100];
+  char *var_cpy = NULL;
+  snprintf (processid, 100, "%p", proc);
+  var_cpy = xbt_strdup (category);
+  xbt_dict_set (current_task_category, processid, var_cpy, xbt_free);
+}
+
+char *__TRACE_category_get (smx_process_t proc)
+{
+  char processid[100];
+  snprintf (processid, 100, "%p", proc);
+  return xbt_dict_get_or_null (current_task_category, processid);
+}
+
+void __TRACE_category_unset (smx_process_t proc)
+{
+  char processid[100];
+  snprintf (processid, 100, "%p", proc);
+  xbt_dict_remove (current_task_category, processid);
+}
+
+void __TRACE_msg_category_set (smx_process_t proc, m_task_t task)
+{
+  __TRACE_category_set (proc, task->category);
+}
+
+
+#endif
index 1d87e24..8b1d08c 100644 (file)
@@ -89,6 +89,7 @@ int TRACE_start ()
   defined_types = xbt_dict_new();
   created_categories = xbt_dict_new();
   __TRACE_msg_init();
+  __TRACE_category_init ();
   __TRACE_surf_init();
   __TRACE_msg_process_init ();
   __TRACE_smpi_init ();
index adfbc59..5e868c3 100644 (file)
@@ -9,37 +9,12 @@
 #ifdef HAVE_TRACING
 
 static xbt_dict_t task_containers = NULL;
-static xbt_dict_t current_task_category = NULL;
 
 void __TRACE_msg_init (void)
 {
-  current_task_category = xbt_dict_new();
   task_containers = xbt_dict_new();
 }
 
-void __TRACE_current_category_set (m_task_t task)
-{
-  char processid[100];
-  char *var_cpy = NULL;
-  snprintf (processid, 100, "%p", SIMIX_process_self());
-  var_cpy = xbt_strdup (task->category);
-  xbt_dict_set (current_task_category, processid, var_cpy, xbt_free);
-}
-
-void __TRACE_current_category_unset ()
-{
-  char processid[100];
-  snprintf (processid, 100, "%p", SIMIX_process_self());
-  xbt_dict_remove (current_task_category, processid);
-}
-
-char *__TRACE_current_category_get (smx_process_t proc)
-{
-  char processid[100];
-  snprintf (processid, 100, "%p", proc);
-  return xbt_dict_get_or_null (current_task_category, processid);
-}
-
 void __TRACE_task_location (m_task_t task)
 {
        char container[200];
@@ -131,7 +106,7 @@ void TRACE_msg_task_execute_start (m_task_t task)
   TRACE_task_container (task, name, 200);
   if (IS_TRACING_TASKS) pajePushState (MSG_get_clock(), "task-state", name, "execute");
 
-  __TRACE_current_category_set (task);
+  __TRACE_msg_category_set (SIMIX_process_self(), task);
 }
 
 void TRACE_msg_task_execute_end (m_task_t task)
@@ -142,7 +117,7 @@ void TRACE_msg_task_execute_end (m_task_t task)
   TRACE_task_container (task, name, 200);
   if (IS_TRACING_TASKS) pajePopState (MSG_get_clock(), "task-state", name);
 
-  __TRACE_current_category_unset();
+  __TRACE_category_unset(SIMIX_process_self());
 }
 
 /* MSG_task_destroy related functions */
@@ -198,7 +173,7 @@ int TRACE_msg_task_put_start (m_task_t task)
   __TRACE_task_location_not_present (task);
 
   //set current category
-  __TRACE_current_category_set (task);
+  __TRACE_msg_category_set (SIMIX_process_self(), task);
   return 1;
 }
 
@@ -206,7 +181,7 @@ void TRACE_msg_task_put_end (void)
 {
   if (!IS_TRACING) return;
 
-  __TRACE_current_category_unset ();
+  __TRACE_category_unset (SIMIX_process_self());
 }
 
 #endif
index a5db650..e44ed32 100644 (file)
@@ -66,11 +66,15 @@ char *TRACE_process_container (m_process_t process, char *output, int len);
 char *TRACE_process_alias_container (m_process_t process, m_host_t host, char *output, int len);
 char *TRACE_task_alias_container (m_task_t task, m_process_t process, m_host_t host, char *output, int len);
 
+/* from categories.c */
+void __TRACE_category_init (void);
+void __TRACE_category_set (smx_process_t proc, const char *category);
+char *__TRACE_category_get (smx_process_t proc);
+void __TRACE_category_unset (smx_process_t proc);
+void __TRACE_msg_category_set (smx_process_t proc, m_task_t task);
+
 /* declaration of instrumentation functions from msg_task_instr.c */
 void __TRACE_msg_init (void);
-void __TRACE_current_category_set (m_task_t task);
-void __TRACE_current_category_unset (void);
-char *__TRACE_current_category_get (smx_process_t proc);
 void __TRACE_task_location (m_task_t task);
 void __TRACE_task_location_present (m_task_t task);
 void __TRACE_task_location_not_present (m_task_t task);
index c95ac72..bb959d5 100644 (file)
@@ -16,7 +16,7 @@ void TRACE_smx_action_execute (smx_action_t act)
   if (!IS_TRACING) return;
 
   act->counter = counter++;
-  category = __TRACE_current_category_get (SIMIX_process_self());
+  category = __TRACE_category_get (SIMIX_process_self());
   if (category){
        act->category = xbt_new (char, strlen (category)+1);
        strncpy (act->category, category, strlen(category)+1);
@@ -29,7 +29,7 @@ void TRACE_smx_action_communicate (smx_action_t act, smx_process_t proc)
   if (!IS_TRACING) return;
 
   act->counter = counter++;
-  category = __TRACE_current_category_get (proc);
+  category = __TRACE_category_get (proc);
   if (category){
     act->category = xbt_strdup (category);
   }