X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Flttv%2Fstate.c;h=1e7d1d2b120b59a0fb306b6ece649886e457f923;hb=dc6b246703be1051c20919746dc34eccbc8912ea;hp=92c2aec5006797a6c2713515560fc62a887496c3;hpb=7ad3837aacd155c87986363f434f6a2fe5ce6546;p=lttv.git diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index 92c2aec5..1e7d1d2b 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 @@ -30,6 +31,7 @@ #include #include #include +#include /* Comment : * Mathieu Desnoyers @@ -51,7 +53,8 @@ GQuark LTT_FACILITY_LIST, LTT_FACILITY_FS, LTT_FACILITY_USER_GENERIC, - LTT_FACILITY_BLOCK; + LTT_FACILITY_BLOCK, + LTT_FACILITY_STATEDUMP; /* Events Quarks */ @@ -77,7 +80,9 @@ GQuark LTT_EVENT_THREAD_BRAND, LTT_EVENT_REQUEST_ISSUE, LTT_EVENT_REQUEST_COMPLETE, - LTT_EVENT_LIST_INTERRUPT; + LTT_EVENT_LIST_INTERRUPT, + LTT_EVENT_SYS_CALL_TABLE, + LTT_EVENT_SOFTIRQ_VEC; /* Fields Quarks */ @@ -106,7 +111,9 @@ GQuark LTT_FIELD_MAJOR, LTT_FIELD_OPERATION, LTT_FIELD_ACTION, - LTT_FIELD_NUM; + LTT_FIELD_ID, + LTT_FIELD_ADDRESS, + LTT_FIELD_SYMBOL; LttvExecutionMode LTTV_STATE_MODE_UNKNOWN, @@ -142,6 +149,7 @@ LttvCPUMode LTTV_CPU_IDLE, LTTV_CPU_BUSY, LTTV_CPU_IRQ, + LTTV_CPU_SOFT_IRQ, LTTV_CPU_TRAP; LttvIRQMode @@ -168,7 +176,10 @@ 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_SOFT_IRQS, + LTTV_STATE_RESOURCE_TRAPS, LTTV_STATE_RESOURCE_BLKDEVS; static void create_max_time(LttvTraceState *tcs); @@ -252,12 +263,15 @@ static void lttv_state_free_usertraces(GHashTable *usertraces) g_hash_table_destroy(usertraces); } - +gboolean rettrue(gpointer key, gpointer value, gpointer user_data) +{ + return TRUE; +} static void restore_init_state(LttvTraceState *self) { - guint i, nb_cpus, nb_irqs; + guint i, nb_cpus, nb_irqs, nb_soft_irqs, nb_traps; //LttvTracefileState *tfcs; @@ -283,6 +297,8 @@ restore_init_state(LttvTraceState *self) nb_cpus = ltt_trace_get_num_cpu(self->parent.t); nb_irqs = self->nb_irqs; + nb_soft_irqs = self->nb_soft_irqs; + nb_traps = self->nb_traps; /* Put the per cpu running_process to beginning state : process 0. */ for(i=0; i< nb_cpus; i++) { @@ -313,9 +329,20 @@ restore_init_state(LttvTraceState *self) g_array_remove_range(self->irq_states[i].mode_stack, 0, self->irq_states[i].mode_stack->len); } + /* reset softirq states */ + for(i=0; isoft_irq_states[i].running = 0; + } + + /* reset trap states */ + for(i=0; itrap_states[i].running = 0; + } + /* reset bdev states */ g_hash_table_foreach(self->bdev_states, bdevstate_free_cb, NULL); - g_hash_table_steal_all(self->bdev_states); + //g_hash_table_steal_all(self->bdev_states); + g_hash_table_foreach_steal(self->bdev_states, rettrue, NULL); #if 0 nb_tracefile = self->parent.tracefiles->len; @@ -481,6 +508,13 @@ init(LttvTracesetState *self, LttvTraceset *ts) g_assert(tcs->irq_states[j].mode_stack != NULL); } + /* init soft irq stuff */ + /* the kernel has a statically fixed max of 32 softirqs */ + tcs->soft_irq_states = g_new(LttvSoftIRQState, tcs->nb_soft_irqs); + + /* init trap stuff */ + tcs->trap_states = g_new(LttvTrapState, tcs->nb_traps); + /* init bdev resource stuff */ tcs->bdev_states = g_hash_table_new(g_int_hash, g_int_equal); @@ -589,7 +623,7 @@ static void write_process_state(gpointer key, gpointer value, process = (LttvProcessState *)value; fprintf(fp, -" \n", +" \n", process, process->pid, process->tgid, process->ppid, g_quark_to_string(process->type), process->creation_time.tv_sec, @@ -598,7 +632,7 @@ static void write_process_state(gpointer key, gpointer value, process->insertion_time.tv_nsec, g_quark_to_string(process->name), g_quark_to_string(process->brand), - process->cpu); + process->cpu, process->free_events); for(i = 0 ; i < process->execution_stack->len; i++) { es = &g_array_index(process->execution_stack, LttvExecutionState, i); @@ -699,6 +733,7 @@ static void write_process_state_raw(gpointer key, gpointer value, //fputc('\0', fp); fwrite(&process->brand, sizeof(process->brand), 1, fp); fwrite(&process->pid, sizeof(process->pid), 1, fp); + fwrite(&process->free_events, sizeof(process->free_events), 1, fp); fwrite(&process->tgid, sizeof(process->tgid), 1, fp); fwrite(&process->ppid, sizeof(process->ppid), 1, fp); fwrite(&process->cpu, sizeof(process->cpu), 1, fp); @@ -848,6 +883,7 @@ static void read_process_state_raw(LttvTraceState *self, FILE *fp, fread(&tmp.name, sizeof(tmp.name), 1, fp); fread(&tmp.brand, sizeof(tmp.brand), 1, fp); fread(&tmp.pid, sizeof(tmp.pid), 1, fp); + fread(&tmp.free_events, sizeof(tmp.free_events), 1, fp); fread(&tmp.tgid, sizeof(tmp.tgid), 1, fp); fread(&tmp.ppid, sizeof(tmp.ppid), 1, fp); fread(&tmp.cpu, sizeof(tmp.cpu), 1, fp); @@ -878,7 +914,7 @@ static void read_process_state_raw(LttvTraceState *self, FILE *fp, (gchar*)g_ptr_array_index(quarktable, tmp.brand)); process->name = g_quark_from_string((gchar*)g_ptr_array_index(quarktable, tmp.name)); - + process->free_events = tmp.free_events; do { if(feof(fp) || ferror(fp)) goto end_loop; @@ -1154,7 +1190,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); } @@ -1280,7 +1354,7 @@ static void lttv_state_free_blkdev_hashtable(GHashTable *ht) static void state_save(LttvTraceState *self, LttvAttribute *container) { - guint i, nb_tracefile, nb_cpus, nb_irqs; + guint i, nb_tracefile, nb_cpus, nb_irqs, nb_soft_irqs, nb_traps; LttvTracefileState *tfcs; @@ -1351,6 +1425,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); @@ -1364,6 +1442,22 @@ static void state_save(LttvTraceState *self, LttvAttribute *container) *(value.v_pointer) = lttv_state_copy_irq_states(self->irq_states, nb_irqs); } + /* save the soft irq state */ + nb_soft_irqs = self->nb_soft_irqs; + { + value = lttv_attribute_add(container, LTTV_STATE_RESOURCE_SOFT_IRQS, + LTTV_POINTER); + *(value.v_pointer) = lttv_state_copy_soft_irq_states(self->soft_irq_states, nb_soft_irqs); + } + + /* save the trap state */ + nb_traps = self->nb_traps; + { + value = lttv_attribute_add(container, LTTV_STATE_RESOURCE_TRAPS, + LTTV_POINTER); + *(value.v_pointer) = lttv_state_copy_trap_states(self->trap_states, nb_traps); + } + /* save the blkdev states */ value = lttv_attribute_add(container, LTTV_STATE_RESOURCE_BLKDEVS, LTTV_POINTER); @@ -1373,7 +1467,7 @@ static void state_save(LttvTraceState *self, LttvAttribute *container) static void state_restore(LttvTraceState *self, LttvAttribute *container) { - guint i, nb_tracefile, pid, nb_cpus, nb_irqs; + guint i, nb_tracefile, pid, nb_cpus, nb_irqs, nb_soft_irqs, nb_traps; LttvTracefileState *tfcs; @@ -1432,6 +1526,20 @@ static void state_restore(LttvTraceState *self, LttvAttribute *container) lttv_state_free_irq_states(self->irq_states, nb_irqs); self->irq_states = lttv_state_copy_irq_states(*(value.v_pointer), nb_irqs); + /* restore soft irq resource states */ + nb_soft_irqs = self->nb_soft_irqs; + type = lttv_attribute_get_by_name(container, LTTV_STATE_RESOURCE_SOFT_IRQS, &value); + g_assert(type == LTTV_POINTER); + lttv_state_free_soft_irq_states(self->soft_irq_states, nb_soft_irqs); + self->soft_irq_states = lttv_state_copy_soft_irq_states(*(value.v_pointer), nb_soft_irqs); + + /* restore trap resource states */ + nb_traps = self->nb_traps; + type = lttv_attribute_get_by_name(container, LTTV_STATE_RESOURCE_TRAPS, &value); + g_assert(type == LTTV_POINTER); + lttv_state_free_trap_states(self->trap_states, nb_traps); + self->trap_states = lttv_state_copy_trap_states(*(value.v_pointer), nb_traps); + /* restore the blkdev states */ type = lttv_attribute_get_by_name(container, LTTV_STATE_RESOURCE_BLKDEVS, &value); g_assert(type == LTTV_POINTER); @@ -1479,7 +1587,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; @@ -1508,13 +1616,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++) { @@ -1633,6 +1759,7 @@ create_name_tables(LttvTraceState *tcs) hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 1); if(!lttv_trace_find_hook(tcs->parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY, FIELD_ARRAY(LTT_FIELD_SYSCALL_ID), NULL, NULL, &hooks)) { @@ -1655,6 +1782,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); @@ -1667,6 +1795,7 @@ create_name_tables(LttvTraceState *tcs) lttv_trace_hook_remove_all(&hooks); if(!lttv_trace_find_hook(tcs->parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_ENTRY, FIELD_ARRAY(LTT_FIELD_TRAP_ID), NULL, NULL, &hooks)) { @@ -1695,6 +1824,7 @@ create_name_tables(LttvTraceState *tcs) lttv_trace_hook_remove_all(&hooks); if(!lttv_trace_find_hook(tcs->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_ENTRY, FIELD_ARRAY(LTT_FIELD_IRQ_ID), NULL, NULL, &hooks)) { @@ -1724,9 +1854,10 @@ create_name_tables(LttvTraceState *tcs) } */ - name_tables->nb_softirqs = 256; - name_tables->soft_irq_names = g_new(GQuark, 256); - for(i = 0 ; i < 256 ; i++) { + /* the kernel is limited to 32 statically defined softirqs */ + name_tables->nb_softirqs = 32; + name_tables->soft_irq_names = g_new(GQuark, name_tables->nb_softirqs); + for(i = 0 ; i < name_tables->nb_softirqs ; i++) { g_string_printf(fe_name, "softirq %d", i); name_tables->soft_irq_names[i] = g_quark_from_string(fe_name->str); } @@ -1755,7 +1886,7 @@ get_name_tables(LttvTraceState *tcs) tcs->irq_names = name_tables->irq_names; tcs->soft_irq_names = name_tables->soft_irq_names; tcs->nb_irqs = name_tables->nb_irqs; - tcs->nb_softirqs = name_tables->nb_softirqs; + tcs->nb_soft_irqs = name_tables->nb_softirqs; } @@ -2040,6 +2171,7 @@ lttv_state_create_process(LttvTraceState *tcs, LttvProcessState *parent, process->creation_time.tv_nsec); process->pid_time = g_quark_from_string(buffer); process->cpu = cpu; + process->free_events = 0; //process->last_cpu = tfs->cpu_name; //process->last_cpu_index = ltt_tracefile_num(((LttvTracefileContext*)tfs)->tf); process->execution_stack = g_array_sized_new(FALSE, FALSE, @@ -2112,19 +2244,25 @@ 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) +static int exit_process(LttvTracefileState *tfs, LttvProcessState *process) { LttvTraceState *ts = LTTV_TRACE_STATE(tfs->parent.t_context); LttvProcessState key; + /* Wait for both schedule with exit dead and process free to happen. + * They can happen in any order. */ + if (++(process->free_events) < 2) + return 0; + key.pid = process->pid; key.cpu = process->cpu; g_hash_table_remove(ts->processes, &key); g_array_free(process->execution_stack, TRUE); g_array_free(process->user_stack, TRUE); g_free(process); + return 1; } @@ -2192,6 +2330,7 @@ static gboolean syscall_exit(void *hook_data, void *call_data) static gboolean trap_entry(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; + LttvTraceState *ts = (LttvTraceState *)s->parent.t_context; LttEvent *e = ltt_tracefile_get_event(s->parent.tf); LttvTraceHook *th = (LttvTraceHook *)hook_data; struct marker_field *f = lttv_trace_get_hook_field(th, 0); @@ -2216,18 +2355,28 @@ static gboolean trap_entry(void *hook_data, void *call_data) /* update cpu status */ cpu_push_mode(s->cpu_state, LTTV_CPU_TRAP); + /* update trap status */ + s->cpu_state->last_trap = trap; + ts->trap_states[trap].running++; + return FALSE; } static gboolean trap_exit(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; + LttvTraceState *ts = (LttvTraceState *)s->parent.t_context; + guint trap = s->cpu_state->last_trap; pop_state(s, LTTV_STATE_TRAP); /* update cpu status */ cpu_pop_mode(s->cpu_state); + /* update trap status */ + if(ts->trap_states[trap].running) + ts->trap_states[trap].running--; + return FALSE; } @@ -2270,12 +2419,20 @@ static gboolean irq_entry(void *hook_data, void *call_data) static gboolean soft_irq_exit(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; + LttvTraceState *ts = (LttvTraceState *)s->parent.t_context; + guint softirq = s->cpu_state->last_soft_irq; pop_state(s, LTTV_STATE_SOFT_IRQ); - return FALSE; -} + /* update softirq status */ + if(ts->soft_irq_states[softirq].running) + ts->soft_irq_states[softirq].running--; + /* update cpu status */ + cpu_pop_mode(s->cpu_state); + + return FALSE; +} static gboolean irq_exit(void *hook_data, void *call_data) { @@ -2296,6 +2453,7 @@ static gboolean irq_exit(void *hook_data, void *call_data) static gboolean soft_irq_entry(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; + LttvTraceState *ts = (LttvTraceState *)s->parent.t_context; LttEvent *e = ltt_tracefile_get_event(s->parent.tf); //guint8 ev_id = ltt_event_eventtype_id(e); LttvTraceHook *th = (LttvTraceHook *)hook_data; @@ -2303,7 +2461,7 @@ static gboolean soft_irq_entry(void *hook_data, void *call_data) LttvExecutionSubmode submode; guint64 softirq = ltt_event_get_long_unsigned(e, f); - guint64 nb_softirqs = ((LttvTraceState *)(s->parent.t_context))->nb_softirqs; + guint64 nb_softirqs = ((LttvTraceState *)(s->parent.t_context))->nb_soft_irqs; if(softirq < nb_softirqs) { submode = ((LttvTraceState *)(s->parent.t_context))->soft_irq_names[softirq]; @@ -2317,6 +2475,14 @@ static gboolean soft_irq_entry(void *hook_data, void *call_data) /* Do something with the info about being in user or system mode when int? */ push_state(s, LTTV_STATE_SOFT_IRQ, submode); + + /* update cpu status */ + cpu_push_mode(s->cpu_state, LTTV_CPU_SOFT_IRQ); + + /* update softirq status */ + s->cpu_state->last_soft_irq = softirq; + ts->soft_irq_states[softirq].running++; + return FALSE; } @@ -2467,6 +2633,58 @@ static gboolean function_exit(void *hook_data, void *call_data) return FALSE; } +static gboolean dump_syscall(void *hook_data, void *call_data) +{ + LttvTracefileState *s = (LttvTracefileState *)call_data; + LttvTraceState *ts = (LttvTraceState*)s->parent.t_context; + LttEvent *e = ltt_tracefile_get_event(s->parent.tf); + LttvTraceHook *th = (LttvTraceHook *)hook_data; + guint id; + guint64 address; + char *symbol; + + id = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 0)); + address = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1)); + symbol = ltt_event_get_string(e, lttv_trace_get_hook_field(th, 2)); + + if (ts->nb_syscalls < id) { + GQuark *old_names = ts->syscall_names; + guint new_nb_syscalls = max(id + 1, ts->nb_syscalls * 2); + guint i; + GString *fe_name = g_string_new(""); + ts->syscall_names = g_new(GQuark, new_nb_syscalls); + memcpy(ts->syscall_names, old_names, + ts->nb_syscalls * sizeof(GQuark)); + for(i = ts->nb_syscalls ; i < new_nb_syscalls ; i++) { + g_string_printf(fe_name, "syscall %d", i); + ts->syscall_names[i] = g_quark_from_string(fe_name->str); + } + g_string_free(fe_name, TRUE); + ts->nb_syscalls = new_nb_syscalls; + } + ts->syscall_names[id] = g_quark_from_string(symbol); + + return FALSE; +} + +static gboolean dump_softirq(void *hook_data, void *call_data) +{ + LttvTracefileState *s = (LttvTracefileState *)call_data; + LttvTraceState *ts = (LttvTraceState*)s->parent.t_context; + LttEvent *e = ltt_tracefile_get_event(s->parent.tf); + LttvTraceHook *th = (LttvTraceHook *)hook_data; + guint id; + guint64 address; + char *symbol; + + id = ltt_event_get_unsigned(e, lttv_trace_get_hook_field(th, 0)); + address = ltt_event_get_long_unsigned(e, lttv_trace_get_hook_field(th, 1)); + symbol = ltt_event_get_string(e, lttv_trace_get_hook_field(th, 2)); + ts->soft_irq_names[id] = g_quark_from_string(symbol); + + return FALSE; +} + static gboolean schedchange(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; @@ -2519,9 +2737,13 @@ static gboolean schedchange(void *hook_data, void *call_data) process->state->change = s->parent.timestamp; } - if(state_out == 32 || state_out == 128) - exit_process(s, process); /* EXIT_DEAD || TASK_DEAD */ - /* see sched.h for states */ + if(state_out == 32 || state_out == 64) { /* EXIT_DEAD || TASK_DEAD */ + /* see sched.h for states */ + if (!exit_process(s, process)) { + process->state->s = LTTV_STATE_DEAD; + process->state->change = s->parent.timestamp; + } + } } } process = ts->running_process[cpu] = @@ -2538,9 +2760,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; } @@ -2610,8 +2841,9 @@ static gboolean process_fork(void *hook_data, void *call_data) * * Simply put a correct parent. */ - g_assert(0); /* This is a problematic case : the process has been created - before the fork event */ + g_error("Process %u has been created before fork on cpu %u. Probably an unsynchronized TSC problem on the traced machine.", child_pid, cpu); + //g_assert(0); /* This is a problematic case : the process has been created + // before the fork event */ child_process->ppid = process->pid; child_process->tgid = child_tgid; } @@ -2640,11 +2872,13 @@ static gboolean process_kernel_thread(void *hook_data, void *call_data) 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 = - &g_array_index(process->execution_stack, LttvExecutionState, 0); - es->t = LTTV_STATE_SYSCALL; + if (process->state->s != LTTV_STATE_DEAD) { + process->execution_stack = + g_array_set_size(process->execution_stack, 1); + es = process->state = + &g_array_index(process->execution_stack, LttvExecutionState, 0); + es->t = LTTV_STATE_SYSCALL; + } process->type = LTTV_STATE_KERNEL_THREAD; return FALSE; @@ -2688,7 +2922,10 @@ static gboolean process_free(void *hook_data, void *call_data) g_assert(release_pid != 0); process = lttv_state_find_process(ts, ANY_CPU, release_pid); - + if(likely(process != NULL)) + exit_process(s, process); + return FALSE; +//DISABLED if(likely(process != NULL)) { /* release_task is happening at kernel level : we can now safely release * the data structure of the process */ @@ -2869,6 +3106,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)); @@ -3034,84 +3273,100 @@ void lttv_state_add_event_hooks(LttvTracesetState *self) //hn = 0; lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY, FIELD_ARRAY(LTT_FIELD_SYSCALL_ID), syscall_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_EXIT, NULL, syscall_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_ENTRY, FIELD_ARRAY(LTT_FIELD_TRAP_ID), trap_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_EXIT, NULL, trap_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_ENTRY, FIELD_ARRAY(LTT_FIELD_IRQ_ID), irq_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_EXIT, NULL, irq_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_ENTRY, FIELD_ARRAY(LTT_FIELD_SOFT_IRQ_ID), soft_irq_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_EXIT, NULL, soft_irq_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_SCHED_SCHEDULE, FIELD_ARRAY(LTT_FIELD_PREV_PID, LTT_FIELD_NEXT_PID, LTT_FIELD_PREV_STATE), schedchange, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FORK, FIELD_ARRAY(LTT_FIELD_PARENT_PID, LTT_FIELD_CHILD_PID, LTT_FIELD_CHILD_TGID), process_fork, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_KTHREAD_CREATE, FIELD_ARRAY(LTT_FIELD_PID), process_kernel_thread, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_EXIT, FIELD_ARRAY(LTT_FIELD_PID), process_exit, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FREE, FIELD_ARRAY(LTT_FIELD_PID), process_free, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_FS, LTT_EVENT_EXEC, FIELD_ARRAY(LTT_FIELD_FILENAME), process_exec, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_USER_GENERIC, LTT_EVENT_THREAD_BRAND, FIELD_ARRAY(LTT_FIELD_NAME), thread_brand, NULL, &hooks); /* statedump-related hooks */ lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_LIST, LTT_EVENT_PROCESS_STATE, FIELD_ARRAY(LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME, LTT_FIELD_TYPE, LTT_FIELD_MODE, LTT_FIELD_SUBMODE, @@ -3119,35 +3374,53 @@ void lttv_state_add_event_hooks(LttvTracesetState *self) enum_process_state, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_LIST, LTT_EVENT_STATEDUMP_END, NULL, statedump_end, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_LIST, LTT_EVENT_LIST_INTERRUPT, - FIELD_ARRAY(LTT_FIELD_ACTION, LTT_FIELD_NUM), + FIELD_ARRAY(LTT_FIELD_ACTION, LTT_FIELD_IRQ_ID), enum_interrupt, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_BLOCK, LTT_EVENT_REQUEST_ISSUE, FIELD_ARRAY(LTT_FIELD_MAJOR, LTT_FIELD_MINOR, LTT_FIELD_OPERATION), bdev_request_issue, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_BLOCK, LTT_EVENT_REQUEST_COMPLETE, FIELD_ARRAY(LTT_FIELD_MAJOR, LTT_FIELD_MINOR, LTT_FIELD_OPERATION), bdev_request_complete, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_USER_GENERIC, LTT_EVENT_FUNCTION_ENTRY, FIELD_ARRAY(LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE), function_entry, NULL, &hooks); lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_USER_GENERIC, LTT_EVENT_FUNCTION_EXIT, FIELD_ARRAY(LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE), function_exit, NULL, &hooks); + lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_STATEDUMP, + LTT_EVENT_SYS_CALL_TABLE, + FIELD_ARRAY(LTT_FIELD_ID, LTT_FIELD_ADDRESS, LTT_FIELD_SYMBOL), + dump_syscall, NULL, &hooks); + + lttv_trace_find_hook(ts->parent.t, + LTT_FACILITY_STATEDUMP, + LTT_EVENT_SOFTIRQ_VEC, + FIELD_ARRAY(LTT_FIELD_ID, LTT_FIELD_ADDRESS, LTT_FIELD_SYMBOL), + dump_softirq, NULL, &hooks); + /* Add these hooks to each event_by_id hooks list */ nb_tracefile = ts->parent.tracefiles->len; @@ -3766,8 +4039,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"); @@ -3798,7 +4071,10 @@ 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_SOFT_IRQS = g_quark_from_string("soft irq resource states"); + LTTV_STATE_RESOURCE_TRAPS = g_quark_from_string("trap resource states"); LTTV_STATE_RESOURCE_BLKDEVS = g_quark_from_string("blkdevs resource states"); @@ -3808,16 +4084,16 @@ static void module_init() LTT_FACILITY_LIST = g_quark_from_string("list"); LTT_FACILITY_USER_GENERIC = g_quark_from_string("user_generic"); LTT_FACILITY_BLOCK = g_quark_from_string("block"); - - + LTT_FACILITY_STATEDUMP = g_quark_from_string("statedump"); + LTT_EVENT_SYSCALL_ENTRY = g_quark_from_string("syscall_entry"); LTT_EVENT_SYSCALL_EXIT = g_quark_from_string("syscall_exit"); LTT_EVENT_TRAP_ENTRY = g_quark_from_string("trap_entry"); LTT_EVENT_TRAP_EXIT = g_quark_from_string("trap_exit"); LTT_EVENT_IRQ_ENTRY = g_quark_from_string("irq_entry"); LTT_EVENT_IRQ_EXIT = g_quark_from_string("irq_exit"); - LTT_EVENT_SOFT_IRQ_ENTRY = g_quark_from_string("soft_irq_entry"); - LTT_EVENT_SOFT_IRQ_EXIT = g_quark_from_string("soft_irq_exit"); + LTT_EVENT_SOFT_IRQ_ENTRY = g_quark_from_string("softirq_entry"); + LTT_EVENT_SOFT_IRQ_EXIT = g_quark_from_string("softirq_exit"); LTT_EVENT_SCHED_SCHEDULE = g_quark_from_string("sched_schedule"); LTT_EVENT_PROCESS_FORK = g_quark_from_string("process_fork"); LTT_EVENT_KTHREAD_CREATE = g_quark_from_string("kthread_create"); @@ -3831,8 +4107,9 @@ static void module_init() LTT_EVENT_THREAD_BRAND = g_quark_from_string("thread_brand"); LTT_EVENT_REQUEST_ISSUE = g_quark_from_string("_blk_request_issue"); LTT_EVENT_REQUEST_COMPLETE = g_quark_from_string("_blk_request_complete"); - LTT_EVENT_LIST_INTERRUPT = g_quark_from_string("interrupt");; - + LTT_EVENT_LIST_INTERRUPT = g_quark_from_string("interrupt"); + LTT_EVENT_SYS_CALL_TABLE = g_quark_from_string("sys_call_table"); + LTT_EVENT_SOFTIRQ_VEC = g_quark_from_string("softirq_vec"); LTT_FIELD_SYSCALL_ID = g_quark_from_string("syscall_id"); LTT_FIELD_TRAP_ID = g_quark_from_string("trap_id"); @@ -3858,12 +4135,15 @@ static void module_init() LTT_FIELD_MINOR = g_quark_from_string("minor"); LTT_FIELD_OPERATION = g_quark_from_string("direction"); LTT_FIELD_ACTION = g_quark_from_string("action"); - LTT_FIELD_NUM = g_quark_from_string("num"); + LTT_FIELD_ID = g_quark_from_string("id"); + LTT_FIELD_ADDRESS = g_quark_from_string("address"); + LTT_FIELD_SYMBOL = g_quark_from_string("symbol"); 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_SOFT_IRQ = g_quark_from_string("softirq"); LTTV_CPU_TRAP = g_quark_from_string("trap"); LTTV_IRQ_UNKNOWN = g_quark_from_string("unknown");