X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Flttv%2Fstate.c;h=4c1d67bff0e8f2aaa643a94c5dbc40a3bb701815;hb=6418800de0a7d64b67cfbd88bea09d7d9e6dc438;hp=a75161f3c4dcafc97dab2c23010a7a0e850660dc;hpb=b895e4db7d86af2af0b536b97c3fdf563f348ad1;p=lttv.git diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index a75161f3..4c1d67bf 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -16,6 +16,7 @@ * MA 02111-1307, USA. */ +#define _GNU_SOURCE #ifdef HAVE_CONFIG_H #include #endif @@ -23,10 +24,9 @@ #include #include #include -#include #include #include -#include +#include #include #include @@ -75,7 +75,8 @@ GQuark LTT_EVENT_FUNCTION_EXIT, LTT_EVENT_THREAD_BRAND, LTT_EVENT_REQUEST_ISSUE, - LTT_EVENT_REQUEST_COMPLETE; + LTT_EVENT_REQUEST_COMPLETE, + LTT_EVENT_LIST_INTERRUPT; /* Fields Quarks */ @@ -102,7 +103,9 @@ GQuark LTT_FIELD_CALL_SITE, LTT_FIELD_MINOR, LTT_FIELD_MAJOR, - LTT_FIELD_OPERATION; + LTT_FIELD_OPERATION, + LTT_FIELD_ACTION, + LTT_FIELD_NUM; LttvExecutionMode LTTV_STATE_MODE_UNKNOWN, @@ -192,7 +195,6 @@ static LttvBdevState *bdevstate_new(void); static void bdevstate_free(LttvBdevState *); static void bdevstate_free_cb(gpointer key, gpointer value, gpointer user_data); static LttvBdevState *bdevstate_copy(LttvBdevState *bds); -static LttvBdevState *bdev_state_get(LttvTraceState *ts, guint16 devcode); void lttv_state_save(LttvTraceState *self, LttvAttribute *container) @@ -256,7 +258,7 @@ restore_init_state(LttvTraceState *self) { guint i, nb_cpus, nb_irqs; - LttvTracefileState *tfcs; + //LttvTracefileState *tfcs; LttTime start_time, end_time; @@ -354,7 +356,7 @@ state_load_saved_states(LttvTraceState *tcs) { FILE *fp; GPtrArray *quarktable; - char *trace_path; + const char *trace_path; char path[PATH_MAX]; guint count; guint i; @@ -519,7 +521,7 @@ fini(LttvTracesetState *self) LttvTraceState *tcs; - LttvTracefileState *tfcs; + //LttvTracefileState *tfcs; LttvAttributeValue v; @@ -607,7 +609,7 @@ static void write_process_state(gpointer key, gpointer value, } for(i = 0 ; i < process->user_stack->len; i++) { - address = &g_array_index(process->user_stack, guint64, i); + address = g_array_index(process->user_stack, guint64, i); fprintf(fp, " \n", address); } @@ -742,7 +744,7 @@ static void write_process_state_raw(gpointer key, gpointer value, } for(i = 0 ; i < process->user_stack->len; i++) { - address = &g_array_index(process->user_stack, guint64, i); + address = g_array_index(process->user_stack, guint64, i); fputc(HDR_USER_STACK, fp); fwrite(&address, sizeof(address), 1, fp); #if 0 @@ -838,9 +840,7 @@ static void read_process_state_raw(LttvTraceState *self, FILE *fp, LttvProcessState tmp; GQuark tmpq; - guint i; guint64 *address; - guint cpu; /* TODO : check return value */ fread(&tmp.type, sizeof(tmp.type), 1, fp); @@ -1077,7 +1077,7 @@ void lttv_trace_states_read_raw(LttvTraceState *tcs, FILE *fp, end_loop: *(tcs->max_time_state_recomputed_in_seek) = tcs->parent.time_span.end_time; restore_init_state(tcs); - lttv_process_trace_seek_time(tcs, ltt_time_zero); + lttv_process_trace_seek_time(&tcs->parent, ltt_time_zero); return; } @@ -1242,11 +1242,11 @@ static LttvBdevState *bdevstate_copy(LttvBdevState *bds) static void insert_and_copy_bdev_state(gpointer k, gpointer v, gpointer u) { - GHashTable *ht = (GHashTable *)u; + //GHashTable *ht = (GHashTable *)u; LttvBdevState *bds = (LttvBdevState *)v; LttvBdevState *newbds; - newbds = bdevstate_copy(v); + newbds = bdevstate_copy(bds); g_hash_table_insert(u, k, newbds); } @@ -1287,12 +1287,8 @@ static void state_save(LttvTraceState *self, LttvAttribute *container) guint *running_process; - LttvAttributeType type; - LttvAttributeValue value; - LttvAttributeName name; - LttEventPosition *ep; tracefiles_tree = lttv_attribute_find_subdir(container, @@ -1354,7 +1350,6 @@ static void state_save(LttvTraceState *self, LttvAttribute *container) /* save the cpu state */ { - guint size = sizeof(LttvCPUState)*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); @@ -1363,7 +1358,6 @@ static void state_save(LttvTraceState *self, LttvAttribute *container) /* save the irq state */ nb_irqs = self->nb_irqs; { - guint size = sizeof(LttvCPUState)*nb_irqs; value = lttv_attribute_add(container, LTTV_STATE_RESOURCE_IRQS, LTTV_POINTER); *(value.v_pointer) = lttv_state_copy_irq_states(self->irq_states, nb_irqs); @@ -1500,8 +1494,6 @@ static void state_saved_free(LttvTraceState *self, LttvAttribute *container) gboolean is_named; - LttEventPosition *ep; - tracefiles_tree = lttv_attribute_find_subdir(container, LTTV_STATE_TRACEFILES); g_object_ref(G_OBJECT(tracefiles_tree)); @@ -1622,17 +1614,7 @@ typedef struct _LttvNameTables { static void create_name_tables(LttvTraceState *tcs) { - int i, nb; - - GQuark f_name, e_name; - - LttvTraceHook h; - - LttvTraceHookByFacility *thf; - - LttEventType *et; - - LttType *t; + int i; GString *fe_name = g_string_new(""); @@ -1640,76 +1622,65 @@ create_name_tables(LttvTraceState *tcs) LttvAttributeValue v; + GArray *hooks; + lttv_attribute_find(tcs->parent.t_a, LTTV_STATE_NAME_TABLES, LTTV_POINTER, &v); g_assert(*(v.v_pointer) == NULL); *(v.v_pointer) = name_tables; -#if 0 // Use iteration over the facilities_by_name and then list all event - // types of each facility - nb = ltt_trace_eventtype_number(tcs->parent.t); - name_tables->eventtype_names = g_new(GQuark, nb); - for(i = 0 ; i < nb ; i++) { - et = ltt_trace_eventtype_get(tcs->parent.t, i); - e_name = ltt_eventtype_name(et); - f_name = ltt_facility_name(ltt_eventtype_facility(et)); - g_string_printf(fe_name, "%s.%s", f_name, e_name); - name_tables->eventtype_names[i] = g_quark_from_string(fe_name->str); - } -#endif //0 - if(!lttv_trace_find_hook(tcs->parent.t, - LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY, - LTT_FIELD_SYSCALL_ID, 0, 0, - NULL, NULL, &h)) { - - thf = lttv_trace_hook_get_first(&h); - - t = ltt_field_type(thf->f1); - nb = ltt_type_element_number(t); - - lttv_trace_hook_destroy(&h); - name_tables->syscall_names = g_new(GQuark, nb); - name_tables->nb_syscalls = nb; + hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 1); - for(i = 0 ; i < nb ; i++) { - name_tables->syscall_names[i] = ltt_enum_string_get(t, i); - if(!name_tables->syscall_names[i]) { - GString *string = g_string_new(""); - g_string_printf(string, "syscall %u", i); - name_tables->syscall_names[i] = g_quark_from_string(string->str); - g_string_free(string, TRUE); - } + if(!lttv_trace_find_hook(tcs->parent.t, + LTT_EVENT_SYSCALL_ENTRY, + FIELD_ARRAY(LTT_FIELD_SYSCALL_ID), + NULL, NULL, &hooks)) { + +// th = lttv_trace_hook_get_first(&th); +// +// t = ltt_field_type(th->f1); +// nb = ltt_type_element_number(t); +// +// name_tables->syscall_names = g_new(GQuark, nb); +// name_tables->nb_syscalls = nb; +// +// for(i = 0 ; i < nb ; i++) { +// name_tables->syscall_names[i] = ltt_enum_string_get(t, i); +// if(!name_tables->syscall_names[i]) { +// GString *string = g_string_new(""); +// g_string_printf(string, "syscall %u", i); +// name_tables->syscall_names[i] = g_quark_from_string(string->str); +// g_string_free(string, TRUE); +// } +// } + + name_tables->syscall_names = g_new(GQuark, 256); + for(i = 0 ; i < 256 ; i++) { + g_string_printf(fe_name, "syscall %d", i); + name_tables->syscall_names[i] = g_quark_from_string(fe_name->str); } - - //name_tables->syscall_names = g_new(GQuark, 256); - //for(i = 0 ; i < 256 ; i++) { - // g_string_printf(fe_name, "syscall %d", i); - // name_tables->syscall_names[i] = g_quark_from_string(fe_name->str); - //} } else { name_tables->syscall_names = NULL; name_tables->nb_syscalls = 0; } + lttv_trace_hook_destroy(&hooks); - if(!lttv_trace_find_hook(tcs->parent.t, LTT_FACILITY_KERNEL_ARCH, + if(!lttv_trace_find_hook(tcs->parent.t, LTT_EVENT_TRAP_ENTRY, - LTT_FIELD_TRAP_ID, 0, 0, - NULL, NULL, &h)) { - - thf = lttv_trace_hook_get_first(&h); - - t = ltt_field_type(thf->f1); - //nb = ltt_type_element_number(t); + FIELD_ARRAY(LTT_FIELD_TRAP_ID), + NULL, NULL, &hooks)) { + +// th = lttv_trace_hook_get_first(&th); +// +// t = ltt_field_type(th->f1); +// //nb = ltt_type_element_number(t); +// +// name_tables->trap_names = g_new(GQuark, nb); +// for(i = 0 ; i < nb ; i++) { +// name_tables->trap_names[i] = g_quark_from_string( +// ltt_enum_string_get(t, i)); +// } - lttv_trace_hook_destroy(&h); - - /* - name_tables->trap_names = g_new(GQuark, nb); - for(i = 0 ; i < nb ; i++) { - name_tables->trap_names[i] = g_quark_from_string( - ltt_enum_string_get(t, i)); - } - */ name_tables->nb_traps = 256; name_tables->trap_names = g_new(GQuark, 256); for(i = 0 ; i < 256 ; i++) { @@ -1720,19 +1691,13 @@ create_name_tables(LttvTraceState *tcs) name_tables->trap_names = NULL; name_tables->nb_traps = 0; } + lttv_trace_hook_destroy(&hooks); if(!lttv_trace_find_hook(tcs->parent.t, - LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_ENTRY, - LTT_FIELD_IRQ_ID, 0, 0, - NULL, NULL, &h)) { + LTT_EVENT_IRQ_ENTRY, + FIELD_ARRAY(LTT_FIELD_IRQ_ID), + NULL, NULL, &hooks)) { - thf = lttv_trace_hook_get_first(&h); - - t = ltt_field_type(thf->f1); - //nb = ltt_type_element_number(t); - - lttv_trace_hook_destroy(&h); - /* name_tables->irq_names = g_new(GQuark, nb); for(i = 0 ; i < nb ; i++) { @@ -1750,6 +1715,7 @@ create_name_tables(LttvTraceState *tcs) name_tables->nb_irqs = 0; name_tables->irq_names = NULL; } + lttv_trace_hook_destroy(&hooks); /* name_tables->soft_irq_names = g_new(GQuark, nb); for(i = 0 ; i < nb ; i++) { @@ -1763,7 +1729,7 @@ create_name_tables(LttvTraceState *tcs) g_string_printf(fe_name, "softirq %d", i); name_tables->soft_irq_names[i] = g_quark_from_string(fe_name->str); } - + g_array_free(hooks, TRUE); g_string_free(fe_name, TRUE); } @@ -1927,9 +1893,6 @@ static void push_state(LttvTracefileState *tfs, LttvExecutionMode t, int lttv_state_pop_state_cleanup(LttvProcessState *process, LttvTracefileState *tfs) { - guint cpu = tfs->cpu; - LttvTraceState *ts = (LttvTraceState*)tfs->parent.t_context; - guint depth = process->execution_stack->len; if(depth == 1){ @@ -2001,10 +1964,10 @@ static gint search_usertrace(gconstpointer a, gconstpointer b) /* Get smaller keys */ if(res->best) { if(ltt_time_compare(*elem_time, *res->best) < 0) { - res->best = elem_time; + res->best = (LttTime *)elem_time; } } else { - res->best = elem_time; + res->best = (LttTime *)elem_time; } return -1; } @@ -2041,8 +2004,6 @@ lttv_state_create_process(LttvTraceState *tcs, LttvProcessState *parent, LttvExecutionState *es; - LttvTraceContext *tc = (LttvTraceContext*)tcs; - char buffer[128]; process->pid = pid; @@ -2188,8 +2149,8 @@ static gboolean syscall_entry(void *hook_data, void *call_data) LttvTraceState *ts = (LttvTraceState*)s->parent.t_context; LttvProcessState *process = ts->running_process[cpu]; LttEvent *e = ltt_tracefile_get_event(s->parent.tf); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; - LttField *f = thf->f1; + LttvTraceHook *th = (LttvTraceHook *)hook_data; + struct marker_field *f = th->f1; LttvExecutionSubmode submode; @@ -2231,8 +2192,8 @@ static gboolean trap_entry(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; LttEvent *e = ltt_tracefile_get_event(s->parent.tf); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; - LttField *f = thf->f1; + LttvTraceHook *th = (LttvTraceHook *)hook_data; + struct marker_field *f = th->f1; LttvExecutionSubmode submode; @@ -2274,18 +2235,14 @@ static gboolean 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 fac_id = ltt_event_facility_id(e); - guint8 ev_id = ltt_event_eventtype_id(e); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; - // g_assert(lttv_trace_hook_get_first((LttvTraceHook *)hook_data)->f1 != NULL); - g_assert(thf->f1 != NULL); - // g_assert(thf == lttv_trace_hook_get_first((LttvTraceHook *)hook_data)); - LttField *f = thf->f1; + //guint8 ev_id = ltt_event_eventtype_id(e); + LttvTraceHook *th = (LttvTraceHook *)hook_data; + g_assert(th->f1 != NULL); + struct marker_field *f = th->f1; LttvExecutionSubmode submode; guint64 irq = ltt_event_get_long_unsigned(e, f); guint64 nb_irqs = ((LttvTraceState *)(s->parent.t_context))->nb_irqs; - GString *string; if(irq < nb_irqs) { submode = ((LttvTraceState *)(s->parent.t_context))->irq_names[irq]; @@ -2340,18 +2297,14 @@ static gboolean soft_irq_entry(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; LttEvent *e = ltt_tracefile_get_event(s->parent.tf); - guint8 fac_id = ltt_event_facility_id(e); - guint8 ev_id = ltt_event_eventtype_id(e); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; - // g_assert(lttv_trace_hook_get_first((LttvTraceHook *)hook_data)->f1 != NULL); - g_assert(thf->f1 != NULL); - // g_assert(thf == lttv_trace_hook_get_first((LttvTraceHook *)hook_data)); - LttField *f = thf->f1; + //guint8 ev_id = ltt_event_eventtype_id(e); + LttvTraceHook *th = (LttvTraceHook *)hook_data; + g_assert(th->f1 != NULL); + struct marker_field *f = th->f1; LttvExecutionSubmode submode; guint64 softirq = ltt_event_get_long_unsigned(e, f); guint64 nb_softirqs = ((LttvTraceState *)(s->parent.t_context))->nb_softirqs; - GString *string; if(softirq < nb_softirqs) { submode = ((LttvTraceState *)(s->parent.t_context))->soft_irq_names[softirq]; @@ -2368,18 +2321,34 @@ static gboolean soft_irq_entry(void *hook_data, void *call_data) return FALSE; } +static gboolean enum_interrupt(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; + + GQuark action = g_quark_from_string(ltt_event_get_string(e, th->f1)); + guint irq = ltt_event_get_long_unsigned(e, th->f2); + + ts->irq_names[irq] = action; + + return FALSE; +} + + static gboolean bdev_request_issue(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 fac_id = ltt_event_facility_id(e); - guint8 ev_id = ltt_event_eventtype_id(e); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; + //guint8 ev_id = ltt_event_eventtype_id(e); + LttvTraceHook *th = (LttvTraceHook *)hook_data; - guint major = ltt_event_get_long_unsigned(e, thf->f1); - guint minor = ltt_event_get_long_unsigned(e, thf->f2); - guint oper = ltt_event_get_long_unsigned(e, thf->f3); + guint major = ltt_event_get_long_unsigned(e, th->f1); + guint minor = ltt_event_get_long_unsigned(e, th->f2); + guint oper = ltt_event_get_long_unsigned(e, th->f3); guint16 devcode = MKDEV(major,minor); /* have we seen this block device before? */ @@ -2398,11 +2367,11 @@ static gboolean bdev_request_complete(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); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; + LttvTraceHook *th = (LttvTraceHook *)hook_data; - guint major = ltt_event_get_long_unsigned(e, thf->f1); - guint minor = ltt_event_get_long_unsigned(e, thf->f2); - guint oper = ltt_event_get_long_unsigned(e, thf->f3); + guint major = ltt_event_get_long_unsigned(e, th->f1); + guint minor = ltt_event_get_long_unsigned(e, th->f2); + //guint oper = ltt_event_get_long_unsigned(e, th->f3); guint16 devcode = MKDEV(major,minor); /* have we seen this block device before? */ @@ -2470,11 +2439,10 @@ static gboolean function_entry(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; LttEvent *e = ltt_tracefile_get_event(s->parent.tf); - guint8 fac_id = ltt_event_facility_id(e); - guint8 ev_id = ltt_event_eventtype_id(e); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; - g_assert(thf->f1 != NULL); - LttField *f = thf->f1; + //guint8 ev_id = ltt_event_eventtype_id(e); + LttvTraceHook *th = (LttvTraceHook *)hook_data; + g_assert(th->f1 != NULL); + struct marker_field *f = th->f1; guint64 funcptr = ltt_event_get_long_unsigned(e, f); push_function(s, funcptr); @@ -2485,15 +2453,12 @@ static gboolean function_exit(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; LttEvent *e = ltt_tracefile_get_event(s->parent.tf); - guint8 fac_id = ltt_event_facility_id(e); - guint8 ev_id = ltt_event_eventtype_id(e); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; - g_assert(thf->f1 != NULL); - LttField *f = thf->f1; + //guint8 ev_id = ltt_event_eventtype_id(e); + LttvTraceHook *th = (LttvTraceHook *)hook_data; + g_assert(th->f1 != NULL); + struct marker_field *f = th->f1; guint64 funcptr = ltt_event_get_long_unsigned(e, f); - LttvExecutionSubmode submode; - pop_function(s, funcptr); return FALSE; } @@ -2504,16 +2469,16 @@ static gboolean schedchange(void *hook_data, void *call_data) guint cpu = s->cpu; LttvTraceState *ts = (LttvTraceState*)s->parent.t_context; LttvProcessState *process = ts->running_process[cpu]; - LttvProcessState *old_process = ts->running_process[cpu]; + //LttvProcessState *old_process = ts->running_process[cpu]; LttEvent *e = ltt_tracefile_get_event(s->parent.tf); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; + LttvTraceHook *th = (LttvTraceHook *)hook_data; guint pid_in, pid_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_long_int(e, thf->f3); + pid_out = ltt_event_get_unsigned(e, th->f1); + pid_in = ltt_event_get_unsigned(e, th->f2); + state_out = ltt_event_get_long_int(e, th->f3); if(likely(process != NULL)) { @@ -2580,25 +2545,25 @@ static gboolean process_fork(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; LttEvent *e = ltt_tracefile_get_event(s->parent.tf); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; + LttvTraceHook *th = (LttvTraceHook *)hook_data; guint parent_pid; guint child_pid; /* In the Linux Kernel, there is one PID per thread. */ guint child_tgid; /* tgid in the Linux kernel is the "real" POSIX PID. */ - LttvProcessState *zombie_process; + //LttvProcessState *zombie_process; guint cpu = s->cpu; LttvTraceState *ts = (LttvTraceState*)s->parent.t_context; LttvProcessState *process = ts->running_process[cpu]; LttvProcessState *child_process; /* Parent PID */ - parent_pid = ltt_event_get_unsigned(e, thf->f1); + parent_pid = ltt_event_get_unsigned(e, th->f1); /* Child PID */ - child_pid = ltt_event_get_unsigned(e, thf->f2); + child_pid = ltt_event_get_unsigned(e, th->f2); s->parent.target_pid = child_pid; /* Child TGID */ - if(thf->f3) child_tgid = ltt_event_get_unsigned(e, thf->f3); + if(th->f3) child_tgid = ltt_event_get_unsigned(e, th->f3); else child_tgid = 0; /* Mathieu : it seems like the process might have been scheduled in before the @@ -2655,15 +2620,14 @@ static gboolean process_kernel_thread(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; LttEvent *e = ltt_tracefile_get_event(s->parent.tf); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; + LttvTraceHook *th = (LttvTraceHook *)hook_data; guint pid; - guint cpu = s->cpu; LttvTraceState *ts = (LttvTraceState*)s->parent.t_context; LttvProcessState *process; LttvExecutionState *es; /* PID */ - pid = (guint)ltt_event_get_long_unsigned(e, thf->f1); + pid = (guint)ltt_event_get_long_unsigned(e, th->f1); s->parent.target_pid = pid; process = lttv_state_find_process_or_create(ts, ANY_CPU, pid, @@ -2682,14 +2646,12 @@ static gboolean process_exit(void *hook_data, void *call_data) { LttvTracefileState *s = (LttvTracefileState *)call_data; LttEvent *e = ltt_tracefile_get_event(s->parent.tf); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; - LttField *f; + LttvTraceHook *th = (LttvTraceHook *)hook_data; guint pid; - guint cpu = s->cpu; LttvTraceState *ts = (LttvTraceState*)s->parent.t_context; LttvProcessState *process; // = ts->running_process[cpu]; - pid = ltt_event_get_unsigned(e, thf->f1); + pid = ltt_event_get_unsigned(e, th->f1); s->parent.target_pid = pid; // FIXME : Add this test in the "known state" section @@ -2707,12 +2669,12 @@ static gboolean process_free(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); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; + LttvTraceHook *th = (LttvTraceHook *)hook_data; guint release_pid; LttvProcessState *process; /* PID of the process to release */ - release_pid = ltt_event_get_unsigned(e, thf->f1); + release_pid = ltt_event_get_unsigned(e, th->f1); s->parent.target_pid = release_pid; g_assert(release_pid != 0); @@ -2754,7 +2716,7 @@ static gboolean process_exec(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); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; + LttvTraceHook *th = (LttvTraceHook *)hook_data; //gchar *name; guint cpu = s->cpu; LttvProcessState *process = ts->running_process[cpu]; @@ -2772,7 +2734,7 @@ static gboolean process_exec(void *hook_data, void *call_data) process->name = g_quark_from_string(null_term_name); #endif //0 - process->name = g_quark_from_string(ltt_event_get_string(e, thf->f1)); + process->name = g_quark_from_string(ltt_event_get_string(e, th->f1)); process->brand = LTTV_STATE_UNBRANDED; //g_free(null_term_name); return FALSE; @@ -2783,12 +2745,12 @@ static gboolean thread_brand(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); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; + LttvTraceHook *th = (LttvTraceHook *)hook_data; gchar *name; guint cpu = s->cpu; LttvProcessState *process = ts->running_process[cpu]; - name = ltt_event_get_string(e, thf->f1); + name = ltt_event_get_string(e, th->f1); process->brand = g_quark_from_string(name); return FALSE; @@ -2800,7 +2762,6 @@ static void fix_process(gpointer key, gpointer value, LttvProcessState *process; LttvExecutionState *es; process = (LttvProcessState *)value; - LttvTracefileContext *tfc = (LttvTracefileContext *)user_data; LttTime *timestamp = (LttTime*)user_data; if(process->type == LTTV_STATE_KERNEL_THREAD) { @@ -2852,14 +2813,16 @@ static gboolean statedump_end(void *hook_data, void *call_data) LttvTracefileState *s = (LttvTracefileState *)call_data; LttvTraceState *ts = (LttvTraceState*)s->parent.t_context; LttvTracefileContext *tfc = (LttvTracefileContext *)call_data; - LttEvent *e = ltt_tracefile_get_event(s->parent.tf); - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; + //LttEvent *e = ltt_tracefile_get_event(s->parent.tf); + //LttvTraceHook *th = (LttvTraceHook *)hook_data; /* For all processes */ /* if kernel thread, if stack[0] is unknown, set to syscall mode, wait */ /* else, if stack[0] is unknown, set to user mode, running */ g_hash_table_foreach(ts->processes, fix_process, &tfc->timestamp); + + return FALSE; } static gboolean enum_process_state(void *hook_data, void *call_data) @@ -2867,9 +2830,7 @@ static gboolean enum_process_state(void *hook_data, void *call_data) LttvTracefileState *s = (LttvTracefileState *)call_data; LttEvent *e = ltt_tracefile_get_event(s->parent.tf); //It's slow : optimise later by doing this before reading trace. - LttEventType *et = ltt_event_eventtype(e); - // - LttvTraceHookByFacility *thf = (LttvTraceHookByFacility *)hook_data; + LttvTraceHook *th = (LttvTraceHook *)hook_data; guint parent_pid; guint pid; guint tgid; @@ -2878,43 +2839,50 @@ static gboolean enum_process_state(void *hook_data, void *call_data) LttvTraceState *ts = (LttvTraceState*)s->parent.t_context; LttvProcessState *process = ts->running_process[cpu]; LttvProcessState *parent_process; - LttField *f4, *f5, *f6, *f7, *f8; + struct marker_field *f4, *f5, *f6, *f7, *f8; GQuark type, mode, submode, status; LttvExecutionState *es; guint i, nb_cpus; + struct marker_info *mi; /* PID */ - pid = ltt_event_get_unsigned(e, thf->f1); + pid = ltt_event_get_unsigned(e, th->f1); s->parent.target_pid = pid; /* Parent PID */ - parent_pid = ltt_event_get_unsigned(e, thf->f2); + parent_pid = ltt_event_get_unsigned(e, th->f2); /* Command name */ - command = ltt_event_get_string(e, thf->f3); + command = ltt_event_get_string(e, th->f3); /* type */ - f4 = ltt_eventtype_field_by_name(et, LTT_FIELD_TYPE); + mi = marker_get_info_from_id(ts->parent.t, e->event_id); + f4 = marker_get_field(mi, 3); + g_assert(f4->name == LTT_FIELD_TYPE); type = ltt_enum_string_get(ltt_field_type(f4), ltt_event_get_unsigned(e, f4)); /* mode */ - f5 = ltt_eventtype_field_by_name(et, LTT_FIELD_MODE); + f5 = marker_get_field(mi, 4); + g_assert(f5->name == LTT_FIELD_MODE); mode = ltt_enum_string_get(ltt_field_type(f5), ltt_event_get_unsigned(e, f5)); /* submode */ - f6 = ltt_eventtype_field_by_name(et, LTT_FIELD_SUBMODE); + f6 = marker_get_field(mi, 5); + g_assert(f6->name == LTT_FIELD_SUBMODE); submode = ltt_enum_string_get(ltt_field_type(f6), ltt_event_get_unsigned(e, f6)); /* status */ - f7 = ltt_eventtype_field_by_name(et, LTT_FIELD_STATUS); + f7 = marker_get_field(mi, 6); + g_assert(f7->name == LTT_FIELD_STATUS); status = ltt_enum_string_get(ltt_field_type(f7), ltt_event_get_unsigned(e, f7)); /* TGID */ - f8 = ltt_eventtype_field_by_name(et, LTT_FIELD_TGID); + f8 = marker_get_field(mi, 7); + g_assert(f8->name == LTT_FIELD_TGID); if(f8) tgid = ltt_event_get_unsigned(e, f8); else tgid = 0; @@ -3041,7 +3009,7 @@ void lttv_state_add_event_hooks(LttvTracesetState *self) { LttvTraceset *traceset = self->parent.ts; - guint i, j, k, l, nb_trace, nb_tracefile; + guint i, j, k, nb_trace, nb_tracefile; LttvTraceState *ts; @@ -3049,10 +3017,8 @@ void lttv_state_add_event_hooks(LttvTracesetState *self) GArray *hooks; - LttvTraceHookByFacility *thf; + LttvTraceHook *th; - LttvTraceHook *hook; - LttvAttributeValue val; gint ret; @@ -3066,133 +3032,136 @@ void lttv_state_add_event_hooks(LttvTracesetState *self) associated by id hooks. */ hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 19); - hooks = g_array_set_size(hooks, 19); // Max possible number of hooks. - hn = 0; + //hooks = g_array_set_size(hooks, 19); // Max possible number of hooks. + //hn = 0; - ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_ENTRY, - LTT_FIELD_SYSCALL_ID, 0, 0, - syscall_entry, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); - if(ret) hn--; + lttv_trace_find_hook(ts->parent.t, + LTT_EVENT_SYSCALL_ENTRY, + FIELD_ARRAY(LTT_FIELD_SYSCALL_ID), + syscall_entry, NULL, &hooks); - ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_SYSCALL_EXIT, - 0, 0, 0, - syscall_exit, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); - if(ret) hn--; + lttv_trace_find_hook(ts->parent.t, + LTT_EVENT_SYSCALL_EXIT, + FIELD_ARRAY(0), + syscall_exit, NULL, &hooks); - ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_ENTRY, - LTT_FIELD_TRAP_ID, 0, 0, - trap_entry, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); - if(ret) hn--; + lttv_trace_find_hook(ts->parent.t, + LTT_EVENT_TRAP_ENTRY, + FIELD_ARRAY(LTT_FIELD_TRAP_ID), + trap_entry, NULL, &hooks); ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_TRAP_EXIT, + LTT_EVENT_TRAP_EXIT, 0, 0, 0, trap_exit, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_ENTRY, + LTT_EVENT_IRQ_ENTRY, LTT_FIELD_IRQ_ID, 0, 0, irq_entry, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_KERNEL, LTT_EVENT_IRQ_EXIT, + LTT_EVENT_IRQ_EXIT, 0, 0, 0, irq_exit, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_ENTRY, + LTT_EVENT_SOFT_IRQ_ENTRY, LTT_FIELD_SOFT_IRQ_ID, 0, 0, soft_irq_entry, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_KERNEL, LTT_EVENT_SOFT_IRQ_EXIT, + LTT_EVENT_SOFT_IRQ_EXIT, 0, 0, 0, soft_irq_exit, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_KERNEL, LTT_EVENT_SCHED_SCHEDULE, + LTT_EVENT_SCHED_SCHEDULE, LTT_FIELD_PREV_PID, LTT_FIELD_NEXT_PID, LTT_FIELD_PREV_STATE, schedchange, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FORK, + LTT_EVENT_PROCESS_FORK, LTT_FIELD_PARENT_PID, LTT_FIELD_CHILD_PID, LTT_FIELD_CHILD_TGID, process_fork, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_KERNEL_ARCH, LTT_EVENT_KTHREAD_CREATE, + LTT_EVENT_KTHREAD_CREATE, LTT_FIELD_PID, 0, 0, process_kernel_thread, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_EXIT, + LTT_EVENT_PROCESS_EXIT, LTT_FIELD_PID, 0, 0, process_exit, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_KERNEL, LTT_EVENT_PROCESS_FREE, + LTT_EVENT_PROCESS_FREE, LTT_FIELD_PID, 0, 0, process_free, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_FS, LTT_EVENT_EXEC, + LTT_EVENT_EXEC, LTT_FIELD_FILENAME, 0, 0, process_exec, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_USER_GENERIC, LTT_EVENT_THREAD_BRAND, + LTT_EVENT_THREAD_BRAND, LTT_FIELD_NAME, 0, 0, thread_brand, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; /* statedump-related hooks */ ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_LIST, LTT_EVENT_PROCESS_STATE, + LTT_EVENT_PROCESS_STATE, LTT_FIELD_PID, LTT_FIELD_PARENT_PID, LTT_FIELD_NAME, enum_process_state, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_LIST, LTT_EVENT_STATEDUMP_END, + LTT_EVENT_STATEDUMP_END, 0, 0, 0, statedump_end, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_BLOCK, LTT_EVENT_REQUEST_ISSUE, + LTT_EVENT_LIST_INTERRUPT, + LTT_FIELD_ACTION, LTT_FIELD_NUM, 0, + enum_interrupt, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); + if(ret) hn--; + + ret = lttv_trace_find_hook(ts->parent.t, + LTT_EVENT_REQUEST_ISSUE, LTT_FIELD_MAJOR, LTT_FIELD_MINOR, LTT_FIELD_OPERATION, bdev_request_issue, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_BLOCK, LTT_EVENT_REQUEST_COMPLETE, + LTT_EVENT_REQUEST_COMPLETE, LTT_FIELD_MAJOR, LTT_FIELD_MINOR, LTT_FIELD_OPERATION, bdev_request_complete, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_USER_GENERIC, LTT_EVENT_FUNCTION_ENTRY, + LTT_EVENT_FUNCTION_ENTRY, LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE, 0, function_entry, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; ret = lttv_trace_find_hook(ts->parent.t, - LTT_FACILITY_USER_GENERIC, LTT_EVENT_FUNCTION_EXIT, + LTT_EVENT_FUNCTION_EXIT, LTT_FIELD_THIS_FN, LTT_FIELD_CALL_SITE, 0, function_exit, NULL, &g_array_index(hooks, LttvTraceHook, hn++)); if(ret) hn--; @@ -3209,15 +3178,12 @@ void lttv_state_add_event_hooks(LttvTracesetState *self) LttvTracefileContext*, j)); for(k = 0 ; k < hooks->len ; k++) { - hook = &g_array_index(hooks, LttvTraceHook, k); - for(l=0;lfac_list->len;l++) { - thf = g_array_index(hook->fac_list, LttvTraceHookByFacility*, l); + th = &g_array_index(hooks, LttvTraceHook, k); lttv_hooks_add( - lttv_hooks_by_id_find(tfs->parent.event_by_id, thf->id), - thf->h, - thf, + lttv_hooks_by_id_find(tfs->parent.event_by_id, th->id), + th->h, + th, LTTV_PRIO_STATE); - } } } lttv_attribute_find(ts->parent.a, LTTV_STATE_HOOKS, LTTV_POINTER, &val); @@ -3238,7 +3204,7 @@ void lttv_state_remove_event_hooks(LttvTracesetState *self) { LttvTraceset *traceset = self->parent.ts; - guint i, j, k, l, nb_trace, nb_tracefile; + guint i, j, k, nb_trace, nb_tracefile; LttvTraceState *ts; @@ -3246,9 +3212,7 @@ void lttv_state_remove_event_hooks(LttvTracesetState *self) GArray *hooks; - LttvTraceHook *hook; - - LttvTraceHookByFacility *thf; + LttvTraceHook *th; LttvAttributeValue val; @@ -3269,15 +3233,11 @@ void lttv_state_remove_event_hooks(LttvTracesetState *self) LttvTracefileContext*, j)); for(k = 0 ; k < hooks->len ; k++) { - hook = &g_array_index(hooks, LttvTraceHook, k); - for(l=0;lfac_list->len;l++) { - thf = g_array_index(hook->fac_list, LttvTraceHookByFacility*, l); - + th = &g_array_index(hooks, LttvTraceHook, k); lttv_hooks_remove_data( - lttv_hooks_by_id_find(tfs->parent.event_by_id, thf->id), - thf->h, - thf); - } + lttv_hooks_by_id_find(tfs->parent.event_by_id, th->id), + th->h, + th); } } for(k = 0 ; k < hooks->len ; k++) @@ -3298,16 +3258,8 @@ static gboolean state_save_event_hook(void *hook_data, void *call_data) LttvTracefileState *self = (LttvTracefileState *)call_data; - LttvTracefileState *tfcs; - LttvTraceState *tcs = (LttvTraceState *)(self->parent.t_context); - LttEventPosition *ep; - - guint i; - - LttTracefile *tf; - LttvAttribute *saved_states_tree, *saved_state_tree; LttvAttributeValue value; @@ -3900,6 +3852,7 @@ 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_FIELD_SYSCALL_ID = g_quark_from_string("syscall_id"); @@ -3925,6 +3878,8 @@ static void module_init() LTT_FIELD_MAJOR = g_quark_from_string("major"); 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"); LTTV_CPU_UNKNOWN = g_quark_from_string("unknown"); LTTV_CPU_IDLE = g_quark_from_string("idle");