mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-09 22:50:54 +00:00
Move match to front (add_trace_to_tree): Break as soon as a recursive call
2006-11-22 Soren Sandmann <sandmann@daimi.au.dk> * profile.c (add_trace_to_tree): Move match to front (add_trace_to_tree): Break as soon as a recursive call is found. * stackstash.c (do_callback): Manual tail call optimization.
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
d1a082ffec
commit
d3c0e7be5c
@ -1,3 +1,10 @@
|
|||||||
|
2006-11-22 Soren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
|
* profile.c (add_trace_to_tree): Move match to front
|
||||||
|
(add_trace_to_tree): Break as soon as a recursive call is found.
|
||||||
|
|
||||||
|
* stackstash.c (do_callback): Manual tail call optimization.
|
||||||
|
|
||||||
2006-11-20 Soren Sandmann <sandmann@daimi.au.dk>
|
2006-11-20 Soren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
* sysprof.c (ensure_profile): reset the collector after generating
|
* sysprof.c (ensure_profile): reset the collector after generating
|
||||||
|
|||||||
@ -156,9 +156,9 @@ on_read (gpointer data)
|
|||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
g_print ("pid: %d (%d)\n", trace.pid, trace.n_addresses);
|
g_print ("pid: %d (%d)\n", trace->pid, trace->n_addresses);
|
||||||
for (i=0; i < trace.n_addresses; ++i)
|
for (i=0; i < trace->n_addresses; ++i)
|
||||||
g_print ("rd: %08x\n", trace.addresses[i]);
|
g_print ("rd: %08x\n", trace->addresses[i]);
|
||||||
g_print ("-=-\n");
|
g_print ("-=-\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
21
profile.c
21
profile.c
@ -256,20 +256,30 @@ add_trace_to_tree (GList *trace, gint size, gpointer data)
|
|||||||
GList *list;
|
GList *list;
|
||||||
ProfileDescendant *parent = NULL;
|
ProfileDescendant *parent = NULL;
|
||||||
int i, len;
|
int i, len;
|
||||||
ProfileDescendant **tree = data;
|
ProfileDescendant **tree = data;
|
||||||
|
|
||||||
if (!nodes_to_unmark)
|
if (!nodes_to_unmark)
|
||||||
nodes_to_unmark = g_ptr_array_new ();
|
nodes_to_unmark = g_ptr_array_new ();
|
||||||
|
|
||||||
for (list = g_list_last (trace); list != NULL; list = list->prev)
|
for (list = g_list_last (trace); list != NULL; list = list->prev)
|
||||||
{
|
{
|
||||||
gpointer address = list->data;
|
gpointer address = list->data;
|
||||||
ProfileDescendant *match = NULL;
|
ProfileDescendant *match = NULL;
|
||||||
|
ProfileDescendant *prev = NULL;
|
||||||
|
|
||||||
for (match = *tree; match != NULL; match = match->siblings)
|
for (match = *tree; match != NULL; prev = match, match = match->siblings)
|
||||||
{
|
{
|
||||||
if (match->name == address)
|
if (match->name == address)
|
||||||
|
{
|
||||||
|
if (prev)
|
||||||
|
{
|
||||||
|
/* Move to front */
|
||||||
|
prev->siblings = match->siblings;
|
||||||
|
match->siblings = *tree;
|
||||||
|
*tree = match;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!match)
|
if (!match)
|
||||||
@ -282,7 +292,10 @@ add_trace_to_tree (GList *trace, gint size, gpointer data)
|
|||||||
for (n = parent; n != NULL; n = n->parent)
|
for (n = parent; n != NULL; n = n->parent)
|
||||||
{
|
{
|
||||||
if (n->name == address)
|
if (n->name == address)
|
||||||
|
{
|
||||||
seen_tree_node = n;
|
seen_tree_node = n;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seen_tree_node)
|
if (seen_tree_node)
|
||||||
|
|||||||
25
stackstash.c
25
stackstash.c
@ -204,21 +204,26 @@ do_callback (StackNode *node,
|
|||||||
{
|
{
|
||||||
GList link;
|
GList link;
|
||||||
|
|
||||||
if (!node)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (trace)
|
if (trace)
|
||||||
trace->prev = &link;
|
trace->prev = &link;
|
||||||
|
|
||||||
link.next = trace;
|
link.next = trace;
|
||||||
link.data = node->address;
|
|
||||||
link.prev = NULL;
|
link.prev = NULL;
|
||||||
|
|
||||||
if (node->size)
|
|
||||||
func (&link, node->size, data);
|
|
||||||
|
|
||||||
do_callback (node->children, &link, func, data);
|
while (node)
|
||||||
do_callback (node->siblings, trace, func, data);
|
{
|
||||||
|
link.data = node->address;
|
||||||
|
|
||||||
|
if (node->size)
|
||||||
|
func (&link, node->size, data);
|
||||||
|
|
||||||
|
do_callback (node->children, &link, func, data);
|
||||||
|
|
||||||
|
node = node->siblings;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trace)
|
||||||
|
trace->prev = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user