diff options
Diffstat (limited to 'ext/mysqlnd/mysqlnd_debug.c')
-rw-r--r-- | ext/mysqlnd/mysqlnd_debug.c | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c index 296a31dfb0..413ba30088 100644 --- a/ext/mysqlnd/mysqlnd_debug.c +++ b/ext/mysqlnd/mysqlnd_debug.c @@ -269,11 +269,11 @@ MYSQLND_METHOD(mysqlnd_debug, func_enter)(MYSQLND_DEBUG * self, const char ** p = self->skip_functions; while (*p) { if (*p == func_name) { - zend_stack_push(&self->call_stack, "", sizeof("")); + zend_stack_push(&self->call_stack, ""); #ifndef MYSQLND_PROFILING_DISABLED if (self->flags & MYSQLND_DEBUG_PROFILE_CALLS) { uint64_t some_time = 0; - zend_stack_push(&self->call_time_stack, &some_time, sizeof(some_time)); + zend_stack_push(&self->call_time_stack, &some_time); } #endif return FALSE; @@ -282,16 +282,16 @@ MYSQLND_METHOD(mysqlnd_debug, func_enter)(MYSQLND_DEBUG * self, } } - zend_stack_push(&self->call_stack, func_name, func_name_len + 1); + zend_stack_push(&self->call_stack, func_name); #ifndef MYSQLND_PROFILING_DISABLED if (self->flags & MYSQLND_DEBUG_PROFILE_CALLS) { uint64_t some_time = 0; - zend_stack_push(&self->call_time_stack, &some_time, sizeof(some_time)); + zend_stack_push(&self->call_time_stack, &some_time); } #endif if (zend_hash_num_elements(&self->not_filtered_functions) && - 0 == zend_hash_exists(&self->not_filtered_functions, func_name, strlen(func_name) + 1)) + 0 == zend_hash_str_exists(&self->not_filtered_functions, func_name, strlen(func_name))) { return FALSE; } @@ -336,11 +336,11 @@ MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int lin return PASS; } - zend_stack_top(&self->call_stack, (void **)&func_name); + func_name = zend_stack_top(&self->call_stack); #ifndef MYSQLND_PROFILING_DISABLED if (profile_calls) { - zend_stack_top(&self->call_time_stack, (void **)&mine_non_own_time_ptr); + mine_non_own_time_ptr = zend_stack_top(&self->call_time_stack); mine_non_own_time = *mine_non_own_time_ptr; zend_stack_del_top(&self->call_time_stack); /* callee - removing ourselves */ } @@ -349,7 +349,7 @@ MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int lin if (func_name[0] == '\0') { ; /* don't log that function */ } else if (!zend_hash_num_elements(&self->not_filtered_functions) || - 1 == zend_hash_exists(&self->not_filtered_functions, func_name, strlen(func_name) + 1)) + 1 == zend_hash_str_exists(&self->not_filtered_functions, func_name, strlen(func_name))) { #ifndef MYSQLND_PROFILING_DISABLED if (FALSE == profile_calls) { @@ -367,7 +367,7 @@ MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int lin func_name, (unsigned int) call_time, (unsigned int) own_time, (unsigned int) mine_non_own_time ); - if (SUCCESS == zend_hash_find(&self->function_profiles, func_name, func_name_len + 1, (void **) &f_profile)) { + if ((f_profile = zend_hash_str_find_ptr(&self->function_profiles, func_name, func_name_len)) != NULL) { /* found */ if (f_profile) { if (mine_non_own_time < f_profile->min_in_calls) { @@ -411,16 +411,16 @@ MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int lin f_profile->min_total = f_profile->max_total = f_profile->avg_total = call_time; f_profile->min_own = f_profile->max_own = f_profile->avg_own = own_time; f_profile->calls = 1; - zend_hash_add(&self->function_profiles, func_name, func_name_len+1, f_profile, sizeof(struct st_mysqlnd_dbg_function_profile), NULL); + zend_hash_str_add_mem(&self->function_profiles, func_name, func_name_len, f_profile, sizeof(struct st_mysqlnd_dbg_function_profile)); } if ((uint) zend_stack_count(&self->call_time_stack)) { uint64_t parent_non_own_time = 0; - zend_stack_top(&self->call_time_stack, (void **)&parent_non_own_time_ptr); + parent_non_own_time_ptr = zend_stack_top(&self->call_time_stack); parent_non_own_time = *parent_non_own_time_ptr; parent_non_own_time += call_time; zend_stack_del_top(&self->call_time_stack); /* the caller */ - zend_stack_push(&self->call_time_stack, &parent_non_own_time, sizeof(parent_non_own_time)); /* add back the caller */ + zend_stack_push(&self->call_time_stack, &parent_non_own_time); /* add back the caller */ } } #endif @@ -440,29 +440,22 @@ MYSQLND_METHOD(mysqlnd_debug, close)(MYSQLND_DEBUG * self) #ifndef MYSQLND_PROFILING_DISABLED if (!(self->flags & MYSQLND_DEBUG_FLUSH) && (self->flags & MYSQLND_DEBUG_PROFILE_CALLS)) { struct st_mysqlnd_dbg_function_profile * f_profile; - HashPosition pos_values; + zend_string *string_key = NULL; self->m->log_va(self, __LINE__, __FILE__, 0, "info : ", "number of functions: %d", zend_hash_num_elements(&self->function_profiles)); - zend_hash_internal_pointer_reset_ex(&self->function_profiles, &pos_values); - while (zend_hash_get_current_data_ex(&self->function_profiles, (void **) &f_profile, &pos_values) == SUCCESS) { - char *string_key = NULL; - uint string_key_len; - ulong num_key; - - zend_hash_get_current_key_ex(&self->function_profiles, &string_key, &string_key_len, &num_key, 0, &pos_values); - + ZEND_HASH_FOREACH_STR_KEY_PTR(&self->function_profiles, string_key, f_profile) { self->m->log_va(self, __LINE__, __FILE__, -1, "info : ", "%-40s\tcalls=%5llu own_slow=%5llu in_calls_slow=%5llu total_slow=%5llu" " min_own=%5llu max_own=%7llu avg_own=%7llu " " min_in_calls=%5llu max_in_calls=%7llu avg_in_calls=%7llu" " min_total=%5llu max_total=%7llu avg_total=%7llu" - ,string_key + ,string_key->val ,(uint64_t) f_profile->calls ,(uint64_t) f_profile->own_underporm_calls ,(uint64_t) f_profile->in_calls_underporm_calls ,(uint64_t) f_profile->total_underporm_calls - + ,(uint64_t) f_profile->min_own ,(uint64_t) f_profile->max_own ,(uint64_t) f_profile->avg_own @@ -473,8 +466,7 @@ MYSQLND_METHOD(mysqlnd_debug, close)(MYSQLND_DEBUG * self) ,(uint64_t) f_profile->max_total ,(uint64_t) f_profile->avg_total ); - zend_hash_move_forward_ex(&self->function_profiles, &pos_values); - } + } ZEND_HASH_FOREACH_END(); } #endif @@ -592,8 +584,8 @@ MYSQLND_METHOD(mysqlnd_debug, set_mode)(MYSQLND_DEBUG * self, const char * const memcpy(func_name, mode + i + 1, func_name_len); func_name[func_name_len] = '\0'; - zend_hash_add_empty_element(&self->not_filtered_functions, - func_name, func_name_len + 1); + zend_hash_str_add_empty_element(&self->not_filtered_functions, + func_name, func_name_len); i = j; } if (mode[j] == ':') { @@ -730,8 +722,8 @@ mysqlnd_debug_init(const char * skip_functions[] TSRMLS_DC) #endif ret->nest_level_limit = 0; ret->pid = getpid(); - zend_stack_init(&ret->call_stack); - zend_stack_init(&ret->call_time_stack); + zend_stack_init(&ret->call_stack, sizeof(char *)); + zend_stack_init(&ret->call_time_stack, sizeof(uint64_t)); zend_hash_init(&ret->not_filtered_functions, 0, NULL, NULL, 0); zend_hash_init(&ret->function_profiles, 0, NULL, NULL, 0); |