简体   繁体   English

在HHVM中调试?

[英]Debugging in HHVM?

When running my PHP scripts in HHVM I see that I can pass a debug-host and debug-port arguments, but I can't seem to work out exactly what it does and how to use it. 在HHVM中运行我的PHP脚本时,我看到我可以传递调试主机和调试端口参数,但我似乎无法确切地知道它的作用以及如何使用它。

Are those arguments for debugging HHVM itself (or maybe the compiled PHP itself) or is it for debugging the PHP script? 这些参数是用于调试HHVM本身(或者可能是编译的PHP本身)还是用于调试PHP脚本? That is to say, is it for debugging the way that HHVM works, or is it for debugging as I would normally do with XDebug, say? 也就是说,它是用于调试HHVM的工作方式,还是用于调试,就像我通常使用XDebug一样,比如说?

At first I tried to connect it to my IDE that is set up for XDebug, but that doesn't seem to do anything so without going on a wild goose chase I thought I would ask here. 起初我尝试将它连接到我为XDebug设置的IDE,但这似乎没有做任何事情,所以没有进行疯狂的追逐,我想我会问这里。

What are the debug arguments for HHVM for, exactly, and how can I use them to debug my PHP scripts in HHVM please? 什么是HHVM的调试参数,确切地说,我如何使用它们来调试HHVM中的PHP脚本?

Getting remote debugging working was fairly tricky and involved some gotchas and misunderstandings of the documentation. 远程调试工作相当棘手,涉及一些问题和对文档的误解。

You have to configure what they call as "sandbox" on the server side. 您必须在服务器端配置他们称为“沙箱”的内容。

Then you have to use another instance of hhvm invoked with -m debug -h to attach the debugger to the running server. 然后,您必须使用-m debug -h调用的另一个hhvm实例将调试器附加到正在运行的服务器。 From there you can then use the full features of the debugger. 然后,您可以使用调试器的全部功能。

I wrote an article describing the process . 我写了一篇描述这个过程文章

It seems that HHVM is adding XDebug in version 3.3.0 LTS. 似乎HHVM在版本3.3.0 LTS中添加XDebug。 Clearly it's not production ready yet. 显然,它尚未准备好生产。 You can enable it by adding xdebug options listed below to your server.ini file. 您可以通过将以下列出的xdebug选项添加到server.ini文件来启用它。 It connects, but usually ends up crashing HHVM for me. 它连接,但通常最终会让HHVM崩溃。

hhvm.xdebug-not-done.enable=1
hhvm.xdebug-not-done.remote_enable=1
hhvm.xdebug-not-done.idekey="PHPSTORM"
hhvm.xdebug-not-done.remote_host="localhost"
hhvm.xdebug-not-done.remote_port=9089

Doing a little looking into this, I found this: https://github.com/dpaneda/hiphop-php/blob/master/doc/command.compiled which says: 稍微研究一下,我发现了这个: https//github.com/dpaneda/hiphop-php/blob/master/doc/command.compiled其中说:

= --debug-host = --debug-host

When running "debug" mode, specifies which HPHPi server to attach to. 运行“调试”模式时,指定要附加到哪个HPHPi服务器。

= --debug-port = --debug-port

When running "debug" mode, specifies which HPHPi server port to connect. 运行“调试”模式时,指定要连接的HPHPi服务器端口。

So apparently those were originally for the HPHPi (Hip Hop Interpreter) which was replaced by the HPVM (Hip Hop Virtual Machine). 显然那些最初用于HPHPi(Hip Hop Interpreter)的HPHPi(Hip Hop虚拟机)取代了它。

Curiously, the virtual machine help says: 奇怪的是,虚拟机帮助说:

-h [ --debug-host ] arg connect to debugger server at specified address -h [--debug-host] arg连接到指定地址的调试器服务器

–debug-port arg (=-1) connect to debugger server at specified port -debug-port arg(= -1)连接到指定端口的调试器服务器

So it appears they repurposed the CLI arguments to point to a "debugger" but have no mention of what to use their in any documentation that I can find. 因此,看起来他们重新调整了CLI参数以指向“调试器”,但没有提到在我能找到的任何文档中使用它们的内容。

I also found some of the source which sort of indicates how it works: https://github.com/facebook/hhvm/blob/5aee62fc5135b089d5c213a6ac243321555f6672/hphp/test/server/debugger/tests/test_base.inc#L6-L38 我也发现了一些哪种类型的指示源的工作原理是: https://github.com/facebook/hhvm/blob/5aee62fc5135b089d5c213a6ac243321555f6672/hphp/test/server/debugger/tests/test_base.inc#L6-L38

In Response to Lance Badger : 回应Lance Badger

3.4.0 renamed xdebug-not-done to xdebug. 3.4.0将xdebug-not-done重命名为xdebug。 The xdebug section of your php.ini should therefore look like this: 因此,php.ini的xdebug部分应如下所示:

xdebug.enable=1
xdebug.remote_enable=1
xdebug.idekey="PHPSTORM"
xdebug.remote_host="localhost"
xdebug.remote_port=9089

Sources: Issue 4348 , Pull Request 3779 资料来源: 问题4348拉动请求3779

So with pointers from cillosis, I've found the follow: 所以有了来自cillosis的指针,我发现了以下内容:

If I want to run a script from the CLI, I can just use hhvm script_name.php . 如果我想从CLI运行脚本,我可以使用hhvm script_name.php However, if I want to debug it, I can run hhvm -md script_name.php which will put me into a debugger for running the script. 但是,如果我想调试它,我可以运行hhvm -md script_name.php ,它将把我放入调试器来运行脚本。

Using -ms I can run HHVM in server mode. 使用-ms我可以在服务器模式下运行HHVM。 I believe, then, that that is what the --debug-host and --debug-port are referring to. 我相信,那就是--debug-host--debug-port所指的那个。 That is to say, if I'm running one instance of HHVM in server mode somewhere, I can connect from another instance of HHVM when it is running in debug mode. 也就是说,如果我在服务器模式的某个地方运行一个HHVM实例,我可以在调试模式下运行时从另一个HHVM实例连接。 I think. 我认为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM