diff options
author | Soren Sandmann <sandmann@redhat.com> | 2006-03-12 04:00:23 +0000 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@src.gnome.org> | 2006-03-12 04:00:23 +0000 |
commit | 9859854cc18cd67876b2f1280a02556cedfc6cc4 (patch) | |
tree | 60ecf40d6b15322525052d7b09df2a5f852e8a75 | |
parent | 849efc820deef78c2ee35947713f007902411f81 (diff) |
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
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | TODO | 4 | ||||
-rw-r--r-- | collector.c | 14 | ||||
-rw-r--r-- | profile.c | 4 | ||||
-rw-r--r-- | stackstash.c | 38 | ||||
-rw-r--r-- | stackstash.h | 3 |
6 files changed, 56 insertions, 18 deletions
@@ -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 @@ -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) diff --git a/collector.c b/collector.c index ec1b240..5bad4ef 100644 --- a/collector.c +++ b/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); } diff --git a/stackstash.c b/stackstash.c index cee0d2b..d22c69f 100644 --- a/stackstash.c +++ b/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); diff --git a/stackstash.h b/stackstash.h index 1faa5f9..f965d4e 100644 --- a/stackstash.h +++ b/stackstash.h @@ -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 |