X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Flttv%2Fstate.c;h=952f6cde9bf866dfc8b349e17d533744b9183e65;hb=ba68a75e8481bdcf718bba531a672c18e5a07a81;hp=06d22007b1beb1c3f01feec428a5247e1153b9d8;hpb=43fb1d98c1e2bfc231a4c6a3a7f03c912f49ca48;p=lttv.git diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index 06d22007..952f6cde 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -21,6 +21,7 @@ #include #endif +#include #include #include #include @@ -167,6 +168,7 @@ static GQuark LTTV_STATE_NAME_TABLES, LTTV_STATE_TRACE_STATE_USE_COUNT, LTTV_STATE_RESOURCE_CPUS, + LTTV_STATE_RESOURCE_CPUS_COUNT, LTTV_STATE_RESOURCE_IRQS, LTTV_STATE_RESOURCE_BLKDEVS; @@ -1153,7 +1155,7 @@ static void lttv_state_free_cpu_states(LttvCPUState *states, guint n) guint i; for(i=0; imode_stack, FALSE); + g_array_free(bds->mode_stack, TRUE); g_free(bds); } @@ -1350,6 +1352,10 @@ static void state_save(LttvTraceState *self, LttvAttribute *container) /* save the cpu state */ { + value = lttv_attribute_add(container, LTTV_STATE_RESOURCE_CPUS_COUNT, + LTTV_UINT); + *(value.v_uint) = nb_cpus; + value = lttv_attribute_add(container, LTTV_STATE_RESOURCE_CPUS, LTTV_POINTER); *(value.v_pointer) = lttv_state_copy_cpu_states(self->cpu_states, nb_cpus); @@ -1478,7 +1484,7 @@ static void state_restore(LttvTraceState *self, LttvAttribute *container) static void state_saved_free(LttvTraceState *self, LttvAttribute *container) { - guint i, nb_tracefile, nb_cpus; + guint i, nb_tracefile, nb_cpus, nb_irqs; LttvTracefileState *tfcs; @@ -1507,13 +1513,31 @@ static void state_saved_free(LttvTraceState *self, LttvAttribute *container) lttv_attribute_remove_by_name(container, LTTV_STATE_PROCESSES); /* Free running processes array */ - nb_cpus = ltt_trace_get_num_cpu(self->parent.t); type = lttv_attribute_get_by_name(container, LTTV_STATE_RUNNING_PROCESS, &value); g_assert(type == LTTV_POINTER); running_process = *(value.v_pointer); g_free(running_process); + /* free cpu resource states */ + type = lttv_attribute_get_by_name(container, LTTV_STATE_RESOURCE_CPUS_COUNT, &value); + g_assert(type == LTTV_UINT); + nb_cpus = *value.v_uint; + type = lttv_attribute_get_by_name(container, LTTV_STATE_RESOURCE_CPUS, &value); + g_assert(type == LTTV_POINTER); + lttv_state_free_cpu_states(*(value.v_pointer), nb_cpus); + + /* free irq resource states */ + nb_irqs = self->nb_irqs; + type = lttv_attribute_get_by_name(container, LTTV_STATE_RESOURCE_IRQS, &value); + g_assert(type == LTTV_POINTER); + lttv_state_free_irq_states(*(value.v_pointer), nb_irqs); + + /* free the blkdev states */ + type = lttv_attribute_get_by_name(container, LTTV_STATE_RESOURCE_BLKDEVS, &value); + g_assert(type == LTTV_POINTER); + lttv_state_free_blkdev_hashtable(*(value.v_pointer)); + nb_tracefile = self->parent.tracefiles->len; for(i = 0 ; i < nb_tracefile ; i++) { @@ -1655,6 +1679,7 @@ create_name_tables(LttvTraceState *tcs) // } // } + name_tables->nb_syscalls = 256; name_tables->syscall_names = g_new(GQuark, 256); for(i = 0 ; i < 256 ; i++) { g_string_printf(fe_name, "syscall %d", i); @@ -2114,7 +2139,7 @@ lttv_state_find_process_or_create(LttvTraceState *ts, guint cpu, guint pid, * the parent waits for its child terminaison, but may also happen in special * cases in the child's exit : when the parent ignores its children SIGCCHLD or * has the flag SA_NOCLDWAIT. It can also happen when the child is part - * of a killed thread ground, but isn't the leader. + * of a killed thread group, but isn't the leader. */ static void exit_process(LttvTracefileState *tfs, LttvProcessState *process) { @@ -2540,9 +2565,18 @@ static gboolean schedchange(void *hook_data, void *call_data) /* update cpu status */ if(pid_in == 0) + /* going to idle task */ cpu_set_base_mode(s->cpu_state, LTTV_CPU_IDLE); - else + else { + /* scheduling a real task. + * we must be careful here: + * if we just schedule()'ed to a process that is + * in a trap, we must put the cpu in trap mode + */ cpu_set_base_mode(s->cpu_state, LTTV_CPU_BUSY); + if(process->state->t == LTTV_STATE_TRAP) + cpu_push_mode(s->cpu_state, LTTV_CPU_TRAP); + } return FALSE; } @@ -2871,6 +2905,8 @@ static gboolean enum_process_state(void *hook_data, void *call_data) f = lttv_trace_get_hook_field(th, 3); type = ltt_enum_string_get(f, ltt_event_get_unsigned(e, f)); + //FIXME: type is rarely used, enum must match possible types. + /* mode */ f = lttv_trace_get_hook_field(th, 4); mode = ltt_enum_string_get(f,ltt_event_get_unsigned(e, f)); @@ -3790,8 +3826,8 @@ lttv_tracefile_state_get_type(void) static void module_init() { - LTTV_STATE_UNNAMED = g_quark_from_string("UNNAMED"); - LTTV_STATE_UNBRANDED = g_quark_from_string("UNBRANDED"); + LTTV_STATE_UNNAMED = g_quark_from_string(""); + LTTV_STATE_UNBRANDED = g_quark_from_string(""); LTTV_STATE_MODE_UNKNOWN = g_quark_from_string("MODE_UNKNOWN"); LTTV_STATE_USER_MODE = g_quark_from_string("USER_MODE"); LTTV_STATE_SYSCALL = g_quark_from_string("SYSCALL"); @@ -3822,6 +3858,7 @@ static void module_init() LTTV_STATE_TRACE_STATE_USE_COUNT = g_quark_from_string("trace_state_use_count"); LTTV_STATE_RESOURCE_CPUS = g_quark_from_string("cpu resource states"); + LTTV_STATE_RESOURCE_CPUS = g_quark_from_string("cpu count"); LTTV_STATE_RESOURCE_IRQS = g_quark_from_string("irq resource states"); LTTV_STATE_RESOURCE_BLKDEVS = g_quark_from_string("blkdevs resource states");