首页 > 解决方案 > xDebug 在 Mac 上的安装问题

问题描述

我正在遵循https://xdebug.org/docs/install指南

当我sudo make test在我的 MAC 2 中运行 PHP 版本时,根据项目需要安装了 PHP5 和 PHP7。

PHP         : /usr/local/php5/bin/php 
PHP_SAPI    : cli
PHP_VERSION : 7.2.7

它给出了以下错误

=====================================================================
EXPECTED FAILED TEST SUMMARY
---------------------------------------------------------------------
Test for bug #1530: Code coverage incorrect for last code line in a loop [tests/bug01530.phpt]  XFAIL REASON: PHP bug #76046: PHP generates "FE_FREE" opcode on the wrong line.
=====================================================================

You may have found a problem in PHP.
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP's behavior.
If you don't want to send the report immediately you can choose
option "s" to save it.  You can then email it to qa-reports@lists.php.net later.
Do you want to send this report now? [Yns]: 

我尝试了 2-3 次,但出现了同样的问题。

标签: phpmacosxdebug

解决方案


测试失败的原因很明显:

XFAIL 原因:PHP 错误#76046:PHP 在错误的行上生成“FE_FREE”操作码。

您需要修补zend_compile.cPHP 源代码(或等待固定版本)。不修补zend_compile.c测试覆盖结果可能不准确 - 但是,常见的调试应该可以工作。make test不会检查它,什么时候xdebug不会部分依赖它(测试的标题甚至明确说明了它检查错误的原因)。这是diff,它增加了CG(zend_lineno) = ast->lineno;. 这“解决了 100% 的问题”,而不仅仅是它的症状:

index f1dd49a..9c0893b 100644 (file)
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4807,6 +4807,7 @@ void zend_compile_foreach(zend_ast *ast) /* {{{ */

        zend_end_loop(opnum_fetch, &reset_node);

+       CG(zend_lineno) = ast->lineno;
        opline = zend_emit_op(NULL, ZEND_FE_FREE, &reset_node, NULL);
}
/* }}} */

此错误影响 PHP 7.0、7.1、7.2 - 至少没有报告 PHP 5.x。因为这不是一个xdebug错误,所以即使测试失败,安装也不应该比现在更糟。安装xdebug,不是sudo make test但是make && sudo make install(只make install需要sudo)。


推荐阅读