diff --git a/ChangeLog b/ChangeLog index fe18595b..586885d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sun Nov 6 17:06:52 2005 Soeren Sandmann + + * profile.c (add_trace_to_tree): Turn this function into a + StackFunction. + + * stackstash.c (stack_node_foreach_trace): Make this function take + a StackFunction, and reimplement with do_callback(). + Sat Nov 5 18:06:40 2005 Soeren Sandmann * profile.c (profile_create_descendants): Use callbacks from diff --git a/profile.c b/profile.c index af581872..c3eb9820 100644 --- a/profile.c +++ b/profile.c @@ -29,15 +29,6 @@ typedef struct Node Node; -static void -update() -{ -#if 0 - while (g_main_pending()) - g_main_iteration (FALSE); -#endif -} - struct Profile { StackStash * stash; @@ -243,27 +234,24 @@ profile_new (StackStash *stash) } static void -add_trace_to_tree (GSList *trace, gpointer data) +add_trace_to_tree (GSList *trace, gint size, gpointer data) { GSList *list; GPtrArray *nodes_to_unmark = g_ptr_array_new (); ProfileDescendant *parent = NULL; int i, len; ProfileDescendant **tree = data; - guint size = ((StackNode *)trace->data)->size; trace = g_slist_reverse (g_slist_copy (trace)); for (list = trace; list != NULL; list = list->next) { - StackNode *node = list->data; + gpointer address = list->data; ProfileDescendant *match = NULL; - update(); - for (match = *tree; match != NULL; match = match->siblings) { - if (match->name == node->address) + if (match->name == address) break; } @@ -276,7 +264,7 @@ add_trace_to_tree (GSList *trace, gpointer data) seen_tree_node = NULL; for (n = parent; n != NULL; n = n->parent) { - if (n->name == node->address) + if (n->name == address) seen_tree_node = n; } @@ -300,7 +288,7 @@ add_trace_to_tree (GSList *trace, gpointer data) { match = g_new (ProfileDescendant, 1); - match->name = node->address; + match->name = address; match->non_recursion = 0; match->self = 0; match->children = NULL; diff --git a/stackstash.c b/stackstash.c index af82f509..1a4c7d36 100644 --- a/stackstash.c +++ b/stackstash.c @@ -61,7 +61,6 @@ decorate_node (StackStash *stash, /* FIXME: we will probably want to do this lazily, * and more efficiently (only walk the tree once). */ - for (n = node->parent; n != NULL; n = n->parent) { if (n->address == node->address) @@ -128,23 +127,23 @@ stack_stash_add_trace (StackStash *stash, static void do_callback (StackNode *node, - GSList *trace, - StackFunction stack_func, + const GSList *trace, + StackFunction func, gpointer data) { GSList link; - + if (!node) return; - link.next = trace; + link.next = (GSList *)trace; link.data = node->address; - - do_callback (node->siblings, trace, stack_func, data); - do_callback (node->children, &link, stack_func, data); if (node->size) - stack_func (&link, node->size, data); + func (&link, node->size, data); + + do_callback (node->children, &link, func, data); + do_callback (node->siblings, trace, func, data); } void @@ -155,40 +154,20 @@ stack_stash_foreach (StackStash *stash, do_callback (stash->root, NULL, stack_func, data); } -static void -do_node_callback (StackNode *node, const GSList *trace, - StackTraceFunction func, - gpointer data) -{ - GSList link; - - if (!node) - return; - - link.next = (GSList *)trace; - link.data = node; - - if (node->size) - func (&link, data); - - do_node_callback (node->children, &link, func, data); - do_node_callback (node->siblings, trace, func, data); -} - void -stack_node_foreach_trace (StackNode *node, - StackTraceFunction func, - gpointer data) +stack_node_foreach_trace (StackNode *node, + StackFunction func, + gpointer data) { GSList link; link.next = NULL; - link.data = node; + link.data = node->address; if (node->size) - func (&link, data); + func (&link, node->size, data); - do_node_callback (node->children, &link, func, data); + do_callback (node->children, &link, func, data); } static void diff --git a/stackstash.h b/stackstash.h index 1a5ce6c7..0bd8909e 100644 --- a/stackstash.h +++ b/stackstash.h @@ -54,16 +54,14 @@ void stack_stash_add_trace (StackStash *stash, void stack_stash_foreach (StackStash *stash, StackFunction stack_func, gpointer data); +void stack_node_foreach_trace (StackNode *node, + StackFunction stack_func, + gpointer data); StackNode *stack_stash_find_node (StackStash *stash, gpointer address); /* FIXME: should probably return a list */ void stack_node_list_leaves (StackNode *node, GList **leaves); -typedef void (* StackTraceFunction) (GSList *trace, gpointer data); -void stack_node_foreach_trace (StackNode *node, - StackTraceFunction func, - gpointer data); - typedef void (* StackNodeFunc) (StackNode *node, gpointer data); void stack_stash_foreach_by_address (StackStash *stash, diff --git a/sysprof.c b/sysprof.c index c7877785..7a0359ba 100644 --- a/sysprof.c +++ b/sysprof.c @@ -1003,7 +1003,7 @@ on_object_selection_changed (GtkTreeSelection *selection, set_busy (app->main_window, TRUE); - gdk_window_process_all_updates (); + gdk_window_process_all_updates (); /* Display updated selection */ fill_descendants_tree (app); fill_callers_list (app);