Optional parameter for debug_print_backtrace()

php.internals

Andrey Hristov

22 years ago
Hi internals, what do you think about adding an optional parameter to debug_print_backtrace() (PHP 5 only) so instead of printing the stacktrace to get it as string. The information provided by debug_print_backtrace() is more than the information provided by debug_backtrace(). So if the parameter is added the function will behave just like print_r() which has second optional parameter. I have made a patch which is available here : http://hristov.com/andrey/projects/php_stuff/patches/debug_print_backtrace_as_string.diff.txt Andrey

Andi Gutmans

22 years ago
What else does debug_print_backtrace() include? If the info is more maybe we should change debug_backtrace()? In any case, in general I don't have a problem to do this. Might be nicer if we could do it without output buffering though but I haven't looked at the code to see how hard that would be. Andi At 11:56 PM 3/18/2004 +0100, Andrey Hristov wrote:

Derick Rethans

22 years ago
On Fri, 19 Mar 2004, Andi Gutmans wrote:
> What else does debug_print_backtrace() include? If the info is more maybe > we should change debug_backtrace()? > In any case, in general I don't have a problem to do this. Might be nicer > if we could do it without output buffering though but I haven't looked at > the code to see how hard that would be.
4 to 10 lines of code :) Derick

Andrey Hristov

22 years ago
Andi Gutmans wrote:
> What else does debug_print_backtrace() include? If the info is more > maybe we should change debug_backtrace()? > In any case, in general I don't have a problem to do this. Might be > nicer if we could do it without output buffering though but I haven't > looked at the code to see how hard that would be. > > Andi > > At 11:56 PM 3/18/2004 +0100, Andrey Hristov wrote: > >> Hi internals, >> what do you think about adding an optional parameter to >> debug_print_backtrace() (PHP 5 only) so instead of printing the >> stacktrace to get it as string. The information provided by >> debug_print_backtrace() is more than the information provided by >> debug_backtrace(). >> So if the parameter is added the function will behave just like >> print_r() which has second optional parameter. >> I have made a patch which is available here : >> http://hristov.com/andrey/projects/php_stuff/patches/debug_print_backtrace_as_string.diff.txt >> >> >> >> Andrey > >
Hmmm, looks I was kinda fooled by some script a month ago. I was suprised that with debug_print_backtrace() I was able to see the arguments of the stack since I haven't seen the same done by debug_backtrace(). But few minutes ago I took a look at the code of both functions and they try to extract the arguments from the stack. So this optional parameter to debug_print_backtrace() is not needed. But a question arose, in which cases the arguments from the stack will be extracted and returned?(hope this won't be treated as php-general question ;) ) I tried to simulate something with a small script with no success. Andrey

Stefan Walk

22 years ago
On Fri, Mar 19, 2004 at 10:00:16AM +0100, Andrey Hristov wrote:
> Hmmm, > looks I was kinda fooled by some script a month ago. I was suprised that > with debug_print_backtrace() I was able to see the arguments of the stack > since I haven't seen the same done by debug_backtrace(). But few minutes > ago I took a look at the code of both functions and they try to extract the > arguments from the stack. So this optional parameter to > debug_print_backtrace() is not needed. > But a question arose, in which cases the arguments from the stack will be > extracted and returned?(hope this won't be treated as php-general question > ;) ) I tried to simulate something with a small script with no success. > > > Andrey
Seems behaviour changed from PHP4 to PHP5. et@edea:~$ php -r 'function f() { var_dump(array_keys(array_shift(debug_backtrace()))); } f(1,3);' array(4) { [0]=> string(4) "file" [1]=> string(4) "line" [2]=> string(8) "function" [3]=> string(4) "args" } et@edea:~$ php5 -r 'function f() { var_dump(array_keys(array_shift(debug_backtrace()))); } f(1,3);' array(3) { [0]=> string(4) "file" [1]=> string(4) "line" [2]=> string(8) "function" } Note that if you join() the result of array_keys the args argument disappears in php4 as well... This is not mentioned in the changelog, afaik. Maybe it should be?
-- Regards, Stefan Walk <swalk@prp.physik.tu-darmstadt.de>