开发者

xdebug_start_trace behaving strangely

I'm trying to reduce my script memory usage even more. I am trying to make my script generate output with xdebug to analyse the memory usage. It's a CLI based script has shebang

#!/usr/local/bin/php -q

I pass a parameter to it and check it with

$argc > 1 && is_numeric( $argv[1] )

When I login to ssh and do ./script.php 90 and add this code,

if( $argv[1] == 90 ) {
       xdebug_start_trace('/var/www/html/logs/' . rand(1,9999999) );
}

I see the output file in the logs folder.

But when I put the xdebug_开发者_JS百科start_trace without the if statement in production script, no output file is created.

The script.php is called from another php file, placed in another folder, so I use absolute path in the filename and call it using exec and append &> /dev/null & to it, so it runs in the background.

This is driving me crazy! Help, guys!


Don't know why this occurred but I got an error

PHP Notice: Function trace already started in /var/www/html/script.php on line 9 [Check "Edit" for info]

Although, there is no code that triggers this xdebug_start_trace();.

So I put xdebug_stop_trace(); before xdebug_start_trace();, everything works fine.

Strange.

Edit: I was getting the above error as I had set auto_trace to On in php.ini

Also, turns out that if you are append &> /dev/null & to the command, no xdebug log is generated. However, if I do &> /dev/null (notice the last & ), xdebug generates logs. This is probably related to custom output xdebug must be using internally. Not sure, though.


You mean ...

if( $argv[1] == 90 ) {
       xdebug_start_trace('/var/www/html/logs/' . rand(1,9999999) );
}

... leads to a trace-file and ...

xdebug_start_trace('/var/www/html/logs/' . rand(1,9999999) );

... just leaving out the condiional statement gives you none?

And well, I really cannot believe that the tracing starts out of no where ... so there has to be a function call somewhere. Given your description it seems like your setup is pretty messed up. So I don't think your problem is in any way related to XDebug, but this trace-phenomenon is just a random symptom you happend to notice.

Try to set up a scripting which is as simple as possible and still gives you this. Then post again what's going on, b/c your description is also pretty confusing IMHO.

Best

Raffael

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