xdebug / vscode-php-debug

PHP Debug Adapter for Visual Studio Code 🐞⛔
MIT License
786 stars 177 forks source link

Remote host debugging not working #14

Closed mogarick closed 8 years ago

mogarick commented 8 years ago

I'm trying to make this work with the zero config chrome extension for debug but it doesn't stop on the breakpoints. I can see in the callstack that something happened but it then disappears. I also have a custom local domain (not localhost) and I'm using an idekey value. Are this options and way of debugging currently supported?

felixfbecker commented 8 years ago

remote host debugging will come in the next update, but as long as the source files are on your PC it should work currently. You dont need a chrome extension if you set xdebug.remote_autostart, I dont know if it also works with the extension.

felixfbecker commented 8 years ago

Could you please set xdebug.remote_log = /path/to/logfile in your php.ini and post the logs you get?

mogarick commented 8 years ago

Hi, So maybe the problem is the server is on a VM on my Computer. The files are on my computer but they're accessed from a nginx + php5-fpm Vagrant VM (homestead) with mapping to the same directory. So this qualifies as remote host debugging I guess. Am I right?

There is no log output in the debug file. Only this:

Log opened at 2016-01-14 15:39:01
I: Connecting to configured address/port: localhost:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="dbgp://stdin" language="PHP" protocol_version="1.0" appid="1969"><engine version="2.3.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>

-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

Log closed at 2016-01-14 15:41:02

this is the debug config in my /etc/php5/fpm/conf.d/20-xdebug.ini file

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_log=/var/log/xdebug.log
xdebug.remote_port = 9000
xdebug.max_nesting_level = 512

This config works without a hitch for intelliJ Idea without any additional debug config setup. I just click on the "Listening for PHP Debug Connections", enable the debug extension in chrome, go to my local domain URL and the IDE catches the connection and asks for confirmation. Then it's just a matter of navigate my app to a point where there's a break point and the the IDE stops there an debugging begins.

This doesn't happen with your VSCode extension. I start the debugging clicking the play icon and when navigating in my app I only see very short lived entries in the call stack pane that show and alms immediately go away and never stops in breakpoints.

felixfbecker commented 8 years ago

You are right, if it is running in a VM that means the file paths in VS Code and in XDebug differ, which is not supported in the currently released version (but is on master already). xdebug.remote_autoconnect is just for the purpose of remote host debugging. But your remote log confuses me:

fileuri="dbgp://stdin"

See, XDebug would normally report a file:// uri with the entered script. Instead, it is using the dbgp:// protocol to indicate a virtual source, which is stdin (and not implemented atm, because I cant think of an example where this is needed). Any idea why it is reporting stdin as source? What is the log when you use ItelliJ debugger?

mogarick commented 8 years ago

The thing is the debugger is not getting updated for the activities. It only has the entry I indicated in my last post and nothing else has been written on it since then. I have been debugging at IntelliJ, navigated the app with the browser debug extension enabled and nothing gets written to the log.

I tried to edit the lauch.json file addind the var stopOnEntry: true and started the debugger. That makes the call stack to start being filled with requests but nothing else happens. I can continues using the app wit debug enabled in browser and nothing. The interesting thing is that I can't not stop the debugger after that. Nothing happens when I click on stop. If i click on Continua I get this error every time:

request 'continue': exception while processing request (exception: Cannot read property 'sendRunCommand' of null)

felixfbecker commented 8 years ago

Yeah that is because we are trying to send a run command even though we dont have a connection yet.

I really need to see some logs to help you... Are you sure that

Also, please

mogarick commented 8 years ago

The server was properly restarted by means of command sudo service php5-fpm restart and I even restarted the homestead VM but I don't know why it doesn't log anything in the file. I only have logs for nginx and the php5-fpm services but there's nothing related to xdebug in them.

The xdebug version is the one that comes with the homestead vm. I can't upgrade in this moment because of a project I'm working on.

I don't get any kind of xdebug logs with intelliJ either.

here are the phpinfo section regarding xdebug in my homestead vm.

screen shot 2016-01-14 at 16 32 20 screen shot 2016-01-14 at 16 32 37 screen shot 2016-01-14 at 16 32 47

