[英]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. 我试图使我的脚本使用xdebug生成输出以分析内存使用情况。 It's a CLI based script has shebang 这是一个基于CLI的脚本有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, 当我登录ssh并执行./script.php 90
并添加以下代码时,
if( $argv[1] == 90 ) {
xdebug_start_trace('/var/www/html/logs/' . rand(1,9999999) );
}
I see the output file in the logs
folder. 我在logs
文件夹中看到了输出文件。
But when I put the xdebug_start_trace
without the if
statement in production script, no output file is created. 但是当我在生产脚本中xdebug_start_trace
没有if
语句的xdebug_start_trace
时,没有创建输出文件。
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. script.php
是从另一个php文件中调用的,该文件位于另一个文件夹中,因此我在文件名中使用绝对路径,并使用exec
调用它,并将&> /dev/null &
附加到它,因此它在后台运行。
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] PHP Notice: Function trace already started in /var/www/html/script.php on line 9
[检查“编辑”获取信息]
Although, there is no code that triggers this xdebug_start_trace();
虽然,没有代码可以触发这个xdebug_start_trace();
. 。
So I put xdebug_stop_trace();
所以我把xdebug_stop_trace();
before xdebug_start_trace();
在xdebug_start_trace();
之前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 编辑:我得到了上述错误,因为我在php.ini中将auto_trace设置为On
Also, turns out that if you are append &> /dev/null &
to the command, no xdebug log is generated. 此外,事实证明,如果您追加&> /dev/null &
命令,则不会生成xdebug日志。 However, if I do &> /dev/null
(notice the last &
), xdebug generates logs. 但是,如果我执行&> /dev/null
(注意最后一个&
),xdebug会生成日志。 This is probably related to custom output xdebug must be using internally. 这可能与自定义输出有关xdebug必须在内部使用。 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. 所以我不认为你的问题与XDebug有任何关系,但这种痕迹现象只是你经常发现的随机症状。
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. 然后又发布了什么,b / c你的描述也很混乱恕我直言。
Best 最好
Raffael 拉斐尔
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.