Debugging in HHVM?

不打扰是莪最后的温柔 提交于 2019-12-05 01:07:36

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. 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. Clearly it's not production ready yet. You can enable it by adding xdebug options listed below to your server.ini file. It connects, but usually ends up crashing HHVM for me.

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
tback

In Response to Lance Badger :

3.4.0 renamed xdebug-not-done to xdebug. The xdebug section of your php.ini should therefore look like this:

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

Sources: Issue 4348, Pull Request 3779

Jeremy Harris

Doing a little looking into this, I found this: https://github.com/dpaneda/hiphop-php/blob/master/doc/command.compiled which says:

= --debug-host

When running "debug" mode, specifies which HPHPi server to attach to.

= --debug-port

When running "debug" mode, specifies which HPHPi server port to connect.

So apparently those were originally for the HPHPi (Hip Hop Interpreter) which was replaced by the HPVM (Hip Hop Virtual Machine).

Curiously, the virtual machine help says:

-h [ --debug-host ] arg connect to debugger server at specified address

–debug-port arg (=-1) connect to debugger server at specified port

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.

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

So with pointers from cillosis, I've found the follow:

If I want to run a script from the CLI, I can just use hhvm script_name.php. However, if I want to debug it, I can run hhvm -m d script_name.php which will put me into a debugger for running the script.

Using -m s I can run HHVM in server mode. I believe, then, that that is what the --debug-host and --debug-port are referring to. 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. I think.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!