mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
Use callbacks from stackstash.
Sat Nov 5 18:06:40 2005 Soeren Sandmann <sandmann@redhat.com> * profile.c (profile_create_descendants): Use callbacks from stackstash. * stackstash.c (stack_node_foreach_trace): New function * stackstash.c (do_node_callback): New function
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
1f5b6ff38c
commit
c0aed2a4de
@ -1,3 +1,11 @@
|
|||||||
|
Sat Nov 5 18:06:40 2005 Soeren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
|
* profile.c (profile_create_descendants): Use callbacks from
|
||||||
|
stackstash.
|
||||||
|
|
||||||
|
* stackstash.c (stack_node_foreach_trace): New function
|
||||||
|
* stackstash.c (do_node_callback): New function
|
||||||
|
|
||||||
Sat Nov 5 12:39:33 2005 Soeren Sandmann <sandmann@redhat.com>
|
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.c (add_trace_to_tree): Don't compute the total field.
|
||||||
|
|||||||
35
profile.c
35
profile.c
@ -243,12 +243,16 @@ profile_new (StackStash *stash)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_trace_to_tree (ProfileDescendant **tree, GList *trace, guint size)
|
add_trace_to_tree (GSList *trace, gpointer data)
|
||||||
{
|
{
|
||||||
GList *list;
|
GSList *list;
|
||||||
GPtrArray *nodes_to_unmark = g_ptr_array_new ();
|
GPtrArray *nodes_to_unmark = g_ptr_array_new ();
|
||||||
ProfileDescendant *parent = NULL;
|
ProfileDescendant *parent = NULL;
|
||||||
int i, len;
|
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)
|
for (list = trace; list != NULL; list = list->next)
|
||||||
{
|
{
|
||||||
@ -329,20 +333,7 @@ add_trace_to_tree (ProfileDescendant **tree, GList *trace, guint size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_ptr_array_free (nodes_to_unmark, TRUE);
|
g_ptr_array_free (nodes_to_unmark, TRUE);
|
||||||
}
|
g_slist_free (trace);
|
||||||
|
|
||||||
static void
|
|
||||||
add_leaf_to_tree (ProfileDescendant **tree, StackNode *leaf, StackNode *top)
|
|
||||||
{
|
|
||||||
GList *trace = NULL;
|
|
||||||
StackNode *node;
|
|
||||||
|
|
||||||
for (node = leaf; node != top->parent; node = node->parent)
|
|
||||||
trace = g_list_prepend (trace, node);
|
|
||||||
|
|
||||||
add_trace_to_tree (tree, trace, leaf->size);
|
|
||||||
|
|
||||||
g_list_free (trace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileDescendant *
|
ProfileDescendant *
|
||||||
@ -356,17 +347,7 @@ profile_create_descendants (Profile *profile,
|
|||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
if (node->toplevel)
|
if (node->toplevel)
|
||||||
{
|
stack_node_foreach_trace (node, add_trace_to_tree, &tree);
|
||||||
GList *leaves = NULL;
|
|
||||||
GList *list;
|
|
||||||
|
|
||||||
stack_node_list_leaves (node, &leaves);
|
|
||||||
|
|
||||||
for (list = leaves; list != NULL; list = list->next)
|
|
||||||
add_leaf_to_tree (&tree, list->data, node);
|
|
||||||
|
|
||||||
g_list_free (leaves);
|
|
||||||
}
|
|
||||||
|
|
||||||
node = node->next;
|
node = node->next;
|
||||||
}
|
}
|
||||||
|
|||||||
36
stackstash.c
36
stackstash.c
@ -155,6 +155,42 @@ stack_stash_foreach (StackStash *stash,
|
|||||||
do_callback (stash->root, NULL, stack_func, data);
|
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)
|
||||||
|
{
|
||||||
|
GSList link;
|
||||||
|
|
||||||
|
link.next = NULL;
|
||||||
|
link.data = node;
|
||||||
|
|
||||||
|
if (node->size)
|
||||||
|
func (&link, data);
|
||||||
|
|
||||||
|
do_node_callback (node->children, &link, func, data);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
stack_node_free (StackNode *node)
|
stack_node_free (StackNode *node)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -59,6 +59,11 @@ StackNode *stack_stash_find_node (StackStash *stash,
|
|||||||
/* FIXME: should probably return a list */
|
/* FIXME: should probably return a list */
|
||||||
void stack_node_list_leaves (StackNode *node,
|
void stack_node_list_leaves (StackNode *node,
|
||||||
GList **leaves);
|
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,
|
typedef void (* StackNodeFunc) (StackNode *node,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
void stack_stash_foreach_by_address (StackStash *stash,
|
void stack_stash_foreach_by_address (StackStash *stash,
|
||||||
|
|||||||
Reference in New Issue
Block a user