eclipse Xdebug 忽略断点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3422433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:58:01  来源:igfitidea点击:

Xdebug ignores breakpoints

phpeclipsenetbeansxdebug

提问by enricog

I am currently trying to get Xdebugto work on our development server. As client I am using netbeans and the connection so far works without problems. But when I try to set a breakpoint within netbeans it is just getting ignored.

我目前正在尝试让Xdebug在我们的开发服务器上工作。作为客户端,我使用的是 netbeans,到目前为止连接工作没有问题。但是当我尝试在 netbeans 中设置断点时,它只是被忽略了。

And yeah, I already googled for hours and also found some questions here that perfectly fit my description: SO 1SO 2

是的,我已经用谷歌搜索了几个小时,还在这里发现了一些完全符合我描述的问题: SO 1 SO 2

But this does not seem to solve it for me. The Xdebugmodule is loaded via zend_extension=path/to/xdebug. so in the

但这似乎并不能为我解决。该Xdebug模块通过 zend_extension=path/to/xdebug 加载。所以在

/etc/php5/conf.d/xdebug.ini

/etc/php5/conf.d/xdebug.ini

I also looked at the php5/apache and php5/cli php.ini to make sure it is not loaded with extension= somewhere there. I also checked the "additional .ini files parsed" found by phpinfo() and it seems to be nowhere else loaded.

我还查看了 php5/apache 和 php5/cli php.ini 以确保它没有加载 extension= 某处。我还检查了 phpinfo() 找到的“已解析的其他 .ini 文件”,但似乎没有其他地方加载。

By executing php -m I can see the loaded Xdebug module in

通过执行 php -m 我可以看到加载的 Xdebug 模块

[PHP Modules]

[PHP Modules]

and in

并在

[Zend Modules]

[Zend Modules]

Not sure if this indicates that it is still loaded twice or if it is fine like that? Still if I remove the zend_extension=/path/to/xdebug.sofrom the conf.d/xdebug.iniit is also no longer loaded. So I really assume it is only loaded there.

不确定这是否表明它仍然被加载了两次,或者它是否很好?尽管如此,如果我zend_extension=/path/to/xdebug.so从中删除conf.d/xdebug.ini它也不再加载。所以我真的假设它只在那里加载。

If I set the remote_log option is see that Netbeansis trying to set something:

如果我设置了 remote_log 选项,就会看到它Netbeans正在尝试设置一些东西:

<- breakpoint_set -i 452 -t line -s enabled 
   -f file:///http:/development.xxx.de/users/itsame/index.php -n 15
-> <response xmlns="urn:debugger_protocol_v1"
    xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" 
          transaction_id="452" state="enabled" id="258870001">   
    </response>

