void TRACE_activate (void)
{
- if (trace_active){
- THROW0(tracing_error, TRACE_ERROR_ALREADY_ACTIVE,
- "Tracing is already active.");
- }
+ xbt_assert0 (trace_active==0, "Tracing is already active.");
trace_active = 1;
+ DEBUG0 ("Tracing is on");
}
void TRACE_desactivate (void)
{
trace_active = 0;
+ DEBUG0 ("Tracing is off");
}
int TRACE_is_active (void)
char *output = TRACE_get_triva_uncat_conf ();
if (output && strlen(output) > 0){
FILE *file = fopen (output, "w");
- if (!file){
- THROW1(tracing_error, TRACE_ERROR_FILE_OPEN,
- "Unable to open file (%s) for writing triva graph configuration (uncategorized).", output);
- }
+ xbt_assert1 (file != NULL,
+ "Unable to open file (%s) for writing triva graph "
+ "configuration (uncategorized).", output);
fprintf (file,
"{\n"
" node = (HOST);\n"
if (output && strlen(output) > 0){
//check if we do have categories declared
if (xbt_dict_length(created_categories) == 0){
-// INFO0("No categories declared, ignoring generation of triva graph configuration");
+ INFO0("No categories declared, ignoring generation of triva graph configuration");
return;
}
xbt_dict_cursor_t cursor=NULL;
char *key, *data;
FILE *file = fopen (output, "w");
- if (!file){
- THROW1(tracing_error, TRACE_ERROR_FILE_OPEN,
- "Unable to open file (%s) for writing triva graph configuration (categorized).", output);
- }
+ xbt_assert1 (file != NULL,
+ "Unable to open file (%s) for writing triva graph "
+ "configuration (categorized).", output);
fprintf (file,
"{\n"
" node = (HOST);\n"
return 0;
}
+ DEBUG0("Tracing starts");
+
/* open the trace file */
TRACE_paje_start();
{
if (!TRACE_is_active())
return 1;
+ XBT_IN;
/* close the trace file */
TRACE_paje_end();
/* activate trace */
TRACE_desactivate ();
+ DEBUG0("Tracing system is shutdown");
return 0;
}
if (!TRACE_is_active())
return;
- //check if type is already defined
- if (xbt_dict_get_or_null(defined_types, type)) {
- THROW1(tracing_error, TRACE_ERROR_TYPE_ALREADY_DEFINED,
- "Type %s is already defined", type);
- }
- //check if parent_type is already defined
- if (strcmp(parent_type, "0")
- && !xbt_dict_get_or_null(defined_types, parent_type)) {
- THROW1(tracing_error, TRACE_ERROR_TYPE_NOT_DEFINED,
- "Type (used as parent) %s is not defined", parent_type);
- }
+ char *defined;
+ //type must not exist
+ defined = xbt_dict_get_or_null(defined_types, type);
+ xbt_assert1 (defined == NULL, "Type %s is already defined", type);
+ //parent_type must exist or be different of 0
+ defined = xbt_dict_get_or_null(defined_types, parent_type);
+ xbt_assert1 (defined != NULL || strcmp(parent_type, "0") == 0,
+ "Type (used as parent) %s is not defined", parent_type);
pajeDefineContainerType(type, parent_type, type);
if (final) {
if (!TRACE_is_active())
return 1;
+ char *defined = xbt_dict_get_or_null(defined_types, type);
//check if type is defined
- if (!xbt_dict_get_or_null(defined_types, type)) {
- THROW1(tracing_error, TRACE_ERROR_TYPE_NOT_DEFINED,
- "Type %s is not defined", type);
- return 1;
- }
+ xbt_assert1 (defined != NULL, "Type %s is not defined", type);
//check if parent_category exists
- if (strcmp(parent_category, "0")
- && !xbt_dict_get_or_null(created_categories, parent_category)) {
- THROW1(tracing_error, TRACE_ERROR_CATEGORY_NOT_DEFINED,
- "Category (used as parent) %s is not created", parent_category);
- return 1;
- }
+ defined = xbt_dict_get_or_null(created_categories, parent_category);
+ xbt_assert1 (defined != NULL || strcmp(parent_category, "0") == 0,
+ "Category (used as parent) %s is not created", parent_category);
//check if category is created
- if (xbt_dict_get_or_null(created_categories, category)) {
- return 1;
- }
+ char *created = xbt_dict_get_or_null(created_categories, category);
+ xbt_assert1 (created == NULL, "Category %s is already defined", category);
pajeCreateContainer(MSG_get_clock(), category, type, parent_category,
category);
snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%s", color);
}
+ DEBUG2("CAT,declare %s, %s", category, final_color);
+
/* for registering application categories on top of platform */
snprintf(state, 100, "b%s", category);
if (TRACE_platform_is_enabled())
if (!mark_type)
return;
+ DEBUG1("MARK,declare %s", mark_type);
pajeDefineEventType(mark_type, "0", mark_type);
}
if (!mark_type || !mark_value)
return;
+ DEBUG2("MARK %s %s", mark_type, mark_value);
pajeNewEvent(MSG_get_clock(), mark_type, "0", mark_value);
}
if (!TRACE_is_active())
return;
+ xbt_assert3(task->category == NULL, "Task %p(%s) already has a category (%s).",
+ task, task->name, task->category);
+
//set task category
- task->category = xbt_new(char, strlen(category) + 1);
- strncpy(task->category, category, strlen(category) + 1);
+ task->category = xbt_strdup (category);
+ DEBUG3("MSG task %p(%s), category %s", task, task->name, task->category);
//tracing task location based on host
TRACE_task_location(task);
static long long counter = 0;
task->counter = counter++;
task->category = NULL;
+ DEBUG2("CREATE %p, %lld", task, task->counter);
}
/* MSG_task_execute related functions */
if (!task->category)
return;
+ DEBUG3("EXEC,in %p, %lld, %s", task, task->counter, task->category);
+
TRACE_task_container(task, name, 200);
if (TRACE_msg_task_is_enabled())
pajePushState(MSG_get_clock(), "task-state", name, "execute");
pajePopState(MSG_get_clock(), "task-state", name);
TRACE_category_unset(SIMIX_process_self());
+
+ DEBUG3("EXEC,out %p, %lld, %s", task, task->counter, task->category);
}
/* MSG_task_destroy related functions */
//finish the location of this task
TRACE_task_location_not_present(task);
+ DEBUG3("DESTROY %p, %lld, %s", task, task->counter, task->category);
+
//free category
xbt_free(task->category);
return;
{
if (!TRACE_is_active())
return;
+
+ DEBUG0("GET,in");
}
void TRACE_msg_task_get_end(double start_time, m_task_t task)
TRACE_task_location(task);
TRACE_task_location_present(task);
+
+ DEBUG3("GET,out %p, %lld, %s", task, task->counter, task->category);
}
/* MSG_task_put related functions */
if (!task->category)
return 0;
+ DEBUG3("PUT,in %p, %lld, %s", task, task->counter, task->category);
+
TRACE_task_container(task, name, 200);
if (TRACE_msg_task_is_enabled())
pajePopState(MSG_get_clock(), "task-state", name);
return;
TRACE_category_unset(SIMIX_process_self());
+
+ DEBUG0("PUT,in");
}
#endif /* HAVE_TRACING */
#ifdef HAVE_TRACING
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje, instr, "Paje tracing event system");
+
static FILE *tracing_file = NULL;
static int pajeDefineContainerTypeId = 0;
{
char *filename = TRACE_get_filename();
tracing_file = fopen(filename, "w");
- if (!tracing_file) {
- THROW1(tracing_error, TRACE_ERROR_FILE_OPEN,
- "Tracefile %s could not be opened for writing.", filename);
- }
+ xbt_assert1 (tracing_file != NULL, "Tracefile %s could not be opened for writing.", filename);
+
+ DEBUG1("Filename %s is open for writing", filename);
/* output header */
TRACE_paje_create_header();
void TRACE_paje_end(void)
{
fclose(tracing_file);
+ char *filename = TRACE_get_filename();
+ DEBUG1("Filename %s is closed", filename);
}
void TRACE_paje_create_header(void)
{
+ DEBUG0 ("Define paje header");
fprintf(tracing_file, "\
%%EventDef PajeDefineContainerType %d \n\
%% Alias string \n\
act->counter = counter++;
char *category = TRACE_category_get(SIMIX_process_self());
if (category) {
- act->category = xbt_new(char, strlen(category) + 1);
- strncpy(act->category, category, strlen(category) + 1);
+ act->category = xbt_strdup(category);
+ DEBUG2("Create Execute SMX action %p, category %s", act, act->category);
}
TRACE_surf_resource_utilization_start(act);
}
char *category = TRACE_category_get(proc);
if (category) {
act->category = xbt_strdup(category);
+ DEBUG2("Create Communicate SMX action %p, category %s", act, act->category);
}
TRACE_surf_resource_utilization_start(act);
}
return;
if (act->category) {
+ DEBUG2("Destroy SMX action %p, category %s", act, act->category);
xbt_free(act->category);
}
TRACE_surf_resource_utilization_end(act);