mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
updates
2006-03-11 Soren Sandmann <sandmann@redhat.com> * TODO: updates * stackstash.[ch]: Make stackstash refcounted * collector.c, profile.c: Update for refcounted stackstash, plug leak. * collector.c (open_fd): Remove FIXME comment
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
849efc820d
commit
9859854cc1
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
2006-03-11 Soren Sandmann <sandmann@redhat.com>
|
||||
|
||||
* TODO: updates
|
||||
|
||||
* stackstash.[ch]: Make stackstash refcounted
|
||||
|
||||
* collector.c, profile.c: Update for refcounted stackstash, plug
|
||||
leak.
|
||||
|
||||
* collector.c (open_fd): Remove FIXME comment
|
||||
|
||||
2006-03-05 Soeren Sandmann <sandmann@redhat.com>
|
||||
|
||||
* sysprof-text.c, collector.c, sysprof.c: Do proper
|
||||
|
||||
4
TODO
4
TODO
@ -79,8 +79,6 @@ Before 1.2:
|
||||
- a more pragmatic approach might be to just walk the tree and
|
||||
save it.
|
||||
|
||||
- make stackstash ref counted
|
||||
|
||||
- plug all the leaks
|
||||
- don't leak the presentation strings/objects
|
||||
- loading and saving probably leak right now
|
||||
@ -471,6 +469,8 @@ Later:
|
||||
|
||||
DONE:
|
||||
|
||||
- make stackstash ref counted
|
||||
|
||||
- Charge 'self' properly to processes that don't get any stack trace at all
|
||||
(probably we get that for free with stackstash reorganisation)
|
||||
|
||||
|
||||
14
collector.c
14
collector.c
@ -205,7 +205,6 @@ open_fd (Collector *collector,
|
||||
{
|
||||
set_no_module_error (err);
|
||||
|
||||
/* FIXME: set error */
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@ -243,7 +242,7 @@ void
|
||||
collector_reset (Collector *collector)
|
||||
{
|
||||
if (collector->stash)
|
||||
stack_stash_free (collector->stash);
|
||||
stack_stash_unref (collector->stash);
|
||||
|
||||
process_flush_caches();
|
||||
|
||||
@ -313,13 +312,16 @@ resolve_symbols (GList *trace, gint size, gpointer data)
|
||||
unique_dup (info->unique_symbols,
|
||||
"Everything"));
|
||||
|
||||
stack_stash_add_trace (info->resolved_stash, (gulong *)resolved_trace->pdata, resolved_trace->len, size);
|
||||
stack_stash_add_trace (info->resolved_stash,
|
||||
(gulong *)resolved_trace->pdata,
|
||||
resolved_trace->len, size);
|
||||
}
|
||||
|
||||
Profile *
|
||||
collector_create_profile (Collector *collector)
|
||||
{
|
||||
ResolveInfo info;
|
||||
Profile *profile;
|
||||
|
||||
info.resolved_stash = stack_stash_new ();
|
||||
info.unique_symbols = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
@ -327,8 +329,12 @@ collector_create_profile (Collector *collector)
|
||||
stack_stash_foreach (collector->stash, resolve_symbols, &info);
|
||||
|
||||
g_hash_table_destroy (info.unique_symbols);
|
||||
|
||||
profile = profile_new (info.resolved_stash);
|
||||
|
||||
stack_stash_unref (info.resolved_stash);
|
||||
|
||||
return profile_new (info.resolved_stash);
|
||||
return profile;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@ -228,7 +228,7 @@ profile_new (StackStash *stash)
|
||||
{
|
||||
Profile *profile = g_new (Profile, 1);
|
||||
|
||||
profile->stash = stash;
|
||||
profile->stash = stack_stash_ref (stash);
|
||||
|
||||
return profile;
|
||||
}
|
||||
@ -456,7 +456,7 @@ profile_list_callers (Profile *profile,
|
||||
void
|
||||
profile_free (Profile *profile)
|
||||
{
|
||||
/* FIXME unref stash */
|
||||
stack_stash_unref (profile->stash);
|
||||
g_free (profile);
|
||||
}
|
||||
|
||||
|
||||
38
stackstash.c
38
stackstash.c
@ -23,6 +23,7 @@ struct StackStash
|
||||
{
|
||||
StackNode *root;
|
||||
GHashTable *nodes_by_data;
|
||||
int ref_count;
|
||||
};
|
||||
|
||||
static StackNode *
|
||||
@ -39,18 +40,25 @@ stack_node_new (void)
|
||||
return node;
|
||||
}
|
||||
|
||||
/* Stach */
|
||||
StackStash *
|
||||
stack_stash_new (void)
|
||||
static StackStash *
|
||||
create_stack_stash (void)
|
||||
{
|
||||
StackStash *stash = g_new (StackStash, 1);
|
||||
|
||||
stash->root = NULL;
|
||||
stash->nodes_by_data = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
stash->ref_count = 1;
|
||||
|
||||
return stash;
|
||||
}
|
||||
|
||||
/* Stach */
|
||||
StackStash *
|
||||
stack_stash_new (void)
|
||||
{
|
||||
return create_stack_stash();
|
||||
}
|
||||
|
||||
void
|
||||
decorate_node (StackStash *stash,
|
||||
StackNode *node)
|
||||
@ -187,8 +195,8 @@ stack_node_free (StackNode *node)
|
||||
g_free (node);
|
||||
}
|
||||
|
||||
void
|
||||
stack_stash_free (StackStash *stash)
|
||||
static void
|
||||
stack_stash_free (StackStash *stash)
|
||||
{
|
||||
stack_node_free (stash->root);
|
||||
g_hash_table_destroy (stash->nodes_by_data);
|
||||
@ -196,6 +204,21 @@ stack_stash_free (StackStash *stash)
|
||||
g_free (stash);
|
||||
}
|
||||
|
||||
void
|
||||
stack_stash_unref (StackStash *stash)
|
||||
{
|
||||
stash->ref_count--;
|
||||
if (stash->ref_count == 0)
|
||||
stack_stash_free (stash);
|
||||
}
|
||||
|
||||
StackStash *
|
||||
stack_stash_ref (StackStash *stash)
|
||||
{
|
||||
stash->ref_count++;
|
||||
return stash;
|
||||
}
|
||||
|
||||
StackNode *
|
||||
stack_stash_find_node (StackStash *stash,
|
||||
gpointer data)
|
||||
@ -256,10 +279,7 @@ build_hash_table (StackNode *node,
|
||||
StackStash *
|
||||
stack_stash_new_from_root (StackNode *root)
|
||||
{
|
||||
StackStash *stash = g_new (StackStash, 1);
|
||||
|
||||
stash->root = root;
|
||||
stash->nodes_by_data = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
StackStash *stash = create_stack_stash();
|
||||
|
||||
build_hash_table (stash->root, stash);
|
||||
|
||||
|
||||
@ -64,8 +64,9 @@ StackNode *stack_stash_find_node (StackStash *stash,
|
||||
void stack_stash_foreach_by_address (StackStash *stash,
|
||||
StackNodeFunc func,
|
||||
gpointer data);
|
||||
void stack_stash_free (StackStash *stash);
|
||||
StackNode *stack_stash_get_root (StackStash *stash);
|
||||
StackStash *stack_stash_new_from_root (StackNode *root);
|
||||
StackStash *stack_stash_ref (StackStash *stash);
|
||||
void stack_stash_unref (StackStash *stash);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user