felixfbecker commented 8 years ago

The settings seem fine. I don't know why you cannot get logs, but your setup will not work currently anyway because remote host debugging is not released yet.

If you want to try out the feature, what you could do is clone this repo, put it in your extension folder and run npm install and npm run compile. Then set localSourceRoot and serverSourceRoot settings like explained in the readme.

mogarick commented 8 years ago

Thank you. I'll try it later and keep you informed about the results. When are you planing to release this feature oficially? :)

felixfbecker commented 8 years ago

I initially thought about releasing it together with conditional breakpoints after the Code January iteration. But I might actually release it earlier. I just had some problems with debugging lately and dont want to push a buggy update, and there are still open issues and PR

felixfbecker commented 8 years ago

@mogarick Just pushed an important commit, you might want to pull that

mogarick commented 8 years ago

I'll check it out Thank you! :)

mogarick commented 8 years ago

Hi again @felixfbecker I tried the new version but there was no luck. Here's what I did:

0.1. Removed current extension version previously installed from VS Code Extensions commands. 0.2. Closed VS Code 0.3 Disabled xdebug chrome browser extension

  1. cd ~/.vscode/extensions
  2. git clone https://github.com/felixfbecker/vscode-php-debug.git
  3. cd vscode-php-debug
  4. npm install
  5. npm run compile
  6. Open VS Code and checked the extension was registered / detected.
  7. Set a breakpoint in on of my files
  8. Click on Debug Icon from VS Code tool bar (left) and then click on gear icon to open launch.json
  9. Added the 2 lines for remote debugging. Heres is the file contents:
{
    "version": "0.2.0",

    "configurations": [
        {

            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",            
            "port": 9000,
            "serverSourceRoot": "/home/vagrant/projects/myproject/Development/cigniter/coin",
            "localSourceRoot": "./"

        }
    ]
}
  1. Click on the Play Icon
  2. Opened my browser and went to my app url: http://myproject.local/coin
  3. Navigate to functionality where the break point was set
  4. The code executed but VSCode didn't stop at break point. I only saw short-lived elements in call stack but that was it, no stop and then they disappeared almost immediately.

Here's a Screenshot where you can see my break point and the extension running and listening:

screen shot 2016-01-15 at 13 01 51

Here's again my xdebug config section for php.ini

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_log=/var/log/xdebug.log
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.max_nesting_level = 512

My xdebug file has more content but I'm still confused about it because some times it works and some times nothing gets written on it while debugging.

Log opened at 2016-01-14 15:39:01
I: Connecting to configured address/port: localhost:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="dbgp://stdin" language="PHP" protocol_version="1.0" appid="1969"><engine version="2.3.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>

-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

Log closed at 2016-01-14 15:41:02

Log opened at 2016-01-14 23:09:02
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 10.0.2.2:9000. :-|
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="dbgp://stdin" language="PHP" protocol_version="1.0" appid="2849" idekey="inversa"><engine version="2.3.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>

<- feature_set -i 0 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="0" feature="show_hidden" success="1"></response>

<- feature_set -i 1 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_depth" success="1"></response>

<- feature_set -i 2 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_children" success="1"></response>

<- status -i 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="3" status="starting" reason="ok"></response>

<- step_into -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>

<- eval -i 5 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="5"><error code="5"><message><![CDATA[command is not available]]></message></error></response>

Log closed at 2016-01-14 23:09:02

Log opened at 2016-01-14 23:39:01
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 10.0.2.2:9000. :-|
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="dbgp://stdin" language="PHP" protocol_version="1.0" appid="2896" idekey="inversa"><engine version="2.3.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>

<- feature_set -i 0 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="0" feature="show_hidden" success="1"></response>

<- feature_set -i 1 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_depth" success="1"></response>

<- feature_set -i 2 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_children" success="1"></response>

<- status -i 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="3" status="starting" reason="ok"></response>

<- step_into -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>

<- eval -i 5 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="5"><error code="5"><message><![CDATA[command is not available]]></message></error></response>

Log closed at 2016-01-14 23:39:01

