[xdebug-dev] xdebug xdebug/config.m4 xdebug/php_xdebug.h xdebug/xdebug.c xdebug/xdebug_compat.c xdebug/xdebug_compat.h xdebug/xt.vim xdebug/tests/test11.phpt xdebug/tests/test8.phpt - Implemented showing returng values in traces. The xdebug.collect_return

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Sun, 11 Apr 2004 16:22:09 +0200

Date: Sun Apr 11 16:22:09 CEST 2004
User: Derick Rethans
Directory: xdebug

Log Message:
[4.00]
- Implemented showing returng values in traces. The xdebug.collect_return
  php.ini settings needs to be activated for this.
- Modified two test cases to test for the new feature
- Added xdebug_compat.c to the extension files.

Modified files:
           xdebug/config.m4 (version: 1.21)
           xdebug/php_xdebug.h (version: 1.72)
           xdebug/xdebug.c (version: 1.207)
           xdebug/xdebug_compat.c (version: 1.3)
           xdebug/xdebug_compat.h (version: 1.3)
           xdebug/xt.vim (version: 1.2)
           xdebug/tests/test11.phpt (version: 1.8)
           xdebug/tests/test8.phpt (version: 1.9)

[FILE: /xdebug/config.m4]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- xdebug/config.m4:1.20 Thu Mar 04 10:46:44 2004 GMT
+++ xdebug/config.m4 Sun Apr 11 12:22:08 2004 GMT
@@ -1,11 +1,11 @@
-dnl $Id: cvstemp,v 1.20 2004/03/04 11:46:44 derick Exp $
+dnl $Id: cvstemp,v 1.21 2004/04/11 14:22:08 derick Exp $
 dnl config.m4 for extension xdebug
 
 PHP_ARG_ENABLE(xdebug, whether to enable eXtended debugging support,
 [ --enable-xdebug Enable Xdebug support])
 
 if test "$PHP_XDEBUG" != "no"; then
- PHP_NEW_EXTENSION(xdebug, xdebug.c xdebug_code_coverage.c xdebug_com.c xdebug_handler_dbgp.c xdebug_handler_gdb.c xdebug_handler_php3.c xdebug_handlers.c xdebug_llist.c xdebug_hash.c xdebug_private.c xdebug_profiler.c xdebug_str.c xdebug_superglobals.c xdebug_var.c xdebug_xml.c usefulstuff.c, $ext_shared)
+ PHP_NEW_EXTENSION(xdebug, xdebug.c xdebug_code_coverage.c xdebug_com.c xdebug_compat.c xdebug_handler_dbgp.c xdebug_handler_gdb.c xdebug_handler_php3.c xdebug_handlers.c xdebug_llist.c xdebug_hash.c xdebug_private.c xdebug_profiler.c xdebug_str.c xdebug_superglobals.c xdebug_var.c xdebug_xml.c usefulstuff.c, $ext_shared)
   AC_DEFINE(HAVE_XDEBUG,1,[ ])
 
 dnl Check for new current_execute_data field in zend_executor_globals

