+Sat Nov 5 12:39:33 2005 Soeren Sandmann <sandmann@redhat.com>
+
+ * profile.c (add_trace_to_tree): Don't compute the total field.
+
+ * profile.h (struct ProfileDescendant): Remove 'total' field.
+
+ * sysprof.c: Delete DESCENDANTS_TOTAL column and everything
+ related to it.
+
+ * profile.c: Remove commented out code
+
+ * sfile.c (handle_text): Don't copy the text
+
2005-11-04 Soren Sandmann <sandmann@redhat.com>
* collector.[ch]: Add copyright statement.
return result;
}
-#if 0
-static void
-make_hash_table (Node *node, GHashTable *table)
-{
- if (!node)
- return;
-
- g_assert (node->object);
-
- node->next = g_hash_table_lookup (table, node->object);
- g_hash_table_insert (table, node->object, node);
-
- g_assert (node->siblings != (void *)0x11);
-
- make_hash_table (node->siblings, table);
- make_hash_table (node->children, table);
-}
-#endif
-
Profile *
profile_load (const char *filename, GError **err)
{
{
GList *list;
GPtrArray *nodes_to_unmark = g_ptr_array_new ();
- GPtrArray *nodes_to_unmark_recursive = g_ptr_array_new ();
ProfileDescendant *parent = NULL;
int i, len;
- GPtrArray *seen_objects = g_ptr_array_new ();
-
for (list = trace; list != NULL; list = list->next)
{
StackNode *node = list->data;
if (!match)
{
ProfileDescendant *seen_tree_node;
+ ProfileDescendant *n;
/* Have we seen this object further up the tree? */
seen_tree_node = NULL;
- for (i = 0; i < seen_objects->len; ++i)
+ for (n = parent; n != NULL; n = n->parent)
{
- ProfileDescendant *n = seen_objects->pdata[i];
if (n->name == node->address)
seen_tree_node = n;
}
ProfileDescendant *node;
g_assert (parent);
-
+
for (node = parent; node != seen_tree_node->parent; node = node->parent)
{
node->non_recursion -= size;
}
match = seen_tree_node;
-
- g_ptr_array_remove_range (seen_objects, 0, seen_objects->len);
- for (node = match; node != NULL; node = node->parent)
- g_ptr_array_add (seen_objects, node);
}
}
match->name = node->address;
match->non_recursion = 0;
- match->total = 0;
match->self = 0;
match->children = NULL;
match->marked_non_recursive = 0;
- match->marked_total = FALSE;
match->parent = parent;
-
match->siblings = *tree;
*tree = match;
}
++match->marked_non_recursive;
}
- if (!match->marked_total)
- {
- g_ptr_array_add (nodes_to_unmark_recursive, match);
-
- match->total += size;
- match->marked_total = TRUE;
- }
-
if (!list->next)
match->self += size;
- g_ptr_array_add (seen_objects, match);
-
tree = &(match->children);
parent = match;
}
- g_ptr_array_free (seen_objects, TRUE);
-
len = nodes_to_unmark->len;
for (i = 0; i < len; ++i)
{
tree_node->marked_non_recursive = 0;
}
- len = nodes_to_unmark_recursive->len;
- for (i = 0; i < len; ++i)
- {
- ProfileDescendant *tree_node = nodes_to_unmark_recursive->pdata[i];
-
- tree_node->marked_total = FALSE;
- }
-
g_ptr_array_free (nodes_to_unmark, TRUE);
- g_ptr_array_free (nodes_to_unmark_recursive, TRUE);
}
static void
{
char * name;
guint self;
- guint total;
guint non_recursion;
ProfileDescendant * parent;
ProfileDescendant * siblings;
ProfileDescendant * children;
int marked_non_recursive;
- int marked_total;
};
struct ProfileCaller
*/
return transition->to;
}
-#if 0
- else
- g_print ("transition: %d (%s)\n", transition->kind, transition->element);
-#endif
}
return NULL;
};
static gboolean
+is_all_blank (const char *text)
+{
+ while (g_ascii_isspace (*text))
+ text++;
+
+ return (*text == '\0');
+}
+
+static gboolean
get_number (const char *text, int *number)
{
char *end;
int result;
- char *stripped;
gboolean retval;
- stripped = g_strstrip (g_strdup (text));
- result = strtol (stripped, &end, 10);
-
- retval = (*end == '\0');
+ result = strtol (text, &end, 10);
+ retval = is_all_blank (end);
+
if (retval && number)
*number = result;
- g_free (stripped);
-
return retval;
}
return TRUE;
}
+static const char *
+skip_whitespace (const char *text)
+{
+ while (g_ascii_isspace (*text))
+ text++;
+
+ return text;
+}
+
static void
handle_text (GMarkupParseContext *context,
const gchar *text,
{
BuildContext *build = user_data;
Instruction instruction;
- char *free_me;
SType target_type;
- text = free_me = g_strstrip (g_strdup (text));
-
- if (strlen (text) == 0)
- goto out;
-
+ if (*text == '\0')
+ return;
+
+ text = skip_whitespace (text);
+ if (*text == '\0')
+ return;
+
build->state = state_transition_text (build->state, &instruction.type, &target_type);
if (!build->state)
{
int line, ch;
g_markup_parse_context_get_position (context, &line, &ch);
-#if 0
- g_print ("line: %d char: %d\n", line, ch);
-#endif
set_invalid_content_error (err, "Unexpected text data");
- goto out;
+ return;
}
instruction.name = NULL;
if (!get_number (text, &instruction.u.pointer.target_id))
{
set_invalid_content_error (err, "Contents '%s' of pointer element is not a number", text);
- goto out;
+ return;
}
break;
if (!get_number (text, &instruction.u.integer.value))
{
set_invalid_content_error (err, "Contents '%s' of integer element not a number", text);
- goto out;
+ return;
}
break;
if (!decode_text (text, &instruction.u.string.value))
{
set_invalid_content_error (err, "Contents '%s' of text element is illformed", text);
- goto out;
+ return;
}
break;
}
g_array_append_val (build->instructions, instruction);
-
- out:
- g_free (free_me);
}
static void
DESCENDANTS_NAME,
DESCENDANTS_SELF,
DESCENDANTS_NON_RECURSE,
- DESCENDANTS_TOTAL,
DESCENDANTS_OBJECT
};
DESCENDANTS_NAME, node->name,
DESCENDANTS_SELF, 100 * (node->self)/(double)size,
DESCENDANTS_NON_RECURSE, 100 * (node->non_recursion)/(double)size,
- DESCENDANTS_TOTAL, 100 * (node->total)/(double)size,
DESCENDANTS_OBJECT, node->name,
-1);
}
tree_store =
- gtk_tree_store_new (5,
+ gtk_tree_store_new (4,
G_TYPE_STRING,
G_TYPE_DOUBLE,
G_TYPE_DOUBLE,
- G_TYPE_DOUBLE,
G_TYPE_POINTER);
if (app->profile)