LttvAttributeName name;
LttvAttributeType type;
AttributeValue value;
+ gboolean is_named;
} Attribute;
return self->attributes->len;
}
-
gboolean
lttv_attribute_named(LttvAttribute *self, gboolean *homogeneous)
{
return TRUE;
}
-
LttvAttributeType
lttv_attribute_get(LttvAttribute *self, unsigned i, LttvAttributeName *name,
- LttvAttributeValue *v)
+ LttvAttributeValue *v, gboolean *is_named)
{
Attribute *a;
a = &g_array_index(self->attributes, Attribute, i);
*name = a->name;
*v = address_of_value(a->type, &(a->value));
+ *is_named = a->is_named;
return a->type;
}
if(i != 0) g_error("duplicate entry in attribute table");
a.name = name;
+ a.is_named = 1;
+ 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, GUINT_TO_POINTER(name),
+ GUINT_TO_POINTER(i + 1));
+ return address_of_value(t, &(pa->value));
+}
+
+LttvAttributeValue
+lttv_attribute_add_unnamed(LttvAttribute *self, LttvAttributeName name,
+ LttvAttributeType t)
+{
+ unsigned i;
+
+ Attribute a, *pa;
+
+ 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.is_named = 0;
a.type = t;
a.value = init_value(t);
g_array_append_val(self->attributes, a);
return (LttvAttribute *)new;
}
+/*CHECK*/LttvAttribute*
+lttv_attribute_find_subdir_unnamed(LttvAttribute *self, LttvAttributeName name)
+{
+ unsigned i;
+
+ Attribute a;
+
+ LttvAttribute *new;
+
+ i = (unsigned)g_hash_table_lookup(self->names, GUINT_TO_POINTER(name));
+ if(likely(i != 0)) {
+ a = g_array_index(self->attributes, Attribute, i - 1);
+ if(likely(a.type == LTTV_GOBJECT && LTTV_IS_IATTRIBUTE(a.value.dv_gobject))) {
+ return LTTV_ATTRIBUTE(a.value.dv_gobject);
+ }
+ else return NULL;
+ }
+ new = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
+ *(lttv_attribute_add_unnamed(self, name, LTTV_GOBJECT).v_gobject)
+ = G_OBJECT(new);
+ return (LttvAttribute *)new;
+}
+
gboolean
lttv_attribute_find(LttvAttribute *self, LttvAttributeName name,
LttvAttributeType t, LttvAttributeValue *v)
return TRUE;
}
+gboolean
+lttv_attribute_find_unnamed(LttvAttribute *self, LttvAttributeName name,
+ LttvAttributeType t, LttvAttributeValue *v)
+{
+ unsigned i;
+
+ Attribute *a;
+
+ i = (unsigned)g_hash_table_lookup(self->names, GUINT_TO_POINTER(name));
+ if(likely(i != 0)) {
+ a = &g_array_index(self->attributes, Attribute, i - 1);
+ if(unlikely(a->type != t)) return FALSE;
+ *v = address_of_value(t, &(a->value));
+ return TRUE;
+ }
+
+ *v = lttv_attribute_add_unnamed(self, name, t);
+ return TRUE;
+}
+
/*void lttv_attribute_recursive_free(LttvAttribute *self)
{
for(i = 0 ; i < nb ; i++) {
a = &g_array_index(src->attributes, Attribute, i);
if(a->type == LTTV_GOBJECT && LTTV_IS_ATTRIBUTE(a->value.dv_gobject)) {
- lttv_attribute_recursive_add(
- /*CHECK*/(LttvAttribute *)lttv_attribute_find_subdir(dest, a->name),
- (LttvAttribute *)(a->value.dv_gobject));
+ if(a->is_named)
+ lttv_attribute_recursive_add(
+ /*CHECK*/(LttvAttribute *)lttv_attribute_find_subdir(dest, a->name),
+ (LttvAttribute *)(a->value.dv_gobject));
+ else
+ lttv_attribute_recursive_add(
+ /*CHECK*/(LttvAttribute *)lttv_attribute_find_subdir_unnamed(
+ dest, a->name), (LttvAttribute *)(a->value.dv_gobject));
}
else {
- g_assert(lttv_attribute_find(dest, a->name, a->type, &value));
+ if(a->is_named)
+ g_assert(lttv_attribute_find(dest, a->name, a->type, &value));
+ else
+ g_assert(lttv_attribute_find_unnamed(dest, a->name, a->type, &value));
switch(a->type) {
case LTTV_INT:
*value.v_int += a->value.dv_int;
lttv_attribute_named;
klass->get = (LttvAttributeType (*) (LttvIAttribute *self, unsigned i,
- LttvAttributeName *name, LttvAttributeValue *v)) lttv_attribute_get;
+ LttvAttributeName *name, LttvAttributeValue *v, gboolean *is_named))
+ lttv_attribute_get;
klass->get_by_name = (LttvAttributeType (*) (LttvIAttribute *self,
LttvAttributeName name, LttvAttributeValue *v))
klass->add = (LttvAttributeValue (*) (LttvIAttribute *self,
LttvAttributeName name, LttvAttributeType t)) lttv_attribute_add;
+ klass->add_unnamed = (LttvAttributeValue (*) (LttvIAttribute *self,
+ LttvAttributeName name, LttvAttributeType t)) lttv_attribute_add_unnamed;
+
klass->remove = (void (*) (LttvIAttribute *self, unsigned i))
lttv_attribute_remove;
klass->find_subdir = (LttvIAttribute* (*) (LttvIAttribute *self,
LttvAttributeName name)) lttv_attribute_find_subdir;
+ klass->find_subdir = (LttvIAttribute* (*) (LttvIAttribute *self,
+ LttvAttributeName name)) lttv_attribute_find_subdir_unnamed;
}
static void
/* Get the i th attribute along with its type and a pointer to its value. */
LttvAttributeType lttv_attribute_get(LttvAttribute *self, unsigned i,
- LttvAttributeName *name, LttvAttributeValue *v);
+ LttvAttributeName *name, LttvAttributeValue *v, gboolean *is_named);
/* Get the named attribute in the table along with its type and a pointer to
LttvAttributeValue lttv_attribute_add(LttvAttribute *self,
LttvAttributeName name, LttvAttributeType t);
+LttvAttributeValue lttv_attribute_add_unnamed(LttvAttribute *self,
+ LttvAttributeName name, LttvAttributeType t);
/* Remove an attribute */
LttvAttribute* lttv_attribute_find_subdir(LttvAttribute *self,
LttvAttributeName name);
+LttvAttribute* lttv_attribute_find_subdir_unnamed(LttvAttribute *self,
+ LttvAttributeName name);
+
+
gboolean lttv_attribute_find(LttvAttribute *self, LttvAttributeName name,
LttvAttributeType t, LttvAttributeValue *v);
LttvAttributeType lttv_iattribute_get(LttvIAttribute *self, unsigned i,
- LttvAttributeName *name, LttvAttributeValue *v)
+ LttvAttributeName *name, LttvAttributeValue *v, gboolean *is_named)
{
- return LTTV_IATTRIBUTE_GET_CLASS (self)->get (self, i, name, v);
+ return LTTV_IATTRIBUTE_GET_CLASS (self)->get (self, i, name, v, is_named);
}
return LTTV_IATTRIBUTE_GET_CLASS (self)->add (self, name, t);
}
+LttvAttributeValue lttv_iattribute_add_unnamed(LttvIAttribute *self,
+ LttvAttributeName name, LttvAttributeType t)
+{
+ return LTTV_IATTRIBUTE_GET_CLASS (self)->add_unnamed (self, name, t);
+}
void lttv_iattribute_remove(LttvIAttribute *self, unsigned i)
{
return LTTV_IATTRIBUTE_GET_CLASS (self)->find_subdir (self, name);
}
+LttvIAttribute* lttv_iattribute_find_subdir_unnamed(LttvIAttribute *self,
+ LttvAttributeName name)
+{
+ return LTTV_IATTRIBUTE_GET_CLASS (self)->find_subdir_unnamed (self, name);
+}
+
+
/* Find the named attribute in the table, which must be of the specified type.
If it does not exist, it is created with a default value of 0 (NULL for
LttvAttributeName name;
+ gboolean is_named;
+
int i;
int nb_attributes = lttv_iattribute_get_number(self);
copy = LTTV_IATTRIBUTE_GET_CLASS(self)->new_attribute(NULL);
for(i = 0 ; i < nb_attributes ; i++) {
- t = lttv_iattribute_get(self, i, &name, &v);
- v_copy = lttv_iattribute_add(copy, name, t);
+ t = lttv_iattribute_get(self, i, &name, &v, &is_named);
+ if(is_named)
+ v_copy = lttv_iattribute_add(copy, name, t);
+ else
+ v_copy = lttv_iattribute_add_unnamed(copy, name, t);
lttv_iattribute_copy_value(t, v_copy, v);
}
return copy;
LttvAttributeName name;
+ gboolean is_named;
+
int i;
int nb_attributes = lttv_iattribute_get_number(self);
copy = LTTV_IATTRIBUTE_GET_CLASS(self)->new_attribute(NULL);
for(i = 0 ; i < nb_attributes ; i++) {
- t = lttv_iattribute_get(self, i, &name, &v);
- v_copy = lttv_iattribute_add(copy, name, t);
+ t = lttv_iattribute_get(self, i, &name, &v, &is_named);
+ if(is_named)
+ v_copy = lttv_iattribute_add(copy, name, t);
+ else
+ v_copy = lttv_iattribute_add_unnamed(copy, name, t);
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));
gboolean (*named) (LttvIAttribute *self, gboolean *homogeneous);
LttvAttributeType (*get) (LttvIAttribute *self, unsigned i,
- LttvAttributeName *name, LttvAttributeValue *v);
+ LttvAttributeName *name, LttvAttributeValue *v, gboolean *is_named);
LttvAttributeType (*get_by_name) (LttvIAttribute *self,
LttvAttributeName name, LttvAttributeValue *v);
LttvAttributeValue (*add) (LttvIAttribute *self, LttvAttributeName name,
LttvAttributeType t);
+ LttvAttributeValue (*add_unnamed) (LttvIAttribute *self,
+ LttvAttributeName name,
+ LttvAttributeType t);
+
void (*remove) (LttvIAttribute *self, unsigned i);
void (*remove_by_name) (LttvIAttribute *self,
LttvIAttribute* (*find_subdir) (LttvIAttribute *self,
LttvAttributeName name);
+
+ LttvIAttribute* (*find_subdir_unnamed) (LttvIAttribute *self,
+ LttvAttributeName name);
+
};
/* Get the i th attribute along with its type and a pointer to its value. */
LttvAttributeType lttv_iattribute_get(LttvIAttribute *self, unsigned i,
- LttvAttributeName *name, LttvAttributeValue *v);
+ LttvAttributeName *name, LttvAttributeValue *v, gboolean *is_named);
/* Get the named attribute in the table along with its type and a pointer to
LttvAttributeValue lttv_iattribute_add(LttvIAttribute *self,
LttvAttributeName name, LttvAttributeType t);
+LttvAttributeValue lttv_iattribute_add_unnamed(LttvIAttribute *self,
+ LttvAttributeName name, LttvAttributeType t);
/* Remove an attribute */
void lttv_iattribute_remove(LttvIAttribute *self, unsigned i);
LttvIAttribute* lttv_iattribute_find_subdir(LttvIAttribute *self,
LttvAttributeName name);
+LttvIAttribute* lttv_iattribute_find_subdir_unnamed(LttvIAttribute *self,
+ LttvAttributeName name);
/* The remaining utility functions are not part of the LttvIAttribute
interface but operate on objects implementing it. */
LttvAttributeName name;
+ gboolean is_named;
+
LttEventPosition *ep;
LttvTracesetContext *tsc = self->parent.ts_context;
tfcs =
LTTV_TRACEFILE_STATE(g_array_index(self->parent.tracefiles,
LttvTracefileContext*, i));
- type = lttv_attribute_get(tracefiles_tree, i, &name, &value);
+ type = lttv_attribute_get(tracefiles_tree, i, &name, &value, &is_named);
g_assert(type == LTTV_GOBJECT);
tracefile_tree = *((LttvAttribute **)(value.v_gobject));
#if 0
LttvAttributeName name;
+ gboolean is_named;
+
LttEventPosition *ep;
tracefiles_tree = lttv_attribute_find_subdir(container,
tfcs =
LTTV_TRACEFILE_STATE(g_array_index(self->parent.tracefiles,
LttvTracefileContext*, i));
- type = lttv_attribute_get(tracefiles_tree, i, &name, &value);
+ type = lttv_attribute_get(tracefiles_tree, i, &name, &value, &is_named);
g_assert(type == LTTV_GOBJECT);
tracefile_tree = *((LttvAttribute **)(value.v_gobject));
LttvAttributeName name;
+ gboolean is_named;
+
LttvAttribute *saved_states;
saved_states = lttv_attribute_find_subdir(self->parent.t_a,
nb = lttv_attribute_get_number(saved_states);
for(i = 0 ; i < nb ; i++) {
- type = lttv_attribute_get(saved_states, i, &name, &value);
+ type = lttv_attribute_get(saved_states, i, &name, &value, &is_named);
g_assert(type == LTTV_GOBJECT);
state_saved_free(self, *((LttvAttribute **)value.v_gobject));
}
LttvAttributeName name;
+ gboolean is_named;
+
LttvAttribute *saved_states_tree, *saved_state_tree, *closest_tree;
//g_tree_destroy(self->parent.pqueue);
max_pos = lttv_attribute_get_number(saved_states_tree) - 1;
mid_pos = max_pos / 2;
while(min_pos < max_pos) {
- type = lttv_attribute_get(saved_states_tree, mid_pos, &name, &value);
+ type = lttv_attribute_get(saved_states_tree, mid_pos, &name, &value,
+ &is_named);
g_assert(type == LTTV_GOBJECT);
saved_state_tree = *((LttvAttribute **)(value.v_gobject));
type = lttv_attribute_get_by_name(saved_state_tree, LTTV_STATE_TIME,
LTTV_STATS_AFTER_HOOKS;
static void
-find_event_tree(LttvTracefileStats *tfcs, GQuark pid_time, GQuark cpu,
+find_event_tree(LttvTracefileStats *tfcs, GQuark pid_time, guint cpu,
guint64 function,
GQuark mode, GQuark sub_mode, LttvAttribute **events_tree,
LttvAttribute **event_types_tree);
tfcs = LTTV_TRACEFILE_STATS(*tfs);
tfcs->stats = lttv_attribute_find_subdir(tracefiles_stats,
ltt_tracefile_long_name(tfcs->parent.parent.tf));
+ guint cpu = tfcs->parent.cpu;
find_event_tree(tfcs, LTTV_STATS_PROCESS_UNKNOWN,
- ltt_tracefile_long_name(tfcs->parent.parent.tf),
+ cpu,
0x0ULL,
LTTV_STATE_MODE_UNKNOWN,
LTTV_STATE_SUBMODE_UNKNOWN, &tfcs->current_events_tree,
static void
find_event_tree(LttvTracefileStats *tfcs,
GQuark pid_time,
- GQuark cpu,
+ guint cpu,
guint64 function,
GQuark mode,
GQuark sub_mode,
LttvAttribute **events_tree,
LttvAttribute **event_types_tree)
{
- LttvAttribute *a;
+ LttvAttribute *a, *prev_a;
gchar fstring[MAX_64_HEX_STRING_LEN];
g_assert(snprintf(fstring, MAX_64_HEX_STRING_LEN-1,
a = lttv_attribute_find_subdir(tcs->stats, LTTV_STATS_PROCESSES);
a = lttv_attribute_find_subdir(a, pid_time);
a = lttv_attribute_find_subdir(a, LTTV_STATS_CPU);
- a = lttv_attribute_find_subdir(a, cpu);
+ a = lttv_attribute_find_subdir_unnamed(a, cpu);
a = lttv_attribute_find_subdir(a, LTTV_STATS_FUNCTIONS);
a = lttv_attribute_find_subdir(a, g_quark_from_string(fstring));
a = lttv_attribute_find_subdir(a, LTTV_STATS_MODE_TYPES);
LttvExecutionState *es = process->state;
find_event_tree(tfcs, process->pid_time,
- ltt_tracefile_long_name(tfcs->parent.parent.tf),
+ cpu,
process->current_function,
es->t, es->n, &(tfcs->current_events_tree),
&(tfcs->current_event_types_tree));
process = lttv_state_find_process_or_create(ts,
ANY_CPU, pid_in, &tfcs->parent.parent.timestamp);
+ guint cpu = tfcs->parent.cpu;
+
find_event_tree(tfcs, process->pid_time,
- ltt_tracefile_long_name(tfcs->parent.parent.tf),
+ cpu,
process->current_function,
process->state->t, process->state->n, &(tfcs->current_events_tree),
&(tfcs->current_event_types_tree));
LttvAttributeName name;
+ gboolean is_named;
+
unsigned sum;
int i, j, k, l, m, nb_process, nb_cpu, nb_mode_type, nb_submode,
nb_process = lttv_attribute_get_number(processes_tree);
for(i = 0 ; i < nb_process ; i++) {
- type = lttv_attribute_get(processes_tree, i, &name, &value);
+ type = lttv_attribute_get(processes_tree, i, &name, &value, &is_named);
process_tree = LTTV_ATTRIBUTE(*(value.v_gobject));
cpus_tree = lttv_attribute_find_subdir(process_tree, LTTV_STATS_CPU);
nb_cpu = lttv_attribute_get_number(cpus_tree);
for(j = 0 ; j < nb_cpu ; j++) {
- type = lttv_attribute_get(cpus_tree, j, &name, &value);
+ type = lttv_attribute_get(cpus_tree, j, &name, &value, &is_named);
cpu_tree = LTTV_ATTRIBUTE(*(value.v_gobject));
trace_cpu_tree = lttv_attribute_find_subdir(main_tree, LTTV_STATS_CPU);
- trace_cpu_tree = lttv_attribute_find_subdir(trace_cpu_tree, name);
+ trace_cpu_tree = lttv_attribute_find_subdir_unnamed(trace_cpu_tree, name);
cpu_functions_tree = lttv_attribute_find_subdir(cpu_tree,
LTTV_STATS_FUNCTIONS);
nb_functions = lttv_attribute_get_number(cpu_functions_tree);
for(nf=0; nf < nb_functions; nf++) {
- type = lttv_attribute_get(cpu_functions_tree, nf, &name, &value);
+ type = lttv_attribute_get(cpu_functions_tree, nf, &name, &value,
+ &is_named);
function_tree = LTTV_ATTRIBUTE(*(value.v_gobject));
function_mode_types_tree = lttv_attribute_find_subdir(function_tree,
LTTV_STATS_MODE_TYPES);
nb_mode_type = lttv_attribute_get_number(function_mode_types_tree);
for(k = 0 ; k < nb_mode_type ; k++) {
- type = lttv_attribute_get(function_mode_types_tree, k, &name, &value);
+ type = lttv_attribute_get(function_mode_types_tree, k, &name, &value,
+ &is_named);
mode_tree = LTTV_ATTRIBUTE(*(value.v_gobject));
submodes_tree = lttv_attribute_find_subdir(mode_tree,
nb_submode = lttv_attribute_get_number(submodes_tree);
for(l = 0 ; l < nb_submode ; l++) {
- type = lttv_attribute_get(submodes_tree, l, &name, &value);
+ type = lttv_attribute_get(submodes_tree, l, &name, &value,
+ &is_named);
submode_tree = LTTV_ATTRIBUTE(*(value.v_gobject));
event_types_tree = lttv_attribute_find_subdir(submode_tree,
sum = 0;
for(m = 0 ; m < nb_event_type ; m++) {
- type = lttv_attribute_get(event_types_tree, m, &name, &value);
+ type = lttv_attribute_get(event_types_tree, m, &name, &value,
+ &is_named);
sum += *(value.v_uint);
}
lttv_attribute_find(submode_tree, LTTV_STATS_EVENTS_COUNT,
LTTV_UINT, &value);
*(value.v_uint) = sum;
- type = lttv_attribute_get(submodes_tree, l, &name, &value);
+ type = lttv_attribute_get(submodes_tree, l, &name, &value,
+ &is_named);
submode_tree = LTTV_ATTRIBUTE(*(value.v_gobject));
lttv_attribute_recursive_add(mode_events_tree, event_types_tree);
lttv_attribute_recursive_add(mode_types_tree, submode_tree);
LttvToolbars * toolbar;
LttvMenus * menu;
LttvAttributeValue value;
+ gboolean is_named;
g_assert(lttv_iattribute_find_by_path(attributes_global,
"viewers/toolbar", LTTV_POINTER, &value));
LttvAttributeType type;
for(i=0;i<num;i++) {
- type = lttv_iattribute_get(LTTV_IATTRIBUTE(attribute), i, &name, &value);
+ type = lttv_iattribute_get(LTTV_IATTRIBUTE(attribute), i, &name, &value,
+ &is_named);
g_assert(type == LTTV_POINTER);
if(*(value.v_pointer) == view_constructor) {
lttv_iattribute_remove(LTTV_IATTRIBUTE(attribute), i);
LttvAttributeType type;
LttvAttributeName name;
LttvAttributeValue value;
+ gboolean is_named;
g_assert(attribute =
LTTV_ATTRIBUTE(lttv_iattribute_find_subdir(LTTV_IATTRIBUTE(g_attribute),
LTTV_TRACES)));
- type = lttv_iattribute_get(LTTV_IATTRIBUTE(attribute), num, &name, &value);
+ type = lttv_iattribute_get(LTTV_IATTRIBUTE(attribute), num, &name, &value,
+ &is_named);
if(type == LTTV_POINTER) {
return (LttvTrace *)*(value.v_pointer);
LttvAttributeName name;
LttvAttributeValue value;
LttvAttributeType type;
+ gboolean is_named;
gchar * str, dir_str[PATH_LENGTH];
GtkTreePath * path;
GtkTreeIter iter;
nb = lttv_attribute_get_number(stats);
for(i = 0 ; i < nb ; i++) {
- type = lttv_attribute_get(stats, i, &name, &value);
+ type = lttv_attribute_get(stats, i, &name, &value, &is_named);
switch(type) {
case LTTV_GOBJECT:
if(LTTV_IS_ATTRIBUTE(*(value.v_gobject))) {
- sprintf(dir_str, "%s", g_quark_to_string(name));
subtree = (LttvAttribute *)*(value.v_gobject);
+ if(is_named)
+ sprintf(dir_str, "%s", g_quark_to_string(name));
+ else
+ sprintf(dir_str, "%lu", name);
gtk_tree_store_append (store, &iter, parent);
gtk_tree_store_set (store, &iter,NAME_COLUMN,dir_str,-1);
path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
LttvAttributeName name;
LttvAttributeValue value;
LttvAttributeType type;
+ gboolean is_named;
gchar type_name[PATH_LENGTH], type_value[PATH_LENGTH];
GtkTextIter text_iter;
flag = 0;
nb = lttv_attribute_get_number(stats);
for(i = 0 ; i < nb ; i++) {
- type = lttv_attribute_get(stats, i, &name, &value);
- sprintf(type_name,"%s", g_quark_to_string(name));
+ type = lttv_attribute_get(stats, i, &name, &value, &is_named);
+ if(is_named)
+ sprintf(type_name,"%s", g_quark_to_string(name));
+ else
+ sprintf(type_name,"%lu", name);
type_value[0] = '\0';
switch(type) {
case LTTV_INT:
LttvAttributeType type;
+ gboolean is_named;
+
nb = lttv_attribute_get_number(tree);
for(i = 0 ; i < nb ; i++) {
- type = lttv_attribute_get(tree, i, &name, &value);
- fprintf(fp, "%s%s: ", indent->str, g_quark_to_string(name));
+ type = lttv_attribute_get(tree, i, &name, &value, &is_named);
+ if(is_named)
+ fprintf(fp, "%s%s: ", indent->str, g_quark_to_string(name));
+ else
+ fprintf(fp, "%s%lu: ", indent->str, name);
switch(type) {
case LTTV_INT: