1 /* Copyright (c) 2010. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "simgrid_config.h"
11 #include "instr/instr_private.h"
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_api, instr, "API");
15 xbt_dict_t created_categories;
17 void TRACE_category(const char *category)
19 TRACE_category_with_color (category, NULL);
22 void TRACE_category_with_color (const char *category, const char *color)
24 if (!TRACE_is_active())
27 xbt_assert1 (instr_platform_traced(),
28 "%s must be called after environment creation", __FUNCTION__);
30 //check if category is already created
31 char *created = xbt_dict_get_or_null(created_categories, category);
33 xbt_dict_set (created_categories, category, xbt_strdup("1"), xbt_free);
36 char final_color[INSTR_DEFAULT_STR_SIZE];
38 //generate a random color
39 double red = drand48();
40 double green = drand48();
41 double blue = drand48();
42 snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%f %f %f", red, green, blue);
44 snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%s", color);
47 DEBUG2("CAT,declare %s, %s", category, final_color);
51 // - //for m_process_t
52 // - if (TRACE_msg_process_is_enabled())
53 // - pajeDefineContainerType("process", type, "process");
54 // - if (TRACE_msg_process_is_enabled())
55 // - pajeDefineStateType("process-state", "process", "process-state");
57 // - if (TRACE_msg_task_is_enabled())
58 // - pajeDefineContainerType("task", type, "task");
59 // - if (TRACE_msg_task_is_enabled())
60 // - pajeDefineStateType("task-state", "task", "task-state");
63 //define the type of this category on top of hosts and links
64 if (TRACE_categorized ()){
65 instr_new_user_variable_type (category, final_color);
69 void TRACE_declare_mark(const char *mark_type)
71 if (!TRACE_is_active())
76 DEBUG1("MARK,declare %s", mark_type);
77 pajeDefineEventType(mark_type, "0", mark_type);
80 void TRACE_mark(const char *mark_type, const char *mark_value)
82 if (!TRACE_is_active())
84 if (!mark_type || !mark_value)
87 DEBUG2("MARK %s %s", mark_type, mark_value);
88 pajeNewEvent(MSG_get_clock(), mark_type, "0", mark_value);
91 #endif /* HAVE_TRACING */