[PHP-DEV] call_stack

2002-11-27 Thread Miham KEREKES
Hi!

I'm new to this list, I want to know if there is any function which
could return the actual call stack, or is it planned to be added?
It could be very useful (for example in my case, now :-).

If it's already implemented, i'm sorry, i could not be able to find it
in the doc.. In this case RTFM is ok. 

Thanks,
Miham KEREKES.

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread Derick Rethans
On Wed, 27 Nov 2002, Miham KEREKES wrote:

 Hi!
 
 I'm new to this list, I want to know if there is any function which
 could return the actual call stack, or is it planned to be added?
 It could be very useful (for example in my case, now :-).

debug_backtrace() will be available in PHP 4.3.0 and higher.

Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread Phil Dier
On Wed, 27 Nov 2002 15:41:25 +0100 (CET)
Derick Rethans [EMAIL PROTECTED] wrote:

 On Wed, 27 Nov 2002, Miham KEREKES wrote:
 
  Hi!
  
  I'm new to this list, I want to know if there is any function which
  could return the actual call stack, or is it planned to be added?
  It could be very useful (for example in my case, now :-).
 
 debug_backtrace() will be available in PHP 4.3.0 and higher.
 
 Derick
 

I thought debug_backtrace() was a ze2 thing.  Does that mean 4.3 is going to
use ze2?

Phil Dier

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread George Schlossnagle
debug_backtrace was backported into ze1.  4.3 will sstill use ze1.

George

Phil Dier wrote:


On Wed, 27 Nov 2002 15:41:25 +0100 (CET)
Derick Rethans [EMAIL PROTECTED] wrote:


On Wed, 27 Nov 2002, Miham KEREKES wrote:


Hi!

I'm new to this list, I want to know if there is any function which
could return the actual call stack, or is it planned to be added?
It could be very useful (for example in my case, now :-).


debug_backtrace() will be available in PHP 4.3.0 and higher.

Derick



I thought debug_backtrace() was a ze2 thing.  Does that mean 4.3 is going to
use ze2?

Phil Dier






--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread Sterling Hughes
 On Wed, 27 Nov 2002 15:41:25 +0100 (CET)
 Derick Rethans [EMAIL PROTECTED] wrote:
 
  On Wed, 27 Nov 2002, Miham KEREKES wrote:
  
   Hi!
   
   I'm new to this list, I want to know if there is any function which
   could return the actual call stack, or is it planned to be added?
   It could be very useful (for example in my case, now :-).
  
  debug_backtrace() will be available in PHP 4.3.0 and higher.
  
  Derick
  
 
 I thought debug_backtrace() was a ze2 thing.  Does that mean 4.3 is going to
 use ze2?


it has been backported...

-Sterling

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread Andi Gutmans
At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote:

On Wed, 27 Nov 2002, Miham KEREKES wrote:

 Hi!

 I'm new to this list, I want to know if there is any function which
 could return the actual call stack, or is it planned to be added?
 It could be very useful (for example in my case, now :-).

debug_backtrace() will be available in PHP 4.3.0 and higher.


if someone has time to implement debug_print_backtrace() that would be 
cool. Using the raw debug_backtrace() is a bitch.

Andi


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] call_stack

2002-11-27 Thread Andi Gutmans
At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote:

On Wed, 27 Nov 2002, Andi Gutmans wrote:

 At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote:
 On Wed, 27 Nov 2002, Miham KEREKES wrote:
 
 debug_backtrace() will be available in PHP 4.3.0 and higher.

 if someone has time to implement debug_print_backtrace() that would be
 cool. Using the raw debug_backtrace() is a bitch.

If you're trying to volunteer me it's not going to work :P


Damn! Maybe someone else? :)

Andi


--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread George Schlossnagle
I'll do it, if you want.

Andi Gutmans wrote:


At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote:


On Wed, 27 Nov 2002, Andi Gutmans wrote:

 At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote:
 On Wed, 27 Nov 2002, Miham KEREKES wrote:
 
 debug_backtrace() will be available in PHP 4.3.0 and higher.

 if someone has time to implement debug_print_backtrace() that would be
 cool. Using the raw debug_backtrace() is a bitch.

