diff -ru xdebug-2.0.5/php_xdebug.h xdebug-2.0.5-modified/php_xdebug.h --- xdebug-2.0.5/php_xdebug.h 1970-01-01 20:13:08.000000000 +1100 +++ xdebug-2.0.5-modified/php_xdebug.h 2011-03-30 16:05:11.442678999 +1100 @@ -141,6 +141,8 @@ FILE *trace_file; zend_bool do_trace; zend_bool auto_trace; + zend_bool trace_enable_trigger; + char *trace_enable_trigger_value; char *trace_output_dir; char *trace_output_name; long trace_options; @@ -199,6 +201,7 @@ char *profiler_output_dir; char *profiler_output_name; /* "pid" or "crc32" */ zend_bool profiler_enable_trigger; + char *profiler_enable_trigger_value; zend_bool profiler_append; /* profiler globals */ diff -ru xdebug-2.0.5/xdebug.c xdebug-2.0.5-modified/xdebug.c --- xdebug-2.0.5/xdebug.c 1970-01-01 20:13:08.000000000 +1100 +++ xdebug-2.0.5-modified/xdebug.c 2011-03-31 17:01:14.885110998 +1100 @@ -253,6 +253,8 @@ PHP_INI_BEGIN() /* Debugger settings */ STD_PHP_INI_BOOLEAN("xdebug.auto_trace", "0", PHP_INI_ALL, OnUpdateBool, auto_trace, zend_xdebug_globals, xdebug_globals) + STD_PHP_INI_BOOLEAN("xdebug.trace_enable_trigger", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, trace_enable_trigger, zend_xdebug_globals, xdebug_globals) + STD_PHP_INI_ENTRY("xdebug.trace_enable_trigger_value", "", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateString, trace_enable_trigger_value, zend_xdebug_globals, xdebug_globals) STD_PHP_INI_ENTRY("xdebug.trace_output_dir", "/tmp", PHP_INI_ALL, OnUpdateString, trace_output_dir, zend_xdebug_globals, xdebug_globals) STD_PHP_INI_ENTRY("xdebug.trace_output_name", "trace.%c", PHP_INI_ALL, OnUpdateString, trace_output_name, zend_xdebug_globals, xdebug_globals) #if ZEND_EXTENSION_API_NO < 90000000 @@ -300,11 +302,12 @@ STD_PHP_INI_ENTRY("xdebug.profiler_output_dir", "/tmp", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateString, profiler_output_dir, zend_xdebug_globals, xdebug_globals) STD_PHP_INI_ENTRY("xdebug.profiler_output_name", "cachegrind.out.%p", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateString, profiler_output_name, zend_xdebug_globals, xdebug_globals) STD_PHP_INI_BOOLEAN("xdebug.profiler_enable_trigger", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, profiler_enable_trigger, zend_xdebug_globals, xdebug_globals) + STD_PHP_INI_ENTRY("xdebug.profiler_enable_trigger_value", "", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateString, profiler_enable_trigger_value, zend_xdebug_globals, xdebug_globals) STD_PHP_INI_BOOLEAN("xdebug.profiler_append", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, profiler_append, zend_xdebug_globals, xdebug_globals) STD_PHP_INI_BOOLEAN("xdebug.profiler_aggregate", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, profiler_aggregate, zend_xdebug_globals, xdebug_globals) /* Remote debugger settings */ - STD_PHP_INI_BOOLEAN("xdebug.remote_enable", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, remote_enable, zend_xdebug_globals, xdebug_globals) + STD_PHP_INI_BOOLEAN("xdebug.remote_enable", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, remote_enable, zend_xdebug_globals, xdebug_globals) STD_PHP_INI_ENTRY("xdebug.remote_handler", "dbgp", PHP_INI_ALL, OnUpdateString, remote_handler, zend_xdebug_globals, xdebug_globals) STD_PHP_INI_ENTRY("xdebug.remote_host", "localhost", PHP_INI_ALL, OnUpdateString, remote_host, zend_xdebug_globals, xdebug_globals) PHP_INI_ENTRY("xdebug.remote_mode", "req", PHP_INI_ALL, OnUpdateDebugMode) @@ -437,6 +440,9 @@ if (strcasecmp(envvar, "profiler_enable_trigger") == 0) { name = "xdebug.profiler_enable_trigger"; } else + if (strcasecmp(envvar, "trace_enable") == 0) { + name = "xdebug.trace_enable"; + } else if (strcasecmp(envvar, "remote_log") == 0) { name = "xdebug.remote_log"; } @@ -785,11 +791,40 @@ XG(remote_enabled) = 0; XG(profiler_enabled) = 0; XG(breakpoints_allowed) = 1; - if (XG(auto_trace) && XG(trace_output_dir) && strlen(XG(trace_output_dir))) { + if ( + ( + XG(auto_trace) + || + ( + /* Check for special GET/POST parameter to start the trace */ + XG(trace_enable_trigger) && + ( + ( + PG(http_globals)[TRACK_VARS_GET] && + zend_hash_find(PG(http_globals)[TRACK_VARS_GET]->value.ht, "XDEBUG_TRACE", sizeof("XDEBUG_TRACE"), (void **) &dummy) == SUCCESS + ) || ( + PG(http_globals)[TRACK_VARS_POST] && + zend_hash_find(PG(http_globals)[TRACK_VARS_POST]->value.ht, "XDEBUG_TRACE", sizeof("XDEBUG_TRACE"), (void **) &dummy) == SUCCESS + ) || ( + PG(http_globals)[TRACK_VARS_COOKIE] && + zend_hash_find(PG(http_globals)[TRACK_VARS_COOKIE]->value.ht, "XDEBUG_TRACE", sizeof("XDEBUG_TRACE"), (void **) &dummy) == SUCCESS + ) + ) && ( + (strlen(XG(trace_enable_trigger_value)) == 0) || + (strcmp(XG(trace_enable_trigger_value), Z_STRVAL_PP(dummy)) == 0) + ) + + ) + ) && XG(trace_output_dir) && strlen(XG(trace_output_dir))) { + /* In case we do an auto-trace we are not interested in the return * value, but we still have to free it. */ xdfree(xdebug_start_trace(NULL, XG(trace_options) TSRMLS_CC)); } + php_syslog(LOG_NOTICE, "trace_enable_trigger_value: '%s'", XG(trace_enable_trigger_value)); + php_syslog(LOG_NOTICE, "dummy: '%s'", Z_STRVAL_PP(dummy)); + + /* Initialize some debugger context properties */ XG(context).program_name = NULL; @@ -1494,6 +1529,9 @@ PG(http_globals)[TRACK_VARS_COOKIE] && zend_hash_find(PG(http_globals)[TRACK_VARS_COOKIE]->value.ht, "XDEBUG_PROFILE", sizeof("XDEBUG_PROFILE"), (void **) &dummy) == SUCCESS ) + ) && ( + (strlen(XG(profiler_enable_trigger_value)) == 0) || + (strcmp(XG(profiler_enable_trigger_value), Z_STRVAL_PP(dummy)) == 0) ) ) )