diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 873f226a..083c8e32 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,7 +32,7 @@ jobs: - name: Compile run: | phpize - ./configure --enable-php-debugger + ./configure --enable-php-debugger-dev make -j$(nproc) - name: Find PHP diff --git a/config.m4 b/config.m4 index e738d6b5..3b0958db 100644 --- a/config.m4 +++ b/config.m4 @@ -2,8 +2,8 @@ dnl config.m4 for extension PHP Debugger (based on Xdebug) PHP_ARG_ENABLE(php-debugger, whether to enable PHP Debugger support, [ --enable-php-debugger Enable PHP Debugger support]) -PHP_ARG_ENABLE(xdebug-dev, whether to enable PHP Debugger developer build flags, -[ --enable-xdebug-dev PHP Debugger: Enable developer flags],, no) +PHP_ARG_ENABLE(php-debugger-dev, whether to enable PHP Debugger developer build flags, +[ --enable-php-debugger-dev PHP Debugger: Enable developer flags],, no) @@ -53,7 +53,7 @@ if test "$PHP_PHP_DEBUGGER" != "no"; then CPPFLAGS=$old_CPPFLAGS - if test "$PHP_XDEBUG_DEV" = "yes"; then + if test "$PHP_PHP_DEBUGGER_DEV" = "yes"; then AX_CHECK_COMPILE_FLAG(-Wbool-conversion, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wbool-conversion") AX_CHECK_COMPILE_FLAG(-Wdeclaration-after-statement, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wdeclaration-after-statement") AX_CHECK_COMPILE_FLAG(-Wdiscarded-qualifiers, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wdiscarded-qualifiers") @@ -85,6 +85,8 @@ if test "$PHP_PHP_DEBUGGER" != "no"; then AX_CHECK_COMPILE_FLAG(-Wstring-conversion, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wstring-conversion") AX_CHECK_COMPILE_FLAG(-Wwrite-strings, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wwrite-strings") AX_CHECK_COMPILE_FLAG(-Wpointer-arith, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wpointer-arith") + AX_CHECK_COMPILE_FLAG(-Wstrict-prototypes, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wstrict-prototypes") + AX_CHECK_COMPILE_FLAG(-Wold-style-definition, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -Wold-style-definition") AX_CHECK_COMPILE_FLAG(-fdiagnostics-show-option, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fdiagnostics-show-option") AX_CHECK_COMPILE_FLAG(-fno-exceptions, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fno-exceptions") AX_CHECK_COMPILE_FLAG(-fno-omit-frame-pointer, _MAINTAINER_CFLAGS="$_MAINTAINER_CFLAGS -fno-omit-frame-pointer") diff --git a/php_xdebug.h b/php_xdebug.h index 85e1149a..33340a64 100644 --- a/php_xdebug.h +++ b/php_xdebug.h @@ -68,7 +68,7 @@ PHP_RSHUTDOWN_FUNCTION(xdebug); PHP_MINFO_FUNCTION(xdebug); ZEND_MODULE_POST_ZEND_DEACTIVATE_D(xdebug); -int xdebug_is_output_tty(); +int xdebug_is_output_tty(void); ZEND_BEGIN_MODULE_GLOBALS(xdebug) struct { diff --git a/src/base/base.c b/src/base/base.c index 2069f9d6..45c4b317 100644 --- a/src/base/base.c +++ b/src/base/base.c @@ -329,277 +329,6 @@ void xdebug_build_fname(xdebug_func *tmp, zend_execute_data *edata) #define NO_VARIADIC INT_MAX #define DEBUG 0 -static void collect_params_internal(function_stack_entry *fse, zend_execute_data *zdata, zend_op_array *op_array) -{ - int i; - int is_variadic = !!(zdata->func->common.fn_flags & ZEND_ACC_VARIADIC); - int is_trampoline = !!(zdata->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE); - int variadic_at_pos = NO_VARIADIC; - int variadic_sensitive = 0; - int names_expected = 0; - int arguments_sent = 0; - int arguments_storage = 0; - - arguments_sent = ZEND_CALL_NUM_ARGS(zdata); - if (arguments_sent > USHRT_MAX) { - return; - } - - names_expected = zdata->func->internal_function.num_args; - if (names_expected > arguments_sent) { - names_expected = arguments_sent; - } -#if DEBUG - fprintf(stderr, "\nF: %s\n - CALL_NUM_ARGS: %d, op_array->num_args: %d, is_variadic: %d, trampoline: %d\n", fse->function.function, ZEND_CALL_NUM_ARGS(zdata), op_array->num_args, is_variadic, is_trampoline); -#endif - - /* If this function is variadic, we have an extra name field in arg_info, and also an extra - * argument sent to the function. */ - if (is_variadic && !is_trampoline) { - names_expected++; - } - - /* Pick the highest of "expected arguments" and "arguments given" (also - * taking into account the extra one for variadics */ - if (names_expected > arguments_sent) { - arguments_storage = names_expected; - } else { - arguments_storage = arguments_sent; - } - - fse->varc = arguments_storage; - fse->var = xdmalloc(fse->varc * sizeof(xdebug_var_name)); - -#if DEBUG - fprintf(stderr, " - names_expected: %d, arguments_sent: %d, arguments_storage: %d, fse->varc: %d\n", names_expected, arguments_sent, arguments_storage, fse->varc); -#endif - - /* Initialise everything in storage */ - for (i = 0; i < fse->varc; i++) { - fse->var[i].name = NULL; - ZVAL_UNDEF(&fse->var[i].data); - fse->var[i].is_variadic = 0; - } - - /* Collect Names */ - for (i = 0; i < names_expected; i++) { - if (op_array->arg_info[i].name) { -#if PHP_VERSION_ID >= 80600 - fse->var[i].name = zend_string_copy(zdata->func->internal_function.arg_info[i].name); -#else - fse->var[i].name = zend_string_init( - zdata->func->internal_function.arg_info[i].name, - strlen(zdata->func->internal_function.arg_info[i].name), - 0 - ); -#endif - - /* If an argument is a variadic, then we mark that on this 'name', - * and also remember which position the variadic started */ - if (ZEND_ARG_IS_VARIADIC(&op_array->arg_info[i]) && variadic_at_pos == NO_VARIADIC) { - fse->var[i].is_variadic = 1; - variadic_at_pos = i; - } - } - } - - /* Collect Arguments */ - for (i = 0; i < arguments_sent; i++) { -#if PHP_VERSION_ID >= 80200 - zend_attribute *attribute; -#else - void *attribute = NULL; -#endif - - /* The index in ZEND_CALL_ARG is 1-based */ -#if DEBUG - fprintf(stderr, "Copying argument %d\n", i); -#endif -#if PHP_VERSION_ID >= 80200 - attribute = zend_get_parameter_attribute_str( - zdata->func->common.attributes, - "sensitiveparameter", - sizeof("sensitiveparameter") - 1, - i - ); -#endif - if (attribute && fse->var[i].is_variadic) { - variadic_sensitive = 1; - } -# if DEBUG - fprintf(stderr, "SENSTIVIVE %d ", attribute != NULL); -# endif - - if ((variadic_sensitive || attribute != NULL) && !fse->var[i].is_variadic) { - ZVAL_STRING(&(fse->var[i].data), "[Sensitive Parameter]"); - } else { - ZVAL_COPY(&(fse->var[i].data), ZEND_CALL_ARG(zdata, i + 1)); - } -#if DEBUG - fprintf(stderr, "OK\n"); -#endif - } - - if (ZEND_CALL_INFO(zdata) & ZEND_CALL_HAS_EXTRA_NAMED_PARAMS) { - zend_string *name; - zval *param; - int i = fse->varc; - - fse->varc += zend_hash_num_elements(zdata->extra_named_params); - fse->var = xdrealloc(fse->var, fse->varc * sizeof(xdebug_var_name)); - - ZEND_HASH_FOREACH_STR_KEY_VAL(zdata->extra_named_params, name, param) { - fse->var[i].name = zend_string_copy(name); - ZVAL_COPY(&(fse->var[i].data), param); - fse->var[i].is_variadic = 0; - i++; - } ZEND_HASH_FOREACH_END(); - } - -#if DEBUG - for (i = 0; i < fse->varc; i++) { - fprintf(stderr, "%2d %-20s %c %s\n", i, fse->var[i].name ? ZSTR_VAL(fse->var[i].name) : "---", fse->var[i].is_variadic ? 'V' : ' ', xdebug_get_zval_value_line(&fse->var[i].data, 0, NULL)->d); - } -#endif -} - -static void collect_params(function_stack_entry *fse, zend_execute_data *zdata, zend_op_array *op_array) -{ - int i; - int is_variadic = !!(zdata->func->common.fn_flags & ZEND_ACC_VARIADIC); - int is_trampoline = !!(zdata->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE); - int variadic_at_pos = NO_VARIADIC; - int variadic_sensitive = 0; - int names_expected = 0; - int arguments_sent = 0; - int arguments_storage = 0; - - arguments_sent = ZEND_CALL_NUM_ARGS(zdata); - - /* The op_array contains the number of * (named) arguments. */ - names_expected = op_array->num_args; - -#if DEBUG - fprintf(stderr, "\nF: %s\n - CALL_NUM_ARGS: %d, op_array->num_args: %d, is_variadic: %d, trampoline: %d\n", fse->function.function, ZEND_CALL_NUM_ARGS(zdata), op_array->num_args, is_variadic, is_trampoline); -#endif - - /* If this function is variadic, we have an extra name field in arg_info, and also an extra - * argument sent to the function. */ - if (is_variadic && !is_trampoline) { - names_expected++; - arguments_sent++; - } - - /* Pick the highest of "expected arguments" and "arguments given" (also - * taking into account the extra one for variadics */ - if (names_expected > arguments_sent) { - arguments_storage = names_expected; - } else { - arguments_storage = arguments_sent; - } - - fse->varc = arguments_storage; - fse->var = xdmalloc(fse->varc * sizeof(xdebug_var_name)); - -#if DEBUG - fprintf(stderr, " - names_expected: %d, arguments_sent: %d, arguments_storage: %d, fse->varc: %d\n", names_expected, arguments_sent, arguments_storage, fse->varc); -#endif - - /* Initialise everything in storage */ - for (i = 0; i < fse->varc; i++) { - fse->var[i].name = NULL; - ZVAL_UNDEF(&fse->var[i].data); - fse->var[i].is_variadic = 0; - } - - /* Collect Names */ - for (i = 0; i < names_expected; i++) { - if (op_array->arg_info[i].name) { - fse->var[i].name = zend_string_copy(op_array->arg_info[i].name); - } - - /* If an argument is a variadic, then we mark that on this 'name', - * and also remember which position the variadic started */ - if (ZEND_ARG_IS_VARIADIC(&op_array->arg_info[i]) && variadic_at_pos == NO_VARIADIC) { - fse->var[i].is_variadic = 1; - variadic_at_pos = i; - } - } - - /* Collect Arguments */ - for (i = 0; i < fse->varc; i++) { -#if PHP_VERSION_ID >= 80200 - zend_attribute *attribute; -#else - void *attribute = NULL; -#endif - - /* The index in ZEND_CALL_ARG is 1-based */ -#if DEBUG - fprintf(stderr, "Copying argument %d: ", i); -#endif - if (i < names_expected || is_trampoline) { -#if DEBUG - fprintf(stderr, "ARG "); -#endif -#if PHP_VERSION_ID >= 80200 - attribute = zend_get_parameter_attribute_str( - zdata->func->common.attributes, - "sensitiveparameter", - sizeof("sensitiveparameter") - 1, - i - ); -#endif - if (attribute && fse->var[i].is_variadic) { - variadic_sensitive = 1; - } -# if DEBUG - fprintf(stderr, "SENSITIVE %d ", attribute != NULL); -# endif - - if ((variadic_sensitive || attribute != NULL) && !fse->var[i].is_variadic) { - ZVAL_STRING(&(fse->var[i].data), "[Sensitive Parameter]"); - } else { - ZVAL_COPY(&(fse->var[i].data), ZEND_CALL_ARG(zdata, i + 1)); - } - } else { -#if DEBUG - fprintf(stderr, "VAR_NUM "); -#endif - if (variadic_sensitive) { - ZVAL_STRING(&(fse->var[i].data), "[Sensitive Parameter]"); - } else { - ZVAL_COPY(&(fse->var[i].data), ZEND_CALL_VAR_NUM(zdata, zdata->func->op_array.last_var + zdata->func->op_array.T + i - names_expected)); - } - } -#if DEBUG - fprintf(stderr, "OK\n"); -#endif - } - - if (ZEND_CALL_INFO(zdata) & ZEND_CALL_HAS_EXTRA_NAMED_PARAMS) { - zend_string *name; - zval *param; - int i = fse->varc; - - fse->varc += zend_hash_num_elements(zdata->extra_named_params); - fse->var = xdrealloc(fse->var, fse->varc * sizeof(xdebug_var_name)); - - ZEND_HASH_FOREACH_STR_KEY_VAL(zdata->extra_named_params, name, param) { - fse->var[i].name = zend_string_copy(name); - ZVAL_COPY(&(fse->var[i].data), param); - fse->var[i].is_variadic = 0; - i++; - } ZEND_HASH_FOREACH_END(); - } - -#if DEBUG - for (i = 0; i < fse->varc; i++) { - fprintf(stderr, "%2d %-20s %c %s\n", i, fse->var[i].name ? ZSTR_VAL(fse->var[i].name) : "---", fse->var[i].is_variadic ? 'V' : ' ', xdebug_get_zval_value_line(&fse->var[i].data, 0, NULL)->d); - } -#endif -} - function_stack_entry *xdebug_add_stack_frame(zend_execute_data *zdata, zend_op_array *op_array, int type) { zend_execute_data *edata; @@ -1188,7 +917,7 @@ void xdebug_base_minit(INIT_FUNC_ARGS) xdebug_base_overloaded_functions_setup(); } -void xdebug_base_mshutdown() +void xdebug_base_mshutdown(void) { /* Reset compile and error callbacks */ zend_compile_file = old_compile_file; @@ -1201,13 +930,13 @@ void xdebug_base_mshutdown() #endif } -void xdebug_base_post_startup() +void xdebug_base_post_startup(void) { old_compile_file = zend_compile_file; zend_compile_file = xdebug_compile_file; } -void xdebug_base_rinit() +void xdebug_base_rinit(void) { XG_BASE(statement_handler_enabled) = true; XG_BASE(observer_active) = true; @@ -1269,7 +998,7 @@ void xdebug_base_rinit() } } -void xdebug_base_rinit_if_enabled() +void xdebug_base_rinit_if_enabled(void) { CG(compiler_options) = CG(compiler_options) | ZEND_COMPILE_EXTENDED_STMT; xdebug_disable_opcache_optimizer(); @@ -1286,7 +1015,7 @@ void xdebug_base_rinit_if_enabled() } } -void xdebug_base_post_deactivate() +void xdebug_base_post_deactivate(void) { xdebug_hash_destroy(XG_BASE(fiber_stacks)); XG_BASE(fiber_stacks) = NULL; @@ -1312,7 +1041,7 @@ void xdebug_base_post_deactivate() #endif } -void xdebug_base_rshutdown() +void xdebug_base_rshutdown(void) { /* Signal that we're no longer in a request */ XG_BASE(in_execution) = 0; diff --git a/src/base/base.h b/src/base/base.h index 676c57f9..4aaab078 100644 --- a/src/base/base.h +++ b/src/base/base.h @@ -18,14 +18,14 @@ #define __XDEBUG_BASE_H__ void xdebug_base_minit(INIT_FUNC_ARGS); -void xdebug_base_mshutdown(); +void xdebug_base_mshutdown(void); -void xdebug_base_post_startup(); +void xdebug_base_post_startup(void); -void xdebug_base_rinit(); -void xdebug_base_rinit_if_enabled(); -void xdebug_base_post_deactivate(); -void xdebug_base_rshutdown(); +void xdebug_base_rinit(void); +void xdebug_base_rinit_if_enabled(void); +void xdebug_base_post_deactivate(void); +void xdebug_base_rshutdown(void); void xdebug_func_dtor_by_ref(xdebug_func *elem); /* TODO: Remove this API */ void xdebug_func_dtor(xdebug_func *elem); diff --git a/src/base/filter.c b/src/base/filter.c index fbb927c4..a6d1f78b 100644 --- a/src/base/filter.c +++ b/src/base/filter.c @@ -100,7 +100,6 @@ void xdebug_filter_run_internal(function_stack_entry *fse, int group, unsigned c { xdebug_llist_element *le; unsigned int k; - function_stack_entry tmp_fse; int (*filter_to_run)(function_stack_entry *fse, unsigned char *filtered_flag, char *filter); le = XDEBUG_LLIST_HEAD(filters); diff --git a/src/debugger/com.c b/src/debugger/com.c index 316cc27f..9a6b96d3 100644 --- a/src/debugger/com.c +++ b/src/debugger/com.c @@ -538,7 +538,7 @@ static void xdebug_init_cloud_debugger(const char *cloud_id) /** * dXXXXXXa-cXXa-4XX7-9XX3-fXXXXXXXXXX0 */ -static int ide_key_is_cloud_id() +static int ide_key_is_cloud_id(void) { const char *k = XG_DBG(ide_key); @@ -553,7 +553,7 @@ static int ide_key_is_cloud_id() return 1; } -static bool is_opcache_enabled() +static bool is_opcache_enabled(void) { zend_string *opcache_enable = ZSTR_INIT_LITERAL("opcache.enable", 0); zend_string *opcache_enable_cli = ZSTR_INIT_LITERAL("opcache.enable_cli", 0); @@ -580,7 +580,7 @@ static bool is_opcache_enabled() return true; } -static void warn_if_opcache_is_loaded_after_xdebug() +static void warn_if_opcache_is_loaded_after_xdebug(void) { bool xdebug_loaded = false; zend_llist_element *ext_ptr = zend_extensions.head; @@ -604,7 +604,7 @@ static void warn_if_opcache_is_loaded_after_xdebug() } while (ext_ptr != NULL); } -static void xdebug_init_debugger() +static void xdebug_init_debugger(void) { xdebug_str *connection_attempts = xdebug_str_new(); @@ -690,20 +690,20 @@ int xdebug_early_connect_to_client(void) return (XG_DBG(context).socket >= 0) ? 1 : 0; } -void xdebug_abort_debugger() +void xdebug_abort_debugger(void) { if (XG_DBG(remote_connection_enabled)) { xdebug_mark_debug_connection_not_active(); } } -void xdebug_restart_debugger() +void xdebug_restart_debugger(void) { xdebug_abort_debugger(); xdebug_init_debugger(); } -void xdebug_mark_debug_connection_active() +void xdebug_mark_debug_connection_active(void) { XG_DBG(remote_connection_enabled) = 1; XG_DBG(remote_connection_pid) = xdebug_get_pid(); @@ -711,13 +711,13 @@ void xdebug_mark_debug_connection_active() XG_BASE(observer_active) = 1; } -void xdebug_mark_debug_connection_pending() +void xdebug_mark_debug_connection_pending(void) { XG_DBG(remote_connection_enabled) = 0; XG_DBG(remote_connection_pid) = 0; } -void xdebug_mark_debug_connection_not_active() +void xdebug_mark_debug_connection_not_active(void) { if (XG_DBG(remote_connection_enabled)) { xdebug_close_socket(XG_DBG(context).socket); @@ -752,7 +752,7 @@ bool xdebug_should_ignore(void) } -void xdebug_debug_init_if_requested_on_connect_to_client() +void xdebug_debug_init_if_requested_on_connect_to_client(void) { RETURN_IF_MODE_IS_NOT(XDEBUG_MODE_STEP_DEBUG); @@ -765,7 +765,7 @@ void xdebug_debug_init_if_requested_on_connect_to_client() } } -void xdebug_debug_init_if_requested_on_error() +void xdebug_debug_init_if_requested_on_error(void) { RETURN_IF_MODE_IS_NOT(XDEBUG_MODE_STEP_DEBUG); @@ -778,7 +778,7 @@ void xdebug_debug_init_if_requested_on_error() } } -void xdebug_debug_init_if_requested_on_xdebug_break() +void xdebug_debug_init_if_requested_on_xdebug_break(void) { RETURN_IF_MODE_IS_NOT(XDEBUG_MODE_STEP_DEBUG); @@ -799,7 +799,7 @@ static void xdebug_update_ide_key(char *new_key) XG_DBG(ide_key) = xdstrdup(new_key); } -static int xdebug_handle_start_session() +static int xdebug_handle_start_session(void) { int activate_session = 0; zval *dummy; @@ -860,7 +860,7 @@ static int xdebug_handle_start_session() return activate_session; } -static void xdebug_handle_stop_session() +static void xdebug_handle_stop_session(void) { /* Remove session cookie if requested */ if ( diff --git a/src/debugger/debugger.c b/src/debugger/debugger.c index 489a574c..b6324586 100644 --- a/src/debugger/debugger.c +++ b/src/debugger/debugger.c @@ -833,7 +833,7 @@ static size_t xdebug_ub_write(const char *string, size_t length) return xdebug_orig_ub_write(string, length); } -static void xdebug_hook_output_handlers() +static void xdebug_hook_output_handlers(void) { /* Override output handler for capturing output */ if (xdebug_orig_ub_write == NULL) { @@ -842,7 +842,7 @@ static void xdebug_hook_output_handlers() } } -static void xdebug_unhook_output_handlers() +static void xdebug_unhook_output_handlers(void) { /* Restore original output handler */ sapi_module.ub_write = xdebug_orig_ub_write; @@ -1200,7 +1200,7 @@ void xdebug_debugger_register_eval(function_stack_entry *fse) } } -void xdebug_debugger_restart_if_pid_changed() +void xdebug_debugger_restart_if_pid_changed(void) { zend_ulong pid; diff --git a/src/lib/lib.c b/src/lib/lib.c index ca37dfe4..59604fbf 100644 --- a/src/lib/lib.c +++ b/src/lib/lib.c @@ -858,7 +858,7 @@ void xdebug_lib_register_compiled_variables(function_stack_entry *fse) } } -bool xdebug_lib_path_mapping_enabled() +bool xdebug_lib_path_mapping_enabled(void) { return !!XINI_LIB(path_mapping); } diff --git a/src/lib/lib.h b/src/lib/lib.h index edda7b13..a43a54a8 100644 --- a/src/lib/lib.h +++ b/src/lib/lib.h @@ -306,5 +306,5 @@ zend_string* xdebug_wrap_closure_location_around_function_name(zend_op_array *op void xdebug_lib_register_compiled_variables(function_stack_entry *fse); -bool xdebug_lib_path_mapping_enabled(); +bool xdebug_lib_path_mapping_enabled(void); #endif diff --git a/src/lib/log.c b/src/lib/log.c index dceab356..2e7ad9f5 100644 --- a/src/lib/log.c +++ b/src/lib/log.c @@ -452,15 +452,6 @@ static int is_using_private_tmp_directory(char *file_name) return (XG_BASE(private_tmp) && (strstr(file_name, "/tmp") == file_name)); } -static const char* private_tmp_directory(char *file_name) -{ - if (is_using_private_tmp_directory(file_name)) { - return XG_BASE(private_tmp); - } - - return ""; -} - static void xdebug_print_settings(void) { zend_module_entry *module; @@ -825,7 +816,7 @@ void xdebug_open_log(void) } } -void xdebug_close_log() +void xdebug_close_log(void) { char *timestr; diff --git a/src/lib/var.c b/src/lib/var.c index 3aa0f221..2d02c9e3 100644 --- a/src/lib/var.c +++ b/src/lib/var.c @@ -98,7 +98,6 @@ HashTable *xdebug_objdebug_pp(zval **zval_pp, int flags) Z_OBJ_HANDLER(dzval, get_debug_info) && !EG(exception) ) { - void *original_trace_context; zend_object *orig_exception; XG_BASE(in_debug_info) = 1; diff --git a/xdebug.c b/xdebug.c index 3e982036..e99c35c2 100644 --- a/xdebug.c +++ b/xdebug.c @@ -238,13 +238,16 @@ static inline bool php_debugger_ini_is_explicitly_set(zend_ini_entry *entry) static void php_debugger_sync_canonical(zend_ini_entry *alias_entry, zend_string *new_value) { const char *alias_name = ZSTR_VAL(alias_entry->name); + char canonical[128]; + zend_string *key; + zend_ini_entry *canon; + if (strncmp(alias_name, "php_debugger.", sizeof("php_debugger.") - 1) != 0) return; - char canonical[128]; snprintf(canonical, sizeof(canonical), "xdebug.%s", alias_name + sizeof("php_debugger.") - 1); - zend_string *key = zend_string_init(canonical, strlen(canonical), 0); - zend_ini_entry *canon = zend_hash_find_ptr(EG(ini_directives), key); + key = zend_string_init(canonical, strlen(canonical), 0); + canon = zend_hash_find_ptr(EG(ini_directives), key); zend_string_release(key); if (!canon) return; @@ -253,8 +256,9 @@ static void php_debugger_sync_canonical(zend_ini_entry *alias_entry, zend_string } #define PHP_DEBUGGER_INI_WRAPPER(name, delegate) \ static PHP_INI_MH(name) { \ + int rc; \ if (!php_debugger_ini_is_explicitly_set(entry)) return SUCCESS; \ - int rc = delegate(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); \ + rc = delegate(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); \ if (rc == SUCCESS) php_debugger_sync_canonical(entry, new_value); \ return rc; \ } @@ -473,6 +477,7 @@ int xdebug_is_output_tty(void) PHP_MINIT_FUNCTION(xdebug) { + zend_string *alias_name; ZEND_INIT_MODULE_GLOBALS(xdebug, php_xdebug_init_globals, php_xdebug_shutdown_globals); REGISTER_INI_ENTRIES(); @@ -485,7 +490,7 @@ PHP_MINIT_FUNCTION(xdebug) xdebug_compat_module_entry.type = MODULE_PERSISTENT; xdebug_compat_module_entry.module_number = module_number; xdebug_compat_module_entry.zend_api = ZEND_MODULE_API_NO; - zend_string *alias_name = zend_string_init_interned("xdebug", sizeof("xdebug") - 1, 1); + alias_name = zend_string_init_interned("xdebug", sizeof("xdebug") - 1, 1); zend_hash_add_ptr(&module_registry, alias_name, &xdebug_compat_module_entry); zend_string_release(alias_name); }