But it seems to have no effect (looks pretty much the same like in the other SO questions I have posted above. But if i do a manual xdebug_break() inside the php code it handels it properly.

但它似乎没有效果(看起来与我上面发布的其他 SO 问题几乎相同。但是如果我在 php 代码中手动执行 xdebug_break() ,它会正确处理它。

PHP Version is 5.2.6 and Xdebug is 2.1. Any suggestions where I could have a look next?

PHP 版本为 5.2.6,Xdebug 为 2.1。有什么建议我可以看看下一步吗?

采纳答案by Jeroen Fiege

It looks like there is something wrong with the path to the file containing the breakpoint.

包含断点的文件的路径似乎有问题。

<- breakpoint_set -i 452 -t line -s enabled 
   -f file:///http:/development.xxx.de/users/itsame/index.php -n 15 ->

I've had a similar problem with Eclipse. Only my breakpoints in the index file were accepted and breakpoints in other files—that were included in the index—were ignored.

我在 Eclipse 上遇到了类似的问题。只有我在索引文件中的断点被接受,其他文件中的断点——包含在索引中——被忽略。

I looked in the remote_log file and saw the following:

我查看了 remote_log 文件,看到了以下内容:

<- breakpoint_set -i 260 -t line 
   -f file:///~jeroen/workspace/fieg/wp-content/plugins/fieg/fieg.php -n 22-> 
<response xmlns="urn:debugger_protocol_v1" 
   xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" 
   transaction_id="260" id="48060002"></response>

I noticed that the path for the breakpoint was all wrong. It turned out that I had to setup Port Mapping in Eclipse. After setting the correct mapping the breakpoints started working. Also my remote_log now shows the correct path:

我注意到断点的路径都是错误的。结果我不得不在 Eclipse 中设置端口映射。设置正确的映射后,断点开始工作。我的 remote_log 现在也显示了正确的路径:

<- breakpoint_set -i 333 -t line 
   -f file:///Users/jeroen/Workspace/fieg/wp-content/plugins/fieg/fieg.php -n 12->     
<response xmlns="urn:debugger_protocol_v1" 
   xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" 
   transaction_id="333" id="48080005"></response>

I'm not sure if there is an equivalent of the Eclipse Port Mapping configuration in Netbeans, but hopefully I pointed you in the good direction.

我不确定 Netbeans 中是否有等效的 Eclipse 端口映射配置,但希望我为您指出了好的方向。

回答by drstockz

For me the problem was "Project properties > Source > Web Root:" was not set (it had a default " as its value).

对我来说,问题是“项目属性 > 源 > Web 根:”没有设置(它有一个默认值)。

After setting it to be my web root on disk, the breakpoints started working.

将其设置为磁盘上的 Web 根目录后,断点开始工作。

回答by dajibs

In your php.ini file, set this directive:

在您的 php.ini 文件中,设置以下指令:

report_zend_debug = 1

I hope this help someone?

我希望这对某人有帮助?

回答by Seth Battin

The question mentioned that the xdebug.ini file exists, but does not report its contents. My default installation's file only included:

问题提到 xdebug.ini 文件存在,但没有报告其内容。我的默认安装文件只包括:

zend_extension=/usr/lib/php5/20100525/xdebug.so

But in order for debugging to actually happen, it must be enabled. Add this line:

但是为了实际进行调试,必须启用它。添加这一行:

xdebug.remote_enable=1

Then phpinfo()will report a functioning xdebug:

然后phpinfo()会报告一个正常运行的 xdebug:

enter image description here

在此处输入图片说明

回答by hserge

Go to: Project > Properties > Run Configuration > Advanced (button)

去: Project > Properties > Run Configuration > Advanced (button)

Remove all the mappings from the "Path Mapping" if you are not using Xdebug for remote debugging. This would help to fix this issue.

如果您不使用 Xdebug 进行远程调试,请从“路径映射”中删除所有映射。这将有助于解决这个问题。

回答by AmarLakhtakia

I came across this post trying to solve my xdebug problem in eclipse not breaking at break points for a web application. I found the comments herein very useful. Also, this post http://www.devside.net/wamp-server/netbeans-waiting-for-connection-netbeans-xdebug-issuecame in very handy to solve my issue. I just had to set the following flag in my relevant php.ini.

我遇到了这篇文章,试图解决我在 Eclipse 中的 xdebug 问题,而不是在 Web 应用程序的断点处中断。我发现这里的评论非常有用。此外,这篇文章http://www.devside.net/wamp-server/netbeans-waiting-for-connection-netbeans-xdebug-issue非常方便地解决了我的问题。我只需要在我的相关 php.ini 中设置以下标志。

xdebug.remote_enable=1

xdebug.remote_enable=1

xdebug would continuously wait on the session but after setting the remote debug flag the session wait issue, breaking point issue as well the xdebug log file that I had defined also started logging transactions.

xdebug 将持续等待会话,但在设置远程调试标志后,会话等待问题、断点问题以及我定义的 xdebug 日志文件也开始记录事务。

回答by pgr

Yet another possible solution, the only one that worked for me, after trying everything in this post and in many others...

在尝试了这篇文章和许多其他文章中的所有内容之后,另一种可能的解决方案,唯一对我有用的解决方案......

I'm debugging a PHP project through XDEBUG on Eclipse Neon on Windows. The source is remote Linux, mounted locally as a drive through SFTP. It's probably my own fault that this isn't set up correctly...

我正在 Windows 上的 Eclipse Neon 上通过 XDEBUG 调试 PHP 项目。源是远程 Linux,通过 SFTP 在本地安装为驱动器。设置不正确可能是我自己的错...

In Eclipse, right-click your project, then select Configure, then Add PHP Support. Immediately, the DLTK indexing started; before that it wouldn't start no matter what.

在 Eclipse 中,右键单击您的项目,然后选择Configure,然后选择Add PHP Support。DLTK 索引立即开始;在此之前,它无论如何都不会启动。

Then I had to open my source and set the breakpoints through Remote File Explorer. I hope this helps someone.

然后我不得不打开我的源代码并通过远程文件资源管理器设置断点。我希望这可以帮助别人。

回答by Oliver Schnell

I had the same problem: Eclipse breakpoints did not work, xdebug_break() did work. My problem were spaces in the path:

我遇到了同样的问题:Eclipse 断点不起作用,xdebug_break() 起作用了。我的问题是路径中的空格:

<- breakpoint_set -i 1323 -t line -f file:///Users/admin/Documents/projects/something/path%2520with%2520space/web/index.php -n 223
-> 
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="1323" id="385680235"></response>

After changing the path to something without spaces the breakpoints in Eclipse worked fine.

将路径更改为没有空格的路径后,Eclipse 中的断点工作正常。

回答by Vadim H

Solved! When creating a new project in NetBeans, I first set the root folder of the project to the WordPress theme folder of my WordPress site. So instead, I created a new project with the root of it being the root of the entire WordPress site rather than just its theme, and the breakpoints started to work. Woohoo!

解决了!在 NetBeans 中创建新项目时,我首先将项目的根文件夹设置为我的 WordPress 站点的 WordPress 主题文件夹。所以相反,我创建了一个新项目,它的根是整个 WordPress 站点的根,而不仅仅是它的主题,断点开始工作。呜呼!