From: schnorr Date: Mon, 13 Dec 2010 16:45:00 +0000 (+0000) Subject: [trace] checking if platform is traced in tracing API X-Git-Tag: v3.6_beta2~731 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/9371d0958b1cb03eb1ad4ccc8d2ba04416b4fd28 [trace] checking if platform is traced in tracing API details: - for the features that need a known platform to work git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9192 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/instr/instr_interface.c b/src/instr/instr_interface.c index 2b03005b2e..6c547ee6b1 100644 --- a/src/instr/instr_interface.c +++ b/src/instr/instr_interface.c @@ -23,12 +23,9 @@ void TRACE_category_with_color (const char *category, const char *color) { if (!TRACE_is_active()) return; -// -// { -// //check if hosts have been created -// xbt_assert1 (allHostTypes != NULL && xbt_dict_length(allHostTypes) != 0, -// "%s must be called after environment creation", __FUNCTION__); -// } + + xbt_assert1 (instr_platform_traced(), + "%s must be called after environment creation", __FUNCTION__); //check if category is already created char *created = xbt_dict_get_or_null(created_categories, category); diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index c8faa8511c..051fb32baa 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -187,6 +187,7 @@ void instr_destroy_platform (void); void instr_new_user_variable_type (const char *new_typename, const char *color); void instr_new_user_link_variable_type (const char *new_typename, const char *color); void instr_new_user_host_variable_type (const char *new_typename, const char *color); +int instr_platform_traced (void); #endif /* HAVE_TRACING */ #endif /* INSTR_PRIVATE_H_ */ diff --git a/src/instr/instr_routing.c b/src/instr/instr_routing.c index 03663d5b22..3ed7eed7b0 100644 --- a/src/instr/instr_routing.c +++ b/src/instr/instr_routing.c @@ -47,6 +47,7 @@ typedef struct s_container { xbt_dict_t children; }s_container_t; +static int platform_created = 0; /* indicate whether the platform file has been traced */ static type_t rootType = NULL; /* the root type */ static container_t rootContainer = NULL; /* the root container */ static xbt_dynar_t currentContainer = NULL; /* push and pop, used only in creation */ @@ -456,6 +457,7 @@ static void instr_routing_parse_end_platform () { currentContainer = NULL; recursiveGraphExtraction (rootContainer); + platform_created = 1; } /* @@ -584,5 +586,10 @@ void instr_new_user_host_variable_type (const char *new_typename, const char *c recursiveNewUserHostVariableType (new_typename, color, rootType); } +int instr_platform_traced () +{ + return platform_created; +} + #endif /* HAVE_TRACING */ diff --git a/src/instr/instr_variables.c b/src/instr/instr_variables.c index 7e894f7c52..608186ba7f 100644 --- a/src/instr/instr_variables.c +++ b/src/instr/instr_variables.c @@ -17,6 +17,9 @@ void TRACE_user_link_variable(double time, const char *resource, if (!TRACE_is_active()) return; + xbt_assert1 (instr_platform_traced(), + "%s must be called after environment creation", __FUNCTION__); + char valuestr[100]; snprintf(valuestr, 100, "%g", value); @@ -41,6 +44,9 @@ void TRACE_user_host_variable(double time, const char *variable, if (!TRACE_is_active()) return; + xbt_assert1 (instr_platform_traced(), + "%s must be called after environment creation", __FUNCTION__); + char valuestr[100]; snprintf(valuestr, 100, "%g", value);