Log opened at 2016-01-15 00:09:01
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 10.0.2.2:9000. :-|
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="dbgp://stdin" language="PHP" protocol_version="1.0" appid="2931" idekey="inversa"><engine version="2.3.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>

<- feature_set -i 0 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="0" feature="show_hidden" success="1"></response>

<- feature_set -i 1 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_depth" success="1"></response>

<- feature_set -i 2 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_children" success="1"></response>

<- status -i 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="3" status="starting" reason="ok"></response>

<- step_into -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>

<- eval -i 5 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="5"><error code="5"><message><![CDATA[command is not available]]></message></error></response>

Log closed at 2016-01-15 00:09:01

Log opened at 2016-01-15 00:39:01
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 10.0.2.2:9000. :-|
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="dbgp://stdin" language="PHP" protocol_version="1.0" appid="2984"><engine version="2.3.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>

<- feature_set -i 0 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="0" feature="show_hidden" success="1"></response>

<- feature_set -i 1 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_depth" success="1"></response>

<- feature_set -i 2 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_children" success="1"></response>

<- status -i 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="3" status="starting" reason="ok"></response>

<- step_into -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>

<- eval -i 5 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="5"><error code="5"><message><![CDATA[command is not available]]></message></error></response>

Log closed at 2016-01-15 00:39:01

Log opened at 2016-01-15 04:39:03
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 10.0.2.2:9000. :-|
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="dbgp://stdin" language="PHP" protocol_version="1.0" appid="3707"><engine version="2.3.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>

<- feature_set -i 0 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="0" feature="show_hidden" success="1"></response>

<- feature_set -i 1 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_depth" success="1"></response>

<- feature_set -i 2 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_children" success="1"></response>

<- status -i 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="3" status="starting" reason="ok"></response>

<- step_into -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>

<- eval -i 5 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="5"><error code="5"><message><![CDATA[command is not available]]></message></error></response>

Log closed at 2016-01-15 04:39:03

Log opened at 2016-01-15 05:09:01
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 10.0.2.2:9000. :-|
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="dbgp://stdin" language="PHP" protocol_version="1.0" appid="3751"><engine version="2.3.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>

<- feature_set -i 0 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="0" feature="show_hidden" success="1"></response>

<- feature_set -i 1 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_depth" success="1"></response>

<- feature_set -i 2 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_children" success="1"></response>

<- status -i 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="3" status="starting" reason="ok"></response>

<- step_into -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>

<- eval -i 5 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="5"><error code="5"><message><![CDATA[command is not available]]></message></error></response>

Log closed at 2016-01-15 05:09:01

Log opened at 2016-01-15 06:09:02
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 10.0.2.2:9000. :-|
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="dbgp://stdin" language="PHP" protocol_version="1.0" appid="3831"><engine version="2.3.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>

<- feature_set -i 0 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="0" feature="show_hidden" success="1"></response>

<- feature_set -i 1 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_depth" success="1"></response>

<- feature_set -i 2 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_children" success="1"></response>

<- status -i 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="3" status="starting" reason="ok"></response>

<- step_into -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>

<- eval -i 5 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="5"><error code="5"><message><![CDATA[command is not available]]></message></error></response>

Log closed at 2016-01-15 06:09:02

Log opened at 2016-01-15 06:39:02
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 10.0.2.2:9000. :-|
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="dbgp://stdin" language="PHP" protocol_version="1.0" appid="3905"><engine version="2.3.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>

<- feature_set -i 0 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="0" feature="show_hidden" success="1"></response>

<- feature_set -i 1 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_depth" success="1"></response>

<- feature_set -i 2 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_children" success="1"></response>

<- status -i 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="3" status="starting" reason="ok"></response>

<- step_into -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>

<- eval -i 5 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="5"><error code="5"><message><![CDATA[command is not available]]></message></error></response>

Log closed at 2016-01-15 06:39:02

Log opened at 2016-01-15 07:09:01
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 10.0.2.2:9000. :-|
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="dbgp://stdin" language="PHP" protocol_version="1.0" appid="3939"><engine version="2.3.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>

<- feature_set -i 0 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="0" feature="show_hidden" success="1"></response>

<- feature_set -i 1 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_depth" success="1"></response>

