Holly
Holly

Reputation: 7752

xDebug on Sublime text does not seem to be working properly

I've installed Xdebug on a Vagrant guest Ubuntu 14.04 system and have set it up to work with SublimeText3 on my OSX host system. I followed the instructions here.

Everything seems to kind of work but when I run Xdebug the breakpoint does not turn yellow and it is not clear what point in the code Xdebug is on, I do see the context panel though.

enter image description here

When I check the xDebug logs I see that it connects to the client and then says it can't connect to the client.

Log opened at 2016-03-31 08:08:59
I: 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="file:///vagrant/httpdocs/project-2/index.php" language="PHP" xdebug:language_version="5.5.9-1ubuntu4.14" protocol_version="1.0" appid="2256" idekey="XDEBUG_ECLIPSE"><engine version="2.4.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>

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

<- feature_set -i 2 -v 32 -n max_children
-> <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>

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

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

<- breakpoint_set -i 5 -n 40 -f file%3A///var/www/project-2/index.php -t line
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="5" id="22560001"></response>

<- breakpoint_set -i 6 -n 20 -f file%3A///Users/holy/ubuntu_1404/httpdocs/project-1/app/design/frontend/hoi/default/template/page/html/header.phtml -t line
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="6" id="22560002"></response>

<- breakpoint_set -i 7 -x "Fatal error" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" id="22560003"></response>

<- breakpoint_set -i 8 -x "Catchable fatal error" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="8" id="22560004"></response>

<- breakpoint_set -i 9 -x "Warning" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="9" id="22560005"></response>

<- breakpoint_set -i 10 -x "Parse error" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="10" id="22560006"></response>

<- breakpoint_set -i 11 -x "Notice" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="11" id="22560007"></response>

<- breakpoint_set -i 12 -x "Strict standards" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="12" id="22560008"></response>

<- breakpoint_set -i 13 -x "Deprecated" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="13" id="22560009"></response>

<- breakpoint_set -i 14 -x "Xdebug" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="14" id="22560010"></response>

<- breakpoint_set -i 15 -x "Unknown error" -t exception
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="15" id="22560011"></response>

<- run -i 16
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="16" status="break" reason="ok"><xdebug:message filename="file:///vagrant/httpdocs/project-2/index.php" lineno="40"></xdebug:message></response>

