From a6e716740f12602310c06e53de757acd75197507 Mon Sep 17 00:00:00 2001 From: schnorr Date: Wed, 5 Jan 2011 18:08:58 +0000 Subject: [PATCH] [trace] using process name and PID as identification for user when tracing/msg/process:1 details: - process categorization is deprecated (simpler instrumentation to try to make model-checking possible) - simpler instrumentation == all process being traced when tracing/msg/process:1 git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9366 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- include/msg/datatypes.h | 3 - src/instr/instr_msg_process.c | 185 ++++++++++++++++++---------------- src/instr/instr_msg_task.c | 30 ++++-- src/instr/instr_private.h | 5 +- src/msg/m_process.c | 4 + 5 files changed, 126 insertions(+), 101 deletions(-) diff --git a/include/msg/datatypes.h b/include/msg/datatypes.h index d9d271c4a7..fa9643c481 100644 --- a/include/msg/datatypes.h +++ b/include/msg/datatypes.h @@ -79,9 +79,6 @@ typedef struct m_process { simdata_process_t simdata; /**< @brief simulator data */ void *data; /**< @brief user data */ -#ifdef HAVE_TRACING - char *category; /* process category for instrumentation */ -#endif } s_m_process_t; /** @} */ /** @brief Agent datatype diff --git a/src/instr/instr_msg_process.c b/src/instr/instr_msg_process.c index 6b6408d718..34e2dae73c 100644 --- a/src/instr/instr_msg_process.c +++ b/src/instr/instr_msg_process.c @@ -15,40 +15,13 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg_process, instr, "MSG process"); */ void TRACE_msg_set_process_category(m_process_t process, const char *category, const char *color) { - if (!TRACE_msg_process_is_enabled()) return; - - xbt_assert3(process->category == NULL, - "Process %p(%s) already has a category (%s).", - process, process->name, process->category); - xbt_assert2(process->name != NULL, - "Process %p(%s) must have a unique name in order to be traced.", - process, process->name); - xbt_assert3(getContainer(process->name)==NULL, - "Process %p(%s). Tracing already knows a process with name %s." - "The name of each process must be unique.", process, process->name, process->name); - - if (category == NULL) { - //if user provides a NULL category, process is no longer traced - xbt_free (process->category); - process->category = NULL; - return; - } - - //set process category - process->category = xbt_strdup(category); - DEBUG3("MSG process %p(%s), category %s", process, process->name, process->category); - - m_host_t host = MSG_process_get_host(process); - container_t host_container = getContainer(host->name); - container_t msg = newContainer(process->name, INSTR_MSG_PROCESS, host_container); - type_t type = getType (category); - if (!type){ - type = getVariableType(category, color, msg->type); - } - new_pajeSetVariable (SIMIX_get_clock(), msg, type, 1); + xbt_die("deprecated"); +} - type = getType ("MSG_PROCESS_STATE"); - new_pajeSetState (MSG_get_clock(), msg, type, "executing"); +char *instr_process_id (m_process_t proc, char *str, int len) +{ + snprintf (str, len, "%s-%d", MSG_process_get_name(proc), MSG_process_get_PID(proc)); + return str; } /* @@ -56,92 +29,126 @@ void TRACE_msg_set_process_category(m_process_t process, const char *category, c */ void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host, m_host_t new_host) { - if (!(TRACE_msg_process_is_enabled() && - process->category)) return; - - static long long int counter = 0; - char key[INSTR_DEFAULT_STR_SIZE]; - snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter++); - - //start link - container_t msg = getContainer(process->name); - type_t type = getType ("MSG_PROCESS_LINK"); - new_pajeStartLink (MSG_get_clock(), getRootContainer(), type, msg, "M", key); - - //destroy existing container of this process - destroyContainer(getContainer(process->name)); - - //create new container on the new_host location - msg = newContainer(process->name, INSTR_MSG_PROCESS, getContainer(new_host->name)); - type = getType (process->category); - new_pajeSetVariable (MSG_get_clock(), msg, type, 1); - - //set the state of this new container - type = getType ("MSG_PROCESS_STATE"); - new_pajeSetState (MSG_get_clock(), msg, type, "executing"); - - //end link - msg = getContainer(process->name); - type = getType ("MSG_PROCESS_LINK"); - new_pajeEndLink (MSG_get_clock(), getRootContainer(), type, msg, "M", key); + if (TRACE_msg_process_is_enabled()){ + static long long int counter = 0; + char key[INSTR_DEFAULT_STR_SIZE]; + snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter++); + + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + //start link + container_t msg = getContainer(instr_process_id(process, str, len)); + type_t type = getType ("MSG_PROCESS_LINK"); + new_pajeStartLink (MSG_get_clock(), getRootContainer(), type, msg, "M", key); + + //destroy existing container of this process + destroyContainer(getContainer(instr_process_id(process, str, len))); + + //create new container on the new_host location + msg = newContainer(instr_process_id(process, str, len), INSTR_MSG_PROCESS, getContainer(new_host->name)); +// type = getType (process->category); +// new_pajeSetVariable (MSG_get_clock(), msg, type, 1); + + //set the state of this new container + type = getType ("MSG_PROCESS_STATE"); + new_pajeSetState (MSG_get_clock(), msg, type, "executing"); + + //end link + msg = getContainer(instr_process_id(process, str, len)); + type = getType ("MSG_PROCESS_LINK"); + new_pajeEndLink (MSG_get_clock(), getRootContainer(), type, msg, "M", key); + } +} + +void TRACE_msg_process_create (m_process_t process) +{ + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + m_host_t host = MSG_process_get_host(process); + container_t host_container = getContainer(host->name); + container_t msg = newContainer(instr_process_id(process, str, len), INSTR_MSG_PROCESS, host_container); +// type_t type = getType (category); +// if (!type){ +// type = getVariableType(category, color, msg->type); +// } +// new_pajeSetVariable (SIMIX_get_clock(), msg, type, 1); + + type_t type = getType ("MSG_PROCESS_STATE"); + new_pajeSetState (MSG_get_clock(), msg, type, "executing"); + } } void TRACE_msg_process_kill(m_process_t process) { - if (!(TRACE_msg_process_is_enabled() && - process->category)) return; + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; - //kill means that this process no longer exists, let's destroy it - destroyContainer (getContainer(process->name)); + //kill means that this process no longer exists, let's destroy it + destroyContainer (getContainer(instr_process_id(process, str, len))); + } } void TRACE_msg_process_suspend(m_process_t process) { - if (!(TRACE_msg_process_is_enabled() && - process->category)) return; + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; - container_t process_container = getContainer (process->name); - type_t type = getType ("MSG_PROCESS_STATE"); - new_pajePushState (MSG_get_clock(), process_container, type, "suspend"); + container_t process_container = getContainer (instr_process_id(process, str, len)); + type_t type = getType ("MSG_PROCESS_STATE"); + new_pajePushState (MSG_get_clock(), process_container, type, "suspend"); + } } void TRACE_msg_process_resume(m_process_t process) { - if (!(TRACE_msg_process_is_enabled() && - process->category)) return; + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; - container_t process_container = getContainer (process->name); - type_t type = getType ("MSG_PROCESS_STATE"); - new_pajePopState (MSG_get_clock(), process_container, type); + container_t process_container = getContainer (instr_process_id(process, str, len)); + type_t type = getType ("MSG_PROCESS_STATE"); + new_pajePopState (MSG_get_clock(), process_container, type); + } } void TRACE_msg_process_sleep_in(m_process_t process) { - if (!(TRACE_msg_process_is_enabled() && - process->category)) return; + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; - container_t process_container = getContainer (process->name); - type_t type = getType ("MSG_PROCESS_STATE"); - new_pajePushState (MSG_get_clock(), process_container, type, "sleep"); + container_t process_container = getContainer (instr_process_id(process, str, len)); + type_t type = getType ("MSG_PROCESS_STATE"); + new_pajePushState (MSG_get_clock(), process_container, type, "sleep"); + } } void TRACE_msg_process_sleep_out(m_process_t process) { - if (!(TRACE_msg_process_is_enabled() && - process->category)) return; + if (TRACE_msg_process_is_enabled()){ + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; - container_t process_container = getContainer (process->name); - type_t type = getType ("MSG_PROCESS_STATE"); - new_pajePopState (MSG_get_clock(), process_container, type); + container_t process_container = getContainer (instr_process_id(process, str, len)); + type_t type = getType ("MSG_PROCESS_STATE"); + new_pajePopState (MSG_get_clock(), process_container, type); + } } void TRACE_msg_process_end(m_process_t process) { - if (!(TRACE_msg_process_is_enabled() && - process->category)) return; + if (TRACE_msg_process_is_enabled()) { + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; - //that's the end, let's destroy it - destroyContainer (getContainer(process->name)); + //that's the end, let's destroy it + destroyContainer (getContainer(instr_process_id(process, str, len))); + } } #endif /* HAVE_TRACING */ diff --git a/src/instr/instr_msg_task.c b/src/instr/instr_msg_task.c index f75736fb5b..8a8a6598c5 100644 --- a/src/instr/instr_msg_task.c +++ b/src/instr/instr_msg_task.c @@ -82,7 +82,10 @@ void TRACE_msg_task_execute_start(m_task_t task) } if (TRACE_msg_process_is_enabled()){ - container_t process_container = getContainer (MSG_process_self()->name); + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len)); type_t type = getType ("MSG_PROCESS_STATE"); new_pajePushState (MSG_get_clock(), process_container, type, "task_execute"); } @@ -101,7 +104,10 @@ void TRACE_msg_task_execute_end(m_task_t task) } if (TRACE_msg_process_is_enabled()){ - container_t process_container = getContainer (MSG_process_self()->name); + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len)); type_t type = getType ("MSG_PROCESS_STATE"); new_pajePopState (MSG_get_clock(), process_container, type); } @@ -134,7 +140,10 @@ void TRACE_msg_task_get_start(void) } if (TRACE_msg_process_is_enabled()){ - container_t process_container = getContainer (MSG_process_self()->name); + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len)); type_t type = getType ("MSG_PROCESS_STATE"); new_pajePushState (MSG_get_clock(), process_container, type, "receive"); } @@ -169,7 +178,10 @@ void TRACE_msg_task_get_end(double start_time, m_task_t task) } if (TRACE_msg_process_is_enabled()){ - container_t process_container = getContainer (MSG_process_self()->name); + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len)); type_t type = getType ("MSG_PROCESS_STATE"); new_pajePopState (MSG_get_clock(), process_container, type); @@ -207,7 +219,10 @@ int TRACE_msg_task_put_start(m_task_t task) } if (TRACE_msg_process_is_enabled()){ - container_t process_container = getContainer (MSG_process_self()->name); + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len)); type_t type = getType ("MSG_PROCESS_STATE"); new_pajePushState (MSG_get_clock(), process_container, type, "send"); @@ -229,7 +244,10 @@ void TRACE_msg_task_put_end(void) } if (TRACE_msg_process_is_enabled()){ - container_t process_container = getContainer (MSG_process_self()->name); + int len = INSTR_DEFAULT_STR_SIZE; + char str[INSTR_DEFAULT_STR_SIZE]; + + container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len)); type_t type = getType ("MSG_PROCESS_STATE"); new_pajePopState (MSG_get_clock(), process_container, type); } diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index ff33c7d17d..bf35c825c6 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -94,11 +94,10 @@ int TRACE_msg_task_put_start(m_task_t task); //returns TRUE if the task_put_e void TRACE_msg_task_put_end(void); /* declaration of instrumentation functions from msg_process_instr.c */ -char *TRACE_process_alias_container(m_process_t process, m_host_t host, - char *output, int len); -char *TRACE_process_container(m_process_t process, char *output, int len); +char *instr_process_id (m_process_t proc, char *str, int len); void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host, m_host_t new_host); +void TRACE_msg_process_create (m_process_t process); void TRACE_msg_process_kill(m_process_t process); void TRACE_msg_process_suspend(m_process_t process); void TRACE_msg_process_resume(m_process_t process); diff --git a/src/msg/m_process.c b/src/msg/m_process.c index 0084efddd8..2dcb16f81f 100644 --- a/src/msg/m_process.c +++ b/src/msg/m_process.c @@ -181,6 +181,10 @@ m_process_t MSG_process_create_with_environment(const char *name, return NULL; } +#ifdef HAVE_TRACING + TRACE_msg_process_create (process); +#endif + return process; } -- 2.20.1