Skip to content

Commit

Permalink
added debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
hariharan-devarajan committed May 31, 2024
1 parent 185ae12 commit 2c1a0e7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/gotcha.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ GOTCHA_EXPORT void *gotcha_get_wrappee(gotcha_wrappee_handle_t handle) {
}

GOTCHA_EXPORT enum gotcha_error_t gotcha_unwrap(const char *tool_name) {
debug_printf(1, "Unwrapping Gotcha tool %s\n", tool_name);
struct tool_t *tool_instance = get_tool(tool_name);
if (tool_instance == NULL) return GOTCHA_INVALID_TOOL;
for (int i = 0; i < tool_instance->binding->internal_bindings_size; i++) {
Expand All @@ -549,6 +550,7 @@ GOTCHA_EXPORT enum gotcha_error_t gotcha_unwrap(const char *tool_name) {
lookup_hashtable(&function_hash_table, (void *)name, (void **)&head);
if (hash_result == 0) {
if (head == binding) {
debug_printf(1, "Found function %s wrapped by tool\n", name);
if (head->next_binding == NULL) {
// This is the only binding remove binding from hash table
removefrom_hashtable(&function_hash_table, (void *)name);
Expand All @@ -564,6 +566,7 @@ GOTCHA_EXPORT enum gotcha_error_t gotcha_unwrap(const char *tool_name) {
lookup_hashtable(&notfound_binding_table, (void *)name, (void **)&head);
if (hash_result == 0) {
if (head == binding) {
debug_printf(1, "Found function %s not yet wrapped by tool\n", name);
if (head->next_binding == NULL) {
// This is the only binding remove binding from hash table
removefrom_hashtable(&notfound_binding_table, (void *)name);
Expand All @@ -576,6 +579,7 @@ GOTCHA_EXPORT enum gotcha_error_t gotcha_unwrap(const char *tool_name) {
}
}
}
debug_printf(1, "Removing tool %s from list\n", tool_name);
// Remove tool from our list
remove_tool_from_list(tool_instance);
reorder_tool(tool_instance);
Expand Down

0 comments on commit 2c1a0e7

Please sign in to comment.