Debugging in HHVM?

2019-04-19 09:38发布

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.

Are those arguments for debugging HHVM itself (or maybe the compiled PHP itself) or is it for debugging the PHP script? 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?

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.

What are the debug arguments for HHVM for, exactly, and how can I use them to debug my PHP scripts in HHVM please?

5条回答
时光不老,我们不散
2楼-- · 2019-04-19 10:09

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

查看更多
成全新的幸福
3楼-- · 2019-04-19 10:10

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.

查看更多
手持菜刀,她持情操
4楼-- · 2019-04-19 10:13

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.

查看更多
Root(大扎)
5楼-- · 2019-04-19 10:14

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

查看更多
等我变得足够好
6楼-- · 2019-04-19 10:26

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
查看更多
登录 后发表回答