xdebug_start_trace 行为异常 [英] xdebug_start_trace behaving strangely

查看:31
本文介绍了xdebug_start_trace 行为异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试进一步减少我的脚本内存使用量.我试图让我的脚本使用 xdebug 生成输出来分析内存使用情况.这是一个基于 CLI 的脚本,有 shebang

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] )

当我登录 ssh 并执行 ./script.php 90 并添加此代码时,

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) );
}

我在 logs 文件夹中看到了输出文件.

I see the output file in the logs folder.

但是当我将 xdebug_start_trace 不带 if 语句放入生产脚本时,不会创建任何输出文件.

But when I put the xdebug_start_trace without the if statement in production script, no output file is created.

script.php 是从另一个 php 文件调用的,放在另一个文件夹中,所以我在文件名中使用绝对路径并使用 exec 调用它并附加 &>/dev/null & 到它,所以它在后台运行.

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 注意:第 9 行/var/www/html/script.php 中的函数跟踪已经开始 [检查编辑"获取信息]

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

虽然没有代码触发这个xdebug_start_trace();.

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

所以我把xdebug_stop_trace();放在xdebug_start_trace();之前,一切正常.

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

奇怪.

我收到上述错误,因为我在 php.ini 中将 auto_trace 设置为 On

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

此外,事实证明,如果您附加 &>/dev/null & 到命令,没有生成 xdebug 日志.但是,如果我执行 &>/dev/null (注意最后一个 & ),xdebug 生成日志.这可能与 xdebug 必须在内部使用的自定义输出有关.不过不确定.

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.

这篇关于xdebug_start_trace 行为异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