Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:5007 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69354 invoked by uid 1010); 26 Oct 2003 11:54:06 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 69320 invoked by uid 1007); 26 Oct 2003 11:54:06 -0000 Message-ID: <20031026115406.69319.qmail@pb1.pair.com> To: internals@lists.php.net Date: Sun, 26 Oct 2003 12:54:05 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031009 X-Accept-Language: de-ch, en-us, en MIME-Version: 1.0 References: <3F9A759F.5070402@cschneid.com> In-Reply-To: <3F9A759F.5070402@cschneid.com> X-Enigmail-Version: 0.76.7.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/mixed; boundary="------------070301060701040501030004" X-Posted-By: 195.226.4.61 Subject: Re: Adding vars to debug_backtrace() From: cschneid@cschneid.com (Christian Schneider) --------------070301060701040501030004 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Ok, I worked out a patch which does not leak memory. I don't think thread-safety is an issue here but if anyone with deeper insight into Zend sees any problem with this patch, please tell me. What's the process (and chance :-)) of having this included in a future version of PHP? Should I also look into making a PHP5/Zend2 version of it? Comments welcome, - Chris --------------070301060701040501030004 Content-Type: text/plain; name="vars_debug_backtrace2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="vars_debug_backtrace2.patch" Index: Zend/zend_builtin_functions.c =================================================================== RCS file: /repository/Zend/Attic/zend_builtin_functions.c,v retrieving revision 1.124.2.9 diff -u -r1.124.2.9 zend_builtin_functions.c --- Zend/zend_builtin_functions.c 16 Jun 2003 15:55:07 -0000 1.124.2.9 +++ Zend/zend_builtin_functions.c 26 Oct 2003 11:49:15 -0000 @@ -1186,6 +1186,8 @@ char *call_type; char *include_filename = NULL; zval *stack_frame; + zval *vars; + zval *tmp; void **cur_arg_pos = EG(argument_stack).top_element; void **args = cur_arg_pos; int arg_stack_consistent = 0; @@ -1232,6 +1234,13 @@ * want to pop anything of the argument-stack */ } else { filename = NULL; + } + + if (ptr->function_state.function_symbol_table) { + MAKE_STD_ZVAL(vars); + array_init(vars); + zend_hash_copy(vars->value.ht, ptr->function_state.function_symbol_table, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); + add_assoc_zval_ex(stack_frame, "vars", sizeof("vars"), vars); } function_name = ptr->function_state.function->type != ZEND_OVERLOADED_FUNCTION ? ptr->function_state.function->common.function_name : get_active_function_name(TSRMLS_C); /* "OVERLOADED_FUNCTION" */ --------------070301060701040501030004--