If you're trying to volunteer me it's not going to work :P



Damn! Maybe someone else? :)

Andi




--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread Andi Gutmans
That'd be cool.

At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote:

I'll do it, if you want.

Andi Gutmans wrote:


At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote:


On Wed, 27 Nov 2002, Andi Gutmans wrote:

 At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote:
 On Wed, 27 Nov 2002, Miham KEREKES wrote:
 
 debug_backtrace() will be available in PHP 4.3.0 and higher.

 if someone has time to implement debug_print_backtrace() that would be
 cool. Using the raw debug_backtrace() is a bitch.

If you're trying to volunteer me it's not going to work :P



Damn! Maybe someone else? :)

Andi





--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread Brad Fisher
Andi Gutmans wrote:

 At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote:
 On Wed, 27 Nov 2002, Miham KEREKES wrote:
 
   Hi!
  
   I'm new to this list, I want to know if there is any function which
   could return the actual call stack, or is it planned to be added?
   It could be very useful (for example in my case, now :-).
 
 debug_backtrace() will be available in PHP 4.3.0 and higher.

 if someone has time to implement debug_print_backtrace() that would be
 cool. Using the raw debug_backtrace() is a bitch.

 Andi


In case anyone's interested, here's what I use for my custom error handler:

function __debug_error_handler($type, $msg, $file, $line, $context) {

  if (ini_get('html_errors')) {
$hr = 'HR';
$br = 'BR';
$nbsp = 'nbsp;';
$b = 'B';
$slash_b = '/B';
  } else {
$hr = ---\n;
$br = '';
$nbsp = ' ';
$b = '';
$slash_b = '';
  }

  echo $hr . ini_get('error_prepend_string');

  $list = Array(E_USER_ERROR = 'U_ERROR',
E_USER_WARNING = 'U_WARNING',
E_USER_NOTICE = 'U_NOTICE',
E_ERROR = 'ERROR',
E_WARNING = 'WARNING',
E_NOTICE = 'NOTICE');


  if (array_key_exists($type, $list)) {
$type = $list[$type];
  } else {
$type = UNKNOWN ERROR CODE ($type);
  }

  echo $b$type:$slash_b $msg$br\n;

  $bt = debug_backtrace();

  $from = '';
  for ($i = 1; $i  count($bt); ++$i) {
$step = $bt[$i];
$class = isset($step['class']) ? $step['class'] . '::' : '';

if (empty($step['file']))
  $step['file'] = '';

if (empty($step['line']))
  $step['line'] = '';

printf($nbsp$nbsp %s$b%s%s$slash_b [%s:%s]$br\n,
   $from,
   $class,
   $step['function'],
   $step['file'],
   $step['line']
  );

$from = $nbsp$nbsp$nbsp$nbsp from ;
  }

  echo ini_get('error_append_string');
} // __debug_error_handler





-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread Andi Gutmans
I'd probably go for class::function($arg1, $arg2).
Also take into consideration that the args aren't always available.

Andi

At 02:58 PM 11/27/2002 -0500, George Schlossnagle wrote:

Is there a concensus on how arguments should be printed out?

I'm shooting right now for a 'cluck' style backtrave

class::function() called at file:line


Perhaps

class::function() called at file:line
   Arguments:
   print_r(args)

??


Andi Gutmans wrote:


That'd be cool.

At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote:


I'll do it, if you want.

Andi Gutmans wrote:


At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote:


On Wed, 27 Nov 2002, Andi Gutmans wrote:

 At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote:
 On Wed, 27 Nov 2002, Miham KEREKES wrote:
 
 debug_backtrace() will be available in PHP 4.3.0 and higher.

 if someone has time to implement debug_print_backtrace() that would be
 cool. Using the raw debug_backtrace() is a bitch.

If you're trying to volunteer me it's not going to work :P




Damn! Maybe someone else? :)

Andi










--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread Miham KEREKES
 Is there a concensus on how arguments should be printed out?
 I'm shooting right now for a 'cluck' style backtrave
 class::function() called at file:line
 
 Perhaps
 
 class::function() called at file:line
Arguments:
print_r(args)
 
 ??
Well, probably the following:
class::function() called at file:line 
with arguments: nice_serialize(args)

