【问题标题】:xdebug profiling from command line doesn't work从命令行进行 xdebug 分析不起作用
【发布时间】:2014-09-23 23:44:55
【问题描述】:

当我尝试运行 xdebug 分析(从命令行)时,脚本立即终止。我没有收到任何反馈。 (如果我在关闭 xdebug 配置文件的情况下运行脚本,那么脚本的执行与我预期的完全一样。)我在 Centos 6 中运行 php 5.4.13。

我尝试了两种不同的方法来启用分析:编辑 php.ini,以及在执行脚本时使用 -d 标志。

我的 php.ini 的相关部分如下所示:

[xdebug]
zend_extension="/usr/lib64/php/modules/xdebug.so"
xdebug.remote_enable = 1
xdebug.default_enable = 0
xdebug.profiler_output_dir = "/tmp/profiling"
# xdebug.profiler_enable = 1  # I uncomment this line to try to profile my script

我使用这两个命令之一调用脚本(并确保 ini 文件行被适当地注释掉(或不注释掉)。

$> /usr/bin/php scripts/daemon/PostProcess.php -c 4

$> /usr/bin/php -d xdebug.profiler_enable=1 scripts/daemon/PostProcess.php -c 4

我确信该设置被正确解释。

$> php -d xdebug.profiler_enable=1 --info | grep profile | less

xdebug.profiler_aggregate => Off => Off
xdebug.profiler_append => Off => Off
xdebug.profiler_enable => On => On
xdebug.profiler_enable_trigger => Off => Off
xdebug.profiler_output_dir => /tmp/profiling => /tmp/profiling
xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p

xdebug 可以正常进行调试。以下命令可以正常工作:

$> /usr/bin/php -d xdebug.remote_autostart=On -d xdebug.remote_host=A.B.C.D scripts/daemon/PostProcess.php -c 4

有什么想法吗?

【问题讨论】:

  • 检查对 /tmp/profiling 的写入权限?
  • 分析生成大量文件可能是磁盘空间。运行前检查了吗?
  • 如果你尝试与其他 xdebug / php 版本相同呢?

标签: php xdebug


【解决方案1】:

尝试使用 -ddisplay_errors=1 运行脚本以强制显示 PHP 错误。示例:

/usr/bin/php -ddisplay_errors=1 -d xdebug.profiler_enable=1 scripts/daemon/PostProcess.php -c 4

一般来说,当我遇到您所描述的问题时,我的代码中有一个错误,并且 display_errors 默认处于关闭状态,以防止可能在错误消息中泄露敏感细节。因此,带有错误的消息被隐藏。看看这是否为您提供了纠正问题的信息。

【讨论】:

    猜你喜欢
    • 2013-11-20
    • 2017-12-07
    • 2013-06-14
    • 2012-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多