return FALSE;
}
+gboolean before_enum_process_state(void *hook_data, void *call_data)
+{
+ mode_end((LttvTracefileStats *)call_data);
+ after_mode_end((LttvTracefileStats *)call_data);
+ mode_change((LttvTracefileStats *)call_data);
+ return FALSE;
+}
+
+gboolean after_enum_process_state(void *hook_data, void *call_data)
+{
+ update_event_tree((LttvTracefileStats *)call_data);
+ return FALSE;
+}
+
gboolean process_free(void *hook_data, void *call_data)
{
return FALSE;
}
static void lttv_stats_cleanup_process_state(gpointer key, gpointer value,
- gpointer user_data)
-{
- LttvTraceStats *tcs = (LttvTraceStats *)user_data;
- LttvTraceState *ts = (LttvTraceState *)user_data;
- LttvTracesetContext *tsc = ts->parent.ts_context;
- LttvProcessState *process = (LttvProcessState *)value;
- int i;
- LttvTracefileStats **tfs = (LttvTracefileStats **)
- &g_array_index(ts->parent.tracefiles, LttvTracefileContext*,
- process->cpu);
- int cleanup_empty = 0;
-
- do {
- if(ltt_time_compare(process->state->cum_cpu_time, ltt_time_zero) != 0) {
- find_event_tree(*tfs, process->pid_time,
- process->cpu,
- process->current_function,
- process->state->t, process->state->n, &((*tfs)->current_events_tree),
- &((*tfs)->current_event_types_tree));
- /* FIXME : ok, this is a hack. The time is infinite here :( */
- LttTime save_time = (*tfs)->parent.parent.timestamp;
- LttTime start, end;
- ltt_trace_time_span_get(ts->parent.t, &start, &end);
- (*tfs)->parent.parent.timestamp = end;
- mode_end(*tfs);
- (*tfs)->parent.parent.timestamp = save_time;
- }
- cleanup_empty = lttv_state_pop_state_cleanup(process,
- (LttvTracefileState *)*tfs);
- } while(cleanup_empty != 1);
+ gpointer user_data)
+{
+ LttvTraceStats *tcs = (LttvTraceStats *)user_data;
+ LttvTraceState *ts = (LttvTraceState *)user_data;
+ LttvTracesetContext *tsc = ts->parent.ts_context;
+ LttvProcessState *process = (LttvProcessState *)value;
+ int i;
+ LttvTracefileStats **tfs = (LttvTracefileStats **)
+ &g_array_index(ts->parent.tracefiles, LttvTracefileContext*,
+ process->cpu);
+ int cleanup_empty = 0;
+ LttTime nested_delta = ltt_time_zero;
+ /* FIXME : ok, this is a hack. The time is infinite here :( */
+ LttTime save_time = (*tfs)->parent.parent.timestamp;
+ LttTime start, end;
+ ltt_trace_time_span_get(ts->parent.t, &start, &end);
+ (*tfs)->parent.parent.timestamp = end;
+
+ do {
+ if(ltt_time_compare(process->state->cum_cpu_time, ltt_time_zero) != 0) {
+ find_event_tree(*tfs, process->pid_time,
+ process->cpu,
+ process->current_function,
+ process->state->t, process->state->n, &((*tfs)->current_events_tree),
+ &((*tfs)->current_event_types_tree));
+ /* if it is a running mode, we must count its cpu time */
+ if(process->state->s == LTTV_STATE_RUN)
+ mode_end(*tfs);
+ nested_delta = process->state->cum_cpu_time;
+ }
+ cleanup_empty = lttv_state_pop_state_cleanup(process,
+ (LttvTracefileState *)*tfs);
+ process->state->cum_cpu_time = ltt_time_add(process->state->cum_cpu_time,
+ nested_delta);
+
+ } while(cleanup_empty != 1);
+
+ (*tfs)->parent.parent.timestamp = save_time;
}
/* For each process in the state, for each of their stacked states,
static void lttv_stats_cleanup_state(LttvTraceStats *tcs)
{
LttvTraceState *ts = (LttvTraceState *)tcs;
-
-#if 0
- /* Does not work correctly FIXME. */
- g_hash_table_foreach(ts->processes, lttv_stats_cleanup_process_state,
- tcs);
-#endif //0
+
+ /* Does not work correctly FIXME. */
+ g_hash_table_foreach(ts->processes, lttv_stats_cleanup_process_state,
+ tcs);
}
void
}
}
if(!trace_is_summed) {
- //lttv_attribute_recursive_add(function_tree, mode_types_tree);
+ lttv_attribute_recursive_add(function_tree, mode_types_tree);
}
}
if(!trace_is_summed) {
- //lttv_attribute_recursive_add(cpu_tree, function_tree);
- //lttv_attribute_recursive_add(process_tree, function_tree);
- //lttv_attribute_recursive_add(trace_cpu_tree, function_tree);
- //lttv_attribute_recursive_add(main_tree, function_tree);
+ lttv_attribute_recursive_add(cpu_tree, function_tree);
+ lttv_attribute_recursive_add(process_tree, function_tree);
+ lttv_attribute_recursive_add(trace_cpu_tree, function_tree);
+ lttv_attribute_recursive_add(main_tree, function_tree);
}
- //lttv_attribute_recursive_add(ts_stats, function_tree);
+ lttv_attribute_recursive_add(ts_stats, function_tree);
}
}
}
/* Find the eventtype id for the following events and register the
associated by id hooks. */
- hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 11);
- g_array_set_size(hooks, 11);
- hn=0;
+ hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 12);
+ g_array_set_size(hooks, 12);
+ hn=0;
ret = lttv_trace_find_hook(ts->parent.parent.t,
LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY,
before_function_exit, NULL,
&g_array_index(hooks, LttvTraceHook, hn++));
if(ret) hn--;
-
+
+ /* statedump-related hooks */
+ ret = lttv_trace_find_hook(ts->parent.parent.t,
+ LTT_FACILITY_STATEDUMP, LTT_EVENT_ENUM_PROCESS_STATE,
+ LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME,
+ before_enum_process_state, NULL,
+ &g_array_index(hooks, LttvTraceHook, hn++));
+ if(ret) hn--;
+
g_array_set_size(hooks, hn);
before_hooks = hooks;
- hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 14);
- g_array_set_size(hooks, 14);
- hn=0;
+ hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 15);
+ g_array_set_size(hooks, 15);
+ hn=0;
ret = lttv_trace_find_hook(ts->parent.parent.t,
LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY,
after_function_exit, NULL,
&g_array_index(hooks, LttvTraceHook, hn++));
if(ret) hn--;
-
+
+ /* statedump-related hooks */
+ ret = lttv_trace_find_hook(ts->parent.parent.t,
+ LTT_FACILITY_STATEDUMP, LTT_EVENT_ENUM_PROCESS_STATE,
+ LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME,
+ after_enum_process_state, NULL,
+ &g_array_index(hooks, LttvTraceHook, hn++));
+ if(ret) hn--;
+
g_array_set_size(hooks, hn);
after_hooks = hooks;