where nice_serialize() do almost the same as serialize, but the result
were _more_ human readable

This solution would give shorter trace.

But - it's only my opinion :-)

M.

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread George Schlossnagle
Hmmm  any hints on how to get the variable name out of the stack? 
The code in debug_backtrace seems to only extract the value.

George

Andi Gutmans wrote:

I'd probably go for class::function($arg1, $arg2).
Also take into consideration that the args aren't always available.

Andi

At 02:58 PM 11/27/2002 -0500, George Schlossnagle wrote:


Is there a concensus on how arguments should be printed out?

I'm shooting right now for a 'cluck' style backtrave

class::function() called at file:line


Perhaps

class::function() called at file:line
   Arguments:
   print_r(args)

??


Andi Gutmans wrote:


That'd be cool.

At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote:


I'll do it, if you want.

Andi Gutmans wrote:


At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote:


On Wed, 27 Nov 2002, Andi Gutmans wrote:

 At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote:
 On Wed, 27 Nov 2002, Miham KEREKES wrote:
 
 debug_backtrace() will be available in PHP 4.3.0 and higher.

 if someone has time to implement debug_print_backtrace() that 
would be
 cool. Using the raw debug_backtrace() is a bitch.

If you're trying to volunteer me it's not going to work :P




Damn! Maybe someone else? :)

Andi
















--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread Andi Gutmans
At 03:13 PM 11/27/2002 -0500, George Schlossnagle wrote:

Hmmm  any hints on how to get the variable name out of the stack? The 
code in debug_backtrace seems to only extract the value.

There's no way but I don't think it's needed. When I wrote $arg1 I meant 
the value not the name of the variable. Sorry if I wasn't clear.
Andi


George

Andi Gutmans wrote:


I'd probably go for class::function($arg1, $arg2).
Also take into consideration that the args aren't always available.

Andi

At 02:58 PM 11/27/2002 -0500, George Schlossnagle wrote:


Is there a concensus on how arguments should be printed out?

I'm shooting right now for a 'cluck' style backtrave

class::function() called at file:line


Perhaps

class::function() called at file:line
   Arguments:
   print_r(args)

??


Andi Gutmans wrote:


That'd be cool.

At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote:


I'll do it, if you want.

Andi Gutmans wrote:


At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote:


On Wed, 27 Nov 2002, Andi Gutmans wrote:

 At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote:
 On Wed, 27 Nov 2002, Miham KEREKES wrote:
 
 debug_backtrace() will be available in PHP 4.3.0 and higher.

 if someone has time to implement debug_print_backtrace() that 
would be
 cool. Using the raw debug_backtrace() is a bitch.

If you're trying to volunteer me it's not going to work :P




Damn! Maybe someone else? :)

Andi












--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread George Schlossnagle
Ok... but that looks nasty when you are passed an array or an object.



Andi Gutmans wrote:


At 03:13 PM 11/27/2002 -0500, George Schlossnagle wrote:


Hmmm  any hints on how to get the variable name out of the stack? 
The code in debug_backtrace seems to only extract the value.


There's no way but I don't think it's needed. When I wrote $arg1 I 
meant the value not the name of the variable. Sorry if I wasn't clear.
Andi


George

Andi Gutmans wrote:


I'd probably go for class::function($arg1, $arg2).
Also take into consideration that the args aren't always available.

Andi

At 02:58 PM 11/27/2002 -0500, George Schlossnagle wrote:


Is there a concensus on how arguments should be printed out?

I'm shooting right now for a 'cluck' style backtrave

class::function() called at file:line


Perhaps

class::function() called at file:line
   Arguments:
   print_r(args)

??


Andi Gutmans wrote:


That'd be cool.

At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote:


I'll do it, if you want.

Andi Gutmans wrote:


At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote:


On Wed, 27 Nov 2002, Andi Gutmans wrote:

 At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote:
 On Wed, 27 Nov 2002, Miham KEREKES wrote:
 
 debug_backtrace() will be available in PHP 4.3.0 and higher.

 if someone has time to implement debug_print_backtrace() that 
would be
 cool. Using the raw debug_backtrace() is a bitch.

If you're trying to volunteer me it's not going to work :P