<- feature_set -i 2 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_children" success="1"></response>

<- status -i 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="3" status="starting" reason="ok"></response>

<- step_into -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>

<- eval -i 5 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="5"><error code="5"><message><![CDATA[command is not available]]></message></error></response>

Log closed at 2016-01-15 07:09:01

Log opened at 2016-01-15 15:09:02
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 10.0.2.2:9000. :-|
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="dbgp://stdin" language="PHP" protocol_version="1.0" appid="4778"><engine version="2.3.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>

<- feature_set -i 0 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="0" feature="show_hidden" success="1"></response>

<- feature_set -i 1 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_depth" success="1"></response>

<- feature_set -i 2 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_children" success="1"></response>

<- status -i 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="3" status="starting" reason="ok"></response>

<- step_into -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>

<- eval -i 5 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="5"><error code="5"><message><![CDATA[command is not available]]></message></error></response>

Log closed at 2016-01-15 15:09:04

Log opened at 2016-01-15 15:39:02
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: 10.0.2.2:9000. :-|
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="dbgp://stdin" language="PHP" protocol_version="1.0" appid="4809"><engine version="2.3.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2015 by Derick Rethans]]></copyright></init>

<- feature_set -i 0 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="0" feature="show_hidden" success="1"></response>

<- feature_set -i 1 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_depth" success="1"></response>

<- feature_set -i 2 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_children" success="1"></response>

<- status -i 3
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="3" status="starting" reason="ok"></response>

<- step_into -i 4
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>

<- eval -i 5 -- aXNzZXQoJF9TRVJWRVJbJ1BIUF9JREVfQ09ORklHJ10p
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="5"><error code="5"><message><![CDATA[command is not available]]></message></error></response>

Log closed at 2016-01-15 15:39:02

