Debugging in HHVM?
Asked Answered
S

5

14

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?

Simplex answered 18/10, 2013 at 16:35 Comment(0)
M
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.

Mosera answered 4/12, 2013 at 22:15 Comment(0)
G
6

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
Garrulity answered 29/9, 2014 at 18:56 Comment(3)
It seems there is something missing. Doesn't work like this for me.Mandolin
if you are using 3.4 I think they removed the xdebug-not-doneGarrulity
You're correct. I also noticed it today and posted a reply https://mcmap.net/q/806783/-debugging-in-hhvm .Mandolin
B
2

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

Bekki answered 18/10, 2013 at 16:55 Comment(2)
Interesting... from that doc and looking back at the CLI options I can run HHVM specifically in 'debug mode'... so now I have something else to go off for now. I don't know if it will get me anywhere yet but we will see. Thanks!Simplex
@Simplex An article just popped up on my radar that may also be useful labs.qandidate.com/blog/2013/10/29/…Bekki
M
2

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

Mandolin answered 28/11, 2014 at 10:17 Comment(0)
S
1

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.

Simplex answered 18/10, 2013 at 17:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.