Damn! Maybe someone else? :)

Andi


















--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread Andi Gutmans
At 03:18 PM 11/27/2002 -0500, George Schlossnagle wrote:

Ok... but that looks nasty when you are passed an array or an object.


Yeah but backtraces tend to look nasty :)

Andi




Andi Gutmans wrote:


At 03:13 PM 11/27/2002 -0500, George Schlossnagle wrote:


Hmmm  any hints on how to get the variable name out of the stack? 
The code in debug_backtrace seems to only extract the value.


There's no way but I don't think it's needed. When I wrote $arg1 I meant 
the value not the name of the variable. Sorry if I wasn't clear.
Andi


George

Andi Gutmans wrote:


I'd probably go for class::function($arg1, $arg2).
Also take into consideration that the args aren't always available.

Andi

At 02:58 PM 11/27/2002 -0500, George Schlossnagle wrote:


Is there a concensus on how arguments should be printed out?

I'm shooting right now for a 'cluck' style backtrave

class::function() called at file:line


Perhaps

class::function() called at file:line
   Arguments:
   print_r(args)

??


Andi Gutmans wrote:


That'd be cool.

At 01:32 PM 11/27/2002 -0500, George Schlossnagle wrote:


I'll do it, if you want.

Andi Gutmans wrote:


At 07:23 PM 11/27/2002 +0100, Derick Rethans wrote:


On Wed, 27 Nov 2002, Andi Gutmans wrote:

 At 03:41 PM 11/27/2002 +0100, Derick Rethans wrote:
 On Wed, 27 Nov 2002, Miham KEREKES wrote:
 
 debug_backtrace() will be available in PHP 4.3.0 and higher.

 if someone has time to implement debug_print_backtrace() that 
would be
 cool. Using the raw debug_backtrace() is a bitch.

If you're trying to volunteer me it's not going to work :P





Damn! Maybe someone else? :)

Andi












--
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread Sebastian Bergmann
George Schlossnagle wrote:
 Is there a concensus on how arguments should be printed out?

  I quite like the output of

foreach ($backtrace as $step) {
if (!empty($step['args'])) {
foreach ($step['args'] as $arg) {
$args  = isset($args) ? $args . ', ' : '';
$args .= var_export($arg, true);
}
} else {
$args = '';
}

$args = str_replace(array(\n, ',)'), array('', ')'), $args);

printf(
  %s%s(%s) [%s:%s]\n,
  isset($step['class']) ? $step['class'] . '::' : '',
  $step['function'],
  $args,
  $step['file'],
  $step['line']
);
}

-- 
  Sebastian Bergmann
  http://sebastian-bergmann.de/ http://phpOpenTracker.de/

  Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DEV] call_stack

2002-11-27 Thread George Schlossnagle
Here's first shot at a patch.  The output it generates is ugly as sin if 
you use objects though.  I though about flattening them out, but that 
gets long and nasty (and requires specialized print functions which 
while easy seem to be of marginal use elsewhere.)

George


Index: Zend/zend_builtin_functions.c
===
RCS file: /repository/Zend/zend_builtin_functions.c,v
retrieving revision 1.127
diff -u -3 -r1.127 zend_builtin_functions.c
--- Zend/zend_builtin_functions.c   27 Nov 2002 20:11:39 -  1.127
+++ Zend/zend_builtin_functions.c   27 Nov 2002 22:42:57 -
@@ -68,6 +68,7 @@
 static ZEND_FUNCTION(get_extension_funcs);
 static ZEND_FUNCTION(get_defined_constants);
 static ZEND_FUNCTION(debug_backtrace);
+static ZEND_FUNCTION(debug_print_backtrace);
 #if ZEND_DEBUG
 static ZEND_FUNCTION(zend_test_func);
 #endif
@@ -122,6 +123,7 @@
ZEND_FE(get_extension_funcs,NULL)
ZEND_FE(get_defined_constants,  NULL)
ZEND_FE(debug_backtrace,NULL)
+   ZEND_FE(debug_print_backtrace,  NULL)
 #if ZEND_DEBUG
ZEND_FE(zend_test_func, NULL)
 #endif
