FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » How to get real debug_backtrace using register_tick_function
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
How to get real debug_backtrace using register_tick_function [message #170744] Thu, 18 November 2010 13:28 Go to next message
kenorb is currently offline  kenorb
Messages: 2
Registered: November 2010
Karma: 0
Junior Member
I'm using the register_tick_function as follows:

<code>
function debugger_tick() {
global $debugger_trace;
$debugger_trace[microtime()] = debug_backtrace(TRUE);
}
</code>

Why the backtraces are always the same, from the place where I
registered function via register_tick_function() to that tick
function.
It's possible to get the backtrace of the executed code, not tick
function?
If not, are there any alternatives? Especially without adding any
additional PHP module
Re: How to get real debug_backtrace using register_tick_function [message #170745 is a reply to message #170744] Thu, 18 November 2010 13:54 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 11/18/2010 8:28 AM, kenorb wrote:
> I'm using the register_tick_function as follows:
>
> <code>
> function debugger_tick() {
> global $debugger_trace;
> $debugger_trace[microtime()] = debug_backtrace(TRUE);
> }
> </code>
>
> Why the backtraces are always the same, from the place where I
> registered function via register_tick_function() to that tick
> function.
> It's possible to get the backtrace of the executed code, not tick
> function?
> If not, are there any alternatives? Especially without adding any
> additional PHP module

I'm not sure what you're asking for. debug_backtrace is showing the
tick function, which is the code being executed in this thread.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: How to get real debug_backtrace using register_tick_function [message #170770 is a reply to message #170744] Mon, 22 November 2010 15:49 Go to previous message
kenorb is currently offline  kenorb
Messages: 2
Registered: November 2010
Karma: 0
Junior Member
On Nov 18, 1:28 pm, kenorb <ken...@gmail.com> wrote:
> I'musingtheregister_tick_functionas follows:
>
> <code>
> function debugger_tick() {
>   global $debugger_trace;
>   $debugger_trace[microtime()]  =debug_backtrace(TRUE);}
>
> </code>
>
> Why the backtraces are always the same, from the place where I
> registered function viaregister_tick_function() to that tick
> function.
> It's possible togetthe backtrace of the executed code, not tick
> function?
> If not, are there any alternatives? Especially without adding any
> additional PHP module

I just figure it out.
register_tick_function has completely different scope, so globals
aren't the same globals.
So the solution is to return the backtrace.

declare(ticks = 1);
register_tick_function('debugger_tick');
function debugger_tick($dump = FALSE) {
static $backtraces = array();
$backtraces[] = debug_backtrace(TRUE);
if ($dump) {
return $backtraces;
}
}

So every time when you need to access the backtraces, you need to pass
TRUE to the tick function.
$my_backtraces = debugger_tick(TRUE);

Probably _SESSION will work as well, but I'm not sure.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: Loading missing extensions in Windows
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Dec 18 07:01:07 GMT 2024

Total time taken to generate the page: 0.02729 seconds