From ffd54a901f0062e31ffb35a316de9d8b17104abb Mon Sep 17 00:00:00 2001 From: dagenais Date: Wed, 6 Aug 2003 21:21:19 +0000 Subject: [PATCH] Correct syntax, not done but release often they say :-( git-svn-id: http://ltt.polymtl.ca/svn@171 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/include/lttv/hook.h | 6 +- ltt/branches/poly/include/lttv/processTrace.h | 40 +-- ltt/branches/poly/include/lttv/state.h | 51 ++-- ltt/branches/poly/lttv/attribute.c | 164 +++++++----- ltt/branches/poly/lttv/batchAnalysis.c | 45 ++-- ltt/branches/poly/lttv/hook.c | 15 +- ltt/branches/poly/lttv/iattribute.c | 54 ++-- ltt/branches/poly/lttv/main.c | 28 +- ltt/branches/poly/lttv/module.c | 18 +- ltt/branches/poly/lttv/option.c | 19 +- ltt/branches/poly/lttv/processTrace.c | 161 +++++------ ltt/branches/poly/lttv/state.c | 235 +++++++++------- ltt/branches/poly/lttv/textDump.c | 251 +++++++++--------- 13 files changed, 606 insertions(+), 481 deletions(-) diff --git a/ltt/branches/poly/include/lttv/hook.h b/ltt/branches/poly/include/lttv/hook.h index 677bb892..22624238 100644 --- a/ltt/branches/poly/include/lttv/hook.h +++ b/ltt/branches/poly/include/lttv/hook.h @@ -29,7 +29,7 @@ void lttv_hooks_add(LttvHooks *h, LttvHook f, void *hook_data); /* Add a list of hooks to the list h */ -void lttv_hooks_add(LttvHooks *h, LttvHooks *list); +void lttv_hooks_add_list(LttvHooks *h, LttvHooks *list); /* Remove a hook from the list. Return the hook data. */ @@ -44,7 +44,7 @@ void lttv_hooks_remove_data(LttvHooks *h, LttvHook f, void *hook_data); /* Remove a list of hooks from the hooks list in h. */ -void lttv_hooks_remove_data(LttvHooks *h, LttvHook *list); +void lttv_hooks_remove_data_list(LttvHooks *h, LttvHook *list); /* Return the number of hooks in the list */ @@ -77,7 +77,7 @@ gboolean lttv_hooks_call_check(LttvHooks *h, void *call_data); /* Sometimes different hooks need to be called based on the case. The case is represented by an unsigned integer id */ -typedef struct _LttvHooksById LttvHooksById; +typedef GPtrArray LttvHooksById; /* Create and destroy a hooks by id list */ diff --git a/ltt/branches/poly/include/lttv/processTrace.h b/ltt/branches/poly/include/lttv/processTrace.h index 60dfd7ba..133f7ecd 100644 --- a/ltt/branches/poly/include/lttv/processTrace.h +++ b/ltt/branches/poly/include/lttv/processTrace.h @@ -1,6 +1,7 @@ #ifndef PROCESSTRACE_H #define PROCESSTRACE_H +#include #include #include #include @@ -45,6 +46,16 @@ tracefile contexts may be subtyped as needed. Indeed, both the contexts and the hooks are defined by the caller. */ + +typedef struct _LttvTracesetContext LttvTracesetContext; +typedef struct _LttvTracesetContextClass LttvTracesetContextClass; + +typedef struct _LttvTraceContext LttvTraceContext; +typedef struct _LttvTraceContextClass LttvTraceContextClass; + +typedef struct _LttvTracefileContext LttvTracefileContext; +typedef struct _LttvTracefileContextClass LttvTracefileContextClass; + #define LTTV_TRACESET_CONTEXT_TYPE (lttv_traceset_context_get_type ()) #define LTTV_TRACESET_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACESET_CONTEXT_TYPE, LttvTracesetContext)) #define LTTV_TRACESET_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACESET_CONTEXT_TYPE, LttvTracesetContextClass)) @@ -52,9 +63,6 @@ #define LTTV_IS_TRACESET_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACESET_CONTEXT_TYPE)) #define LTTV_TRACESET_CONTEXT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACESET_CONTEXT_TYPE, LttvTracesetContextClass)) -typedef struct _LttvTracesetContext LttvTracesetContext; -typedef struct _LttvTracesetContextClass LttvTracesetContextClass; - struct _LttvTracesetContext { GObject parent; @@ -98,15 +106,12 @@ lttv_context_new_tracefile_context(LttvTracesetContext *self); #define LTTV_IS_TRACE_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACE_CONTEXT_TYPE)) #define LTTV_TRACE_CONTEXT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACE_CONTEXT_TYPE, LttvTraceContextClass)) -typedef struct _LttvTraceContext LttvTraceContext; -typedef struct _LttvTraceContextClass LttvTraceContextClass; - struct _LttvTraceContext { GObject parent; LttvTracesetContext *ts_context; guint index; /* in ts_context->traces */ - LttvTrace *t; + LttTrace *t; LttvHooks *check; LttvHooks *before; LttvHooks *after; @@ -128,26 +133,23 @@ GType lttv_trace_context_get_type (void); #define LTTV_IS_TRACEFILE_CONTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACEFILE_CONTEXT_TYPE)) #define LTTV_TRACEFILE_CONTEXT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACEFILE_CONTEXT_TYPE, LttvTracefileContextClass)) -typedef struct _LttvTracefileContext LttvTracefileContext; -typedef struct _LttvTracefileContextClass LttvTracefileContextClass; - struct _LttvTracefileContext { GObject parent; LttvTraceContext *t_context; gboolean control; guint index; /* in ts_context->control/per_cpu_tracefiles */ - LttvTracefile *tf; + LttTracefile *tf; LttvHooks *check; LttvHooks *before; LttvHooks *after; - LttvEvent *e; + LttEvent *e; LttvHooks *check_event; LttvHooks *before_event; LttvHooksById *before_event_by_id; LttvHooks *after_event; LttvHooksById *after_event_by_id; - LttTime *time; + LttTime timestamp; LttvAttribute *a; }; @@ -157,7 +159,7 @@ struct _LttvTracefileContextClass { GType lttv_tracefile_context_get_type (void); -void lttv_process_trace(LttvTime start, LttvTime end, LttvTraceset *traceset, +void lttv_process_trace(LttTime start, LttTime end, LttvTraceset *traceset, LttvTracesetContext *context); void lttv_traceset_context_add_hooks(LttvTracesetContext *self, @@ -166,9 +168,12 @@ void lttv_traceset_context_add_hooks(LttvTracesetContext *self, LttvHooks *check_trace, LttvHooks *before_trace, LttvHooks *after_trace, + LttvHooks *check_tracefile, + LttvHooks *before_tracefile, + LttvHooks *after_tracefile, LttvHooks *check_event, LttvHooks *before_event, - LttvHooks *after_event) + LttvHooks *after_event); void lttv_traceset_context_remove_hooks(LttvTracesetContext *self, LttvHooks *before_traceset, @@ -176,8 +181,11 @@ void lttv_traceset_context_remove_hooks(LttvTracesetContext *self, LttvHooks *check_trace, LttvHooks *before_trace, LttvHooks *after_trace, + LttvHooks *check_tracefile, + LttvHooks *before_tracefile, + LttvHooks *after_tracefile, LttvHooks *check_event, LttvHooks *before_event, - LttvHooks *after_event) + LttvHooks *after_event); #endif // PROCESSTRACE_H diff --git a/ltt/branches/poly/include/lttv/state.h b/ltt/branches/poly/include/lttv/state.h index d7b265a3..13b71f2b 100644 --- a/ltt/branches/poly/include/lttv/state.h +++ b/ltt/branches/poly/include/lttv/state.h @@ -1,13 +1,14 @@ #ifndef STATE_H #define STATE_H +#include #include /* The operating system state kept during the trace analysis contains a subset of the real operating system state, sufficient for the analysis, and possibly organized quite differently. - The state information is added to LttvTraceSetContext, LttvTraceContext + The state information is added to LttvTracesetContext, LttvTraceContext and LttvTracefileContext objects, used by processTrace, through subtyping. The context objects already reflect the multiple tracefiles (one per cpu) per trace and multiple traces per trace set. The state @@ -29,6 +30,15 @@ like enumerations. */ +typedef struct _LttvTracesetState LttvTracesetState; +typedef struct _LttvTracesetStateClass LttvTracesetStateClass; + +typedef struct _LttvTraceState LttvTraceState; +typedef struct _LttvTraceStateClass LttvTraceStateClass; + +typedef struct _LttvTracefileState LttvTracefileState; +typedef struct _LttvTracefileStateClass LttvTracefileStateClass; + gboolean lttv_state_add_event_hooks(LttvTracesetState *self); gboolean lttv_state_remove_event_hooks(LttvTracesetState *self); @@ -39,6 +49,12 @@ gboolean lttv_state_remove_event_hooks(LttvTracesetState *self); typedef GQuark LttvInterruptType; +extern LttvInterruptType + LTTV_STATE_USER_MODE, + LTTV_STATE_SYSCALL, + LTTV_STATE_TRAP, + LTTV_STATE_IRQ; + /* The interrupt number depends on the interrupt type. For user mode or kernel thread, which are the normal mode (interrupt stack bottom), it is set to @@ -55,8 +71,16 @@ typedef GQuark LttvInterruptNumber; typedef GQuark LttvProcessStatus; +extern LttvProcessStatus + LTTV_STATE_UNNAMED, + LTTV_STATE_WAIT_FORK, + LTTV_STATE_WAIT_CPU, + LTTV_STATE_EXIT, + LTTV_STATE_WAIT, + LTTV_STATE_RUN; -typedef _LttvInterruptState { + +typedef struct _LttvInterruptState { LttvInterruptType t; LttvInterruptNumber n; LttvTime entry; @@ -75,25 +99,22 @@ typedef struct _LttvProcessState { } LttvProcessState; -/* The LttvTraceSetState, LttvTraceState and LttvTracefileState types +/* The LttvTracesetState, LttvTraceState and LttvTracefileState types inherit from the corresponding Context objects defined in processTrace. */ #define LTTV_TRACESET_STATE_TYPE (lttv_traceset_state_get_type ()) -#define LTTV_TRACESET_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACESET_STATE_TYPE, LttvTraceSetState)) -#define LTTV_TRACESET_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACESET_STATE_TYPE, LttvTraceSetStateClass)) +#define LTTV_TRACESET_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LTTV_TRACESET_STATE_TYPE, LttvTracesetState)) +#define LTTV_TRACESET_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), LTTV_TRACESET_STATE_TYPE, LttvTracesetStateClass)) #define LTTV_IS_TRACESET_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LTTV_TRACESET_STATE_TYPE)) #define LTTV_IS_TRACESET_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACESET_STATE_TYPE)) -#define LTTV_TRACESET_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACESET_STATE_TYPE, LttvTraceSetStateClass)) - -typedef struct _LttvTraceSetState LttvTraceSetState; -typedef struct _LttvTraceSetStateClass LttvTraceSetStateClass; +#define LTTV_TRACESET_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACESET_STATE_TYPE, LttvTracesetStateClass)) -struct _LttvTraceSetState { - LttvTraceSetContext parent; +struct _LttvTracesetState { + LttvTracesetContext parent; }; struct _LttvTracesetStateClass { - LttvTraceSetClass parent; + LttvTracesetContextClass parent; }; GType lttv_traceset_state_get_type (void); @@ -106,9 +127,6 @@ GType lttv_traceset_state_get_type (void); #define LTTV_IS_TRACE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACE_STATE_TYPE)) #define LTTV_TRACE_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACE_STATE_TYPE, LttvTraceStateClass)) -typedef struct _LttvTraceState LttvTraceState; -typedef struct _LttvTraceStateClass LttvTraceStateClass; - struct _LttvTraceState { LttvTraceContext parent; @@ -130,9 +148,6 @@ GType lttv_trace_state_get_type (void); #define LTTV_IS_TRACEFILE_STATE_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), LTTV_TRACEFILE_STATE_TYPE)) #define LTTV_TRACEFILE_STATE_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), LTTV_TRACEFILE_STATE_TYPE, LttvTracefileStateClass)) -typedef struct _LttvTracefileState LttvTracefileState; -typedef struct _LttvTracefileStateClass LttvTracefileStateClass; - struct _LttvTracefileState { LttvTracefileContext parent; diff --git a/ltt/branches/poly/lttv/attribute.c b/ltt/branches/poly/lttv/attribute.c index 6fab25dc..a0452b5f 100644 --- a/ltt/branches/poly/lttv/attribute.c +++ b/ltt/branches/poly/lttv/attribute.c @@ -8,10 +8,10 @@ typedef union _AttributeValue { unsigned long dv_ulong; float dv_float; double dv_double; - timespec dv_timespec; + LttvTime dv_time; gpointer dv_pointer; char *dv_string; - gobject *dv_gobject; + GObject *dv_gobject; } AttributeValue; @@ -22,34 +22,43 @@ typedef struct _Attribute { } Attribute; -GType -lttv_attribute_get_type (void) +LttvAttributeValue address_of_value(LttvAttributeType t, AttributeValue *v) { - static GType type = 0; - if (type == 0) { - static const GTypeInfo info = { - sizeof (LttvAttributeClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - attribute_class_init, /* class_init */ - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (LttvAttribute), - 0, /* n_preallocs */ - attribute_instance_init /* instance_init */ - }; + LttvAttributeValue va; + + switch(t) { + case LTTV_INT: va.v_int = &v->dv_int; break; + case LTTV_UINT: va.v_uint = &v->dv_uint; break; + case LTTV_LONG: va.v_long = &v->dv_long; break; + case LTTV_ULONG: va.v_ulong = &v->dv_ulong; break; + case LTTV_FLOAT: va.v_float = &v->dv_float; break; + case LTTV_DOUBLE: va.v_double = &v->dv_double; break; + case LTTV_TIME: va.v_time = &v->dv_time; break; + case LTTV_POINTER: va.v_pointer = &v->dv_pointer; break; + case LTTV_STRING: va.v_string = &v->dv_string; break; + case LTTV_GOBJECT: va.v_gobject = &v->dv_gobject; break; + } + return va; +} - static const GInterfaceInfo iattribute_info = { - (GInterfaceInitFunc) attribute_interface_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - type = g_type_register_static (G_TYPE_OBJECT, "LttvAttributeType", &info, - 0); - g_type_add_interface_static (type, LTTV_IATTRIBUTE_TYPE, &iattribute_info); +AttributeValue init_value(LttvAttributeType t) +{ + AttributeValue v; + + switch(t) { + case LTTV_INT: v.dv_int = 0; break; + case LTTV_UINT: v.dv_uint = 0; break; + case LTTV_LONG: v.dv_long = 0; break; + case LTTV_ULONG: v.dv_ulong = 0; break; + case LTTV_FLOAT: v.dv_float = 0; break; + case LTTV_DOUBLE: v.dv_double = 0; break; + case LTTV_TIME: v.dv_time.tv_sec = 0; v.dv_time.tv_nsec = 0; break; + case LTTV_POINTER: v.dv_pointer = NULL; break; + case LTTV_STRING: v.dv_string = NULL; break; + case LTTV_GOBJECT: v.dv_gobject = NULL; break; } - return type; + return v; } @@ -76,7 +85,7 @@ lttv_attribute_get(LttvAttribute *self, unsigned i, LttvAttributeName *name, a = &g_array_index(self->attributes, Attribute, i); *name = a->name; - *v = address_of_value(a->type, a->value); + *v = address_of_value(a->type, &(a->value)); return a->type; } @@ -89,12 +98,15 @@ lttv_attribute_get_by_name(LttvAttribute *self, LttvAttributeName name, unsigned i; - i = (unsigned)g_hash_table_lookup(self->names, (gconstpointer)name); - if(i == 0) return LTTV_NONE; + gpointer p; + + p = g_hash_table_lookup(self->names, GUINT_TO_POINTER(name)); + if(p == NULL) return LTTV_NONE; + i = POINTER_TO_GUINT(p); i--; a = &g_array_index(self->attributes, Attribute, i); - *v = address_of_value(a->type, a->value); + *v = address_of_value(a->type, &(a->value)); return a->type; } @@ -107,17 +119,18 @@ lttv_attribute_add(LttvAttribute *self, LttvAttributeName name, Attribute a, *pa; - i = (unsigned)g_hash_table_lookup(self->names, (gconstpointer)name); + i = (unsigned)g_hash_table_lookup(self->names, GUINT_TO_POINTER(name)); if(i != 0) g_error("duplicate entry in attribute table"); - a->name = name; - a->type = t; - a->value = init_value(t); + a.name = name; + a.type = t; + a.value = init_value(t); g_array_append_val(self->attributes, a); i = self->attributes->len - 1; - pa = &g_array_index(self->attributes, Attribute, i) - g_hash_table_insert(self->names, (gconstpointer)name, (gconstpointer)i + 1); - return address_of_value(pa->value, t); + pa = &g_array_index(self->attributes, Attribute, i); + g_hash_table_insert(self->names, GUINT_TO_POINTER(name), + GUINT_TO_POINTER(i + 1)); + return address_of_value(t, &(pa->value)); } @@ -132,14 +145,14 @@ lttv_attribute_remove(LttvAttribute *self, unsigned i) /* Remove the array element and its entry in the name index */ - g_hash_table_remove(self->names, (gconspointer)a->name); + g_hash_table_remove(self->names, GUINT_TO_POINTER(a->name)); g_array_remove_index_fast(self->attributes, i); /* The element used to replace the removed element has its index entry all wrong now. Reinsert it with its new position. */ - g_hash_table_remove(self->names, (gconstpointer)a->name); - g_hash_table_insert(self->names, (gconstpointer)a->name, i + 1); + g_hash_table_remove(self->names, GUINT_TO_POINTER(a->name)); + g_hash_table_insert(self->names, GUINT_TO_POINTER(a->name), GUINT_TO_POINTER(i + 1)); } void @@ -147,7 +160,7 @@ lttv_attribute_remove_by_name(LttvAttribute *self, LttvAttributeName name) { unsigned i; - i = (unsigned)g_hash_table_lookup(self->names, (gconstpointer)name); + i = (unsigned)g_hash_table_lookup(self->names, GUINT_TO_POINTER(name)); if(i == 0) g_error("remove by name non existent attribute"); lttv_attribute_remove(self, i - 1); @@ -167,17 +180,17 @@ lttv_attribute_create_subdir(LttvAttribute *self, LttvAttributeName name) LttvAttribute *new; - i = (unsigned)g_hash_table_lookup(self->names, (gconstpointer)name); + i = (unsigned)g_hash_table_lookup(self->names, GUINT_TO_POINTER(name)); if(i != 0) { a = g_array_index(self->attributes, Attribute, i - 1); - if(a->type == LTTV_GOBJECT && LTTV_IS_IATTRIBUTE(a->value->dv_gobject)) { - return LTTV_IATTRIBUTE(a->value->dv_gobject); + if(a.type == LTTV_GOBJECT && LTTV_IS_IATTRIBUTE(a.value.dv_gobject)) { + return LTTV_IATTRIBUTE(a.value.dv_gobject); } else return NULL; } - new = g_object_new(LTTV_ATTRIBUTE_TYPE); - *(lttv_attribute_add(self, name, LTTV_GOBJECT)->v_gobject) = new; - return new; + new = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL); + *(lttv_attribute_add(self, name, LTTV_GOBJECT).v_gobject) = G_OBJECT(new); + return (LttvIAttribute *)new; } gboolean @@ -188,11 +201,11 @@ lttv_attribute_find(LttvAttribute *self, LttvAttributeName name, Attribute *a; - i = (unsigned)g_hash_table_lookup(self->names, (gconstpointer)name); + i = (unsigned)g_hash_table_lookup(self->names, GUINT_TO_POINTER(name)); if(i != 0) { a = &g_array_index(self->attributes, Attribute, i - 1); if(a->type != t) return FALSE; - *v = address_of_value(a->value, t); + *v = address_of_value(t, &(a->value)); return TRUE; } @@ -233,26 +246,12 @@ attribute_interface_init (gpointer g_iface, gpointer iface_data) } -static guint -quark_hash(gconstpointer key) -{ - return (guint)key; -} - - -static gboolean -quark_equal(gconstpointer a, gconstpointer b) -{ - return (a == b) -} - static void attribute_instance_init (GTypeInstance *instance, gpointer g_class) { LttvAttribute *self = (LttvAttribute *)instance; - self->names = g_hash_table_new(quark_hash, quark_equal); - self->attributes = g_array_new(FALSE, FALSE, - sizeof(Attribute)); + self->names = g_hash_table_new(g_direct_hash, g_direct_equal); + self->attributes = g_array_new(FALSE, FALSE, sizeof(Attribute)); } @@ -261,7 +260,7 @@ attribute_finalize (LttvAttribute *self) { g_hash_table_free(self->names); g_array_free(self->attributes, TRUE); - G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_ATTRIBUTE_TYPE))->finalize(self); + G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_ATTRIBUTE_GET_CLASS(self)))->finalize(G_OBJECT(self)); } @@ -270,6 +269,37 @@ attribute_class_init (LttvAttributeClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->finalize = attribute_finalize; + gobject_class->finalize = (void (*)(GObject *self))attribute_finalize; } +GType +lttv_attribute_get_type (void) +{ + static GType type = 0; + if (type == 0) { + static const GTypeInfo info = { + sizeof (LttvAttributeClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) attribute_class_init, /* class_init */ + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (LttvAttribute), + 0, /* n_preallocs */ + (GInstanceInitFunc) attribute_instance_init /* instance_init */ + }; + + static const GInterfaceInfo iattribute_info = { + (GInterfaceInitFunc) attribute_interface_init, /* interface_init */ + NULL, /* interface_finalize */ + NULL /* interface_data */ + }; + + type = g_type_register_static (G_TYPE_OBJECT, "LttvAttributeType", &info, + 0); + g_type_add_interface_static (type, LTTV_IATTRIBUTE_TYPE, &iattribute_info); + } + return type; +} + + diff --git a/ltt/branches/poly/lttv/batchAnalysis.c b/ltt/branches/poly/lttv/batchAnalysis.c index fa7f2c57..72a642c4 100644 --- a/ltt/branches/poly/lttv/batchAnalysis.c +++ b/ltt/branches/poly/lttv/batchAnalysis.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -35,18 +36,18 @@ void lttv_trace_option(void *hook_data) } -static void process_traceset(void *hook_data, void *call_data) +static gboolean process_traceset(void *hook_data, void *call_data) { LttvTracesetState *tc; LttTime start, end; - tc = g_object_new(LTTV_TRACESET_STATE); + tc = g_object_new(LTTV_TRACESET_STATE_TYPE, NULL); lttv_context_init(LTTV_TRACESET_CONTEXT(tc), traceset); lttv_traceset_context_add_hooks(LTTV_TRACESET_CONTEXT(tc), - before_traceset, after_traceset, before_trace, after_trace, - before_tracefile, after_tracefile, before_event, after_event); + before_traceset, after_traceset, NULL, before_trace, after_trace, + NULL, before_tracefile, after_tracefile, NULL, before_event, after_event); lttv_state_add_event_hooks(tc); start.tv_sec = 0; @@ -54,10 +55,10 @@ static void process_traceset(void *hook_data, void *call_data) end.tv_sec = G_MAXULONG; end.tv_nsec = G_MAXULONG; - lttv_process_trace(start, end, traceset, tc); + lttv_process_trace(start, end, traceset, LTTV_TRACESET_CONTEXT(tc)); lttv_traceset_context_remove_hooks(LTTV_TRACESET_CONTEXT(tc), - before_traceset, after_traceset, before_trace, after_trace, - before_tracefile, after_tracefile, before_event, after_event); + before_traceset, after_traceset, NULL, before_trace, after_trace, + NULL, before_tracefile, after_tracefile, NULL, before_event, after_event); lttv_state_remove_event_hooks(tc); lttv_context_fini(LTTV_TRACESET_CONTEXT(tc)); @@ -67,14 +68,14 @@ static void process_traceset(void *hook_data, void *call_data) void init(LttvModule *self, int argc, char **argv) { - LttvAttribute_value *value; + LttvAttributeValue value; - LttvIAttributes *attributes = LTTV_IATTRIBUTES(lttv_global_attributes()); + LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); lttv_option_add("trace", 't', "add a trace to the trace set to analyse", "pathname of the directory containing the trace", - LTTV_OPT_STRING, &aTrace, lttv_trace_option, NULL); + LTTV_OPT_STRING, &a_trace, lttv_trace_option, NULL); traceset = lttv_traceset_new(); @@ -89,32 +90,32 @@ void init(LttvModule *self, int argc, char **argv) g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/before", LTTV_POINTER, &value)); - *(value->v_pointer) = before_traceset; + *(value.v_pointer) = before_traceset; g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/after", LTTV_POINTER, &value)); - *(value->v_pointer) = after_traceset; + *(value.v_pointer) = after_traceset; g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/before", LTTV_POINTER, &value)); - *(value->v_pointer) = before_trace; + *(value.v_pointer) = before_trace; g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/after", LTTV_POINTER, &value)); - *(value->v_pointer) = after_trace; + *(value.v_pointer) = after_trace; g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/before", LTTV_POINTER, &value)); - *(value->v_pointer) = before_tracefile; + *(value.v_pointer) = before_tracefile; g_assert(lttv_iattribute_find_by_path(attributes, "hooks/tracefile/after", LTTV_POINTER, &value)); - *(value->v_pointer) = after_tracefile; + *(value.v_pointer) = after_tracefile; g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/before", LTTV_POINTER, &value)); - *(value->v_pointer) = before_event; + *(value.v_pointer) = before_event; g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/after", LTTV_POINTER, &value)); - *(value->v_pointer) = after_event; + *(value.v_pointer) = after_event; g_assert(lttv_iattribute_find_by_path(attributes, "hooks/main/before", LTTV_POINTER, &value)); - g_assert((main_hooks = *(value->v_pointer)) != NULL); + g_assert((main_hooks = *(value.v_pointer)) != NULL); lttv_hooks_add(main_hooks, process_traceset, NULL); } @@ -123,7 +124,7 @@ void destroy() { guint i, nb; - lttv_hooks_remove(main_hooks, process_traceset, NULL); + lttv_hooks_remove_data(main_hooks, process_traceset, NULL); lttv_option_remove("trace"); @@ -137,8 +138,8 @@ void destroy() lttv_hooks_destroy(after_event); nb = lttv_traceset_number(traceset); - for(i = 0 ; i < nb, i++) { - ltt_trace_close(lttv_traceset_get(traceset); + for(i = 0 ; i < nb ; i++) { + ltt_trace_close(lttv_traceset_get(traceset, i)); } } diff --git a/ltt/branches/poly/lttv/hook.c b/ltt/branches/poly/lttv/hook.c index 12f12198..5edc6230 100644 --- a/ltt/branches/poly/lttv/hook.c +++ b/ltt/branches/poly/lttv/hook.c @@ -1,8 +1,9 @@ + #include typedef struct _LttvHookClosure { - lttv_hook hook; + LttvHook hook; void *hook_data; } LttvHookClosure; @@ -35,6 +36,7 @@ void lttv_hooks_add_list(LttvHooks *h, LttvHooks *list) { guint i; + if(list == NULL) return; for(i = 0 ; i < list->len; i++) { g_array_append_val(h,g_array_index(list, LttvHookClosure, i)); } @@ -83,6 +85,7 @@ void lttv_hooks_remove_list(LttvHooks *h, LttvHooks *list) LttvHookClosure *c, *c_list; + if(list == NULL) return; for(i = 0, j = 0 ; i < h->len && j < list->len ;) { c = &g_array_index(h, LttvHookClosure, i); c_list = &g_array_index(list, LttvHookClosure, j); @@ -121,9 +124,9 @@ void lttv_hooks_get(LttvHooks *h, unsigned i, LttvHook *f, void **hook_data) } -void lttv_hooks_remove_by_position(LttvHooks *h, unsigned i); +void lttv_hooks_remove_by_position(LttvHooks *h, unsigned i) { - g_array_remove_index(h, i) + g_array_remove_index(h, i); } @@ -133,6 +136,8 @@ gboolean lttv_hooks_call(LttvHooks *h, void *call_data) LttvHookClosure *c; + guint i; + if(h != NULL) { for(i = 0 ; i < h->len ; i++) { c = &g_array_index(h, LttvHookClosure, i); @@ -147,6 +152,8 @@ gboolean lttv_hooks_call_check(LttvHooks *h, void *call_data) { LttvHookClosure *c; + guint i; + for(i = 0 ; i < h->len ; i++) { c = &g_array_index(h, LttvHookClosure, i); if(c->hook(c->hook_data,call_data)) return TRUE; @@ -172,7 +179,7 @@ void lttv_hooks_by_id_destroy(LttvHooksById *h) } -LttvHooks *lttv_hooks_by_id_find(LttvHooksById *h, unsigned id); +LttvHooks *lttv_hooks_by_id_find(LttvHooksById *h, unsigned id) { if(h->len <= id) g_ptr_array_set_size(h, id + 1); if(h->pdata[id] == NULL) h->pdata[id] = lttv_hooks_new(); diff --git a/ltt/branches/poly/lttv/iattribute.c b/ltt/branches/poly/lttv/iattribute.c index 5cf9dbe4..d9934f06 100644 --- a/ltt/branches/poly/lttv/iattribute.c +++ b/ltt/branches/poly/lttv/iattribute.c @@ -1,6 +1,8 @@ +#include + static void -lttv_iattribute_base_init (gpointer g_class) +lttv_iattribute_base_init (gpointer klass) { static gboolean initialized = FALSE; @@ -59,10 +61,10 @@ LttvAttributeType lttv_iattribute_get_by_name(LttvIAttribute *self, } -void lttv_iattribute_add(LttvIAttribute *self, LttvAttributeName name, - LttvAttributeType t, LttvAttributeValue *v) +LttvAttributeValue lttv_iattribute_add(LttvIAttribute *self, + LttvAttributeName name, LttvAttributeType t) { - return LTTV_IATTRIBUTE_GET_CLASS (self)->add (self, name, t, v); + return LTTV_IATTRIBUTE_GET_CLASS (self)->add (self, name, t); } @@ -81,7 +83,7 @@ void lttv_iattribute_remove_by_name(LttvIAttribute *self, LttvIAttribute* lttv_iattribute_create_subdir(LttvIAttribute *self, LttvAttributeName name) { - return LTTV_IATTRIBUTE_GET_CLASS (self)->get_number (self, name); + return LTTV_IATTRIBUTE_GET_CLASS (self)->create_subdir (self, name); } @@ -100,7 +102,7 @@ gboolean lttv_iattribute_find(LttvIAttribute *self, LttvAttributeName name, if(found_type == t) return TRUE; if(found_type == LTTV_NONE) { - v = lttv_iattribute_add(self, name, t); + *v = lttv_iattribute_add(self, name, t); return TRUE; } @@ -114,8 +116,6 @@ gboolean lttv_iattribute_find(LttvIAttribute *self, LttvAttributeName name, gboolean lttv_iattribute_find_by_path(LttvIAttribute *self, char *path, LttvAttributeType t, LttvAttributeValue *v) { - char *cursor; - LttvIAttribute *node = self; LttvAttributeType found_type; @@ -131,7 +131,7 @@ gboolean lttv_iattribute_find_by_path(LttvIAttribute *self, char *path, return FALSE; } - while(cursor = components;;) { + for(cursor = components;;) { name = g_quark_from_string(*cursor); cursor++; @@ -160,7 +160,7 @@ gboolean lttv_iattribute_find_by_path(LttvIAttribute *self, char *path, LttvIAttribute *lttv_iattribute_shallow_copy(LttvIAttribute *self) { - LttvIAttribute copy; + LttvIAttribute *copy; LttvAttributeType t; @@ -172,18 +172,18 @@ LttvIAttribute *lttv_iattribute_shallow_copy(LttvIAttribute *self) int nb_attributes = lttv_iattribute_get_number(self); - copy = LTTV_IATTRIBUTE(g_object_new(G_OBJECT_TYPE(self))); + copy = LTTV_IATTRIBUTE(g_object_new(G_OBJECT_TYPE(self),NULL)); for(i = 0 ; i < nb_attributes ; i++) { t = lttv_iattribute_get(self, i, &name, &v); v_copy = lttv_iattribute_add(copy, name, t); - lttv_iattribute_copy_value(v_copy, v); + lttv_iattribute_copy_value(t, v_copy, v); } } LttvIAttribute *lttv_iattribute_deep_copy(LttvIAttribute *self) { - LttvIAttribute copy, child; + LttvIAttribute *copy, *child; LttvAttributeType t; @@ -195,14 +195,14 @@ LttvIAttribute *lttv_iattribute_deep_copy(LttvIAttribute *self) int nb_attributes = lttv_iattribute_get_number(self); - copy = LTTV_IATTRIBUTE(g_object_new(G_OBJECT_TYPE(self))); + copy = LTTV_IATTRIBUTE(g_object_new(G_OBJECT_TYPE(self), NULL)); for(i = 0 ; i < nb_attributes ; i++) { t = lttv_iattribute_get(self, i, &name, &v); v_copy = lttv_iattribute_add(copy, name, t); - if(t == LTTV_GOBJECT && LTTV_IS_IATTRIBUTE(*(v->v_gobject))) { - child = LTTV_IATTRIBUTE(*(v->v_gobject)); - *(v_copy->v_gobject) = lttv_iattribute_deep_copy(child); + if(t == LTTV_GOBJECT && LTTV_IS_IATTRIBUTE(*(v.v_gobject))) { + child = LTTV_IATTRIBUTE(*(v.v_gobject)); + *(v_copy.v_gobject) = G_OBJECT(lttv_iattribute_deep_copy(child)); } else lttv_iattribute_copy_value(t, v_copy, v); } @@ -213,43 +213,43 @@ void lttv_iattribute_copy_value(LttvAttributeType t, LttvAttributeValue dest, { switch(t) { case LTTV_INT: - *(dest->v_int) = *(src->v_int); + *(dest.v_int) = *(src.v_int); break; case LTTV_UINT: - *(dest->v_uint) = *(src->v_uint); + *(dest.v_uint) = *(src.v_uint); break; case LTTV_LONG: - *(dest->v_long) = *(src->v_long); + *(dest.v_long) = *(src.v_long); break; case LTTV_ULONG: - *(dest->v_ulong) = *(src->v_ulong); + *(dest.v_ulong) = *(src.v_ulong); break; case LTTV_FLOAT: - *(dest->v_float) = *(src->v_float); + *(dest.v_float) = *(src.v_float); break; case LTTV_DOUBLE: - *(dest->v_double) = *(src->v_double); + *(dest.v_double) = *(src.v_double); break; case LTTV_TIME: - *(dest->v_time) = *(src->v_time); + *(dest.v_time) = *(src.v_time); break; case LTTV_POINTER: - *(dest->v_pointer) = *(src->v_pointer); + *(dest.v_pointer) = *(src.v_pointer); break; case LTTV_STRING: - *(dest->v_string) = *(src->v_string); + *(dest.v_string) = *(src.v_string); break; case LTTV_GOBJECT: - *(dest->v_gobject) = *(src->v_gobject); + *(dest.v_gobject) = *(src.v_gobject); break; case LTTV_NONE: diff --git a/ltt/branches/poly/lttv/main.c b/ltt/branches/poly/lttv/main.c index b588e429..1123af44 100644 --- a/ltt/branches/poly/lttv/main.c +++ b/ltt/branches/poly/lttv/main.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -13,11 +14,14 @@ void lttv_option_destroy(); void lttv_module_init(int argc, char **argv); void lttv_module_destroy(); +void lttv_state_init(int argc, char **argv); +void lttv_state_destroy(); + /* The main program maintains a few central data structures and relies on modules for the rest. These data structures may be accessed by modules through an exported API */ -static LttvIAttributes *attributes; +static LttvIAttribute *attributes; static LttvHooks *before_options, @@ -47,7 +51,7 @@ extern struct GMemVTable *glib_mem_profiler_table; int main(int argc, char **argv) { - LttvAttributeValue *value; + LttvAttributeValue value; #ifdef MEMDEBUG g_mem_set_vtable(glib_mem_profiler_table); @@ -55,7 +59,7 @@ int main(int argc, char **argv) { g_mem_profile(); #endif - attributes = LTTV_IATTRIBUTES(g_object_new(LTTV_ATTRIBUTES_TYPE)); + attributes = LTTV_IATTRIBUTE(g_object_new(LTTV_ATTRIBUTE_TYPE, NULL)); before_options = lttv_hooks_new(); after_options = lttv_hooks_new(); @@ -64,22 +68,23 @@ int main(int argc, char **argv) { g_assert(lttv_iattribute_find_by_path(attributes, "hooks/options/before", LTTV_POINTER, &value)); - *(value->v_pointer) = before_options; + *(value.v_pointer) = before_options; g_assert(lttv_iattribute_find_by_path(attributes, "hooks/options/after", LTTV_POINTER, &value)); - *(value->v_pointer) = after_options; + *(value.v_pointer) = after_options; g_assert(lttv_iattribute_find_by_path(attributes, "hooks/main/before", LTTV_POINTER, &value)); - *(value->v_pointer) = before_main; + *(value.v_pointer) = before_main; g_assert(lttv_iattribute_find_by_path(attributes, "hooks/main/after", LTTV_POINTER, &value)); - *(value->v_pointer) = after_main; + *(value.v_pointer) = after_main; /* Initialize the command line options processing */ lttv_option_init(argc,argv); lttv_module_init(argc,argv); + lttv_state_init(argc,argv); /* Initialize the module loading */ @@ -88,11 +93,11 @@ int main(int argc, char **argv) { /* Add some built-in options */ lttv_option_add("module",'m', "load a module", "name of module to load", - LTTV_OPT_STRING, &aModule, lttv_module_option, NULL); + LTTV_OPT_STRING, &a_module, lttv_module_option, NULL); lttv_option_add("modules-path", 'L', "add a directory to the module search path", - "directory to add to the path", LTTV_OPT_STRING, &aModulePath, + "directory to add to the path", LTTV_OPT_STRING, &a_module_path, lttv_module_path_option, NULL); lttv_hooks_call(before_options, NULL); @@ -100,6 +105,7 @@ int main(int argc, char **argv) { lttv_hooks_call(before_main, NULL); lttv_hooks_call(after_main, NULL); + lttv_state_destroy(); lttv_module_destroy(); lttv_option_destroy(); @@ -116,7 +122,7 @@ int main(int argc, char **argv) { } -lttv_attributes *lttv_global_attributes() +LttvAttribute *lttv_global_attributes() { return attributes; } @@ -130,5 +136,5 @@ void lttv_module_option(void *hook_data) void lttv_module_path_option(void *hook_data) { - lttv_module_path_add(a_path); + lttv_module_path_add(a_module_path); } diff --git a/ltt/branches/poly/lttv/module.c b/ltt/branches/poly/lttv/module.c index d207c0a7..0f6f5a07 100644 --- a/ltt/branches/poly/lttv/module.c +++ b/ltt/branches/poly/lttv/module.c @@ -59,7 +59,7 @@ void lttv_module_path_add(const char *name) } -static LttvModuleInfo * +static LttvModule * module_load(const char *name, int argc, char **argv) { GModule *gm; @@ -69,6 +69,8 @@ module_load(const char *name, int argc, char **argv) int i; char *pathname; + + const char *module_name; LttvModuleInit init_function; @@ -97,21 +99,21 @@ module_load(const char *name, int argc, char **argv) /* Check if the module was already opened using the hopefully canonical name returned by g_module_name. */ - pathname = g_module_name(gm); + module_name = g_module_name(gm); - m = g_hash_table_lookup(modules, pathname); + m = g_hash_table_lookup(modules, module_name); if(m == NULL) { /* Module loaded for the first time. Insert it in the table and call the init function if any. */ - m = g_new(LttvModule); + m = g_new(LttvModule, 1); m->module = gm; m->ref_count = 0; m->load_count = 0; m->dependents = g_ptr_array_new(); - g_hash_table_insert(modules, pathname, m); + g_hash_table_insert(modules, (gpointer)module_name, m); if(!g_module_symbol(gm, "init", (gpointer)&init_function)) { g_warning("module %s (%s) has no init function", name, pathname); @@ -132,7 +134,7 @@ module_load(const char *name, int argc, char **argv) } -LttvModuleInfo * +LttvModule * lttv_module_load(const char *name, int argc, char **argv) { LttvModule *m = module_load(name, argc, argv); @@ -159,7 +161,7 @@ static void module_unload(LttvModule *m) char *pathname; - guint len; + guint i, len; /* Decrement the reference count */ @@ -261,7 +263,7 @@ lttv_module_unload_all() g_hash_table_foreach(modules, list_independent, independent_modules); for(i = 0 ; i < independent_modules->len ; i++) { - m = (LttvModule)independent_modules->pdata[i]; + m = (LttvModule *)independent_modules->pdata[i]; while(m->load_count > 0) lttv_module_unload(m); } diff --git a/ltt/branches/poly/lttv/option.c b/ltt/branches/poly/lttv/option.c index 3a95a4af..4c45d2ab 100644 --- a/ltt/branches/poly/lttv/option.c +++ b/ltt/branches/poly/lttv/option.c @@ -1,15 +1,16 @@ -#include +#include +#include #include typedef struct _LttvOption { - const char *long_name; + char *long_name; char char_name; - const char *description; - const char *arg_description; + char *description; + char *arg_description; LttvOptionType t; gpointer p; - LttvOptionHook h; + LttvOptionHook hook; gpointer hook_data; } LttvOption; @@ -43,7 +44,7 @@ void lttv_option_destroy() { LttvOption option; - GPtrArray list = g_ptr_array_new(); + GPtrArray *list = g_ptr_array_new(); int i; @@ -76,7 +77,7 @@ void lttv_option_add(const char *long_name, const char char_name, option->arg_description = g_strdup(arg_description); option->t = t; option->p = p; - option->h = h; + option->hook = h; option->hook_data = hook_data; g_hash_table_insert(options, option->long_name, option); } @@ -105,7 +106,7 @@ static struct poptOption endOption = { NULL, '\0', 0, NULL, 0}; static void build_popts(GPtrArray **plist, struct poptOption **ppopts, poptContext *pc, - int argv, char **argv) + int argc, char **argv) { LttvOption *option; @@ -152,7 +153,7 @@ destroy_popts(GPtrArray **plist, struct poptOption **ppopts, poptContext *pc) { g_ptr_array_free(*plist, TRUE); *plist = NULL; g_free(*ppopts); *ppopts = NULL; - poptFreeContext(*c); + poptFreeContext(*pc); } diff --git a/ltt/branches/poly/lttv/processTrace.c b/ltt/branches/poly/lttv/processTrace.c index 66ba155d..646dd1c8 100644 --- a/ltt/branches/poly/lttv/processTrace.c +++ b/ltt/branches/poly/lttv/processTrace.c @@ -1,9 +1,10 @@ #include +#include -void lttv_context_init(LttvTracesetContext *self) +void lttv_context_init(LttvTracesetContext *self, LttvTraceset *ts) { - LTTV_TRACESET_CONTEXT_GET_CLASS(self)->init(self); + LTTV_TRACESET_CONTEXT_GET_CLASS(self)->init(self, ts); } @@ -47,12 +48,12 @@ init(LttvTracesetContext *self, LttvTraceset *ts) nb_trace = lttv_traceset_number(ts); self->ts = ts; - self->traces = g_new((LttvTraceContext *), nb_trace); + self->traces = g_new(LttvTraceContext *, nb_trace); self->before = lttv_hooks_new(); self->after = lttv_hooks_new(); - self->attributes = g_object_new(LTTV_ATTRIBUTE_TYPE); + self->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL); for(i = 0 ; i < nb_trace ; i++) { - tc = self->new_trace_context(); + tc = LTTV_TRACESET_CONTEXT_GET_CLASS(self)->new_trace_context(self); self->traces[i] = tc; tc->ts_context = self; @@ -61,26 +62,26 @@ init(LttvTracesetContext *self, LttvTraceset *ts) tc->check = lttv_hooks_new(); tc->before = lttv_hooks_new(); tc->after = lttv_hooks_new(); - tc->attributes = g_object_new(LTTV_ATTRIBUTE_TYPE); + tc->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL); nb_control = ltt_trace_control_tracefile_number(tc->t); nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t); nb_tracefile = nb_control + nb_per_cpu; - tc->control_tracefiles = g_new((LttvTracefileContext *), nb_control); - tc->per_cpu_tracefiles = g_new((LttvTracefileContext *), nb_per_cpu); + tc->control_tracefiles = g_new(LttvTracefileContext *, nb_control); + tc->per_cpu_tracefiles = g_new(LttvTracefileContext *, nb_per_cpu); for(j = 0 ; j < nb_tracefile ; j++) { - tfc = self->new_tracefile_context(); + tfc = LTTV_TRACESET_CONTEXT_GET_CLASS(self)->new_tracefile_context(self); if(j < nb_control) { tc->control_tracefiles[j] = tfc; tfc->control = TRUE; tfc->index = j; - tfc->tf = ltt_trace_control_tracefile_get(j); + tfc->tf = ltt_trace_control_tracefile_get(tc->t, j); } else { tc->per_cpu_tracefiles[j - nb_control] = tfc; tfc->control = FALSE; tfc->index = j - nb_control; - tfc->tf = ltt_trace_per_cpu_tracefile_get(j - nb_control); + tfc->tf = ltt_trace_per_cpu_tracefile_get(tc->t, j - nb_control); } tfc->t_context = tc; tfc->check = lttv_hooks_new(); @@ -91,7 +92,7 @@ init(LttvTracesetContext *self, LttvTraceset *ts) tfc->before_event_by_id = lttv_hooks_by_id_new(); tfc->after_event = lttv_hooks_new(); tfc->after_event_by_id = lttv_hooks_by_id_new(); - tfc->attributes = g_object_new(LTTV_ATTRIBUTE_TYPE); + tfc->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL); } } } @@ -105,11 +106,11 @@ void fini(LttvTracesetContext *self) LttvTracefileContext *tfc; - LttvTraceset *ts = tc->ts; + LttvTraceset *ts = self->ts; lttv_hooks_destroy(self->before); lttv_hooks_destroy(self->after); - g_object_unref(self->attributes); + g_object_unref(self->a); nb_trace = lttv_traceset_number(ts); @@ -119,7 +120,7 @@ void fini(LttvTracesetContext *self) lttv_hooks_destroy(tc->check); lttv_hooks_destroy(tc->before); lttv_hooks_destroy(tc->after); - g_object_unref(tc->attributes); + g_object_unref(tc->a); nb_control = ltt_trace_control_tracefile_number(tc->t); nb_per_cpu = ltt_trace_per_cpu_tracefile_number(tc->t); @@ -137,7 +138,7 @@ void fini(LttvTracesetContext *self) lttv_hooks_by_id_destroy(tfc->before_event_by_id); lttv_hooks_destroy(tfc->after_event); lttv_hooks_by_id_destroy(tfc->after_event_by_id); - g_object_unref(tfc->attributes); + g_object_unref(tfc->a); g_object_unref(tfc); } g_free(tc->control_tracefiles); @@ -154,6 +155,9 @@ void lttv_traceset_context_add_hooks(LttvTracesetContext *self, LttvHooks *check_trace, LttvHooks *before_trace, LttvHooks *after_trace, + LttvHooks *check_tracefile, + LttvHooks *before_tracefile, + LttvHooks *after_tracefile, LttvHooks *check_event, LttvHooks *before_event, LttvHooks *after_event) @@ -205,6 +209,9 @@ void lttv_traceset_context_remove_hooks(LttvTracesetContext *self, LttvHooks *check_trace, LttvHooks *before_trace, LttvHooks *after_trace, + LttvHooks *check_tracefile, + LttvHooks *before_tracefile, + LttvHooks *after_tracefile, LttvHooks *check_event, LttvHooks *before_event, LttvHooks *after_event) @@ -253,45 +260,21 @@ void lttv_traceset_context_remove_hooks(LttvTracesetContext *self, LttvTracesetContext * new_traceset_context(LttvTracesetContext *self) { - return g_object_new(LTTV_TRACESET_CONTEXT_TYPE); + return g_object_new(LTTV_TRACESET_CONTEXT_TYPE, NULL); } LttvTraceContext * new_trace_context(LttvTracesetContext *self) { - return g_object_new(LTTV_TRACE_CONTEXT_TYPE); + return g_object_new(LTTV_TRACE_CONTEXT_TYPE, NULL); } LttvTracefileContext * new_tracefile_context(LttvTracesetContext *self) { - return g_object_new(LTTV_TRACEFILE_CONTEXT_TYPE); -} - - -GType -lttv_traceset_context_get_type(void) -{ - static GType type = 0; - if (type == 0) { - static const GTypeInfo info = { - sizeof (LttvTracesetContextClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - traceset_context_class_init, /* class_init */ - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (LttvTracesetContext), - 0, /* n_preallocs */ - traceset_context_instance_init /* instance_init */ - }; - - type = g_type_register_static (G_TYPE_OBJECT, "LttvTracesetContextType", - &info, 0); - } - return type; + return g_object_new(LTTV_TRACEFILE_CONTEXT_TYPE, NULL); } @@ -305,7 +288,7 @@ traceset_context_instance_init (GTypeInstance *instance, gpointer g_class) static void traceset_context_finalize (LttvTracesetContext *self) { - G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACESET_CONTEXT_TYPE))->finalize(self); + G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACESET_CONTEXT_GET_CLASS(self)))->finalize(G_OBJECT(self)); } @@ -314,7 +297,7 @@ traceset_context_class_init (LttvTracesetContextClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->finalize = traceset_context_finalize; + gobject_class->finalize = (void (*)(GObject *self))traceset_context_finalize; klass->init = init; klass->fini = fini; klass->new_traceset_context = new_traceset_context; @@ -324,23 +307,23 @@ traceset_context_class_init (LttvTracesetContextClass *klass) GType -lttv_trace_context_get_type(void) +lttv_traceset_context_get_type(void) { static GType type = 0; if (type == 0) { static const GTypeInfo info = { - sizeof (LttvTraceContextClass), + sizeof (LttvTracesetContextClass), NULL, /* base_init */ NULL, /* base_finalize */ - trace_context_class_init, /* class_init */ + (GClassInitFunc) traceset_context_class_init, /* class_init */ NULL, /* class_finalize */ NULL, /* class_data */ - sizeof (LttvTraceSetContext), + sizeof (LttvTracesetContext), 0, /* n_preallocs */ - trace_context_instance_init /* instance_init */ + (GInstanceInitFunc) traceset_context_instance_init /* instance_init */ }; - type = g_type_register_static (G_TYPE_OBJECT, "LttvTraceContextType", + type = g_type_register_static (G_TYPE_OBJECT, "LttvTracesetContextType", &info, 0); } return type; @@ -357,7 +340,7 @@ trace_context_instance_init (GTypeInstance *instance, gpointer g_class) static void trace_context_finalize (LttvTraceContext *self) { - G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACE_CONTEXT_TYPE))->finalize(self); + G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACE_CONTEXT_GET_CLASS(self)))->finalize(G_OBJECT(self)); } @@ -366,28 +349,28 @@ trace_context_class_init (LttvTraceContextClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->finalize = trace_context_finalize; + gobject_class->finalize = (void (*)(GObject *self)) trace_context_finalize; } GType -lttv_tracefile_context_get_type(void) +lttv_trace_context_get_type(void) { static GType type = 0; if (type == 0) { static const GTypeInfo info = { - sizeof (LttvTracefileContextClass), + sizeof (LttvTraceContextClass), NULL, /* base_init */ NULL, /* base_finalize */ - tracefile_context_class_init, /* class_init */ + (GClassInitFunc) trace_context_class_init, /* class_init */ NULL, /* class_finalize */ NULL, /* class_data */ - sizeof (LttvTracefileContext), + sizeof (LttvTracesetContext), 0, /* n_preallocs */ - tracefile_context_instance_init /* instance_init */ + (GInstanceInitFunc) trace_context_instance_init /* instance_init */ }; - type = g_type_register_static (G_TYPE_OBJECT, "LttvTracefileContextType", + type = g_type_register_static (G_TYPE_OBJECT, "LttvTraceContextType", &info, 0); } return type; @@ -404,7 +387,7 @@ tracefile_context_instance_init (GTypeInstance *instance, gpointer g_class) static void tracefile_context_finalize (LttvTracefileContext *self) { - G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACEFILE_CONTEXT_TYPE))->finalize(self); + G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACEFILE_CONTEXT_GET_CLASS(self)))->finalize(G_OBJECT(self)); } @@ -413,16 +396,40 @@ tracefile_context_class_init (LttvTracefileContextClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->finalize = tracefile_context_finalize; + gobject_class->finalize = (void (*)(GObject *self))tracefile_context_finalize; +} + + +GType +lttv_tracefile_context_get_type(void) +{ + static GType type = 0; + if (type == 0) { + static const GTypeInfo info = { + sizeof (LttvTracefileContextClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) tracefile_context_class_init, /* class_init */ + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (LttvTracefileContext), + 0, /* n_preallocs */ + (GInstanceInitFunc) tracefile_context_instance_init /* instance_init */ + }; + + type = g_type_register_static (G_TYPE_OBJECT, "LttvTracefileContextType", + &info, 0); + } + return type; } -guint compare_tracefile(gconstpointer a, gconstpointer b) +gint compare_tracefile(gconstpointer a, gconstpointer b) { - if((LttvTime *)a->tv_sec > (LttvTime *)b->tv_sec) return 1; - if((LttvTime *)a->tv_sec < (LttvTime *)b->tv_sec) return -1; - if((LttvTime *)a->tv_nsec > (LttvTime *)b->tv_nsec) return 1; - if((LttvTime *)a->tv_nsec < (LttvTime *)b->tv_nsec) return -1; + if(((LttvTime *)a)->tv_sec > ((LttvTime *)b)->tv_sec) return 1; + if(((LttvTime *)a)->tv_sec < ((LttvTime *)b)->tv_sec) return -1; + if(((LttvTime *)a)->tv_nsec > ((LttvTime *)b)->tv_nsec) return 1; + if(((LttvTime *)a)->tv_nsec < ((LttvTime *)b)->tv_nsec) return -1; return 0; } @@ -433,7 +440,7 @@ gboolean get_first(gpointer key, gpointer value, gpointer user_data) { } -void lttv_process_trace(LttvTime start, LttvTime end, LttvTraceset *traceset, +void lttv_process_trace(LttTime start, LttTime end, LttvTraceset *traceset, LttvTracesetContext *context) { GPtrArray *traces = g_ptr_array_new(); @@ -442,7 +449,7 @@ void lttv_process_trace(LttvTime start, LttvTime end, LttvTraceset *traceset, GTree *pqueue = g_tree_new(compare_tracefile); - guint i, j, nbi, nbj, id; + guint i, j, nbi, nbj, id, nb_control, nb_cpu; LttTrace *trace; @@ -491,8 +498,8 @@ void lttv_process_trace(LttvTime start, LttvTime end, LttvTraceset *traceset, tfc->e = event; if(event != NULL) { - tfc->time = ltt_event_time(event); - g_tree_insert(pqueue, &(tfc->time), tfc); + tfc->timestamp = ltt_event_time(event); + g_tree_insert(pqueue, &(tfc->timestamp), tfc); } } } @@ -504,7 +511,7 @@ void lttv_process_trace(LttvTime start, LttvTime end, LttvTraceset *traceset, unless the tracefile is finished or the event is later than the start time. */ - while() { + while(TRUE) { tfc = NULL; g_tree_foreach(pqueue, get_first, &tfc); if(tfc == NULL) break; @@ -513,8 +520,8 @@ void lttv_process_trace(LttvTime start, LttvTime end, LttvTraceset *traceset, or more tracefiles have events for the same time, hope that lookup and remove are consistent. */ - tfc = g_tree_lookup(pqueue, &(tfc->time)); - g_tree_remove(pqueue, &(tfc->time)); + tfc = g_tree_lookup(pqueue, &(tfc->timestamp)); + g_tree_remove(pqueue, &(tfc->timestamp)); if(!lttv_hooks_call(tfc->check_event, context)) { id = lttv_event_id(tfc->e); @@ -527,8 +534,8 @@ void lttv_process_trace(LttvTime start, LttvTime end, LttvTraceset *traceset, event = ltt_tracefile_read(tfc->tf); if(event != NULL) { tfc->e = event; - tfc->time = ltt_event_time(event); - g_tree_insert(pqueue, &(tfc->time), tfc); + tfc->timestamp = ltt_event_time(event); + g_tree_insert(pqueue, &(tfc->timestamp), tfc); } } @@ -549,11 +556,11 @@ void lttv_process_trace(LttvTime start, LttvTime end, LttvTraceset *traceset, } g_assert(j == tracefiles->len); - lttv_hooks_call(after_traceset, context); + lttv_hooks_call(context->after, context); /* Free the traces, tracefiles and pqueue */ g_ptr_array_free(tracefiles, TRUE); g_ptr_array_free(traces, TRUE); - g_tree_destroy(pqueue, TRUE); + g_tree_destroy(pqueue); } diff --git a/ltt/branches/poly/lttv/state.c b/ltt/branches/poly/lttv/state.c index 808bced7..d5957393 100644 --- a/ltt/branches/poly/lttv/state.c +++ b/ltt/branches/poly/lttv/state.c @@ -1,33 +1,52 @@ #include +LttvInterruptType + LTTV_STATE_USER_MODE, + LTTV_STATE_SYSCALL, + LTTV_STATE_TRAP, + LTTV_STATE_IRQ; + + +LttvProcessStatus + LTTV_STATE_UNNAMED, + LTTV_STATE_WAIT_FORK, + LTTV_STATE_WAIT_CPU, + LTTV_STATE_EXIT, + LTTV_STATE_WAIT, + LTTV_STATE_RUN; + static void init(LttvTracesetState *self, LttvTraceset *ts) { guint i, j, nb_trace, nb_tracefile; - LttvTraceState *tc; + LttvTraceContext *tc; - LttvTracefileState *tfc; + LttvTraceState *tcs; + + LttvTracefileContext *tfc; - LTTV_TRACESET_CONTEXT_CLASS(g_type_class_peek_parent(LTTV_TRACESET_STATE_TYPE))->init(self, ts); + LttvTracefileState *tfcs; + + LTTV_TRACESET_CONTEXT_CLASS(g_type_class_peek_parent(LTTV_TRACESET_STATE_GET_CLASS(self)))->init((LttvTracesetContext *)self, ts); nb_trace = lttv_traceset_number(ts); for(i = 0 ; i < nb_trace ; i++) { - tc = (LttvTraceState *)self->traces[i]; - tc->processes = g_hash_table_new(g_direct_hash, g_direct_equal); + tcs = (LttvTraceState *)tc = (LTTV_TRACESET_CONTEXT(self)->traces[i]); + tcs->processes = g_hash_table_new(g_direct_hash, g_direct_equal); nb_tracefile = ltt_trace_control_tracefile_number(tc->t); for(j = 0 ; j < nb_tracefile ; j++) { - tfc = tc->control_tracefiles[j]; - tfc->process = NULL; + tfcs = (LttvTracefileState *)tfc = tc->control_tracefiles[j]; + tfcs->process = NULL; } nb_tracefile = ltt_trace_per_cpu_tracefile_number(tc->t); for(j = 0 ; j < nb_tracefile ; j++) { - tfc = tc->per_cpu_tracefiles[j]; - tfc->process = NULL; + tfcs = (LttvTracefileState *)tfc = tc->per_cpu_tracefiles[j]; + tfcs->process = NULL; } } } @@ -38,38 +57,65 @@ fini(LttvTracesetState *self) { guint i, j, nb_trace, nb_tracefile; - LttvTraceState *tc; + LttvTraceState *tcs; - LttvTracefileState *tfc; + LttvTracefileState *tfcs; - nb_trace = lttv_traceset_number(ts); + nb_trace = lttv_traceset_number(LTTV_TRACESET_CONTEXT(self)->ts); for(i = 0 ; i < nb_trace ; i++) { - tc = (LttvTraceState *)self->traces[i]; - remove_all_processes(tc->processes); - g_hash_table_destroy(tc->processes); + tcs = (LttvTraceState *)(LTTV_TRACESET_CONTEXT(self)->traces[i]); + remove_all_processes(tcs->processes); + g_hash_table_destroy(tcs->processes); } - LTTV_TRACESET_CONTEXT_CLASS(g_type_class_peek_parent(LTTV_TRACESET_STATE_TYPE))->fini(self); + LTTV_TRACESET_CONTEXT_CLASS(g_type_class_peek_parent(LTTV_TRACESET_STATE_GET_CLASS(self)))->fini((LttvTracesetContext *)self); } LttvTracesetContext * new_traceset_context(LttvTracesetContext *self) { - return LTTV_TRACESET_CONTEXT(g_object_new(LTTV_TRACESET_STATE_TYPE)); + return LTTV_TRACESET_CONTEXT(g_object_new(LTTV_TRACESET_STATE_TYPE, NULL)); } LttvTraceContext * new_trace_context(LttvTracesetContext *self) { - return LTTV_TRACE_CONTEXT(g_object_new(LTTV_TRACE_STATE_TYPE)); + return LTTV_TRACE_CONTEXT(g_object_new(LTTV_TRACE_STATE_TYPE, NULL)); } LttvTracefileContext * new_tracefile_context(LttvTracesetContext *self) { - return LTTV_TRACEFILE_CONTEXT(g_object_new(LTTV_TRACEFILE_STATE_TYPE)); + return LTTV_TRACEFILE_CONTEXT(g_object_new(LTTV_TRACEFILE_STATE_TYPE, NULL)); +} + + +static void +traceset_state_instance_init (GTypeInstance *instance, gpointer g_class) +{ +} + + +static void +traceset_state_finalize (LttvTracesetContext *self) +{ + G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACESET_STATE_GET_CLASS(self)))->finalize(G_OBJECT(self)); +} + + +static void +traceset_state_class_init (LttvTracesetContextClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + + gobject_class->finalize = (void (*)(GObject *self)) traceset_state_finalize; + klass->init = (void (*)(LttvTracesetContext *self, LttvTraceset *ts))init; + klass->fini = (void (*)(LttvTracesetContext *self))fini; + klass->new_traceset_context = new_traceset_context; + klass->new_trace_context = new_trace_context; + klass->new_tracefile_context = new_tracefile_context; } @@ -82,12 +128,12 @@ lttv_traceset_state_get_type(void) sizeof (LttvTracesetStateClass), NULL, /* base_init */ NULL, /* base_finalize */ - traceset_state_class_init, /* class_init */ + (GClassInitFunc) traceset_state_class_init, /* class_init */ NULL, /* class_finalize */ NULL, /* class_data */ sizeof (LttvTracesetContext), 0, /* n_preallocs */ - traceset_state_instance_init /* instance_init */ + (GInstanceInitFunc) traceset_state_instance_init /* instance_init */ }; type = g_type_register_static (LTTV_TRACESET_CONTEXT_TYPE, "LttvTracesetStateType", @@ -98,29 +144,24 @@ lttv_traceset_state_get_type(void) static void -traceset_state_instance_init (GTypeInstance *instance, gpointer g_class) +trace_state_instance_init (GTypeInstance *instance, gpointer g_class) { } static void -traceset_context_finalize (LttvTracesetContext *self) +trace_state_finalize (LttvTraceContext *self) { - G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACESET_STATE_TYPE))->finalize(self); + G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACE_STATE_GET_CLASS(self)))->finalize(G_OBJECT(self)); } static void -traceset_state_class_init (LttvTracesetContextClass *klass) +trace_state_class_init (LttvTraceContextClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->finalize = traceset_state_finalize; - klass->init = init; - klass->fini = fini; - klass->new_traceset_context = new_traceset_context; - klass->new_trace_context = new_trace_context; - klass->new_tracefile_context = new_tracefile_context; + gobject_class->finalize = (void (*)(GObject *self)) trace_state_finalize; } @@ -133,12 +174,12 @@ lttv_trace_state_get_type(void) sizeof (LttvTraceStateClass), NULL, /* base_init */ NULL, /* base_finalize */ - trace_state_class_init, /* class_init */ + (GClassInitFunc) trace_state_class_init, /* class_init */ NULL, /* class_finalize */ NULL, /* class_data */ sizeof (LttvTracesetState), 0, /* n_preallocs */ - trace_state_instance_init /* instance_init */ + (GInstanceInitFunc) trace_state_instance_init /* instance_init */ }; type = g_type_register_static (LTTV_TRACE_CONTEXT_TYPE, @@ -149,24 +190,24 @@ lttv_trace_state_get_type(void) static void -trace_state_instance_init (GTypeInstance *instance, gpointer g_class) +tracefile_state_instance_init (GTypeInstance *instance, gpointer g_class) { } static void -trace_state_finalize (LttvTraceContext *self) +tracefile_state_finalize (LttvTracefileState *self) { - G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACE_STATE_TYPE))->finalize(self); + G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACEFILE_STATE_GET_CLASS(self)))->finalize(G_OBJECT(self)); } static void -trace_state_class_init (LttvTraceContextClass *klass) +tracefile_state_class_init (LttvTracefileStateClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - gobject_class->finalize = trace_state_finalize; + gobject_class->finalize = (void (*)(GObject *self)) tracefile_state_finalize; } @@ -179,12 +220,12 @@ lttv_tracefile_state_get_type(void) sizeof (LttvTracefileStateClass), NULL, /* base_init */ NULL, /* base_finalize */ - tracefile_state_class_init, /* class_init */ + (GClassInitFunc) tracefile_state_class_init, /* class_init */ NULL, /* class_finalize */ NULL, /* class_data */ sizeof (LttvTracefileState), 0, /* n_preallocs */ - tracefile_state_instance_init /* instance_init */ + (GInstanceInitFunc) tracefile_state_instance_init /* instance_init */ }; type = g_type_register_static (LTTV_TRACEFILE_CONTEXT_TYPE, @@ -194,33 +235,11 @@ lttv_tracefile_state_get_type(void) } -static void -tracefile_state_instance_init (GTypeInstance *instance, gpointer g_class) -{ -} - - -static void -tracefile_state_finalize (LttvTracefileState *self) -{ - G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACEFILE_STATE_TYPE))->finalize(self); -} - - -static void -tracefile_state_class_init (LttvTracefileStateClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); - - gobject_class->finalize = tracefile_state_finalize; -} - - struct HookData { LttField *f1; LttField *f2; LttField *f3; -} +}; struct HookId { @@ -228,12 +247,13 @@ struct HookId { guint id; void *hook_data; gboolean free_hook_data; -} +}; -void push_state(LttvTracefileState *tfs, LttvInterruptType t, guint state_id) +static void push_state(LttvTracefileState *tfs, LttvInterruptType t, + guint state_id) { - LttvInterruptState intr; + LttvInterruptState *intr; LttvProcessState *process = tfs->process; @@ -243,13 +263,12 @@ void push_state(LttvTracefileState *tfs, LttvInterruptType t, guint state_id) intr = &g_array_index(process->interrupt_stack, LttvInterruptState, depth); intr->t = t; intr->n = state_id; - intr->entry = tfs->time; - intr->last_change = tfs->time; + intr->entry = intr->last_change = LTTV_TRACEFILE_CONTEXT(tfs)->timestamp; intr->s = process->state->s; } -void pop_state(LttvTracefileState *tfs, LttvInterruptType t) +static void pop_state(LttvTracefileState *tfs, LttvInterruptType t) { LttvProcessState *process = tfs->process; @@ -263,25 +282,32 @@ void pop_state(LttvTracefileState *tfs, LttvInterruptType t) } -LttvProcessState *create_process(LttvTraceState *tfs, LttvProcessState *parent, - guint pid) +LttvProcessState *create_process(LttvTracefileState *tfs, + LttvProcessState *parent, guint pid) { LttvProcessState *process = g_new(LttvProcessState, 1); LttvInterruptState *intr; - g_hash_table_insert(tfs->ts->processes, pid, process); + LttvTraceContext *tc; + + LttvTraceContext *tcs; + + tcs = (LttvTraceState *)tc = LTTV_TRACEFILE_CONTEXT(tfs)->ts; + + g_hash_table_insert(tcs->processes, GUINT_TO_POINTER(pid), process); process->pid = pid; - process->birth = tfs->time; + process->birth = tfs->timestamp; process->name = LTTV_STATE_UNNAMED; process->interrupt_stack = g_array_new(FALSE, FALSE, sizeof(LttvInterruptState)); g_array_set_size(process->interrupt_stack, 1); - intr = process->state = process->interrupt_stack->data; + intr = process->state = &g_array_index(process->interrupt_stack, + LttvInterruptState, 0); intr->t = LTTV_STATE_USER_MODE intr->n = 0; - intr->entry = tfs->time; - intr->last_change = tfs->time; + intr->entry = tfs->timestamp; + intr->last_change = tfs->timestamp; intr->s = LTTV_STATE_WAIT_FORK; } @@ -321,7 +347,7 @@ gboolean syscall_entry(void *hook_data, void *call_data) struct LttvTracefileState *s = (LttvTraceFileState *)call_data; - push_state(s, STATE_SYSCALL, ltt_event_get_unsigned(s->e, f)); + push_state(s, LTTV_STATE_SYSCALL, ltt_event_get_unsigned(s->e, f)); return FALSE; } @@ -330,7 +356,7 @@ gboolean syscall_exit(void *hook_data, void *call_data) { struct LttvTracefileState *s = (LttvTraceFileState *)call_data; - pop_state(s, STATE_SYSCALL); + pop_state(s, LTTV_STATE_SYSCALL); return FALSE; } @@ -341,7 +367,7 @@ gboolean trap_entry(void *hook_data, void *call_data) struct LttvTracefileState *s = (LttvTraceFileState *)call_data; - push_state(s, STATE_TRAP, ltt_event_get_unsigned(s->e, f)); + push_state(s, LTTV_STATE_TRAP, ltt_event_get_unsigned(s->e, f)); return FALSE; } @@ -350,7 +376,7 @@ gboolean trap_exit(void *hook_data, void *call_data) { struct LttvTracefileState *s = (LttvTraceFileState *)call_data; - pop_state(s, STATE_TRAP); + pop_state(s, LTTV_STATE_TRAP); return FALSE; } @@ -362,7 +388,7 @@ gboolean irq_entry(void *hook_data, void *call_data) struct LttvTracefileState *s = (LttvTraceFileState *)call_data; /* Do something with the info about being in user or system mode when int? */ - push_state(s, STATE_IRQ, ltt_event_get_unsigned(s->e, f)); + push_state(s, LTTV_STATE_IRQ, ltt_event_get_unsigned(s->e, f)); return FALSE; } @@ -371,7 +397,7 @@ gboolean irq_exit(void *hook_data, void *call_data) { struct LttvTracefileState *s = (LttvTraceFileState *)call_data; - pop_state(s, STATE_IRQ); + pop_state(s, LTTV_STATE_IRQ); return FALSE; } @@ -388,13 +414,13 @@ gboolean schedchange(void *hook_data, void *call_data) pid_out = ltt_event_get_int(s->e, h->f2); state_out = ltt_event_get_int(s->e, h->f3); if(s->process != NULL) { - if(state_out == 0) s->process->state->s = STATE_WAIT_CPU; - else if(s->process->state->s == STATE_EXIT) + if(state_out == 0) s->process->state->s = LTTV_STATE_WAIT_CPU; + else if(s->process->state->s == LTTV_STATE_EXIT) exit_process(s->tc, s->process); - else s->process->state->s = STATE_WAIT; + else s->process->state->s = LTTV_STATE_WAIT; } s->process = find_process(s->tc, pid_in); - s->process->state->s = STATE_RUN; + s->process->state->s = LTTV_STATE_RUN; return FALSE; } @@ -418,7 +444,7 @@ gboolean process_exit(void *hook_data, void *call_data) struct LttvTracefileState *s = (LttvTraceFileState *)call_data; if(s->process != NULL) { - s->process->state->s = STATE_EXIT; + s->process->state->s = LTTV_STATE_EXIT; } return FALSE; } @@ -556,8 +582,9 @@ lttv_state_add_event_hooks(LttvTracesetState *self) hook_id = g_array_index(hooks, struct HookId, k); lttv_hooks_add(lttv_hooks_by_id_find(tfc->before_event_by_id, hook_id->id), hook_id->h, hook_id->hook_data); + } } - lttv_attribute_find(self->a, STATE_HOOKS, LTTV_POINTER, val); + lttv_attribute_find(self->a, LTTV_STATE_HOOKS, LTTV_POINTER, val); val->v_pointer = hooks; } } @@ -584,7 +611,7 @@ lttv_state_remove_event_hooks(LttvTracesetState *self) nb_trace = lttv_traceset_number(ts); for(i = 0 ; i < nb_trace ; i++) { tc = (LttvTraceState *)self->traces[i]; - lttv_attribute_find(self->a, STATE_HOOKS, LTTV_POINTER, val); + lttv_attribute_find(self->a, LTTV_STATE_HOOKS, LTTV_POINTER, val); hooks = val->v_pointer; /* Add these hooks to each before_event_by_id hooks list */ @@ -604,20 +631,36 @@ lttv_state_remove_event_hooks(LttvTracesetState *self) hook_id = g_array_index(hooks, struct HookId, k); lttv_hooks_remove_data(lttv_hooks_by_id_find(tfc->before_event_by_id, hook_id->id), hook_id->h, hook_id->hook_data); - } - for(k = 0 ; k < hooks->len ; k++) { - hook_id = g_array_index(hooks, struct HookId, k); - if(hook_id->free_hook_data) g_free(hook_id->hook_data); + + } + for(k = 0 ; k < hooks->len ; k++) { + hook_id = g_array_index(hooks, struct HookId, k); + if(hook_id->free_hook_data) g_free(hook_id->hook_data); + } } g_array_free(hooks, TRUE); } } +void lttv_state_init(int argc, char **argv) +{ + LTTV_STATE_UNNAMED = g_quark_from_string("unnamed"); + LTTV_STATE_USER_MODE = g_quark_from_string("user mode"); + LTTV_STATE_WAIT_FORK = g_quark_from_string("wait fork"); + LTTV_STATE_SYSCALL = g_quark_from_string("system call"); + LTTV_STATE_TRAP = g_quark_from_string("trap"); + LTTV_STATE_IRQ = g_quark_from_string("irq"); + LTTV_STATE_WAIT_CPU = g_quark_from_string("wait for cpu"); + LTTV_STATE_EXIT = g_quark_from_string("exiting"); + LTTV_STATE_WAIT = g_quark_from_string("wait for I/O"); + LTTV_STATE_RUN = g_quark_from_string("running"); + LTTV_STATE_HOOKS = g_quark_from_string("saved state hooks"); +} - - - +void lttv_state_destroy() +{ +} diff --git a/ltt/branches/poly/lttv/textDump.c b/ltt/branches/poly/lttv/textDump.c index 3fb0b6f7..e4c8d5c7 100644 --- a/ltt/branches/poly/lttv/textDump.c +++ b/ltt/branches/poly/lttv/textDump.c @@ -9,6 +9,11 @@ #include #include #include +#include +#include +#include +#include +#include static gboolean a_field_names, @@ -24,68 +29,96 @@ static LttvHooks *before_event; -void init(int argc, char **argv) -{ - LttvAttributeValue *value; +void print_field(LttEvent *e, LttField *f, GString *s, gboolean field_names) { - LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); + LttType *type; - a_file_name = NULL; - lttv_option_add("output", 'o', - "output file where the text is written", - "file name", - LTTV_OPT_STRING, &a_file_name, NULL, NULL); + LttField *element; - a_field_names = FALSE; - lttv_option_add("field_names", 'l', - "write the field names for each event", - "", - LTTV_OPT_NONE, &a_field_names, NULL, NULL); + char *name; - a_state = FALSE; - lttv_option_add("process_state", 's', - "write the pid and state for each event", - "", - LTTV_OPT_NONE, &a_state, NULL, NULL); + int nb, i; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/before", - LTTV_POINTER, &value)); - g_assert((before_event = *(value->v_pointer)) != NULL); - lttv_hooks_add(before_event, write_event_content, NULL); + type = ltt_field_type(f); + switch(ltt_type_class(type)) { + case LTT_INT: + g_string_append_printf(s, " %ld", ltt_event_get_long_int(e,f)); + break; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/before", - LTTV_POINTER, &value)); - g_assert((before_trace = *(value->v_pointer)) != NULL); - lttv_hooks_add(before_trace, write_trace_header, NULL); + case LTT_UINT: + g_string_append_printf(s, " %lu", ltt_event_get_long_unsigned(e,f)); + break; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/before", - LTTV_POINTER, &value)); - g_assert((before_traceset = *(value->v_pointer)) != NULL); - lttv_hooks_add(before_traceset, write_traceset_header, NULL); + case LTT_FLOAT: + g_string_append_printf(s, " %g", ltt_event_get_double(e,f)); + break; - g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/after", - LTTV_POINTER, &value)); - g_assert((after_traceset = *(value->v_pointer)) != NULL); - lttv_hooks_add(after_traceset, write_traceset_footer, NULL); + case LTT_STRING: + g_string_append_printf(s, " \"%s\"", ltt_event_get_string(e,f)); + break; + + case LTT_ENUM: + g_string_append_printf(s, " %s", ltt_enum_string_get(type, + event_get_unsigned(e,f))); + break; + + case LTT_ARRAY: + case LTT_SEQUENCE: + g_string_append_printf(s, " {"); + nb = ltt_event_field_element_number(e,f); + element = ltt_field_element(f); + for(i = 0 ; i < nb ; i++) { + ltt_event_field_element_select(e,f,i); + print_field(e, element, s, field_names); + } + g_string_append_printf(s, " }"); + break; + + case LTT_STRUCT: + g_string_append_printf(s, " {"); + nb = ltt_type_member_number(type); + for(i = 0 ; i < nb ; i++) { + element = ltt_field_member(f,i); + if(name) { + ltt_type_member_type(type, i, &name); + g_string_append_printf(s, " %s = ", field_names); + } + print_field(e, element, s, field_names); + } + g_string_append_printf(s, " }"); + break; + } } -void destroy() +void lttv_event_to_string(LttEvent *e, LttTracefile *tf, GString *s, + gboolean mandatory_fields, gboolean field_names) { - lttv_option_remove("output"); + LttFacility *facility; - lttv_option_remove("field_names"); + LttEventType *event_type; - lttv_option_remove("process_state"); + LttType *type; + + LttField *field; - lttv_hooks_remove(before_event, write_event, NULL); + LttTime time; - lttv_hooks_remove(before_trace, write_trace_header, NULL); + g_string_set_size(s,0); - lttv_hooks_remove(before_trace, write_traceset_header, NULL); + facility = ltt_event_facility(e); + event_type = ltt_event_eventtype(e); + field = ltt_event_field(e); - lttv_hooks_remove(before_trace, write_traceset_footer, NULL); -} + if(mandatory_fields) { + time = ltt_event_time(e); + g_string_append_printf(s,"%s.%s: %ld.%ld (%s)",ltt_facility_name(facility), + ltt_eventtype_name(event_type), (long)time.tv_sec, time.tv_nsec, + ltt_tracefile_name(tf)); + } + + print_field(e, field, s, field_names); +} /* Insert the hooks before and after each trace and tracefile, and for each @@ -95,7 +128,7 @@ static FILE *a_file; static GString *a_string; -static static gboolean write_traceset_header(void *hook_data, void *call_data) +static gboolean write_traceset_header(void *hook_data, void *call_data) { LttvTracesetContext *tc = (LttvTracesetContext *)call_data; @@ -106,20 +139,20 @@ static static gboolean write_traceset_header(void *hook_data, void *call_data) /* Print the trace set header */ fprintf(a_file,"Trace set contains %d traces\n\n", - lttv_traceset_number(tc->ta); + lttv_traceset_number(tc->ts)); return FALSE; } -static static gboolean write_traceset_footer(void *hook_data, void *call_data) +static gboolean write_traceset_footer(void *hook_data, void *call_data) { LttvTracesetContext *tc = (LttvTracesetContext *)call_data; - if(a_file_name != NULL) a_file = fclose(a_file); - fprintf(a_file,"End trace set\n\n"); + if(a_file_name != NULL) fclose(a_file); + return FALSE; } @@ -150,103 +183,75 @@ static int write_event_content(void *hook_data, void *call_data) if(a_state) { g_string_append_printf(a_string, " %s", - g_quark_to_string(tfs->process->state->s); + g_quark_to_string(tfs->process->state->s)); } - fputs(s, c->fd); + fputs(a_string->str, a_file); return FALSE; } -void lttv_event_to_string(LttEvent *e, LttTracefile *tf, g_string *s, - gboolean mandatory_fields, gboolean field_names) +void init(int argc, char **argv) { - LttFacility *facility; + LttvAttributeValue value; - LttEventType *event_type; - - LttType *type; - - LttField *field; - - LttTime time; - - g_string_set_size(s,0); - - facility = lttv_event_facility(e); - eventtype = ltt_event_eventtype(e); - field = ltt_event_field(e); + LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); - if(mandatory_fields) { - time = ltt_event_time(e); - g_string_append_printf(s,"%s.%s: %ld.%ld (%s)",ltt_facility_name(facility), - ltt_eventtype_name(eventtype), (long)time.tv_sec, time.tv_nsec, - ltt_tracefile_name(tf)); - } + a_file_name = NULL; + lttv_option_add("output", 'o', + "output file where the text is written", + "file name", + LTTV_OPT_STRING, &a_file_name, NULL, NULL); - print_field(e,f,s, field_names); -} + a_field_names = FALSE; + lttv_option_add("field_names", 'l', + "write the field names for each event", + "", + LTTV_OPT_NONE, &a_field_names, NULL, NULL); + a_state = FALSE; + lttv_option_add("process_state", 's', + "write the pid and state for each event", + "", + LTTV_OPT_NONE, &a_state, NULL, NULL); -void print_field(LttEvent *e, LttField *f, g_string *s, gboolean field_names) { + g_assert(lttv_iattribute_find_by_path(attributes, "hooks/event/before", + LTTV_POINTER, &value)); + g_assert((before_event = *(value.v_pointer)) != NULL); + lttv_hooks_add(before_event, write_event_content, NULL); - LttType *type; + g_assert(lttv_iattribute_find_by_path(attributes, "hooks/trace/before", + LTTV_POINTER, &value)); + g_assert((before_trace = *(value.v_pointer)) != NULL); + lttv_hooks_add(before_trace, write_trace_header, NULL); - LttField *element; + g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/before", + LTTV_POINTER, &value)); + g_assert((before_traceset = *(value.v_pointer)) != NULL); + lttv_hooks_add(before_traceset, write_traceset_header, NULL); - char *name; + g_assert(lttv_iattribute_find_by_path(attributes, "hooks/traceset/after", + LTTV_POINTER, &value)); + g_assert((after_traceset = *(value.v_pointer)) != NULL); + lttv_hooks_add(after_traceset, write_traceset_footer, NULL); +} - int nb, i; - type = ltt_field_type(f); - switch(ltt_type_class(type)) { - case LTT_INT: - g_string_append_printf(s, " %ld", ltt_event_get_long_int(e,f)); - break; +void destroy() +{ + lttv_option_remove("output"); - case LTT_UINT: - g_string_append_printf(s, " %lu", ltt_event_get_long_unsigned(e,f)); - break; + lttv_option_remove("field_names"); - case LTT_FLOAT: - g_string_append_printf(s, " %g", ltt_event_get_double(e,f)); - break; + lttv_option_remove("process_state"); - case LTT_STRING: - g_string_append_printf(s, " \"%s\"", ltt_event_get_string(e,f)); - break; + lttv_hooks_remove_data(before_event, write_event_content, NULL); - case LTT_ENUM: - g_string_append_printf(s, " %s", ltt_enum_string_get(type, - event_get_unsigned(e,f)); - break; + lttv_hooks_remove_data(before_trace, write_trace_header, NULL); - case LTT_ARRAY: - case LTT_SEQUENCE: - g_string_append_printf(s, " {"); - nb = ltt_event_field_element_number(e,f); - element = ltt_field_element(f); - for(i = 0 ; i < nb ; i++) { - ltt_event_field_element_select(e,f,i); - print_field(e,element,s); - } - g_string_append_printf(s, " }"); - break; + lttv_hooks_remove_data(before_trace, write_traceset_header, NULL); - case LTT_STRUCT: - g_string_append_printf(s, " {"); - nb = ltt_type_member_number(type); - for(i = 0 ; i < nb ; i++) { - element = ltt_field_member(f,i); - if(name) { - ltt_type_member_type(type, &name); - g_string_append_printf(s, " %s = ", field_names); - } - print_field(e,element,s); - } - g_string_append_printf(s, " }"); - break; - } + lttv_hooks_remove_data(before_trace, write_traceset_footer, NULL); } -- 2.34.1