Bug #18161 Updated: backtrace and zend engine 2 (alpha 2)

From: Date: Wed, 17 Jul 2002 07:50:34 +0000
Subject: Bug #18161 Updated: backtrace and zend engine 2 (alpha 2)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-14379@lists.php.net to get a copy of this message
ID: 18161 Updated by: ol@globalis-ms.com Reported By: ol@globalis-ms.com Status: Open Bug Type: Zend Engine 2 problem Operating System: linux - i386 PHP Version: 4CVS-2002-07-04 New Comment: Hi, Ok, you 're true :) I did not really understood it at first time. I believed is behaviour was a bit like ticks with one call on top and no more. In fact i need to call debug_backtrace as many time that i want/need to trace a single function or method... Thanks for help :) For example this script work fine : <?php function display_backtrace(){ $debug = debug_backtrace(); array_shift($debug); /* remove call to display_backtrace himself */ print_r($debug); // display call stack } function foo() { display_backtrace(); // need to debug } function call_foo(){ foo(); } call_foo(); ?> -- Ol Previous Comments: ------------------------------------------------------------------------ [2002-07-16 15:35:18] optikSmoke@subdimension.com Ummm, I believe the problem you are having is that you are calling debug_backtrace() from the top level of the script. I have been using debug_backtrace() quite effectively to develop a printStackTrace() method for exceptions in my scripts, and in my testing I found that it will nnot output anything unless the call is made from within a function/method. eg: <? function foo() { debug_backtrace(); print_r(debug_backtrace()); } foo(); ?> Try that. I could be wrong, but I don't think debug_backtrace() was meant to be used from the top level of scripts. ------------------------------------------------------------------------ [2002-07-04 07:12:26] ol@globalis-ms.com Hi, I've tried to test the backtrace function in zend engine 2 alpha 2. And i'm not able to get any usable output. Is it a known bug (no KNOWN_BUG file, in archive), or it's just not the right way to use it ? Example 1 (from the Change log doc) Output -> <empty> <?php $backtrace = debug_backtrace(); foreach ($backtrace as $step) { $class = isset($step['class']) ? $step['class'] . '::' : ''; printf( "%s [%s:%s]\n", $step['function'], $step['file'], $step['line'] ); } ?> Example 2 (from my own) Output -> <empty Array> <?php function foo(){ echo "function --> foo\n"; } $backtrace = debug_backtrace(); foo(); print_r($backtrace); ?> Thanks, My conf: ./configure --without-apache --without-pear on a linuxbox - slackware 8.1 / i386 -- Ol ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18161&edit=1

« previous php.bugs (#14379) next »