<- context_get -i 17 -c 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="17" context="1"><property name="$_COOKIE" fullname="$_COOKIE" type="array" children="1" numchildren="3" page="0" pagesize="32"><property name="__zlcmid" fullname="$_COOKIE[&#39;__zlcmid&#39;]" type="string" size="14" encoding="base64"><![CDATA[WnBmUVZIclEzSWtiQmU=]]></property><property name="PHPSESSID" fullname="$_COOKIE[&#39;PHPSESSID&#39;]" type="string" size="26" encoding="base64"><![CDATA[YWplcjAyaGh1bjVya2djZXBiaDc2cjFhbTU=]]></property><property name="XDEBUG_SESSION" fullname="$_COOKIE[&#39;XDEBUG_SESSION&#39;]" type="string" size="14" encoding="base64"><![CDATA[WERFQlVHX0VDTElQU0U=]]></property></property><property name="$_ENV" fullname="$_ENV" type="array" children="0" numchildren="0" page="0" pagesize="32"></property><property name="$_FILES" fullname="$_FILES" type="array" children="0" numchildren="0" page="0" pagesize="32"></property><property name="$_GET" fullname="$_GET" type="array" children="0" numchildren="0" page="0" pagesize="32"></property><property name="$_POST" fullname="$_POST" type="array" children="0" numchildren="0" page="0" pagesize="32"></property><property name="$_REQUEST" fullname="$_REQUEST" type="array" children="0" numchildren="0" page="0" pagesize="32"></property><property name="$_SERVER" fullname="$_SERVER" type="array" children="1" numchildren="35" page="0" pagesize="32"><property name="SCRIPT_URL" fullname="$_SERVER[&#39;SCRIPT_URL&#39;]" type="string" size="1" encoding="base64"><![CDATA[Lw==]]></property><property name="SCRIPT_URI" fullname="$_SERVER[&#39;SCRIPT_URI&#39;]" type="string" size="29" encoding="base64"><![CDATA[aHR0cDovL2Rldi5kaWV0LWV4cGVydC5sb2NhbC8=]]></property><property name="HTTP_AUTHORIZATION" fullname="$_SERVER[&#39;HTTP_AUTHORIZATION&#39;]" type="string" size="0" encoding="base64"><![CDATA[]]></property><property name="HTTP_HOST" fullname="$_SERVER[&#39;HTTP_HOST&#39;]" type="string" size="21" encoding="base64"><![CDATA[ZGV2LmRpZXQtZXhwZXJ0LmxvY2Fs]]></property><property name="HTTP_CONNECTION" fullname="$_SERVER[&#39;HTTP_CONNECTION&#39;]" type="string" size="10" encoding="base64"><![CDATA[a2VlcC1hbGl2ZQ==]]></property><property name="HTTP_CACHE_CONTROL" fullname="$_SERVER[&#39;HTTP_CACHE_CONTROL&#39;]" type="string" size="9" encoding="base64"><![CDATA[bWF4LWFnZT0w]]></property><property name="HTTP_ACCEPT" fullname="$_SERVER[&#39;HTTP_ACCEPT&#39;]" type="string" size="74" encoding="base64"><![CDATA[dGV4dC9odG1sLGFwcGxpY2F0aW9uL3hodG1sK3htbCxhcHBsaWNhdGlvbi94bWw7cT0wLjksaW1hZ2Uvd2VicCwqLyo7cT0wLjg=]]></property><property name="HTTP_UPGRADE_INSECURE_REQUESTS" fullname="$_SERVER[&#39;HTTP_UPGRADE_INSECURE_REQUESTS&#39;]" type="string" size="1" encoding="base64"><![CDATA[MQ==]]></property><property name="HTTP_USER_AGENT" fullname="$_SERVER[&#39;HTTP_USER_AGENT&#39;]" type="string" size="120" encoding="base64"><![CDATA[TW96aWxsYS81LjAgKE1hY2ludG9zaDsgSW50ZWwgTWFjIE9TIFggMTBfMTFfMikgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzQ5LjAuMjYyMy44NyBTYWZhcmkvNTM3LjM2]]></property><property name="HTTP_ACCEPT_ENCODING" fullname="$_SERVER[&#39;HTTP_ACCEPT_ENCODING&#39;]" type="string" size="19" encoding="base64"><![CDATA[Z3ppcCwgZGVmbGF0ZSwgc2RjaA==]]></property><property name="HTTP_ACCEPT_LANGUAGE" fullname="$_SERVER[&#39;HTTP_ACCEPT_LANGUAGE&#39;]" type="string" size="32" encoding="base64"><![CDATA[ZW4tVVMsZW47cT0wLjgsc3Y7cT0wLjYsZXM7cT0wLjQ=]]></property><property name="HTTP_COOKIE" fullname="$_SERVER[&#39;HTTP_COOKIE&#39;]" type="string" size="92" encoding="base64"><![CDATA[X196bGNtaWQ9WnBmUVZIclEzSWtiQmU7IFBIUFNFU1NJRD1hamVyMDJoaHVuNXJrZ2NlcGJoNzZyMWFtNTsgWERFQlVHX1NFU1NJT049WERFQlVHX0VDTElQU0U=]]></property><property name="PATH" fullname="$_SERVER[&#39;PATH&#39;]" type="string" size="60" encoding="base64"><![CDATA[L3Vzci9sb2NhbC9zYmluOi91c3IvbG9jYWwvYmluOi91c3Ivc2JpbjovdXNyL2Jpbjovc2JpbjovYmlu]]></property><property name="SERVER_SIGNATURE" fullname="$_SERVER[&#39;SERVER_SIGNATURE&#39;]" type="string" size="81" encoding="base64"><![CDATA[PGFkZHJlc3M+QXBhY2hlLzIuNC43IChVYnVudHUpIFNlcnZlciBhdCBkZXYuZGlldC1leHBlcnQubG9jYWwgUG9ydCA4MDwvYWRkcmVzcz4K]]></property><property name="SERVER_SOFTWARE" fullname="$_SERVER[&#39;SERVER_SOFTWARE&#39;]" type="string" size="21" encoding="base64"><![CDATA[QXBhY2hlLzIuNC43IChVYnVudHUp]]></property><property name="SERVER_NAME" fullname="$_SERVER[&#39;SERVER_NAME&#39;]" type="string" size="21" encoding="base64"><![CDATA[ZGV2LmRpZXQtZXhwZXJ0LmxvY2Fs]]></property><property name="SERVER_ADDR" fullname="$_SERVER[&#39;SERVER_ADDR&#39;]" type="string" size="13" encoding="base64"><![CDATA[MTkyLjE2OC45OS45OQ==]]></property><property name="SERVER_PORT" fullname="$_SERVER[&#39;SERVER_PORT&#39;]" type="string" size="2" encoding="base64"><![CDATA[ODA=]]></property><property name="REMOTE_ADDR" fullname="$_SERVER[&#39;REMOTE_ADDR&#39;]" type="string" size="12" encoding="base64"><![CDATA[MTkyLjE2OC45OS4x]]></property><property name="DOCUMENT_ROOT" fullname="$_SERVER[&#39;DOCUMENT_ROOT&#39;]" type="string" size="20" encoding="base64"><![CDATA[L3Zhci93d3cvZGlldGF2ZW51ZS8=]]></property><property name="REQUEST_SCHEME" fullname="$_SERVER[&#39;REQUEST_SCHEME&#39;]" type="string" size="4" encoding="base64"><![CDATA[aHR0cA==]]></property><property name="CONTEXT_PREFIX" fullname="$_SERVER[&#39;CONTEXT_PREFIX&#39;]" type="string" size="0" encoding="base64"><![CDATA[]]></property><property name="CONTEXT_DOCUMENT_ROOT" fullname="$_SERVER[&#39;CONTEXT_DOCUMENT_ROOT&#39;]" type="string" size="20" encoding="base64"><![CDATA[L3Zhci93d3cvZGlldGF2ZW51ZS8=]]></property><property name="SERVER_ADMIN" fullname="$_SERVER[&#39;SERVER_ADMIN&#39;]" type="string" size="23" encoding="base64"><![CDATA[Y29udGFjdEBkaWV0LWV4cGVydC5jb20=]]></property><property name="SCRIPT_FILENAME" fullname="$_SERVER[&#39;SCRIPT_FILENAME&#39;]" type="string" size="29" encoding="base64"><![CDATA[L3Zhci93d3cvZGlldGF2ZW51ZS9pbmRleC5waHA=]]></property><property name="REMOTE_PORT" fullname="$_SERVER[&#39;REMOTE_PORT&#39;]" type="string" size="5" encoding="base64"><![CDATA[NDk0MzY=]]></property><property name="GATEWAY_INTERFACE" fullname="$_SERVER[&#39;GATEWAY_INTERFACE&#39;]" type="string" size="7" encoding="base64"><![CDATA[Q0dJLzEuMQ==]]></property><property name="SERVER_PROTOCOL" fullname="$_SERVER[&#39;SERVER_PROTOCOL&#39;]" type="string" size="8" encoding="base64"><![CDATA[SFRUUC8xLjE=]]></property><property name="REQUEST_METHOD" fullname="$_SERVER[&#39;REQUEST_METHOD&#39;]" type="string" size="3" encoding="base64"><![CDATA[R0VU]]></property><property name="QUERY_STRING" fullname="$_SERVER[&#39;QUERY_STRING&#39;]" type="string" size="0" encoding="base64"><![CDATA[]]></property><property name="REQUEST_URI" fullname="$_SERVER[&#39;REQUEST_URI&#39;]" type="string" size="1" encoding="base64"><![CDATA[Lw==]]></property><property name="SCRIPT_NAME" fullname="$_SERVER[&#39;SCRIPT_NAME&#39;]" type="string" size="10" encoding="base64"><![CDATA[L2luZGV4LnBocA==]]></property></property></response>