Log opened at 2016-01-15 18:39:01
I: Connecting to configured address/port: localhost:9000.
E: Could not connect to client. :-(
Log closed at 2016-01-15 18:39:01

Log opened at 2016-01-15 19:09:01
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: localhost:9000. :-|
E: Could not connect to client. :-(
Log closed at 2016-01-15 19:09:01

I hope you can help me to make this work because I don't like the burden of running IntelliJ for debugging PHP. It eats lots of memory resources.

felixfbecker commented 8 years ago

@mogarick Your settings seem fine. The logs unfortunately are mostly from IntelliJ, I can see the max_children gets set to 100, while this adapter sets it to 9999. But the last logs with "Could not connect to client" might be from us.

I don't know how remote_connect_back affects remote host debugging, or if you have to set remote_host. I have not tried remote host debugging (probably I will have to soon, seeing all the issues - setting up a VM and all :/), but others got it working as far as I know. @AndrewNatoli @gianugo Any ideas?

Maybe the issue is that the TCP server we set up listens on localhost and not the exact IP address.

Since there are no logs, all I can ask you to is to debug this adapter (see readme) to actually see where the issue is.

gianugo commented 8 years ago

@mogarick can you try adding  an xdebug_break() statement to your code and see if at least it starts working?@felixfbecker I'd be glad to give you access to a remote endpoint for testing. Send me an email to Gianugo.Rabellino@microsoft.com and I'll share instructions with you.

AndrewNatoli commented 8 years ago

Hey @mogarick

Can you update your php.ini and make xdebug.remote_port use a different port?

Apparently php-fpm and nginx rely on this port for communication which may explain why you're seeing stdin as the input file. Choose 9001 or something and also make that change to your launch.json in vscode.

felixfbecker commented 8 years ago

@gianugo Thanks for the offer, but I just set up my own. Remote host debugging is working fine for me, but I only tested from Windows to Windows.

felixfbecker commented 8 years ago

@mogarick I just released 1.1.0. You can update through F1 Show Outdated Extensions

mogarick commented 8 years ago

@AndrewNatoli I'll change that but I don't think it changes anything because in my config nginx and php-fpm are communicating via unix socket so the port 9000 is free AFAIK.

@gianugo I'll add it and report back the results.

Thank you for the support.

mogarick commented 8 years ago

tl;dr

I updated to the last version of vscode-php-debug and played with permissions and xdebug params in config file but I can't make it work yet.
The debugger apparently works but it doesn't make the script to really stop even though the editor shows the stop style in the break point line and for VSCode itself it really stopped. The truth is the script continued to execute and finished in the browser.

Findings

The xdebug.remote_connect_back = 1 caused vscode-php-debug to crash as soon as any PHP script got executed while navigating the app but removing this param caused vscode-php-debug to catch nothing. PHP-FPM logs showed there were permissions errors with the xdebug log file: ... PHP message: XDebug could not open the remote debug file '/var/log/xdebug.log' while reading response header from upstream, ... I fixed file permissions and then tried again.

With this config, vscode-php-debug doesn't catch a thing:

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_log=/var/log/xdebug.log
xdebug.remote_port = 9000
xdebug.max_nesting_level = 512

With this config, vscode-php-debug does appear to work but crashes a few seconds later (image attached):

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_log=/var/log/xdebug.log
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.max_nesting_level = 512

screen shot 2016-01-17 at 13 22 27

screen shot 2016-01-17 at 13 22 33

I can start the debugger again with no troubles.

With this config, vscode-php-debug does work and stops in break point

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_log=/var/log/xdebug.log
xdebug.remote_host=10.0.2.2
xdebug.remote_port = 9000
xdebug.max_nesting_level = 512

but eventhough it is "stopped" at break point, this is only virtually in VSCode because the php script continues execution and finishes in the browser. And other weird thing is that it skips the first 2 break points and stops in third one.

screen shot 2016-01-17 at 13 25 48 (stopped here) screen shot 2016-01-17 at 13 26 01 (but there were these 2 other break points before)

If I step over en VS Code nothing happens, just the php script finishes but it's weird because in fact the script already executed without stopping.

screen shot 2016-01-17 at 13 26 48

I can execute the script again in the browser and the debugger "stops" virtually again in the third break point.

@gianugo I added the function xdebug_break()and now the debugger pauses in the first break point after the function call. But the same behavior occurs I mean the virtual stop and so on.

screen shot 2016-01-17 at 13 54 06

Other problem: if I click the Stop button the new problem is that debugger can't stop. screen shot 2016-01-17 at 13 35 28

The way I can stop it is clicking Restart button and then bang!: Debug adapter process has terminated unexpectedly.

screen shot 2016-01-17 at 13 36 21

After that any attempt to start the debugger again fails with the same error: Debug adapter process has terminated unexpectedly. I need to reopen VSCode to restablish the correct debug behavior.

Here is the debug file attached:

xdebug-20160117.txt

@AndrewNatoli as you can read, the port was not the problem but I also changed it to 9004 for experimentation and the same problems happened.

felixfbecker commented 8 years ago

@mogarick Great that you got the logs working. I'm taking a look at it right now, I can see that the first encounter between VS Code and XDebug is at line 745. Whats weird is that all commands are sent multiple times. But from your screenshots I can see that you actually got a whole lot of requests going in parallel. These are emulated as threads for VS Code, and as mentioned in the readme, this is still extremely buggy because of some issues in VS Code (any maybe some are my fault too, the lines are blurry). I would ask you to create a dead-simple test.php instead with just a few echo statements and to put that in your webroot and test against that, so we can narrow down the issue.

felixfbecker commented 8 years ago

These logs confuse me:


<- breakpoint_set -i 9 -t line -f file:///home/vagrant/projects/AlexHuerta/Inversa/Development/cigniter/coin/inversa/models/detattendances.php -n 72
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="9" id="62730004"></response>

<- breakpoint_set -i 6 -t line -f file:///home/vagrant/projects/AlexHuerta/Inversa/Development/cigniter/coin/inversa/models/detattendances.php -n 74
<- breakpoint_set -i 10 -t exception -x *
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="10" id="62730005"></response>

-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="6" id="62720001"></response>
felixfbecker commented 8 years ago

@mogarick I can reproduce your issue with not stopping on breakpoints. I'll look into it.

felixfbecker commented 8 years ago

@mogarick Could you try latest master please, with a simple php file?

mogarick commented 8 years ago

It works @felixfbecker!!! (At least in my initial test with the same file ;) )

Here you have a clean log for a session with a very simple PHP file for whatever purposes you may need it.

Thank you!! :+1: :smile:

xdebug.txt

felixfbecker commented 8 years ago

I will make another patch release then :)

