[xdebug-dev] svn: /xdebug/trunk/ php_xdebug.h xdebug.c

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Wed, 30 Mar 2011 20:36:19 +0000

derick Wed, 30 Mar 2011 20:36:19 +0000

Revision: http://svn.xdebug.org/cgi-bin/viewvc.cgi?view=rev&revision=3433&root=xdebug

Log:
- Implemented issue #517: Add a function trace trigger like for the profiler.
  Patch by Patrick Allaert <patrickallaert[@]php.net>.

Changed paths:
    U xdebug/trunk/php_xdebug.h
    U xdebug/trunk/xdebug.c

Modified: xdebug/trunk/php_xdebug.h
===================================================================
--- xdebug/trunk/php_xdebug.h 2011-03-27 14:38:32 UTC (rev 3432)
+++ xdebug/trunk/php_xdebug.h 2011-03-30 20:36:19 UTC (rev 3433)
@@ -180,6 +180,7 @@
         FILE *trace_file;
         zend_bool do_trace;
         zend_bool auto_trace;
+ zend_bool trace_enable_trigger;
         char *trace_output_dir;
         char *trace_output_name;
         long trace_options;

Modified: xdebug/trunk/xdebug.c
===================================================================
--- xdebug/trunk/xdebug.c 2011-03-27 14:38:32 UTC (rev 3432)
+++ xdebug/trunk/xdebug.c 2011-03-30 20:36:19 UTC (rev 3433)
@@ -85,6 +85,8 @@

 int (*xdebug_orig_header_handler)(sapi_header_struct *h XG_SAPI_HEADER_OP_DC, sapi_headers_struct *s TSRMLS_DC);

+static int xdebug_trigger_enabled(int setting, char *var_name);
+
 zend_function_entry xdebug_functions[] = {
         PHP_FE(xdebug_get_stack_depth, NULL)
         PHP_FE(xdebug_get_function_stack, NULL)
@@ -236,6 +238,7 @@
 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_output_dir", XDEBUG_TEMP_DIR, 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)
         STD_PHP_INI_ENTRY("xdebug.trace_format", "0", PHP_INI_ALL, OnUpdateLong, trace_format, zend_xdebug_globals, xdebug_globals)
@@ -809,7 +812,10 @@
         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) || xdebug_trigger_enabled(XG(trace_enable_trigger), "XDEBUG_TRACE"))
+ && 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));
@@ -947,6 +953,32 @@
         DISPLAY_INI_ENTRIES();
 }

+static int xdebug_trigger_enabled(int setting, char *var_name)
+{
+ zval **dummy;
+
+ if (!setting) {
+ return 0;
+ }
+
+ if (
+ (
+ PG(http_globals)[TRACK_VARS_GET] &&
+ zend_hash_find(PG(http_globals)[TRACK_VARS_GET]->value.ht, var_name, strlen(var_name) + 1, (void **) &dummy) == SUCCESS
+ ) || (
+ PG(http_globals)[TRACK_VARS_POST] &&
+ zend_hash_find(PG(http_globals)[TRACK_VARS_POST]->value.ht, var_name, strlen(var_name) + 1, (void **) &dummy) == SUCCESS
+ ) || (
+ PG(http_globals)[TRACK_VARS_COOKIE] &&
+ zend_hash_find(PG(http_globals)[TRACK_VARS_COOKIE]->value.ht, var_name, strlen(var_name) + 1, (void **) &dummy) == SUCCESS
+ )
+ ) {
+ return 1;
+ }
+
+ return 0;
+}
+
 static void add_used_variables(function_stack_entry *fse, zend_op_array *op_array)
 {
         int i = 0;
Received on Wed Mar 30 2011 - 21:36:19 BST

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST