From: Yannick Brosseau Date: Tue, 18 Sep 2012 20:55:01 +0000 (-0400) Subject: Add debug function and some assert to lttv_hook_remove_list X-Git-Tag: v1.5-beta1~38 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=27fb4fd27a32d054c161db031edf02ac015a15ad;p=lttv.git Add debug function and some assert to lttv_hook_remove_list Also add some const correctness to the remove_list function Signed-off-by: Yannick Brosseau --- diff --git a/lttv/lttv/hook.c b/lttv/lttv/hook.c index 62918cd5..3d82f111 100644 --- a/lttv/lttv/hook.c +++ b/lttv/lttv/hook.c @@ -193,19 +193,23 @@ void lttv_hooks_remove_data(LttvHooks *h, LttvHook f, void *hook_data) } -void lttv_hooks_remove_list(LttvHooks *h, LttvHooks *list) +void lttv_hooks_remove_list(LttvHooks *h, const LttvHooks *list) { guint i, j; LttvHookClosure *c, *c_list; if(list == NULL) return; + g_assert(h != list); + /* This iteration assume that both list are in the same order */ for(i = 0, j = 0 ; i < h->len && j < list->len ;) { c = &g_array_index(h, LttvHookClosure, i); c_list = &g_array_index(list, LttvHookClosure, j); if(c->hook == c_list->hook && c->hook_data == c_list->hook_data) { if(c->ref_count == 1) { + int count = h->len; lttv_hooks_remove_by_position(h, i); + g_assert((count-1) == h->len); } else { g_assert(c->ref_count != 0); c->ref_count--; @@ -394,3 +398,22 @@ gboolean lttv_hooks_call_check_merge(LttvHooks *h1, void *call_data1, return FALSE; } + + +void lttv_hooks_print(const LttvHooks *h) +{ + gboolean ret, sum_ret = FALSE; + + LttvHookClosure *c; + + guint i; + + if(likely(h != NULL)) { + for(i = 0 ; i < h->len ; i++) { + c = &g_array_index(h, LttvHookClosure, i); + printf("%p:%i:%i,", c->hook, c->ref_count, c->prio); + } + printf("\n"); + } + +} diff --git a/lttv/lttv/hook.h b/lttv/lttv/hook.h index 81383b5b..65903b28 100644 --- a/lttv/lttv/hook.h +++ b/lttv/lttv/hook.h @@ -77,7 +77,7 @@ void lttv_hooks_remove_data(LttvHooks *h, LttvHook f, void *hook_data); /* Remove a list of hooks from the hooks list in h. */ -void lttv_hooks_remove_list(LttvHooks *h, LttvHooks *list); +void lttv_hooks_remove_list(LttvHooks *h, const LttvHooks *list); /* Return the number of hooks in the list */ @@ -188,4 +188,8 @@ LttvHooks *lttv_hooks_by_id_channel_find(LttvHooksByIdChannelArray *h, #endif /* BABEL_CLEANUP */ +/* Print information about each hook in the list*/ + +void lttv_hooks_print(const LttvHooks *h); + #endif // HOOK_H