hgouveia commented 7 years ago

This bug is back, not working for me again

URL : http://hackerrank.app/test.php?XDEBUG_SESSION_START=VSCODE

this is my xdebug.txt

I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to 192.168.10.1:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///home/vagrant/Php/Joyal/hackerrank/test.php" language="PHP" xdebug:language_version="7.1.3-2+deb.sury.org~xenial+1" protocol_version="1.0" appid="2496" idekey="VSCODE"><engine version="2.5.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2017 by Derick Rethans]]></copyright></init>

-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

Log closed at 2017-05-10 17:08:42

/etc/php/7.1/mods-available/xdebug.ini

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.max_nesting_level = 512
xdebug.remote_log = /tmp/xdebug.txt

not breaking, i also try adding

xdebug.remote_enable=1
xdebug.remote_host=192.168.10.1
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true

also changing the port to 9001 and nothing

image

Php Info

xdebug
xdebug support  enabled
Version     2.5.1
IDE Key     VSCODE
Supported protocols Revision
DBGp - Common DeBuGger Protocol     $Revision: 1.145 $
Directive   Local Value Master Value
xdebug.auto_trace   Off Off
xdebug.cli_color    0   0
xdebug.collect_assignments  Off Off
xdebug.collect_includes On  On
xdebug.collect_params   0   0
xdebug.collect_return   Off Off
xdebug.collect_vars Off Off
xdebug.coverage_enable  On  On
xdebug.default_enable   On  On
xdebug.dump.COOKIE  no value    no value
xdebug.dump.ENV no value    no value
xdebug.dump.FILES   no value    no value
xdebug.dump.GET no value    no value
xdebug.dump.POST    no value    no value
xdebug.dump.REQUEST no value    no value
xdebug.dump.SERVER  no value    no value
xdebug.dump.SESSION no value    no value
xdebug.dump_globals On  On
xdebug.dump_once    On  On
xdebug.dump_undefined   Off Off
xdebug.extended_info    On  On
xdebug.file_link_format no value    no value
xdebug.force_display_errors Off Off
xdebug.force_error_reporting    0   0
xdebug.halt_level   0   0
xdebug.idekey   no value    no value
xdebug.max_nesting_level    512 512
xdebug.max_stack_frames -1  -1
xdebug.overload_var_dump    2   2
xdebug.profiler_aggregate   Off Off
xdebug.profiler_append  Off Off
xdebug.profiler_enable  Off Off
xdebug.profiler_enable_trigger  Off Off
xdebug.profiler_enable_trigger_value    no value    no value
xdebug.profiler_output_dir  /tmp    /tmp
xdebug.profiler_output_name cachegrind.out.%p   cachegrind.out.%p
xdebug.remote_addr_header   no value    no value
xdebug.remote_autostart Off Off
xdebug.remote_connect_back  On  On
xdebug.remote_cookie_expire_time    3600    3600
xdebug.remote_enable    On  On
xdebug.remote_handler   dbgp    dbgp
xdebug.remote_host  localhost   localhost
xdebug.remote_log   /tmp/xdebug.txt /tmp/xdebug.txt
xdebug.remote_mode  req req
xdebug.remote_port  9000    9000
xdebug.scream   Off Off
xdebug.show_error_trace Off Off
xdebug.show_exception_trace Off Off
xdebug.show_local_vars  Off Off
xdebug.show_mem_delta   Off Off
xdebug.trace_enable_trigger Off Off
xdebug.trace_enable_trigger_value   no value    no value
xdebug.trace_format 0   0
xdebug.trace_options    0   0
xdebug.trace_output_dir /tmp    /tmp
xdebug.trace_output_name    trace.%c    trace.%c
xdebug.var_display_max_children 128 128
xdebug.var_display_max_data 512 512
xdebug.var_display_max_depth    3   3

launch.json

image

felixfbecker commented 7 years ago

Please open a new issue.