@@ -1171,6 +1173,151 @@
add_next_index_zval(arg_array, *arg);
}
return arg_array;
+}
+
+
+void debug_print_backtrace_args(zval *arg_array) 
+{
+zval **tmp;
+HashPosition iterator;
+int i = 0;
+
+zend_hash_internal_pointer_reset_ex(arg_array-value.ht, iterator);
+while (zend_hash_get_current_data_ex(arg_array-value.ht, (void **) tmp, 
+iterator) == SUCCESS) {
+   if(i++) {
+   ZEND_PUTS(,);
+   }
+   zend_print_zval_r(*tmp, 4);
+   zend_hash_move_forward_ex(arg_array-value.ht, iterator);
+}
+}
+
+/* {{{ proto void debug_backtrace(void)
+   Prints out a backtrace */
+ZEND_FUNCTION(debug_print_backtrace)
+{
+   zend_execute_data *ptr;
+   int lineno;
+   char *function_name;
+   char *filename;
+   char *class_name;
+   char *call_type;
+   char *include_filename = NULL;
+   zval *stack_frame;
+   zval *arg_array;
+   void **cur_arg_pos = EG(argument_stack).top_element;
+   void **args = cur_arg_pos;
+   int arg_stack_consistent = 0;
+   int frames_on_stack = 0;
+   int indent = 0;
+   int i;
+
+   if (ZEND_NUM_ARGS()) {
+   ZEND_WRONG_PARAM_COUNT();
+   }
+
+   while (--args = EG(argument_stack).elements) {
+   if (*args--) {
+   break;
+   }
+   args -= *(ulong*)args;
+   frames_on_stack++;
+
+   if (args == EG(argument_stack).elements) {
+   arg_stack_consistent = 1;
+   break;
+   }
+   }
+
+   ptr = EG(current_execute_data);
+
+   /* skip debug_backtrace() */
+   ptr = ptr-prev_execute_data;
+   cur_arg_pos -= 2;
+   frames_on_stack--;
+
+   array_init(return_value);
+
+   while (ptr) {
+   if (ptr-op_array) {
+   filename = ptr-op_array-filename;
+   lineno = ptr-opline-lineno;
+   } else {
+   filename = NULL;
+   }
+
+   function_name = ptr-function_state.function-common.function_name;
+
+   if (function_name) {
+   if (ptr-ce) {
+   class_name = ptr-ce-name;
+   call_type = ::;
+   } else if (ptr-object.ptr) {
+   class_name = ptr-object.ptr-value.obj.ce-name;
+   call_type = -;
+   } else {
+   class_name = NULL;
+   call_type = NULL;
+   }
+   if ((! ptr-opline) || ((ptr-opline-opcode == 
+ZEND_DO_FCALL_BY_NAME) || (ptr-opline-opcode == ZEND_DO_FCALL))) {
+   if (arg_stack_consistent  (frames_on_stack  0)) {
+   arg_array = 
+debug_backtrace_get_args(cur_arg_pos TSRMLS_CC);
+   frames_on_stack--;
+   }
+   }   
+   } else {
+   /* i know this is kinda ugly, but i'm trying to avoid extra 
+cycles in the main execution loop */
+   zend_bool build_filename_arg = 1;
+
+   switch (ptr-opline-op2.u.constant.value.lval) {
+   case ZEND_EVAL:
+   function_name = eval;
+   build_filename_arg = 0;
+   break;
+   case ZEND_INCLUDE:
+   function_name = include;
+   

Re: [PHP-DEV] call_stack

2002-11-27 Thread George Schlossnagle
And here is a version which flattens the calling args onto a single line 
(similar to sebastians usersapce script).  Longer, but a bit prettier 
output.



Index: Zend/zend.c
===
RCS file: /repository/Zend/zend.c,v
retrieving revision 1.163
diff -u -3 -r1.163 zend.c
--- Zend/zend.c 17 Nov 2002 13:26:36 -  1.163
+++ Zend/zend.c 27 Nov 2002 23:07:00 -
@@ -138,6 +138,35 @@
 }
 
 
+static void print_flat_hash(HashTable *ht)
+{
+   zval **tmp;
+   char *string_key;
+   HashPosition iterator;
+   ulong num_key;
+   uint str_len;
+   int i = 0;
+
+   zend_hash_internal_pointer_reset_ex(ht, iterator);
+   while (zend_hash_get_current_data_ex(ht, (void **) tmp, iterator) == 
+SUCCESS) {
+   if(i++  0) {
+   ZEND_PUTS(,);
+   }
+   ZEND_PUTS([);
+   switch (zend_hash_get_current_key_ex(ht, string_key, str_len, 
+num_key, 0, iterator)) {
+   case HASH_KEY_IS_STRING:
+   ZEND_PUTS(string_key);
+   break;
+   case HASH_KEY_IS_LONG:
+   zend_printf(%ld, num_key);
+   break;
+   }
+   ZEND_PUTS(] = );
+   zend_print_flat_zval_r(*tmp);
+   zend_hash_move_forward_ex(ht, iterator);
+   }
+}
+
 ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_copy)
 {
if (expr-type==IS_STRING) {
@@ -215,6 +244,43 @@
 }
 
 
+ZEND_API void zend_print_flat_zval_r(zval *expr)
+{
+   zend_write_func_t write_func = zend_write;
+
+   switch(expr-type) {
+   case IS_ARRAY:
+   ZEND_PUTS(Array ();
+   if (++expr-value.ht-nApplyCount1) {
+   ZEND_PUTS( *RECURSION*);
+   expr-value.ht-nApplyCount--;
+   return;
+   }
+   print_flat_hash(expr-value.ht);
+   ZEND_PUTS());
+   expr-value.ht-nApplyCount--;
+   break;
+   case IS_OBJECT:
+   {
+   zend_object *object = Z_OBJ_P(expr);
+
+   if (++object-properties-nApplyCount1) {
+   ZEND_PUTS( *RECURSION*);
+   object-properties-nApplyCount--;
+   return;
+   }
+   zend_printf(%s Object (, object-ce-name);
+   print_flat_hash(object-properties);
+   ZEND_PUTS());
+   object-properties-nApplyCount--;
+   break;
+   }
+   default:
+   zend_print_variable(expr);
+   break;
+   }
+}
+
 ZEND_API void zend_print_zval_r(zval *expr, int indent)
 {
zend_print_zval_r_ex(zend_write, expr, indent);
@@ -253,6 +319,7 @@
break;
}
 }
+
 
 
 static FILE *zend_fopen_wrapper(const char *filename, char **opened_path)
Index: Zend/zend.h
===
RCS file: /repository/Zend/zend.h,v
retrieving revision 1.166
diff -u -3 -r1.166 zend.h
--- Zend/zend.h 17 Nov 2002 13:26:36 -  1.166
+++ Zend/zend.h 27 Nov 2002 23:07:00 -
@@ -383,6 +383,7 @@
 ZEND_API int zend_print_zval(zval *expr, int indent);
 ZEND_API int zend_print_zval_ex(zend_write_func_t write_func, zval *expr, int indent);
 ZEND_API void zend_print_zval_r(zval *expr, int indent);
+ZEND_API void zend_print_flat_zval_r(zval *expr);
 ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int 
indent);
 ZEND_API void zend_output_debug_string(zend_bool trigger_break, char *format, ...);
 
Index: Zend/zend_builtin_functions.c
===
RCS file: /repository/Zend/zend_builtin_functions.c,v
retrieving revision 1.127
diff -u -3 -r1.127 zend_builtin_functions.c
--- Zend/zend_builtin_functions.c   27 Nov 2002 20:11:39 -  1.127
+++ Zend/zend_builtin_functions.c   27 Nov 2002 23:07:00 -
@@ -68,6 +68,7 @@
 static ZEND_FUNCTION(get_extension_funcs);
 static ZEND_FUNCTION(get_defined_constants);
 static ZEND_FUNCTION(debug_backtrace);
+static ZEND_FUNCTION(debug_print_backtrace);
 #if ZEND_DEBUG
 static ZEND_FUNCTION(zend_test_func);
 #endif
@@ -122,6 +123,7 @@
ZEND_FE(get_extension_funcs,NULL)
ZEND_FE(get_defined_constants,  NULL)
ZEND_FE(debug_backtrace,NULL)
+   ZEND_FE(debug_print_backtrace,  NULL)
 #if ZEND_DEBUG