[FILE: /xdebug/php_xdebug.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- xdebug/php_xdebug.h:1.71 Thu Mar 25 16:35:33 2004 GMT
+++ xdebug/php_xdebug.h Sun Apr 11 12:22:08 2004 GMT
@@ -96,6 +96,7 @@
         zend_bool default_enable;
         zend_bool collect_includes;
         zend_bool collect_params;
+ zend_bool collect_return;
         zend_bool extended_info;
         zend_bool show_local_vars;
         zend_bool show_mem_delta;

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.206
retrieving revision 1.207
diff -u -r1.206 -r1.207
--- xdebug/xdebug.c:1.206 Fri Apr 09 21:25:09 2004 GMT
+++ xdebug/xdebug.c Sun Apr 11 12:22:08 2004 GMT
@@ -80,6 +80,7 @@
 
 static zval *get_zval(znode *node, temp_variable *Ts, int *is_var);
 static char* return_trace_stack_frame(function_stack_entry* i, int html TSRMLS_DC);
+static char* return_trace_stack_retval(function_stack_entry* i, zval* retval TSRMLS_DC);
 
 int zend_xdebug_initialised = 0;
 
@@ -212,8 +213,9 @@
         STD_PHP_INI_BOOLEAN("xdebug.auto_trace", "0", PHP_INI_ALL, OnUpdateBool, auto_trace, 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", "crc32", PHP_INI_ALL, OnUpdateString, trace_output_name, zend_xdebug_globals, xdebug_globals)
- STD_PHP_INI_BOOLEAN("xdebug.collect_params", "0", PHP_INI_ALL, OnUpdateBool, collect_params, zend_xdebug_globals, xdebug_globals)
         STD_PHP_INI_BOOLEAN("xdebug.collect_includes","1", PHP_INI_ALL, OnUpdateBool, collect_includes, zend_xdebug_globals, xdebug_globals)
+ STD_PHP_INI_BOOLEAN("xdebug.collect_params", "0", PHP_INI_ALL, OnUpdateBool, collect_params, zend_xdebug_globals, xdebug_globals)
+ STD_PHP_INI_BOOLEAN("xdebug.collect_return", "0", PHP_INI_ALL, OnUpdateBool, collect_return, zend_xdebug_globals, xdebug_globals)
         STD_PHP_INI_BOOLEAN("xdebug.default_enable", "1", PHP_INI_SYSTEM, OnUpdateBool, default_enable, zend_xdebug_globals, xdebug_globals)
         STD_PHP_INI_BOOLEAN("xdebug.extended_info", "1", PHP_INI_SYSTEM, OnUpdateBool, extended_info, zend_xdebug_globals, xdebug_globals)
         STD_PHP_INI_ENTRY("xdebug.manual_url", "http://www.php.net", PHP_INI_ALL, OnUpdateString, manual_url, zend_xdebug_globals, xdebug_globals)
@@ -814,6 +816,7 @@
         zend_execute_data *edata = EG(current_execute_data);
         function_stack_entry *fse;
         char *magic_cookie = NULL;
+ int do_return = (XG(do_trace) && XG(trace_file));
 
         if (XG(level) == 0) {
                 /* Set session cookie if requested */
@@ -914,6 +917,16 @@
                 xdebug_profiler_function_user_begin(fse TSRMLS_CC);
         }
         old_execute(op_array TSRMLS_CC);
+
+ if (XG(collect_return) && do_return && XG(do_trace) && XG(trace_file)) {
+ if (EG(return_value_ptr_ptr) && *EG(return_value_ptr_ptr)) {
+ char* t = return_trace_stack_retval(fse, *EG(return_value_ptr_ptr) TSRMLS_CC);
+ fprintf(XG(trace_file), "%s", t);
+ fflush(XG(trace_file));
+ xdfree(t);
+ }
+ }
+
         if (XG(profiler_enabled)) {
                 xdebug_profiler_function_user_end(fse, op_array TSRMLS_CC);
         }
@@ -927,6 +940,8 @@
 {
         zend_execute_data *edata = EG(current_execute_data);
         function_stack_entry *fse;
+ zend_op *cur_opcode;
+ int do_return = (XG(do_trace) && XG(trace_file));
 
         XG(level)++;
         if (XG(level) == XG(max_nesting_level)) {
@@ -946,6 +961,18 @@
                 xdebug_profiler_function_internal_begin(fse TSRMLS_CC);
         }
         execute_internal(current_execute_data, return_value_used TSRMLS_CC);
+
+ if (XG(collect_return) && do_return && XG(do_trace) && XG(trace_file)) {
+ cur_opcode = *EG(opline_ptr);
+ if (cur_opcode) {
+ zval *ret = xdebug_zval_ptr(&(cur_opcode->result), current_execute_data->Ts TSRMLS_CC);
+ char* t = return_trace_stack_retval(fse, ret TSRMLS_CC);
+ fprintf(XG(trace_file), "%s", t);
+ fflush(XG(trace_file));
+ xdfree(t);
+ }
+ }
+
         if (XG(profiler_enabled)) {
                 xdebug_profiler_function_internal_end(fse TSRMLS_CC);
         }
@@ -1134,6 +1161,28 @@
         }
 }
 
+static char* return_trace_stack_retval(function_stack_entry* i, zval* retval TSRMLS_DC)
+{
+ int j = 0; /* Counter */
+ xdebug_str str = {0, 0, NULL};
+ char *tmp_value;
+
+ xdebug_str_addl(&str, " ", 20, 0);
+ if (XG(show_mem_delta)) {
+ xdebug_str_addl(&str, " ", 8, 0);
+ }
+ for (j = 0; j < i->level; j++) {
+ xdebug_str_addl(&str, " ", 2, 0);
+ }
+ xdebug_str_addl(&str, " >=> ", 7, 0);
+
+ tmp_value = get_zval_value(retval);
+ xdebug_str_add(&str, tmp_value, 1);
+ xdebug_str_addl(&str, "\n", 2, 0);
+
+ return str.d;
+}
+
 static char* return_trace_stack_frame(function_stack_entry* i, int html TSRMLS_DC)
 {
         int c = 0; /* Comma flag */

[FILE: /xdebug/xdebug_compat.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- xdebug/xdebug_compat.c:1.2 Sun Apr 04 19:35:47 2004 GMT
+++ xdebug/xdebug_compat.c Sun Apr 11 12:22:08 2004 GMT
@@ -13,9 +13,10 @@
    | license[@]php.net so we can mail you a copy immediately. |
    +----------------------------------------------------------------------+
    | Author: Jim Winstead <jimw[@]php.net> |
+ | Modifications: Derick Rethans <derick[@]xdebug.org> |
    +----------------------------------------------------------------------+
  */
-/* $Id: cvstemp,v 1.2 2004/04/04 21:35:47 derick Exp $ */
+/* $Id: cvstemp,v 1.3 2004/04/11 14:22:08 derick Exp $ */
 
 #include "php.h"
 #include "main/php_version.h"
@@ -256,3 +257,66 @@
 /* }}} */
 
 #endif
+
+/*
+ +----------------------------------------------------------------------+
+ | Zend Engine |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.00 of the Zend license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.zend.com/license/2_00.txt. |
+ | If you did not receive a copy of the Zend license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license[@]zend.com so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Andi Gutmans <andi[@]zend.com> |
+ | Zeev Suraski <zeev[@]zend.com> |
+ | Modifications: Derick Rethans <derick[@]xdebug.org> |
+ +----------------------------------------------------------------------+
+*/
+
+#define T(offset) (*(temp_variable *)((char *) Ts + offset))
+
+zval *xdebug_zval_ptr(znode *node, temp_variable *Ts TSRMLS_DC)
+{
+ switch (node->op_type) {
+ case IS_CONST:
+ return &node->u.constant;
+ break;
+ case IS_TMP_VAR:
+ return &T(node->u.var).tmp_var;
+ break;
+ case IS_VAR:
+ if (T(node->u.var).var.ptr) {
+ return T(node->u.var).var.ptr;
+ } else {
+ temp_variable *T = &T(node->u.var);
+ zval *str = T->str_offset.str;
+
+ if (T->str_offset.str->type != IS_STRING
+ || ((int)T->str_offset.offset<0)
+ || (T->str_offset.str->value.str.len <= T->str_offset.offset)) {
+ zend_error(E_NOTICE, "Uninitialized string offset: %d", T->str_offset.offset);
+ T->tmp_var.value.str.val = empty_string;
+ T->tmp_var.value.str.len = 0;
+ } else {
+ char c = str->value.str.val[T->str_offset.offset];
+
+ T->tmp_var.value.str.val = estrndup(&c, 1);
+ T->tmp_var.value.str.len = 1;
+ }
+ T->tmp_var.refcount=1;
+ T->tmp_var.is_ref=1;
+ T->tmp_var.type = IS_STRING;
+ return &T->tmp_var;
+ }
+ break;
+ case IS_UNUSED:
+ return NULL;
+ break;
+ }
+ return NULL;
+}

[FILE: /xdebug/xdebug_compat.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- xdebug/xdebug_compat.h:1.2 Sun Apr 04 19:32:49 2004 GMT
+++ xdebug/xdebug_compat.h Sun Apr 11 12:22:08 2004 GMT
@@ -45,4 +45,6 @@
 
 #endif
 
+zval *xdebug_zval_ptr(znode *node, temp_variable *Ts TSRMLS_DC);
+
 #endif

[FILE: /xdebug/xt.vim]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- xdebug/xt.vim:1.1 Fri Jan 16 07:44:07 2004 GMT
+++ xdebug/xt.vim Sun Apr 11 12:22:08 2004 GMT
@@ -22,6 +22,7 @@
 syn match level "->"
 syn match lineno ":\d\+$"
 
+syn match result ">=>.\+"
 
 syn match methodcall "\k\+->"
 syn match staticcall "\k\+::"
@@ -47,6 +48,7 @@
   HiLink date Label
 
   HiLink level SpecialChar
+ HiLink result Constant
 
   HiLink min_memory Constant
   HiLink pls_memory Structure

[FILE: /xdebug/tests/test11.phpt]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- xdebug/tests/test11.phpt:1.7 Tue Mar 16 18:03:37 2004 GMT
+++ xdebug/tests/test11.phpt Sun Apr 11 12:22:09 2004 GMT
@@ -4,6 +4,7 @@
 xdebug.enable=1
 xdebug.auto_trace=0
 xdebug.collect_params=1
+xdebug.collect_return=1
 xdebug.auto_profile=0
 xdebug.show_mem_delta=0
 --FILE--
@@ -23,4 +24,5 @@
 --EXPECTF--
 TRACE START [%d-%d-%d %d:%d:%d]
     %f %d -> blaat() /%s/test11.php:9
+ >=> NULL
     %f %d -> file_get_contents('/tmp/%s') /%s/test11.php:11

[FILE: /xdebug/tests/test8.phpt]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- xdebug/tests/test8.phpt:1.8 Tue Mar 16 18:03:37 2004 GMT
+++ xdebug/tests/test8.phpt Sun Apr 11 12:22:09 2004 GMT
@@ -4,6 +4,7 @@
 xdebug.enable=1
 xdebug.auto_trace=0
 xdebug.collect_params=1
+xdebug.collect_return=1
 xdebug.auto_profile=0
 xdebug.show_mem_delta=0
 --FILE--
@@ -111,15 +112,28 @@
 TRACE START [%d-%d-%d %d:%d:%d]
     %f %d -> a() /%s/test8.php:17
     %f %d -> xdebug_get_function_stack() /%s/test8.php:5
+ >=> array (0 => array ('function' => '{main}', 'file' => '/dat/dev/php/xdebug/tests/test8.php', 'line' => 0, 'params' => array ()), 1 => array ('function' => 'a', 'file' => '/dat/dev/php/xdebug/tests/test8.php', 'line' => 17, 'params' => array ()))
     %f %d -> var_dump(array (0 => array ('function' => '{main}', 'file' => '/%s/test8.php', 'line' => 0, 'params' => array ()), 1 => array ('function' => 'a', 'file' => '/%s/test8.php', 'line' => 17, 'params' => array ()))) /%s/test8.php:5
+ >=> NULL
+ >=> 'a'
     %f %d -> b(2) /%s/test8.php:17
+ >=> '2b'
     %f %d -> c('a', '2b') /%s/test8.php:17
+ >=> '2ba'
     %f %d -> a() /%s/test8.php:17
     %f %d -> xdebug_get_function_stack() /%s/test8.php:5
+ >=> array (0 => array ('function' => '{main}', 'file' => '/dat/dev/php/xdebug/tests/test8.php', 'line' => 0, 'params' => array ()), 1 => array ('function' => 'a', 'file' => '/dat/dev/php/xdebug/tests/test8.php', 'line' => 17, 'params' => array ()))
     %f %d -> var_dump(array (0 => array ('function' => '{main}', 'file' => '/%s/test8.php', 'line' => 0, 'params' => array ()), 1 => array ('function' => 'a', 'file' => '/%s/test8.php', 'line' => 17, 'params' => array ()))) /%s/test8.php:5
+ >=> NULL
+ >=> 'a'
     %f %d -> a() /%s/test8.php:17
     %f %d -> xdebug_get_function_stack() /%s/test8.php:5
+ >=> array (0 => array ('function' => '{main}', 'file' => '/dat/dev/php/xdebug/tests/test8.php', 'line' => 0, 'params' => array ()), 1 => array ('function' => 'a', 'file' => '/dat/dev/php/xdebug/tests/test8.php', 'line' => 17, 'params' => array ()))
     %f %d -> var_dump(array (0 => array ('function' => '{main}', 'file' => '/%s/test8.php', 'line' => 0, 'params' => array ()), 1 => array ('function' => 'a', 'file' => '/%s/test8.php', 'line' => 17, 'params' => array ()))) /%s/test8.php:5
+ >=> NULL
+ >=> 'a'
     %f %d -> c('a', 'a') /%s/test8.php:17
+ >=> 'aa'
     %f %d -> c('2ba', 'aa') /%s/test8.php:17
+ >=> 'aa2ba'
     %f %d -> file_get_contents('/tmp/%s') /%s/test8.php:19
Received on Sun Apr 11 2004 - 16:22:11 BST

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