<- context_get -i 18
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="18" context="0"><property name="$compilerConfig" fullname="$compilerConfig" type="uninitialized"></property><property name="$mageFilename" fullname="$mageFilename" type="uninitialized"></property><property name="$mageRunCode" fullname="$mageRunCode" type="uninitialized"></property><property name="$mageRunType" fullname="$mageRunType" type="uninitialized"></property><property name="$maintenanceFile" fullname="$maintenanceFile" type="uninitialized"></property></response>

<- stack_get -i 19
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="19"><stack where="{main}" level="0" type="file" filename="file:///vagrant/httpdocs/project-2/index.php" lineno="40"></stack></response>

Log opened at 2016-03-31 08:09:06
I: Connecting to configured address/port: 10.0.2.2:9000.
E: Could not connect to client. :-(
Log closed at 2016-03-31 08:09:06

Log opened at 2016-03-31 08:09:06
I: Connecting to configured address/port: 10.0.2.2:9000.
E: Could not connect to client. :-(
Log closed at 2016-03-31 08:09:06

Log opened at 2016-03-31 08:09:06
I: Connecting to configured address/port: 10.0.2.2:9000.
E: Could not connect to client. :-(
Log closed at 2016-03-31 08:09:06

I'm using 10.0.2.2 as the remote host in the php.ini file.

xdebug.remote_host=10.0.2.2

I just took this setting from the tutorial and it seems to work, first I tried 10.0.2.15 as it was the IP address I see when I vagrant ssh

IP address for eth0: 10.0.2.15

And also with ifconfig

vagrant@dev:/var/log/xdebug$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:c9:24:d6  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fec9:24d6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1297 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1004 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:118158 (118.1 KB)  TX bytes:157804 (157.8 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:f4:70:ac  
          inet addr:192.168.99.99  Bcast:192.168.99.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fef4:70ac/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1024 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1263 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:142856 (142.8 KB)  TX bytes:1993376 (1.9 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:104 errors:0 dropped:0 overruns:0 frame:0
          TX packets:104 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:8804 (8.8 KB)  TX bytes:8804 (8.8 KB)

But xDebug does not connect at all when I use 10.0.2.15 as the remote host.

/etc/php5/apache2/php.ini

zend_extension="/usr/lib/php5/20121212/xdebug.so"
xdebug.default_enable = 1
xdebug.idekey = "vagrant"
xdebug.remote_enable = 1
xdebug.remote_autostart = 0
xdebug.remote_port = 9000
xdebug.remote_handler=dbgp
xdebug.remote_log="/var/log/xdebug/xdebug.log"
xdebug.remote_host= 10.0.2.2 ; IDE-Environments IP, from vagrant box

project.sublime-project

{
    "folders":
    [
        {
            "path": "/Users/holy/ubuntu_1404/httpdocs/project"
        }
    ],
    "settings": {
        "xdebug": {
        "path_mapping": {
                 "/var/www/project" : "/Users/holy/ubuntu_1404/httpdocs/project",
            },
        "url": "http://dev.project.local/",
        "super_globals": true,
        "close_on_stop": true
        }
    }
}

Update

After trying suggested answer from @MarcinOrlowski it seems to be working from the logs but in Sublime the Breakpoint still does not turn yellow and I can not see what point in the code Xdebug is on in sublime.

Log opened at 2016-03-31 08:48:15
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to 192.168.99.1:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///vagrant/httpdocs/project/index.php" language="PHP" xdebug:language_version="5.5.9-1ubuntu4.14" protocol_version="1.0" appid="2626" idekey="XDEBUG_ECLIPSE"><engine version="2.4.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>

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

Second Update

Some more details on the remote host...

vagrant@dev:~$ route | grep default | awk '{print $2}'
10.0.2.2
vagrant@dev:~$ telnet 10.0.2.2 9000
Trying 10.0.2.2...
telnet: Unable to connect to remote host: Connection refused
vagrant@dev:~$ tcpdump port 9000
tcpdump: no suitable device found

Upvotes: 0

Views: 1070

Answers (1)

Marcin Orlowski
Marcin Orlowski

Reputation: 75629

I'd remove remote_host entry but add remote_connect_back instead (docs):

If enabled, the xdebug.remote_host setting is ignored and Xdebug will try to connect to the client that made the HTTP request.

So this should do the trick (and you may need to restart httpd on vagrant first)

xdebug.remote_handler="dbgp"
xdebug.remote_port=9000
xdebug.remote_autostart = on
xdebug.remote_start = on
xdebug.remote_enable = on
xdebug.remote_connect_back = on
xdebug.idekey = "vagrant"

BTW: zend_extension path can be relative if you got extension_dir set correctly.

zend_extension=xdebug.so

Upvotes: 1

Related Questions