LTTV_STATE_USER_THREAD,
LTTV_STATE_KERNEL_THREAD;
+LttvCPUMode
+ LTTV_CPU_UNKNOWN,
+ LTTV_CPU_IDLE,
+ LTTV_CPU_BUSY,
+ LTTV_CPU_IRQ,
+ LTTV_CPU_TRAP;
+
static GQuark
LTTV_STATE_TRACEFILES,
LTTV_STATE_PROCESSES,
static void
init(LttvTracesetState *self, LttvTraceset *ts)
{
- guint i, j, nb_trace, nb_tracefile;
+ guint i, j, nb_trace, nb_tracefile, nb_cpu;
LttvTraceContext *tc;
get_max_time(tcs);
nb_tracefile = tc->tracefiles->len;
+ nb_cpu = ltt_trace_get_num_cpu(tc->t);
tcs->processes = NULL;
tcs->usertraces = NULL;
- tcs->running_process = g_new(LttvProcessState*,
- ltt_trace_get_num_cpu(tc->t));
+ tcs->running_process = g_new(LttvProcessState*, nb_cpu);
+ /* init cpu resource stuff */
+ tcs->cpu_states = g_new(LttvCPUState, nb_cpu);
+ for(j = 0; j<nb_cpu; j++) {
+ tcs->cpu_states[j].mode_stack = g_array_new(FALSE, FALSE, sizeof(LttvCPUMode));
+ g_assert(tcs->cpu_states[j].mode_stack != NULL);
+ }
+
restore_init_state(tcs);
for(j = 0 ; j < nb_tracefile ; j++) {
tfcs =
LttvTracefileContext*, j));
tfcs->tracefile_name = ltt_tracefile_name(tfcs->parent.tf);
tfcs->cpu = ltt_tracefile_cpu(tfcs->parent.tf);
+ tfcs->cpu_state = &(tcs->cpu_states[tfcs->cpu]);
if(ltt_tracefile_tid(tfcs->parent.tf) != 0) {
/* It's a Usertrace */
guint tid = ltt_tracefile_tid(tfcs->parent.tf);
#endif
+/* clears the stack and sets the state passed as argument */
+static void cpu_set_base_mode(LttvCPUState *cpust, LttvCPUMode state)
+{
+ g_array_set_size(cpust->mode_stack, 1);
+ ((GQuark *)cpust->mode_stack->data)[0] = state;
+}
+
+static void cpu_push_mode(LttvCPUState *cpust, LttvCPUMode state)
+{
+ g_array_set_size(cpust->mode_stack, cpust->mode_stack->len + 1);
+ ((GQuark *)cpust->mode_stack->data)[cpust->mode_stack->len - 1] = state;
+}
+
+static void cpu_pop_mode(LttvCPUState *cpust)
+{
+ if(cpust->mode_stack->len == 1)
+ cpu_set_base_mode(cpust, LTTV_CPU_UNKNOWN);
+ else
+ g_array_set_size(cpust->mode_stack, cpust->mode_stack->len - 1);
+}
static void push_state(LttvTracefileState *tfs, LttvExecutionMode t,
guint state_id)
}
push_state(s, LTTV_STATE_TRAP, submode);
+
+ /* update cpu status */
+ cpu_push_mode(s->cpu_state, LTTV_CPU_TRAP);
+
return FALSE;
}
-
static gboolean trap_exit(void *hook_data, void *call_data)
{
LttvTracefileState *s = (LttvTracefileState *)call_data;
pop_state(s, LTTV_STATE_TRAP);
+
+ /* update cpu status */
+ cpu_pop_mode(s->cpu_state);
+
return FALSE;
}
-
static gboolean irq_entry(void *hook_data, void *call_data)
{
LttvTracefileState *s = (LttvTracefileState *)call_data;
/* Do something with the info about being in user or system mode when int? */
push_state(s, LTTV_STATE_IRQ, submode);
+
+ /* update cpu status */
+ cpu_push_mode(s->cpu_state, LTTV_CPU_IRQ);
+
return FALSE;
}
LttvTracefileState *s = (LttvTracefileState *)call_data;
pop_state(s, LTTV_STATE_IRQ);
+
+ /* update cpu status */
+ cpu_pop_mode(s->cpu_state);
+
return FALSE;
}
LttEvent *e = ltt_tracefile_get_event(s->parent.tf);
LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data;
guint pid_in, pid_out;
- gint state_out;
+ gint64 state_out;
pid_out = ltt_event_get_unsigned(e, thf->f1);
pid_in = ltt_event_get_unsigned(e, thf->f2);
- state_out = ltt_event_get_int(e, thf->f3);
+ state_out = ltt_event_get_long_int(e, thf->f3);
if(likely(process != NULL)) {
process->usertrace->cpu = cpu;
// process->last_cpu_index = ltt_tracefile_num(((LttvTracefileContext*)s)->tf);
process->state->change = s->parent.timestamp;
+
+ /* update cpu status */
+ if(pid_in == 0)
+ cpu_set_base_mode(s->cpu_state, LTTV_CPU_IDLE);
+ else
+ cpu_set_base_mode(s->cpu_state, LTTV_CPU_BUSY);
+
return FALSE;
}
LttvExecutionState *es;
/* PID */
- pid = ltt_event_get_unsigned(e, thf->f1);
+ pid = (guint)ltt_event_get_long_unsigned(e, thf->f1);
s->parent.target_pid = pid;
- process = lttv_state_find_process(ts, ANY_CPU, pid);
+ process = lttv_state_find_process_or_create(ts, ANY_CPU, pid,
+ <t_time_zero);
process->execution_stack =
g_array_set_size(process->execution_stack, 1);
es = process->state =
process->name = g_quark_from_string(null_term_name);
#endif //0
- process->name = ltt_event_get_string(e, thf->f1);
+ process->name = g_quark_from_string(ltt_event_get_string(e, thf->f1));
process->brand = LTTV_STATE_UNBRANDED;
//g_free(null_term_name);
return FALSE;
LTT_FIELD_THIS_FN = g_quark_from_string("this_fn");
LTT_FIELD_CALL_SITE = g_quark_from_string("call_site");
+ LTTV_CPU_UNKNOWN = g_quark_from_string("unknown");
+ LTTV_CPU_IDLE = g_quark_from_string("idle");
+ LTTV_CPU_BUSY = g_quark_from_string("busy");
+ LTTV_CPU_IRQ = g_quark_from_string("irq");
+ LTTV_CPU_TRAP = g_quark_from_string("trap");
}
static void module_destroy()