X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c85c6cbfb4ee7d118644fef7a3915f7f7f3183d1..2e6458d139c6e634715f1310977c85328756b566:/src/instr/instr_interface.c diff --git a/src/instr/instr_interface.c b/src/instr/instr_interface.c index 8c76011b2f..3d582d8c73 100644 --- a/src/instr/instr_interface.c +++ b/src/instr/instr_interface.c @@ -23,6 +23,22 @@ xbt_dict_t created_categories = NULL; xbt_dict_t declared_marks = NULL; xbt_dict_t user_host_variables = NULL; xbt_dict_t user_link_variables = NULL; +extern xbt_dict_t trivaNodeTypes; +extern xbt_dict_t trivaEdgeTypes; + +static xbt_dynar_t instr_dict_to_dynar (xbt_dict_t filter) +{ + if (!TRACE_is_enabled()) return NULL; + if (!TRACE_needs_platform()) return NULL; + + xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref); + xbt_dict_cursor_t cursor = NULL; + char *name, *value; + xbt_dict_foreach(filter, cursor, name, value) { + xbt_dynar_push_as (ret, char*, xbt_strdup(name)); + } + return ret; +} /** \ingroup TRACE_category * \brief Declare a new category with a random color. @@ -119,13 +135,7 @@ xbt_dynar_t TRACE_get_categories (void) if (!TRACE_is_enabled()) return NULL; if (!TRACE_categorized()) return NULL; - xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref); - xbt_dict_cursor_t cursor = NULL; - char *name, *value; - xbt_dict_foreach(created_categories, cursor, name, value) { - xbt_dynar_push_as (ret, char*, xbt_strdup(name)); - } - return ret; + return instr_dict_to_dynar (created_categories); } /** \ingroup TRACE_mark @@ -211,13 +221,7 @@ xbt_dynar_t TRACE_get_marks (void) { if (!TRACE_is_enabled()) return NULL; - xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref); - xbt_dict_cursor_t cursor = NULL; - char *name, *value; - xbt_dict_foreach(declared_marks, cursor, name, value) { - xbt_dynar_push_as (ret, char*, xbt_strdup(name)); - } - return ret; + return instr_dict_to_dynar (declared_marks); } static void instr_user_variable(double time, @@ -483,6 +487,19 @@ void TRACE_host_variable_sub_with_time (double time, const char *host, const cha instr_user_variable(time, host, variable, "HOST", value, INSTR_US_SUB, NULL, user_host_variables); } +/** \ingroup TRACE_user_variables + * \brief Get declared user host variables + * + * This function should be used to get host variables that were already + * declared with #TRACE_host_variable_declare or with #TRACE_host_variable_declare_with_color. + * + * \return A dynar with the declared host variables, must be freed with xbt_dynar_free. + */ +xbt_dynar_t TRACE_get_host_variables (void) +{ + return instr_dict_to_dynar (user_host_variables); +} + /* for link variables */ /** \ingroup TRACE_user_variables * \brief Declare a new user variable associated to links. @@ -759,4 +776,45 @@ void TRACE_link_srcdst_variable_sub_with_time (double time, const char *src, con instr_user_srcdst_variable (time, src, dst, variable, "LINK", value, INSTR_US_SUB); } +/** \ingroup TRACE_user_variables + * \brief Get declared user link variables + * + * This function should be used to get link variables that were already + * declared with #TRACE_link_variable_declare or with #TRACE_link_variable_declare_with_color. + * + * \return A dynar with the declared link variables, must be freed with xbt_dynar_free. + */ +xbt_dynar_t TRACE_get_link_variables (void) +{ + return instr_dict_to_dynar (user_link_variables); +} + +/** \ingroup TRACE_API + * \brief Get Paje container types that can be mapped to the nodes of a graph. + * + * This function can be used to create a user made + * graph configuration file for Triva. Normally, it is + * used with the functions defined in \ref TRACE_user_variables. + * + * \return A dynar with the types, must be freed with xbt_dynar_free. + */ +xbt_dynar_t TRACE_get_node_types (void) +{ + return instr_dict_to_dynar (trivaNodeTypes); +} + +/** \ingroup TRACE_API + * \brief Get Paje container types that can be mapped to the edges of a graph. + * + * This function can be used to create a user made + * graph configuration file for Triva. Normally, it is + * used with the functions defined in \ref TRACE_user_variables. + * + * \return A dynar with the types, must be freed with xbt_dynar_free. + */ +xbt_dynar_t TRACE_get_edge_types (void) +{ + return instr_dict_to_dynar (trivaEdgeTypes); +} + #endif /* HAVE_TRACING */